إدارة نشاط المستخدم العميل

يمكنك استخدام الطرق التالية لتغيير state ClientUser

يتم ضبط state على ACTIVE لموارد ClientUser الجديدة تلقائيًا بعد قبول الدعوة. يمكنك ضبط state على INACTIVE لحساب ClientUser معيّن لإبطال إذن وصول المستخدم الفردي إلى واجهة مستخدم "سوق الشراء بالنيابة" .

إيقاف

يمكنك إيقاف ClientUser باستخدام الطريقة buyers.clients.users.deactivate .

على سبيل المثال، يمكنك استخدام deactivate لإبطال إذن وصول مستخدم فردي مؤقتًا إلى واجهة مستخدم "سوق المشترين المعتمَدين" لمستخدم فردي ضمن عميل معيّن، ويمكنك استعادته في المستقبل. لإلغاء إذن الوصول نهائيًا، استخدِم buyers.clients.users.delete.

يعرض النموذج التالي كيفية إيقاف ClientUser باستخدام طريقة deactivate.

REST

الطلب

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

الرد

{
 "name": "buyers/12345678/clients/873721984/users/4573644",
 "state": "INACTIVE",
 "email": "jessie@luxurymarscruises.mars"
}

#C

/* 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
 *
 *     http://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.
 */

using Google.Apis.AuthorizedBuyersMarketplace.v1;
using Google.Apis.AuthorizedBuyersMarketplace.v1.Data;
using Mono.Options;

using System;
using System.Collections.Generic;

namespace Google.Apis.AuthorizedBuyersMarketplace.Examples.v1.Buyers.Clients.Users
{
    /// <summary>
    /// Deactivates client user for the given buyer, client, and user IDs.
    ///
    /// Deactivating a client user allows one to temporarily remove a given client user from
    /// accessing the Authorized Buyers UI on behalf of a client. Access can be restored by
    /// calling buyers.clients.users.activate.
    ///
    /// Note that a client user in the "INVITED" state can not be deactivated, and attempting to
    /// deactivate it will result in an error response.    /// </summary>
    public class DeactivateClientUsers : ExampleBase
    {
        private AuthorizedBuyersMarketplaceService mkService;

        /// <summary>
        /// Constructor.
        /// </summary>
        public DeactivateClientUsers()
        {
            mkService = Utilities.GetAuthorizedBuyersMarketplaceService();
        }

        /// <summary>
        /// Returns a description about the code example.
        /// </summary>
        public override string Description
        {
            get => "This code example deactivates a specific client user for a given client.";
        }

        /// <summary>
        /// Parse specified arguments.
        /// </summary>
        protected override Dictionary<string, object> ParseArguments(List<string> exampleArgs) {
            string[] requiredOptions = new string[] {"account_id", "client_id", "user_id"};
            bool showHelp = false;

            string accountId = null;
            string clientId = null;
            string userId = null;


            OptionSet options = new OptionSet {
                "Deactivate a client user with the given buyer, client, and user IDs.",
                {
                    "h|help",
                    "Show help message and exit.",
                    h => showHelp = h != null
                },
                {
                    "a|account_id=",
                    ("[Required] The resource ID of the buyers resource under which the parent " +
                     "client was created. This will be used to construct the name used as a path " +
                     "parameter for the users.deactivate request."),
                    a => accountId = a
                },
                {
                    "c|client_id=",
                    ("[Required] The resource ID of the buyers.clients resource for which the " +
                     "client user was created. This will be used to construct the name used as " +
                     "a path parameter for the users.deactivate request."),
                    c => clientId = c
                },
                {
                    "u|user_id=",
                    ("[Required] The resource ID of the buyers.clients.users resource for which " +
                     "the client user was created. This will be used to construct the name used " +
                     "as a path parameter for the users.deactivate request."),
                    u => userId = u
                },
            };

            List<string> extras = options.Parse(exampleArgs);
            var parsedArgs = new Dictionary<string, object>();

            // Show help message.
            if (showHelp == true)
            {
                options.WriteOptionDescriptions(Console.Out);
                Environment.Exit(0);
            }
            // Set optional arguments.
            parsedArgs["account_id"] = accountId;
            parsedArgs["client_id"] = clientId;
            parsedArgs["user_id"] = userId;
            // Validate that options were set correctly.
            Utilities.ValidateOptions(options, parsedArgs, requiredOptions, extras);

            return parsedArgs;
        }

        /// <summary>
        /// Run the example.
        /// </summary>
        /// <param name="parsedArgs">Parsed arguments for the example.</param>
        protected override void Run(Dictionary<string, object> parsedArgs)
        {
            string accountId = (string) parsedArgs["account_id"];
            string clientId = (string) parsedArgs["client_id"];
            string userId = (string) parsedArgs["user_id"];
            string name = $"buyers/{accountId}/clients/{clientId}/users/{userId}";

            BuyersResource.ClientsResource.UsersResource.DeactivateRequest request =
                mkService.Buyers.Clients.Users.Deactivate(new DeactivateClientUserRequest(), name);
            ClientUser response = null;

            Console.WriteLine("Deactivating client user with name: {0}", name);

            try
            {
                response = request.Execute();
            }
            catch (Exception exception)
            {
                throw new ApplicationException(
                    $"Marketplace API returned error response:\n{exception.Message}");
            }

            Utilities.PrintClientUser(response);
        }
    }
}

Java

/*
 * 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.DeactivateClientUserRequest;
import com.google.api.services.samples.authorizedbuyers.marketplace.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 deactivate a client user for the given buyer, client, and user ID.
 *
 * <p>Deactivating a client user allows one to temporarily remove a given client user from accessing
 * the Authorized Buyers UI on behalf of a client. Access can be restored by calling
 * buyers.clients.users.activate.
 *
 * <p>Note that a client user in the "INVITED" state can not be deactivated, and attempting to
 * deactivate it will result in an error response.
 */
public class DeactivateClientUsers {

  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()
              .deactivate(name, new DeactivateClientUserRequest())
              .execute();
    } catch (IOException ex) {
      System.out.printf("Marketplace API returned error response:%n%s", ex);
      System.exit(1);
    }

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

  public static void main(String[] args) {
    ArgumentParser parser =
        ArgumentParsers.newFor("DeactivateClientUsers")
            .build()
            .defaultHelp(true)
            .description(("Deactivate a client user with the given buyer, client, and user ID."));
    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 name used as a path parameter for the "
                + "users.deactivate request.")
        .required(true)
        .type(Long.class);
    parser
        .addArgument("-c", "--client_id")
        .help(
            "The resource ID of the buyers.clients resource under which the client user was"
                + " created. This will be used to construct the name used as a path parameter for"
                + " the users.deactivate 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 deactivated. "
                + "This will be used to construct the name used as a path parameter for the "
                + "users.deactivate 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);
  }
}

Python

#!/usr/bin/python
#
# Copyright 2021 Google Inc. All Rights Reserved.
#
# 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
#
#      http://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.

"""Deactivates a user with the given account, client, and user ID.

Deactivating a client user allows one to temporarily remove a given client
user from accessing the Authorized Buyers UI on behalf of a client. Access can
be restored by calling buyers.clients.users.activate.

Note that a client user in the "INVITED" state can not be deactivated.
"""


import argparse
import os
import pprint
import sys

sys.path.insert(0, os.path.abspath('../../../..'))

from googleapiclient.errors import HttpError

import util


_CLIENT_USERS_NAME_TEMPLATE = 'buyers/%s/clients/%s/users/%s'

DEFAULT_BUYER_RESOURCE_ID = 'ENTER_BUYER_RESOURCE_ID_HERE'
DEFAULT_CLIENT_RESOURCE_ID = 'ENTER_CLIENT_RESOURCE_ID_HERE'
DEFAULT_CLIENT_USER_RESOURCE_ID = 'ENTER_CLIENT_USER_RESOURCE_ID_HERE'


def main(marketplace, args):
  client_user_name = _CLIENT_USERS_NAME_TEMPLATE % (
      args.account_id, args.client_id, args.client_user_id)

  print(f'Deactivating client user with name "{client_user_name}".')
  try:
    # Construct and execute the request.
    response = marketplace.buyers().clients().users().deactivate(
        name=client_user_name).execute()
  except HttpError as e:
    print(e)
    sys.exit(1)

  pprint.pprint(response)


if __name__ == '__main__':
  try:
    service = util.get_service(version='v1')
  except IOError as ex:
    print(f'Unable to create marketplace service - {ex}')
    print('Did you specify the key file in util.py?')
    sys.exit(1)

  parser = argparse.ArgumentParser(
      description=('Deactivate a client user for the given buyer account, '
                   'client, and client user ID.'))
  # Required fields.
  parser.add_argument(
      '-a', '--account_id', default=DEFAULT_BUYER_RESOURCE_ID,
      help=('The resource ID of the buyers resource under which the client '
            'user was created. This will be used to construct the name used as '
            'a path parameter for the users.deactivate request.'))
  parser.add_argument(
      '-c', '--client_id', default=DEFAULT_CLIENT_RESOURCE_ID,
      help=('The resource ID of the buyers.clients resource under which the '
            'client user was created. This will be used to construct the name '
            'used as a path parameter for the users.deactivate request.'))
  parser.add_argument(
      '-u', '--client_user_id', default=DEFAULT_CLIENT_USER_RESOURCE_ID,
      help=('The resource ID of the buyers.clients.users resource for which '
            'the client user was created. This will be used to construct the '
            'name used as a path parameter for the users.deactivate request.'))

  main(service, parser.parse_args())

جدِّده

يمكنك إعادة تفعيل "ClientUser" باستخدام buyers.clients.users.activate .

على سبيل المثال، إذا أبطلت مؤقتًا إمكانية وصول مستخدم إلى واجهة مستخدم "سوق المشترين المعتمَدين" باستخدام deactivate، يمكنك استخدام activate لاستعادة إمكانية وصوله.

يوضّح المثال التالي كيفية إعادة تفعيل ClientUser باستخدام الطريقة activate.

REST

الطلب

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

الرد

{
 "name": "buyers/12345678/clients/873721984/users/4573644",
 "state": "ACTIVE",
 "email": "jessie@luxurymarscruises.mars"
}

#C

/* 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
 *
 *     http://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.
 */

using Google.Apis.AuthorizedBuyersMarketplace.v1;
using Google.Apis.AuthorizedBuyersMarketplace.v1.Data;
using Mono.Options;

using System;
using System.Collections.Generic;

namespace Google.Apis.AuthorizedBuyersMarketplace.Examples.v1.Buyers.Clients.Users
{
    /// <summary>
    /// Activates client user for the given buyer, client, and user ID.
    ///
    /// Activated client users can access the Authorized Buyers UI on behalf of a client.
    ///
    /// Note that a client user in the "INVITED" state can not be activated, and attempting to
    /// activate it will result in an error response.
    /// </summary>
    public class ActivateClientUsers : ExampleBase
    {
        private AuthorizedBuyersMarketplaceService mkService;

        /// <summary>
        /// Constructor.
        /// </summary>
        public ActivateClientUsers()
        {
            mkService = Utilities.GetAuthorizedBuyersMarketplaceService();
        }

        /// <summary>
        /// Returns a description about the code example.
        /// </summary>
        public override string Description
        {
            get => "This code example activates a specific user for a given client";
        }

        /// <summary>
        /// Parse specified arguments.
        /// </summary>
        protected override Dictionary<string, object> ParseArguments(List<string> exampleArgs) {
            string[] requiredOptions = new string[] {"account_id", "client_id", "user_id"};
            bool showHelp = false;

            string accountId = null;
            string clientId = null;
            string userId = null;

            OptionSet options = new OptionSet {
                "Activate a client user with the given buyer, client, and user ID.",
                {
                    "h|help",
                    "Show help message and exit.",
                    h => showHelp = h != null
                },
                {
                    "a|account_id=",
                    ("[Required] The resource ID of the buyers resource under which the parent " +
                     "client was created. This will be used to construct the name used as a " +
                     "path parameter for the users.activate request."),
                    a => accountId = a
                },
                {
                    "c|client_id=",
                    ("[Required] The resource ID of the buyers.clients resource under which the " +
                     "user was created. This will be used to construct the name used as a path " +
                     "parameter for the users.activate request."),
                    c => clientId = c
                },
                {
                    "u|user_id=",
                    ("[Required] The resource ID of the buyers.clients.users resource for which " +
                     "the user was created. This will be used to construct the name used as a " +
                     "path parameter for the users.activate request."),
                    u => userId = u
                },
            };

            List<string> extras = options.Parse(exampleArgs);
            var parsedArgs = new Dictionary<string, object>();

            // Show help message.
            if (showHelp == true)
            {
                options.WriteOptionDescriptions(Console.Out);
                Environment.Exit(0);
            }
            // Set optional arguments.
            parsedArgs["account_id"] = accountId;
            parsedArgs["client_id"] = clientId;
            parsedArgs["user_id"] = userId;

            // Validate that options were set correctly.
            Utilities.ValidateOptions(options, parsedArgs, requiredOptions, extras);

            return parsedArgs;
        }

        /// <summary>
        /// Run the example.
        /// </summary>
        /// <param name="parsedArgs">Parsed arguments for the example.</param>
        protected override void Run(Dictionary<string, object> parsedArgs)
        {
            string accountId = (string) parsedArgs["account_id"];
            string clientId = (string) parsedArgs["client_id"];
            string userId = (string) parsedArgs["user_id"];
            string name = $"buyers/{accountId}/clients/{clientId}/users/{userId}";

            BuyersResource.ClientsResource.UsersResource.ActivateRequest request =
                mkService.Buyers.Clients.Users.Activate(new ActivateClientUserRequest(), name);
            ClientUser response = null;

            Console.WriteLine("Activating client user with name: {0}", name);

            try
            {
                response = request.Execute();
            }
            catch (Exception exception)
            {
                Console.WriteLine("{0}", exception.ToString());
                throw new ApplicationException(
                    $"Marketplace API returned error response:\n{exception.Message}");
            }

            Utilities.PrintClientUser(response);
        }
    }
}

Java

/*
 * 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.ActivateClientUserRequest;
import com.google.api.services.authorizedbuyersmarketplace.v1.model.ClientUser;
import com.google.api.services.samples.authorizedbuyers.marketplace.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 activate a client user for the given buyer, client, and user ID.
 *
 * <p>Activated client users can access the Authorized Buyers UI on behalf of a client.
 *
 * <p>Note that a client user in the "INVITED" state can not be activated, and attempting to
 * activate it will result in an error response.
 */
public class ActivateClientUsers {

  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()
              .activate(name, new ActivateClientUserRequest())
              .execute();
    } catch (IOException ex) {
      System.out.printf("Marketplace API returned error response:%n%s", ex);
      System.exit(1);
    }

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

  public static void main(String[] args) {
    ArgumentParser parser =
        ArgumentParsers.newFor("ActivateClientUsers")
            .build()
            .defaultHelp(true)
            .description(("Activate a client user with the given buyer, client, and user ID."));
    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 name used as a path parameter for the "
                + "users.activate request.")
        .required(true)
        .type(Long.class);
    parser
        .addArgument("-c", "--client_id")
        .help(
            "The resource ID of the buyers.clients resource under which the client user was"
                + " created. This will be used to construct the name used as a path parameter for"
                + " the users.activate 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 activated. "
                + "This will be used to construct the name used as a path parameter for the "
                + "users.activate 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);
  }
}

Python

#!/usr/bin/python
#
# Copyright 2021 Google Inc. All Rights Reserved.
#
# 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
#
#      http://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.

"""Activates user with the given account, client, and user ID.

Activates an inactive client user such that they are able to access the
Authorized Buyers UI on behalf of a client.

Note that a client user in the "INVITED" state can not be activated.
"""


import argparse
import os
import pprint
import sys

sys.path.insert(0, os.path.abspath('../../../..'))

from googleapiclient.errors import HttpError

import util


_CLIENT_USERS_NAME_TEMPLATE = 'buyers/%s/clients/%s/users/%s'

DEFAULT_BUYER_RESOURCE_ID = 'ENTER_BUYER_RESOURCE_ID_HERE'
DEFAULT_CLIENT_RESOURCE_ID = 'ENTER_CLIENT_RESOURCE_ID_HERE'
DEFAULT_CLIENT_USER_RESOURCE_ID = 'ENTER_CLIENT_USER_RESOURCE_ID_HERE'


def main(marketplace, args):
  client_user_name = _CLIENT_USERS_NAME_TEMPLATE % (
      args.account_id, args.client_id, args.client_user_id)

  print(f'Activating client user with name "{client_user_name}".')
  try:
    # Construct and execute the request.
    response = marketplace.buyers().clients().users().activate(
        name=client_user_name).execute()
  except HttpError as e:
    print(e)
    sys.exit(1)

  pprint.pprint(response)


if __name__ == '__main__':
  try:
    service = util.get_service(version='v1')
  except IOError as ex:
    print(f'Unable to create marketplace service - {ex}')
    print('Did you specify the key file in util.py?')
    sys.exit(1)

  parser = argparse.ArgumentParser(
      description=('Activate a client user for the given buyer account, '
                   'client, and client user ID.'))
  # Required fields.
  parser.add_argument(
      '-a', '--account_id', default=DEFAULT_BUYER_RESOURCE_ID,
      help=('The resource ID of the buyers resource under which the client '
            'user was created. This will be used to construct the name used as '
            'a path parameter for the users.activate request.'))
  parser.add_argument(
      '-c', '--client_id', default=DEFAULT_CLIENT_RESOURCE_ID,
      help=('The resource ID of the buyers.clients resource under which the '
            'client user was created. This will be used to construct the name '
            'used as a path parameter for the users.activate request.'))
  parser.add_argument(
      '-u', '--client_user_id', default=DEFAULT_CLIENT_USER_RESOURCE_ID,
      help=('The resource ID of the buyers.clients.users resource for which '
            'the client user was created. This will be used to construct the '
            'name used as a path parameter for the users.activate request.'))

  main(service, parser.parse_args())