ব্যবহারকারীদের দেখুন, ব্যবহারকারীদের দেখুন

কোনো নির্দিষ্ট Client অধীনে থাকা users দেখার জন্য আপনি নিম্নলিখিত পদ্ধতিগুলো ব্যবহার করতে পারেন।

স্বতন্ত্র ব্যবহারকারী দেখুন

বিদ্যমান কোনো ClientUser সম্পর্কে তথ্য পেতে আপনি buyers.clients.users.get মেথডটি ব্যবহার করতে পারেন।

নিম্নলিখিত নমুনাটি দেখায় যে আপনি কীভাবে get মেথড ব্যবহার করে একজন নির্দিষ্ট ClientUser পুনরুদ্ধার করতে পারেন।

বিশ্রাম

অনুরোধ

GET https://authorizedbuyersmarketplace.googleapis.com/v1/buyers/12345678/clients/873721984/users/4573638?alt=json
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

প্রতিক্রিয়া

{
 "name": "buyers/12345678/clients/873721984/users/4573638",
 "state": "INVITED",
 "email": "testemail87339346@test.com"
}

জাভা

/*
 * Copyright 2022 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.api.services.samples.authorizedbuyers.marketplace.v1.buyers.clients.users;

import com.google.api.services.authorizedbuyersmarketplace.v1.AuthorizedBuyersMarketplace;
import com.google.api.services.authorizedbuyersmarketplace.v1.model.ClientUser;
import com.google.api.services.samples.authorizedbuyers.marketplace.v1.Utils;
import java.io.IOException;
import java.security.GeneralSecurityException;
import net.sourceforge.argparse4j.ArgumentParsers;
import net.sourceforge.argparse4j.inf.ArgumentParser;
import net.sourceforge.argparse4j.inf.ArgumentParserException;
import net.sourceforge.argparse4j.inf.Namespace;

/** This sample illustrates how to get a client user for the given buyer, client, and user IDs. */
public class GetClientUsers {

  public static void execute(AuthorizedBuyersMarketplace marketplaceClient, Namespace parsedArgs) {
    Long accountId = parsedArgs.getLong("account_id");
    Long clientId = parsedArgs.getLong("client_id");
    Long clientUserId = parsedArgs.getLong("client_user_id");
    String name = String.format("buyers/%d/clients/%d/users/%d", accountId, clientId, clientUserId);

    ClientUser clientUser = null;

    try {
      clientUser = marketplaceClient.buyers().clients().users().get(name).execute();
    } catch (IOException ex) {
      System.out.printf("Marketplace API returned error response:%n%s", ex);
      System.exit(1);
    }

    System.out.printf("Found client user with name \"%s\":%n", name);
    Utils.printClientUser(clientUser);
  }

  public static void main(String[] args) {
    ArgumentParser parser =
        ArgumentParsers.newFor("GetClientUsers")
            .build()
            .defaultHelp(true)
            .description(("Get a client user for the given buyer, client, and client user IDs."));
    parser
        .addArgument("-a", "--account_id")
        .help(
            "The resource ID of the buyers resource under which the parent client was created. "
                + "This will be used to construct the parent used as a path parameter for the "
                + "users.get request.")
        .required(true)
        .type(Long.class);
    parser
        .addArgument("-c", "--client_id")
        .help(
            "The resource ID of the buyers.clients resource for which the user was created. This"
                + " will be used to construct the name used as a path parameter for the users.get "
                + "request.")
        .required(true)
        .type(Long.class);
    parser
        .addArgument("-u", "--client_user_id")
        .help(
            "The resource ID of the buyers.clients.users resource that is being retrieved. This"
                + " will be used to construct the name used as a path parameter for the users.get "
                + "request.")
        .required(true)
        .type(Long.class);

    Namespace parsedArgs = null;
    try {
      parsedArgs = parser.parseArgs(args);
    } catch (ArgumentParserException ex) {
      parser.handleError(ex);
      System.exit(1);
    }

    AuthorizedBuyersMarketplace client = null;
    try {
      client = Utils.getMarketplaceClient();
    } catch (IOException ex) {
      System.out.printf("Unable to create Marketplace API service:%n%s", ex);
      System.out.println("Did you specify a valid path to a service account key file?");
      System.exit(1);
    } catch (GeneralSecurityException ex) {
      System.out.printf("Unable to establish secure HttpTransport:%n%s", ex);
      System.exit(1);
    }

    execute(client, parsedArgs);
  }
}

একাধিক ব্যবহারকারীর তালিকা

কোনো নির্দিষ্ট Client ব্যবহারকারীদের তালিকা পেতে আপনি buyers.clients.users.list মেথডটি ব্যবহার করতে পারেন।

উদাহরণস্বরূপ, কোনো নির্দিষ্ট Client পক্ষ থেকে কোনো নির্দিষ্ট ইমেলের অথরাইজড বায়ার্স মার্কেটপ্লেস UI-তে অ্যাক্সেস আছে কি না, তা যাচাই করতে আপনি list ব্যবহার করতে পারেন।

নিম্নলিখিত নমুনাটি দেখায় যে আপনি কীভাবে list মেথড ব্যবহার করে ব্যবহারকারীদের একটি তালিকা পুনরুদ্ধার করতে পারেন।

বিশ্রাম

অনুরোধ

GET https://authorizedbuyersmarketplace.googleapis.com/v1/buyers/12345678/clients/873721984/users?pageSize=3&alt=json
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

প্রতিক্রিয়া

{
 "clientUsers": [
   {
     "name": "buyers/12345678/clients/873721984/users/4573638",
     "state": "INVITED",
     "email": "testemail87339346@test.com"
   },
   {
     "name": "buyers/12345678/clients/873721984/users/4573641",
     "state": "INVITED",
     "email": "testemail88584947@test.com"
   },
   {
     "name": "buyers/12345678/clients/873721984/users/4573644",
     "state": "INACTIVE",
     "email": "jessie@luxurymarscruises.mars"
   }
 ],
 "nextPageToken": "CAQQ4tWk59Td9gIY4tWk59Td9gI="
}

জাভা

/*
 * Copyright 2022 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.api.services.samples.authorizedbuyers.marketplace.v1.buyers.clients.users;

import com.google.api.services.authorizedbuyersmarketplace.v1.AuthorizedBuyersMarketplace;
import com.google.api.services.authorizedbuyersmarketplace.v1.model.ClientUser;
import com.google.api.services.authorizedbuyersmarketplace.v1.model.ListClientUsersResponse;
import com.google.api.services.samples.authorizedbuyers.marketplace.v1.Utils;
import java.io.IOException;
import java.security.GeneralSecurityException;
import java.util.List;
import net.sourceforge.argparse4j.ArgumentParsers;
import net.sourceforge.argparse4j.inf.ArgumentParser;
import net.sourceforge.argparse4j.inf.ArgumentParserException;
import net.sourceforge.argparse4j.inf.Namespace;

/** This sample illustrates how to list client users for a given client. */
public class ListClientUsers {

  public static void execute(AuthorizedBuyersMarketplace marketplaceClient, Namespace parsedArgs) {
    Long accountId = parsedArgs.getLong("account_id");
    Long clientId = parsedArgs.getLong("client_id");
    Integer pageSize = parsedArgs.getInt("page_size");
    String parentClientName = String.format("buyers/%d/clients/%d", accountId, clientId);
    String pageToken = null;

    System.out.printf("Found client users for client with name \"%s\":%n", parentClientName);

    do {
      List<ClientUser> clientUsers = null;

      try {
        ListClientUsersResponse response =
            marketplaceClient
                .buyers()
                .clients()
                .users()
                .list(parentClientName)
                .setPageSize(pageSize)
                .setPageToken(pageToken)
                .execute();

        clientUsers = response.getClientUsers();
        pageToken = response.getNextPageToken();
      } catch (IOException ex) {
        System.out.printf("Marketplace API returned error response:%n%s", ex);
        System.exit(1);
      }
      if (clientUsers == null) {
        System.out.println("No client users found.");
      } else {
        for (ClientUser clientUser : clientUsers) {
          Utils.printClientUser(clientUser);
        }
      }
    } while (pageToken != null);
  }

  public static void main(String[] args) {
    ArgumentParser parser =
        ArgumentParsers.newFor("ListClientUsers")
            .build()
            .defaultHelp(true)
            .description(("Lists client users associated with the given buyer account."));
    parser
        .addArgument("-a", "--account_id")
        .help(
            "The resource ID of the buyers resource under which the parent client was created. "
                + "This will be used to construct the parent used as a path parameter for the "
                + "users.list request.")
        .required(true)
        .type(Long.class);
    parser
        .addArgument("-c", "--client_id")
        .help(
            "The resource ID of the buyers.clients resource we are retrieving client users on"
                + " behalf of. This will be used to construct the parent used as a path parameter"
                + " for the users.list request.")
        .required(true)
        .type(Long.class);
    parser
        .addArgument("-p", "--page_size")
        .help(
            "The number of rows to return per page. The server may return fewer rows than "
                + "specified.")
        .setDefault(Utils.getMaximumPageSize())
        .type(Integer.class);

    Namespace parsedArgs = null;
    try {
      parsedArgs = parser.parseArgs(args);
    } catch (ArgumentParserException ex) {
      parser.handleError(ex);
      System.exit(1);
    }

    AuthorizedBuyersMarketplace client = null;
    try {
      client = Utils.getMarketplaceClient();
    } catch (IOException ex) {
      System.out.printf("Unable to create Marketplace API service:%n%s", ex);
      System.out.println("Did you specify a valid path to a service account key file?");
      System.exit(1);
    } catch (GeneralSecurityException ex) {
      System.out.printf("Unable to establish secure HttpTransport:%n%s", ex);
      System.exit(1);
    }

    execute(client, parsedArgs);
  }
}