Examples of UserServiceInterface


Examples of com.google.api.ads.dfp.v201311.UserServiceInterface

      // Get DfpUser from "~/dfp.properties".
      DfpUser user = new DfpUser();

      // Get UserService.
      UserServiceInterface userService =
          user.getService(DfpService.V201311.USER_SERVICE);

      // Sets defaults for page and filterStatement.
      UserPage page = new UserPage();
      Statement filterStatement = new Statement();
      int offset = 0;

      do {
        // Create a statement to get all users.
        filterStatement.setQuery("LIMIT 500 OFFSET " + offset);

        // Get users by statement.
        page = userService.getUsersByStatement(filterStatement);

        if (page.getResults() != null) {
          int i = page.getStartIndex();
          for (User usr : page.getResults()) {
            System.out.println(i + ") User with ID \"" + usr.getId()
View Full Code Here

Examples of com.google.api.ads.dfp.v201311.UserServiceInterface

      // Get DfpUser from "~/dfp.properties".
      DfpUser user = new DfpUser();

      // Get UserService.
      UserServiceInterface userService =
          user.getService(DfpService.V201311.USER_SERVICE);

      // Create a statement to get all users.
      Statement filterStatement = new Statement("LIMIT 500", null);

      // Get users by statement.
      UserPage page = userService.getUsersByStatement(filterStatement);

      if (page.getResults() != null) {
        User[] users = page.getResults();

        // Update each local users object by changing its name.
        for (User usr : users) {
          usr.setName(usr.getName() + " Sr.");
        }

        // Update the users on the server.
        users = userService.updateUsers(users);

        if (users != null) {
          for (User usr : users) {
            System.out.println("A user with ID \"" + usr.getId()
                + "\", name \"" + usr.getName()
View Full Code Here

Examples of com.google.api.ads.dfp.v201311.UserServiceInterface

      // Get DfpUser from "~/dfp.properties".
      DfpUser user = new DfpUser();

      // Get the UserService.
      UserServiceInterface userService =
          user.getService(DfpService.V201311.USER_SERVICE);

      // Set the ID of the user to deactivate
      Long userId = Long.parseLong("INSERT_USER_ID_HERE");

      // Create filter text to select user by id.
      String statementText = "WHERE id = :userId LIMIT 500";
      Statement filterStatement =
        new StatementBuilder("")
            .putValue("userId", userId)
            .toStatement();

      // Set defaults for page and offset.
      UserPage page = new UserPage();
      int offset = 0;
      List<Long> userIds = new ArrayList<Long>();

      do {
        // Create a statement to page through users.
        filterStatement.setQuery(statementText + " OFFSET " + offset);

        // Get users by statement.
        page = userService.getUsersByStatement(filterStatement);

        if (page.getResults() != null) {
          int i = page.getStartIndex();
          for (User userResult : page.getResults()) {
            System.out.println(i + ") User with ID \"" + userResult.getId()
                + "\", email \"" + userResult.getEmail()
                + "\", and status \"" + (userResult.getIsActive() ? "ACTIVE" : "INACTIVE")
                + "\" will be deactivated.");
            userIds.add(userResult.getId());
            i++;
          }
        }

        offset += 500;
      } while (offset < page.getTotalResultSetSize());

      System.out.println("Number of users to be deactivated: " + userIds.size());

      if (userIds.size() > 0) {
        // Modify statement for action.
        filterStatement.setQuery("WHERE id IN (" + StringUtils.join(userIds, ",") + ")");

        // Create action.
        DeactivateUsers action = new DeactivateUsers();

        // Perform action.
        UpdateResult result = userService.performUserAction(action, filterStatement);

        // Display results.
        if (result != null && result.getNumChanges() > 0) {
          System.out.println("Number of users deactivated: " + result.getNumChanges());
        } else {
View Full Code Here

Examples of com.google.api.ads.dfp.v201311.UserServiceInterface

      // Get DfpUser from "~/dfp.properties".
      DfpUser user = new DfpUser();

      // Get the UserService.
      UserServiceInterface userService =
          user.getService(DfpService.V201311.USER_SERVICE);

      // Get all roles.
      Role[] roles = userService.getAllRoles();
      int numRoles = 0;
      if (roles != null && roles.length > 0) {
        for (Role role : roles) {
          System.out.println("Role with ID \"" + role.getId()
              + "\" and name \"" + role.getName() + "\" was found.");
View Full Code Here

Examples of com.google.api.ads.dfp.v201311.UserServiceInterface

      // Get DfpUser from "~/dfp.properties".
      DfpUser user = new DfpUser();

      // Get UserService.
      UserServiceInterface userService =
          user.getService(DfpService.V201311.USER_SERVICE);

      // Create a statement to get all users sorted by name.
      Statement filterStatement = new Statement("ORDER BY name LIMIT 500", null);

      // Get users by statement.
      UserPage page = userService.getUsersByStatement(filterStatement);

      if (page.getResults() != null) {
        int i = page.getStartIndex();
        for (User usr : page.getResults()) {
          System.out.println(i + ") User with ID \"" + usr.getId()
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.