use of com.google.api.ads.admanager.axis.v202205.Role in project googleads-java-lib by googleads.
the class GetAllRoles method runExample.
/**
* Runs the example.
*
* @param adManagerServices the services factory.
* @param session the session.
* @throws ApiException if the API request failed with one or more service errors.
* @throws RemoteException if the API request failed due to other errors.
*/
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session) throws RemoteException {
// Get the UserService.
UserServiceInterface userService = adManagerServices.get(session, UserServiceInterface.class);
// Get all roles.
Role[] roles = userService.getAllRoles();
int i = 0;
for (Role role : roles) {
System.out.printf("%d) Role with ID %d and name '%s' was found.%n", i++, role.getId(), role.getName());
}
System.out.printf("Number of results found: %d%n", roles.length);
}
use of com.google.api.ads.admanager.axis.v202205.Role in project googleads-java-lib by googleads.
the class GetAllRoles method runExample.
/**
* Runs the example.
*
* @param adManagerServices the services factory.
* @param session the session.
* @throws ApiException if the API request failed with one or more service errors.
* @throws RemoteException if the API request failed due to other errors.
*/
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session) throws RemoteException {
// Get the UserService.
UserServiceInterface userService = adManagerServices.get(session, UserServiceInterface.class);
// Get all roles.
Role[] roles = userService.getAllRoles();
int i = 0;
for (Role role : roles) {
System.out.printf("%d) Role with ID %d and name '%s' was found.%n", i++, role.getId(), role.getName());
}
System.out.printf("Number of results found: %d%n", roles.length);
}
use of com.google.api.ads.admanager.axis.v202205.Role in project googleads-java-lib by googleads.
the class CreateUsers method runExample.
/**
* Runs the example.
*
* @param adManagerServices the services factory.
* @param session the session.
* @param emailAddress the email address of the user.
* @param name the name of the user.
* @throws ApiException if the API request failed with one or more service errors.
* @throws RemoteException if the API request failed due to other errors.
*/
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session, String emailAddress, String name) throws RemoteException {
// Get the UserService.
UserServiceInterface userService = adManagerServices.get(session, UserServiceInterface.class);
// Create a user.
User traffickerUser = new User();
traffickerUser.setEmail(emailAddress);
traffickerUser.setName(name);
// Set the system defined ID of the trafficker role.
// To determine what other roles exist, run GetAllRoles.java.
traffickerUser.setRoleId(-7L);
// Create the user on the server.
User[] users = userService.createUsers(new User[] { traffickerUser });
for (User createdUser : users) {
System.out.printf("A user with ID %d and name '%s' was created.%n", createdUser.getId(), createdUser.getName());
}
}
use of com.google.api.ads.admanager.axis.v202205.Role in project googleads-java-lib by googleads.
the class GetAllRoles method runExample.
/**
* Runs the example.
*
* @param adManagerServices the services factory.
* @param session the session.
* @throws ApiException if the API request failed with one or more service errors.
* @throws RemoteException if the API request failed due to other errors.
*/
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session) throws RemoteException {
// Get the UserService.
UserServiceInterface userService = adManagerServices.get(session, UserServiceInterface.class);
// Get all roles.
Role[] roles = userService.getAllRoles();
int i = 0;
for (Role role : roles) {
System.out.printf("%d) Role with ID %d and name '%s' was found.%n", i++, role.getId(), role.getName());
}
System.out.printf("Number of results found: %d%n", roles.length);
}
use of com.google.api.ads.admanager.axis.v202205.Role in project googleads-java-lib by googleads.
the class GetCurrentUser method runExample.
/**
* Runs the example.
*
* @param adManagerServices the services factory.
* @param session the session.
* @throws ApiException if the API request failed with one or more service errors.
* @throws RemoteException if the API request failed due to other errors.
*/
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session) throws RemoteException {
// Get the UserService.
UserServiceInterface userService = adManagerServices.get(session, UserServiceInterface.class);
// Get the current user.
User user = userService.getCurrentUser();
System.out.printf("User with ID %d, name '%s', email '%s', and role '%s' is the current user.%n", user.getId(), user.getName(), user.getEmail(), user.getRoleName());
}
Aggregations