取消訂閱競價套裝方案

您可以使用下列方法取消訂閱買家帳戶或 使用 AuctionPackage 建立個別用戶端。

如要訂閱競價套裝方案,請參閱 訂閱

取消訂閱買家

您可以使用 buyers.auctionPackages.unsubscribe敬上 如何取消訂閱 AuctionPackage

取消訂閱競價套裝方案會導致您停止收到出價要求 選擇最適合的競價方式您必須取消訂閱所有客戶 才能取消訂閱買方

以下範例示範如何透過 AuctionPackage 搭配 unsubscribe 方法。

REST

要求

POST https://authorizedbuyersmarketplace.googleapis.com/v1/buyers/12345678/auctionPackages/560644393848382202:unsubscribe?alt=json
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

回應

{
 "name": "buyers/12345678/auctionPackages/560644393848382202",
 "creator": "buyers/42528410",
 "displayName": "Top 100 Mars Mobile Apps",
 "description": "Mobile Apps, Display format, United Federation of Mars.",
 "createTime": "2042-03-25T05:20:50.136Z",
 "updateTime": "2042-03-25T05:20:50.136Z"
}

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.AuctionPackages
{
    /// <summary>
    /// Unsubscribes a given buyer account from a specified auction package.
    ///
    /// Once unsubscribed, the bidder will cease receiving bid requests for the auction package
    /// for the specified buyer.
    /// </summary>
    public class UnsubscribeFromAuctionPackages : ExampleBase
    {
        private AuthorizedBuyersMarketplaceService mkService;

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

        /// <summary>
        /// Returns a description about the code example.
        /// </summary>
        public override string Description
        {
            get => "This code example unsubscribes a buyer account from an auction package.";
        }

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

            string accountId = null;
            string auctionPackageId = null;

            OptionSet options = new OptionSet {
                "Unsubscribe the given buyer account from the specified auction package.",
                {
                    "h|help",
                    "Show help message and exit.",
                    h => showHelp = h != null
                },
                {
                    "a|account_id=",
                    ("[Required] The resource ID of the buyers resource that will be " +
                     "unsubscribing from an auction package. This will be used to construct the " +
                     "name used as a path parameter for the auctionPackages.unsubscribe request."),
                    a => accountId = a
                },
                {
                    "auction_package_id=",
                    ("[Required] The resource ID of the buyers.auctionPackages resource that " +
                     "the buyer is unsubscribing from. This will be used to construct the name  " +
                     "used as a path parameter for the auctionPackages.unsubscribe request."),
                    auction_package_id => auctionPackageId = auction_package_id
                },
            };

            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["auction_package_id"] = auctionPackageId;
            // 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 auctionPackageId = (string) parsedArgs["auction_package_id"];
            string name = $"buyers/{accountId}/auctionPackages/{auctionPackageId}";

            BuyersResource.AuctionPackagesResource.UnsubscribeRequest request =
                mkService.Buyers.AuctionPackages.Unsubscribe(new UnsubscribeAuctionPackageRequest(), name);
            AuctionPackage response = null;

            Console.WriteLine("Unsubscribing buyer \"{0}\" from auction package \"{1}\"",
                accountId, auctionPackageId);

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

            Utilities.PrintAuctionPackage(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.auctionPackages;

import com.google.api.services.authorizedbuyersmarketplace.v1.AuthorizedBuyersMarketplace;
import com.google.api.services.authorizedbuyersmarketplace.v1.model.AuctionPackage;
import com.google.api.services.authorizedbuyersmarketplace.v1.model.UnsubscribeAuctionPackageRequest;
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 unsubscribe a given buyer account to a specified auction package.
 *
 * <p>Once unsubscribed, the bidder will cease receiving bid requests for the auction package for
 * the specified buyer.
 */
public class UnsubscribeFromAuctionPackages {

  public static void execute(AuthorizedBuyersMarketplace marketplaceClient, Namespace parsedArgs) {
    Long accountId = parsedArgs.getLong("account_id");
    Long auctionPackageId = parsedArgs.getLong("auction_package_id");
    String name = String.format("buyers/%d/auctionPackages/%d", accountId, auctionPackageId);

    AuctionPackage auctionPackage = null;

    try {
      auctionPackage =
          marketplaceClient
              .buyers()
              .auctionPackages()
              .unsubscribe(name, new UnsubscribeAuctionPackageRequest())
              .execute();
    } catch (IOException ex) {
      System.out.printf("Marketplace API returned error response:%n%s", ex);
      System.exit(1);
    }

    System.out.printf(
        "Unsubscribing buyer with ID \"%d\" from auction package with ID \"%s\":%n",
        accountId, auctionPackageId);
    Utils.printAuctionPackage(auctionPackage);
  }

  public static void main(String[] args) {
    ArgumentParser parser =
        ArgumentParsers.newFor("UnsubscribeFromAuctionPackages")
            .build()
            .defaultHelp(true)
            .description(("Subscribe the given buyer account to the specified auction package."));
    parser
        .addArgument("-a", "--account_id")
        .help(
            "The resource ID of the buyers resource that will be unsubscribing from the auction"
                + " package. This will be used to construct the name used as a path parameter for"
                + " the auctionPackages.unsubscribe request.")
        .required(true)
        .type(Long.class);
    parser
        .addArgument("--auction_package_id")
        .help(
            "The resource ID of the buyers.auctionPackages resource that the buyer is "
                + "unsubscribing from. This will be used to construct the name used as a path "
                + "parameter for the auctionPackages.unsubscribe 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.

"""Unsubscribes a given buyer account from a specified auction package."""


import argparse
import os
import pprint
import sys

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

from googleapiclient.errors import HttpError

import util


_AUCTION_PACKAGE_NAME_TEMPLATE = 'buyers/%s/auctionPackages/%s'

DEFAULT_BUYER_RESOURCE_ID = 'ENTER_BUYER_RESOURCE_ID_HERE'
DEFAULT_AUCTION_PACKAGE_RESOURCE_ID = 'ENTER_CLIENT_RESOURCE_ID_HERE'


def main(marketplace, args):
    account_id = args.account_id
    auction_package_name = _AUCTION_PACKAGE_NAME_TEMPLATE % (
        account_id, args.auction_package_id)

    print(f'Unsubscribing buyer account w/ ID "{account_id}" from auction '
          f'package with name "{auction_package_name}":')
    try:
        # Construct and execute the request.
        response = marketplace.buyers().auctionPackages().unsubscribe(
            name=auction_package_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=('Unsubscribe a given buyer account from a specified '
                     'auction package.'))
    # Required fields.
    parser.add_argument(
        '-a', '--account_id', default=DEFAULT_BUYER_RESOURCE_ID,
        help=('The resource ID of the buyers resource that is to unsubscribe '
              'from an auction package. This will be used to construct the '
              'name used as a path parameter for the '
              'auctionPackages.unsubscribe request.'))
    parser.add_argument(
        '-p', '--auction_package_id',
        default=DEFAULT_AUCTION_PACKAGE_RESOURCE_ID,
        help=('The resource ID of the buyers.auctionPackages resource that the '
              'buyer will unsubscribe from. This will be used to construct the '
              'name used as a path parameter for the '
              'auctionPackages.unsubscribe request.'))

    main(service, parser.parse_args())

取消訂閱客戶

您可以使用 buyers.auctionPackages.unsubscribeClients敬上 方法:從 AuctionPackage 取消訂閱買方的一或多個客戶。

取消訂閱後,您的端點就會停止根據 競價套裝方案的指定目標。

取消訂閱競價套裝方案的所有客戶無法取消訂閱 父項 buyer。如要取消訂閱buyer,請按 有 clientsbuyer 下使用 buyers.auctionPackages.unsubscribeClients, 然後呼叫 buyers.auctionPackages.unsubscribe

以下範例說明瞭如何從 使用 unsubscribeClients 方法建立 AuctionPackage

REST

要求

POST https://authorizedbuyersmarketplace.googleapis.com/v1/buyers/12345678/auctionPackages/560644393848382202:unsubscribeClients?alt=json
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

{
 "clients": [
   "buyers/12345678/clients/136428959"
 ]
}

回應

{
 "name": "buyers/12345678/auctionPackages/560644393848382202",
 "creator": "buyers/42528410",
 "displayName": "Top 100 Mars Mobile Apps",
 "description": "Mobile Apps, Display format, United Federation of Mars.",
 "createTime": "2042-03-25T05:20:50.136Z",
 "updateTime": "2042-03-25T05:20:50.136Z",
 "subscribedClients": [
   "buyers/12345678/clients/873721984",
 ]
}

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.AuctionPackages
{
    /// <summary>
    /// Unsubscribes one or more clients from a specified auction package.
    /// </summary>
    public class UnsubscribeClientsFromAuctionPackages : ExampleBase
    {
        private AuthorizedBuyersMarketplaceService mkService;

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

        /// <summary>
        /// Returns a description about the code example.
        /// </summary>
        public override string Description
        {
            get => "This code example unsubscribes one or more clients from an auction package.";
        }

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

            string accountId = null;
            string auctionPackageId = null;
            IList<string> clientIds = new List<string>();

            OptionSet options = new OptionSet {
                "Unsubscribe one or more clients from the specified auction package.",
                {
                    "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 clients " +
                     "unsubscribing from the auction package exist. This will be used to " +
                     "construct the name used as a path parameter for the " +
                     "auctionPackages.unsubscribeClients request."),
                    a => accountId = a
                },
                {
                    "auction_package_id=",
                    ("[Required] The resource ID of the buyers.auctionPackages resource that " +
                     "the buyer is unsubscribing their clients from. This will be used to " +
                     "construct the name used as a path parameter for the " +
                     "auctionPackages.unsubscribeClients request."),
                    auction_package_id => auctionPackageId = auction_package_id
                },
                {
                    "c|client_id=",
                    ("[Required] The resource IDs of one or more clients existing under the " +
                     "buyer that will be unsubscribed from the auction package. These will be " +
                     "used to construct client names that will be passed in the body of the " +
                     "auctionPackages.unsubscribeClients request. Specify this argument for each " +
                     "client you intend to unsubscribe from the auction package."),
                    c => clientIds.Add(c)
                },
            };

            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["auction_package_id"] = auctionPackageId;
            parsedArgs["client_ids"] = clientIds;
            // 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 auctionPackageId = (string) parsedArgs["auction_package_id"];
            List<string> clientIds = (List<string>) parsedArgs["client_ids"];
            List<string> clientNames = new List<string>();
            string name = $"buyers/{accountId}/auctionPackages/{auctionPackageId}";

            Console.WriteLine("Unsubscribing the following clients for buyer \"{0}\" from " +
                "auction package \"{1}\":", accountId, auctionPackageId);

            foreach (string clientId in clientIds)
            {
                string clientName = $"buyers/{accountId}/clients/{clientId}";
                clientNames.Add(clientName);
                Console.WriteLine($"- {clientName}");
            }

            UnsubscribeClientsRequest unsubscribeClientsRequest = new UnsubscribeClientsRequest()
            {
                Clients = clientNames
            };

            BuyersResource.AuctionPackagesResource.UnsubscribeClientsRequest request =
                mkService.Buyers.AuctionPackages.UnsubscribeClients(
                    unsubscribeClientsRequest, name);
            AuctionPackage response = null;

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

            Utilities.PrintAuctionPackage(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.auctionPackages;

import com.google.api.services.authorizedbuyersmarketplace.v1.AuthorizedBuyersMarketplace;
import com.google.api.services.authorizedbuyersmarketplace.v1.model.AuctionPackage;
import com.google.api.services.authorizedbuyersmarketplace.v1.model.UnsubscribeClientsRequest;
import com.google.api.services.samples.authorizedbuyers.marketplace.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 unsubscribe one or more clients from a specified auction package.
 */
public class UnsubscribeClientsFromAuctionPackages {

  public static void execute(AuthorizedBuyersMarketplace marketplaceClient, Namespace parsedArgs) {
    Long accountId = parsedArgs.getLong("account_id");
    Long auctionPackageId = parsedArgs.getLong("auction_package_id");
    List<String> clientIds = parsedArgs.getList("client_ids");
    String name = String.format("buyers/%d/auctionPackages/%d", accountId, auctionPackageId);

    AuctionPackage auctionPackage = null;

    UnsubscribeClientsRequest unsubscribeClientsRequest = new UnsubscribeClientsRequest();
    unsubscribeClientsRequest.setClients(clientIds);

    try {
      auctionPackage =
          marketplaceClient
              .buyers()
              .auctionPackages()
              .unsubscribeClients(name, unsubscribeClientsRequest)
              .execute();
    } catch (IOException ex) {
      System.out.printf("Marketplace API returned error response:%n%s", ex);
      System.exit(1);
    }

    System.out.printf(
        "Unsubscribing the following clients to for buyer \"%d\" from auction "
            + "package with ID \"%s\":%n",
        accountId, auctionPackageId);
    System.out.println("\t- " + String.join(String.format("%n\t- "), clientIds));
    Utils.printAuctionPackage(auctionPackage);
  }

  public static void main(String[] args) {
    ArgumentParser parser =
        ArgumentParsers.newFor("UnsubscribeClientsFromAuctionPackages")
            .build()
            .defaultHelp(true)
            .description(("Unsubscribe one or more clients from the specified auction package."));
    parser
        .addArgument("-a", "--account_id")
        .help(
            "The resource ID of the buyers resource under which the clients unsubscribing from the"
                + " auction package exist. This will be used to construct the name used as a path"
                + " parameter for the auctionPackages.unsubscribeClients request, and client names"
                + " that will be included in the body of the auctionPackages.unsubscribeClients"
                + " request.")
        .required(true)
        .type(Long.class);
    parser
        .addArgument("--auction_package_id")
        .help(
            "The resource ID of the buyers.auctionPackages resource that the buyer is unsubscribing"
                + " their clients from. This will be used to construct the name used as a path"
                + " parameter for the auctionPackages.unsubscribeClients request.")
        .required(true)
        .type(Long.class);
    parser
        .addArgument("--client_ids")
        .help(
            "The resource IDs of one or more buyers.clients resources that the buyer is"
                + " unsubscribing from an auction package. This will be used to construct client"
                + " names that will be included in the body of the"
                + " auctionPackages.unsubscribeClients request. Specify each client ID separated by"
                + " a space.")
        .required(true)
        .type(Long.class)
        .nargs("+");

    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.

"""Unsubscribes a given set of clients from a specified auction package."""


import argparse
import os
import pprint
import sys

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

from googleapiclient.errors import HttpError

import util


_AUCTION_PACKAGE_NAME_TEMPLATE = 'buyers/%s/auctionPackages/%s'
_CLIENT_NAME_TEMPLATE = 'buyers/%s/clients/%s'

DEFAULT_BUYER_RESOURCE_ID = 'ENTER_BUYER_RESOURCE_ID_HERE'
DEFAULT_AUCTION_PACKAGE_RESOURCE_ID = 'ENTER_CLIENT_RESOURCE_ID_HERE'


def main(marketplace, args):
    account_id = args.account_id
    auction_package_name = _AUCTION_PACKAGE_NAME_TEMPLATE % (
        account_id, args.auction_package_id)

    body = {'clients': [_CLIENT_NAME_TEMPLATE % (account_id, client)
                        for client in args.client_ids]}

    print('Unsubscribing clients from auction package '
          f'"{auction_package_name}" on behalf of buyer account w/ ID '
          f'"{account_id}":')
    try:
        # Construct and execute the request.
        response = marketplace.buyers().auctionPackages().unsubscribeClients(
            auctionPackage=auction_package_name, body=body).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=('Unsubscribe a given buyer\'s clients from a specified '
                     'auction package.'))
    # Required fields.
    parser.add_argument(
        '-a', '--account_id', default=DEFAULT_BUYER_RESOURCE_ID,
        help=('The resource ID of the buyers resource that is to have its '
              'clients unsubscribed from an auction package. This will be used '
              'to construct the name used as a path parameter for the '
              'auctionPackages.unsubscribeClients request.'))
    parser.add_argument(
        '-p', '--auction_package_id',
        default=DEFAULT_AUCTION_PACKAGE_RESOURCE_ID,
        help=('The resource ID of the buyers.auctionPackages resource that the '
              'buyer will unsubscribe one or more of its clients from. This '
              'will be used to construct the name used as a path parameter for '
              'the auctionPackages.unsubscribeClients request.'))
    parser.add_argument(
        '-c', '--client_ids', nargs='*',
        help=('The resource IDs of the buyers.clients resources that are to '
              'be unsubscribed from the auction package. Specify each client '
              'ID separated by a space.'))

    main(service, parser.parse_args())