From 1d38e432a4c7be88930a22daf2a6d74e895a00c8 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Fri, 16 Jun 2023 08:29:00 -0700 Subject: [PATCH] feat: Add support for ListSkuGroups and ListSkuGroupBillableSkus APIs in Cloud Channel APIs (#6365) PiperOrigin-RevId: 540624759 Source-Link: https://github.com/googleapis/googleapis/commit/7f2c9d158ac679bbf84fa110c9e6da692b8f9b9d Source-Link: https://github.com/googleapis/googleapis-gen/commit/2ed2d95b6255d0a33ecd961af6c9ca8b02cd8e03 Copy-Tag: eyJwIjoiQ2hhbm5lbC8uT3dsQm90LnlhbWwiLCJoIjoiMmVkMmQ5NWI2MjU1ZDBhMzNlY2Q5NjFhZjZjOWNhOGIwMmNkOGUwMyJ9 --- Channel/metadata/V1/Service.php | Bin 22135 -> 23217 bytes .../list_sku_group_billable_skus.php | 90 ++++++++ .../list_sku_groups.php | 89 ++++++++ Channel/src/V1/BillableSku.php | 193 ++++++++++++++++ .../CloudChannelServiceBaseClient.php | 106 +++++++++ .../Gapic/CloudChannelServiceGapicClient.php | 208 ++++++++++++++++++ .../V1/ListSkuGroupBillableSkusRequest.php | 178 +++++++++++++++ .../V1/ListSkuGroupBillableSkusResponse.php | 109 +++++++++ Channel/src/V1/ListSkuGroupsRequest.php | 181 +++++++++++++++ Channel/src/V1/ListSkuGroupsResponse.php | 109 +++++++++ Channel/src/V1/SkuGroup.php | 113 ++++++++++ Channel/src/V1/gapic_metadata.json | 10 + .../cloud_channel_service_client_config.json | 10 + ...loud_channel_service_descriptor_config.php | 41 ++++ ...oud_channel_service_rest_client_config.php | 22 ++ .../Client/CloudChannelServiceClientTest.php | 150 +++++++++++++ .../Unit/V1/CloudChannelServiceClientTest.php | 140 ++++++++++++ 17 files changed, 1749 insertions(+) create mode 100644 Channel/samples/V1/CloudChannelServiceClient/list_sku_group_billable_skus.php create mode 100644 Channel/samples/V1/CloudChannelServiceClient/list_sku_groups.php create mode 100644 Channel/src/V1/BillableSku.php create mode 100644 Channel/src/V1/ListSkuGroupBillableSkusRequest.php create mode 100644 Channel/src/V1/ListSkuGroupBillableSkusResponse.php create mode 100644 Channel/src/V1/ListSkuGroupsRequest.php create mode 100644 Channel/src/V1/ListSkuGroupsResponse.php create mode 100644 Channel/src/V1/SkuGroup.php diff --git a/Channel/metadata/V1/Service.php b/Channel/metadata/V1/Service.php index 50819da2be8e122147c7695ec234d0997cefa0a1..ac7f68c1abcecd4a869f4cd35a97442e86623673 100644 GIT binary patch delta 663 zcmeyqhH>Lo#tjcxS^uwKaMB0ibLCBfOH?nU{f1(P=j`N=9x zVC0fV7In(Z$w^GgNd>AZp8P<@mIJPQzlx!nQaYC?vg+cX)Z&8tyy8?LQ!cLJ?9%vj zu*v>hN(g=T1*MEDxD=4JAzK1B!J3OV32J#f(5T4)a!M>9g_8>e6iu5Mx!@)W@o=%^ zCFZ6|Fe)%=a0-cV@uXxH7vv;X#)CzfK%!Q`uN(s=@yOM~oG+x2n4FwnnpaY+Ukzo| z>I1C-2L(_J?)X}zWG-$b2MTd>F#{!`mPv34fK*~yD8$djUYuG~mYJL?!3=hn43|i8 zssvaBRXqzxdh;n6F(Ibg0h=G`9hVng#K^^q96-fFx|0tYNKR5?f%|&0fxfzAFwDWQ zP*XB$y8L7^lk(&OeJO-@ZaK0QBo?LSl?Yv8listSkuGroupBillableSkus($formattedParent); + + /** @var BillableSku $element */ + foreach ($response as $element) { + printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString()); + } + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample has been automatically generated and should be regarded as a code + * template only. It will require modifications to work: + * - It may require correct/in-range values for request initialization. + * - It may require specifying regional endpoints when creating the service client, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $formattedParent = CloudChannelServiceClient::skuGroupName('[ACCOUNT]', '[SKU_GROUP]'); + + list_sku_group_billable_skus_sample($formattedParent); +} +// [END cloudchannel_v1_generated_CloudChannelService_ListSkuGroupBillableSkus_sync] diff --git a/Channel/samples/V1/CloudChannelServiceClient/list_sku_groups.php b/Channel/samples/V1/CloudChannelServiceClient/list_sku_groups.php new file mode 100644 index 000000000000..3b499f9567d6 --- /dev/null +++ b/Channel/samples/V1/CloudChannelServiceClient/list_sku_groups.php @@ -0,0 +1,89 @@ +listSkuGroups($parent); + + /** @var SkuGroup $element */ + foreach ($response as $element) { + printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString()); + } + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample has been automatically generated and should be regarded as a code + * template only. It will require modifications to work: + * - It may require correct/in-range values for request initialization. + * - It may require specifying regional endpoints when creating the service client, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $parent = '[PARENT]'; + + list_sku_groups_sample($parent); +} +// [END cloudchannel_v1_generated_CloudChannelService_ListSkuGroups_sync] diff --git a/Channel/src/V1/BillableSku.php b/Channel/src/V1/BillableSku.php new file mode 100644 index 000000000000..3854708e82f8 --- /dev/null +++ b/Channel/src/V1/BillableSku.php @@ -0,0 +1,193 @@ +google.cloud.channel.v1.BillableSku + */ +class BillableSku extends \Google\Protobuf\Internal\Message +{ + /** + * Resource name of Billable SKU. Format: + * billableSkus/{sku}. + * Example: + * billableSkus/6E1B-6634-470F". + * + * Generated from protobuf field string sku = 1; + */ + private $sku = ''; + /** + * Unique human readable name for the SKU. + * + * Generated from protobuf field string sku_display_name = 2; + */ + private $sku_display_name = ''; + /** + * Resource name of Service which contains Repricing SKU. Format: + * services/{service}. + * Example: + * "services/B7D9-FDCB-15D8". + * + * Generated from protobuf field string service = 3; + */ + private $service = ''; + /** + * Unique human readable name for the Service. + * + * Generated from protobuf field string service_display_name = 4; + */ + private $service_display_name = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $sku + * Resource name of Billable SKU. Format: + * billableSkus/{sku}. + * Example: + * billableSkus/6E1B-6634-470F". + * @type string $sku_display_name + * Unique human readable name for the SKU. + * @type string $service + * Resource name of Service which contains Repricing SKU. Format: + * services/{service}. + * Example: + * "services/B7D9-FDCB-15D8". + * @type string $service_display_name + * Unique human readable name for the Service. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Channel\V1\Service::initOnce(); + parent::__construct($data); + } + + /** + * Resource name of Billable SKU. Format: + * billableSkus/{sku}. + * Example: + * billableSkus/6E1B-6634-470F". + * + * Generated from protobuf field string sku = 1; + * @return string + */ + public function getSku() + { + return $this->sku; + } + + /** + * Resource name of Billable SKU. Format: + * billableSkus/{sku}. + * Example: + * billableSkus/6E1B-6634-470F". + * + * Generated from protobuf field string sku = 1; + * @param string $var + * @return $this + */ + public function setSku($var) + { + GPBUtil::checkString($var, True); + $this->sku = $var; + + return $this; + } + + /** + * Unique human readable name for the SKU. + * + * Generated from protobuf field string sku_display_name = 2; + * @return string + */ + public function getSkuDisplayName() + { + return $this->sku_display_name; + } + + /** + * Unique human readable name for the SKU. + * + * Generated from protobuf field string sku_display_name = 2; + * @param string $var + * @return $this + */ + public function setSkuDisplayName($var) + { + GPBUtil::checkString($var, True); + $this->sku_display_name = $var; + + return $this; + } + + /** + * Resource name of Service which contains Repricing SKU. Format: + * services/{service}. + * Example: + * "services/B7D9-FDCB-15D8". + * + * Generated from protobuf field string service = 3; + * @return string + */ + public function getService() + { + return $this->service; + } + + /** + * Resource name of Service which contains Repricing SKU. Format: + * services/{service}. + * Example: + * "services/B7D9-FDCB-15D8". + * + * Generated from protobuf field string service = 3; + * @param string $var + * @return $this + */ + public function setService($var) + { + GPBUtil::checkString($var, True); + $this->service = $var; + + return $this; + } + + /** + * Unique human readable name for the Service. + * + * Generated from protobuf field string service_display_name = 4; + * @return string + */ + public function getServiceDisplayName() + { + return $this->service_display_name; + } + + /** + * Unique human readable name for the Service. + * + * Generated from protobuf field string service_display_name = 4; + * @param string $var + * @return $this + */ + public function setServiceDisplayName($var) + { + GPBUtil::checkString($var, True); + $this->service_display_name = $var; + + return $this; + } + +} + diff --git a/Channel/src/V1/Client/BaseClient/CloudChannelServiceBaseClient.php b/Channel/src/V1/Client/BaseClient/CloudChannelServiceBaseClient.php index e34e6097ef17..50a19537ec24 100644 --- a/Channel/src/V1/Client/BaseClient/CloudChannelServiceBaseClient.php +++ b/Channel/src/V1/Client/BaseClient/CloudChannelServiceBaseClient.php @@ -71,6 +71,8 @@ use Google\Cloud\Channel\V1\ListProductsRequest; use Google\Cloud\Channel\V1\ListPurchasableOffersRequest; use Google\Cloud\Channel\V1\ListPurchasableSkusRequest; +use Google\Cloud\Channel\V1\ListSkuGroupBillableSkusRequest; +use Google\Cloud\Channel\V1\ListSkuGroupsRequest; use Google\Cloud\Channel\V1\ListSkusRequest; use Google\Cloud\Channel\V1\ListSubscribersRequest; use Google\Cloud\Channel\V1\ListTransferableOffersRequest; @@ -163,6 +165,8 @@ * @method PromiseInterface listProductsAsync(ListProductsRequest $request, array $optionalArgs = []) * @method PromiseInterface listPurchasableOffersAsync(ListPurchasableOffersRequest $request, array $optionalArgs = []) * @method PromiseInterface listPurchasableSkusAsync(ListPurchasableSkusRequest $request, array $optionalArgs = []) + * @method PromiseInterface listSkuGroupBillableSkusAsync(ListSkuGroupBillableSkusRequest $request, array $optionalArgs = []) + * @method PromiseInterface listSkuGroupsAsync(ListSkuGroupsRequest $request, array $optionalArgs = []) * @method PromiseInterface listSkusAsync(ListSkusRequest $request, array $optionalArgs = []) * @method PromiseInterface listSubscribersAsync(ListSubscribersRequest $request, array $optionalArgs = []) * @method PromiseInterface listTransferableOffersAsync(ListTransferableOffersRequest $request, array $optionalArgs = []) @@ -375,6 +379,23 @@ public static function productName(string $product): string ]); } + /** + * Formats a string containing the fully-qualified path to represent a sku_group + * resource. + * + * @param string $account + * @param string $skuGroup + * + * @return string The formatted sku_group resource. + */ + public static function skuGroupName(string $account, string $skuGroup): string + { + return self::getPathTemplate('skuGroup')->render([ + 'account' => $account, + 'sku_group' => $skuGroup, + ]); + } + /** * Parses a formatted name string and returns an associative array of the components in the name. * The following name formats are supported: @@ -386,6 +407,7 @@ public static function productName(string $product): string * - entitlement: accounts/{account}/customers/{customer}/entitlements/{entitlement} * - offer: accounts/{account}/offers/{offer} * - product: products/{product} + * - skuGroup: accounts/{account}/skuGroups/{sku_group} * * The optional $template argument can be supplied to specify a particular pattern, * and must match one of the templates listed above. If no $template argument is @@ -1716,6 +1738,90 @@ public function listPurchasableSkus(ListPurchasableSkusRequest $request, array $ return $this->startApiCall('ListPurchasableSkus', $request, $callOptions); } + /** + * Lists the Billable SKUs in a given SKU group. + * + * Possible error codes: + * PERMISSION_DENIED: If the account making the request and the account + * being queried for are different, or the account doesn't exist. + * INVALID_ARGUMENT: Missing or invalid required parameters in the + * request. + * INTERNAL: Any non-user error related to technical issue in the + * backend. In this case, contact cloud channel support. + * + * Return Value: + * If successful, the [BillableSku][google.cloud.channel.v1.BillableSku] + * resources. The data for each resource is displayed in the ascending order + * of: + * + * * [BillableSku.service_display_name][google.cloud.channel.v1.BillableSku.service_display_name] + * * [BillableSku.sku_display_name][google.cloud.channel.v1.BillableSku.sku_display_name] + * + * If unsuccessful, returns an error. + * + * The async variant is {@see self::listSkuGroupBillableSkusAsync()} . + * + * @param ListSkuGroupBillableSkusRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listSkuGroupBillableSkus(ListSkuGroupBillableSkusRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListSkuGroupBillableSkus', $request, $callOptions); + } + + /** + * Lists the Rebilling supported SKU groups the account is authorized to + * sell. + * Reference: https://cloud.google.com/skus/sku-groups + * + * Possible Error Codes: + * + * * PERMISSION_DENIED: If the account making the request and the account + * being queried are different, or the account doesn't exist. + * * INTERNAL: Any non-user error related to technical issues in the + * backend. In this case, contact Cloud Channel support. + * + * Return Value: + * If successful, the [SkuGroup][google.cloud.channel.v1.SkuGroup] resources. + * The data for each resource is displayed in the alphabetical order of SKU + * group display name. + * The data for each resource is displayed in the ascending order of + * [SkuGroup.display_name][google.cloud.channel.v1.SkuGroup.display_name] + * + * If unsuccessful, returns an error. + * + * The async variant is {@see self::listSkuGroupsAsync()} . + * + * @param ListSkuGroupsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listSkuGroups(ListSkuGroupsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListSkuGroups', $request, $callOptions); + } + /** * Lists the SKUs for a product the reseller is authorized to sell. * diff --git a/Channel/src/V1/Gapic/CloudChannelServiceGapicClient.php b/Channel/src/V1/Gapic/CloudChannelServiceGapicClient.php index 4cd499bab4a0..31214e9e5879 100644 --- a/Channel/src/V1/Gapic/CloudChannelServiceGapicClient.php +++ b/Channel/src/V1/Gapic/CloudChannelServiceGapicClient.php @@ -86,6 +86,10 @@ use Google\Cloud\Channel\V1\ListPurchasableOffersResponse; use Google\Cloud\Channel\V1\ListPurchasableSkusRequest; use Google\Cloud\Channel\V1\ListPurchasableSkusResponse; +use Google\Cloud\Channel\V1\ListSkuGroupBillableSkusRequest; +use Google\Cloud\Channel\V1\ListSkuGroupBillableSkusResponse; +use Google\Cloud\Channel\V1\ListSkuGroupsRequest; +use Google\Cloud\Channel\V1\ListSkuGroupsResponse; use Google\Cloud\Channel\V1\ListSkusRequest; use Google\Cloud\Channel\V1\ListSkusResponse; use Google\Cloud\Channel\V1\ListSubscribersRequest; @@ -220,6 +224,8 @@ class CloudChannelServiceGapicClient private static $productNameTemplate; + private static $skuGroupNameTemplate; + private static $pathTemplateMap; private $operationsClient; @@ -306,6 +312,15 @@ private static function getProductNameTemplate() return self::$productNameTemplate; } + private static function getSkuGroupNameTemplate() + { + if (self::$skuGroupNameTemplate == null) { + self::$skuGroupNameTemplate = new PathTemplate('accounts/{account}/skuGroups/{sku_group}'); + } + + return self::$skuGroupNameTemplate; + } + private static function getPathTemplateMap() { if (self::$pathTemplateMap == null) { @@ -317,6 +332,7 @@ private static function getPathTemplateMap() 'entitlement' => self::getEntitlementNameTemplate(), 'offer' => self::getOfferNameTemplate(), 'product' => self::getProductNameTemplate(), + 'skuGroup' => self::getSkuGroupNameTemplate(), ]; } @@ -446,6 +462,23 @@ public static function productName($product) ]); } + /** + * Formats a string containing the fully-qualified path to represent a sku_group + * resource. + * + * @param string $account + * @param string $skuGroup + * + * @return string The formatted sku_group resource. + */ + public static function skuGroupName($account, $skuGroup) + { + return self::getSkuGroupNameTemplate()->render([ + 'account' => $account, + 'sku_group' => $skuGroup, + ]); + } + /** * Parses a formatted name string and returns an associative array of the components in the name. * The following name formats are supported: @@ -457,6 +490,7 @@ public static function productName($product) * - entitlement: accounts/{account}/customers/{customer}/entitlements/{entitlement} * - offer: accounts/{account}/offers/{offer} * - product: products/{product} + * - skuGroup: accounts/{account}/skuGroups/{sku_group} * * The optional $template argument can be supplied to specify a particular pattern, * and must match one of the templates listed above. If no $template argument is @@ -3091,6 +3125,180 @@ public function listPurchasableSkus($customer, array $optionalArgs = []) return $this->getPagedListResponse('ListPurchasableSkus', $optionalArgs, ListPurchasableSkusResponse::class, $request); } + /** + * Lists the Billable SKUs in a given SKU group. + * + * Possible error codes: + * PERMISSION_DENIED: If the account making the request and the account + * being queried for are different, or the account doesn't exist. + * INVALID_ARGUMENT: Missing or invalid required parameters in the + * request. + * INTERNAL: Any non-user error related to technical issue in the + * backend. In this case, contact cloud channel support. + * + * Return Value: + * If successful, the [BillableSku][google.cloud.channel.v1.BillableSku] + * resources. The data for each resource is displayed in the ascending order + * of: + * + * * [BillableSku.service_display_name][google.cloud.channel.v1.BillableSku.service_display_name] + * * [BillableSku.sku_display_name][google.cloud.channel.v1.BillableSku.sku_display_name] + * + * If unsuccessful, returns an error. + * + * Sample code: + * ``` + * $cloudChannelServiceClient = new CloudChannelServiceClient(); + * try { + * $formattedParent = $cloudChannelServiceClient->skuGroupName('[ACCOUNT]', '[SKU_GROUP]'); + * // Iterate over pages of elements + * $pagedResponse = $cloudChannelServiceClient->listSkuGroupBillableSkus($formattedParent); + * foreach ($pagedResponse->iteratePages() as $page) { + * foreach ($page as $element) { + * // doSomethingWith($element); + * } + * } + * // Alternatively: + * // Iterate through all elements + * $pagedResponse = $cloudChannelServiceClient->listSkuGroupBillableSkus($formattedParent); + * foreach ($pagedResponse->iterateAllElements() as $element) { + * // doSomethingWith($element); + * } + * } finally { + * $cloudChannelServiceClient->close(); + * } + * ``` + * + * @param string $parent Required. Resource name of the SKU group. + * Format: accounts/{account}/skuGroups/{sku_group}. + * @param array $optionalArgs { + * Optional. + * + * @type int $pageSize + * The maximum number of resources contained in the underlying API + * response. The API may return fewer values in a page, even if + * there are additional values to be retrieved. + * @type string $pageToken + * A page token is used to specify a page of values to be returned. + * If no page token is specified (the default), the first page + * of values will be returned. Any page token used here must have + * been generated by a previous call to the API. + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return \Google\ApiCore\PagedListResponse + * + * @throws ApiException if the remote call fails + */ + public function listSkuGroupBillableSkus($parent, array $optionalArgs = []) + { + $request = new ListSkuGroupBillableSkusRequest(); + $requestParamHeaders = []; + $request->setParent($parent); + $requestParamHeaders['parent'] = $parent; + if (isset($optionalArgs['pageSize'])) { + $request->setPageSize($optionalArgs['pageSize']); + } + + if (isset($optionalArgs['pageToken'])) { + $request->setPageToken($optionalArgs['pageToken']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->getPagedListResponse('ListSkuGroupBillableSkus', $optionalArgs, ListSkuGroupBillableSkusResponse::class, $request); + } + + /** + * Lists the Rebilling supported SKU groups the account is authorized to + * sell. + * Reference: https://cloud.google.com/skus/sku-groups + * + * Possible Error Codes: + * + * * PERMISSION_DENIED: If the account making the request and the account + * being queried are different, or the account doesn't exist. + * * INTERNAL: Any non-user error related to technical issues in the + * backend. In this case, contact Cloud Channel support. + * + * Return Value: + * If successful, the [SkuGroup][google.cloud.channel.v1.SkuGroup] resources. + * The data for each resource is displayed in the alphabetical order of SKU + * group display name. + * The data for each resource is displayed in the ascending order of + * [SkuGroup.display_name][google.cloud.channel.v1.SkuGroup.display_name] + * + * If unsuccessful, returns an error. + * + * Sample code: + * ``` + * $cloudChannelServiceClient = new CloudChannelServiceClient(); + * try { + * $parent = 'parent'; + * // Iterate over pages of elements + * $pagedResponse = $cloudChannelServiceClient->listSkuGroups($parent); + * foreach ($pagedResponse->iteratePages() as $page) { + * foreach ($page as $element) { + * // doSomethingWith($element); + * } + * } + * // Alternatively: + * // Iterate through all elements + * $pagedResponse = $cloudChannelServiceClient->listSkuGroups($parent); + * foreach ($pagedResponse->iterateAllElements() as $element) { + * // doSomethingWith($element); + * } + * } finally { + * $cloudChannelServiceClient->close(); + * } + * ``` + * + * @param string $parent Required. The resource name of the account from which to list SKU groups. + * Parent uses the format: accounts/{account}. + * @param array $optionalArgs { + * Optional. + * + * @type int $pageSize + * The maximum number of resources contained in the underlying API + * response. The API may return fewer values in a page, even if + * there are additional values to be retrieved. + * @type string $pageToken + * A page token is used to specify a page of values to be returned. + * If no page token is specified (the default), the first page + * of values will be returned. Any page token used here must have + * been generated by a previous call to the API. + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return \Google\ApiCore\PagedListResponse + * + * @throws ApiException if the remote call fails + */ + public function listSkuGroups($parent, array $optionalArgs = []) + { + $request = new ListSkuGroupsRequest(); + $requestParamHeaders = []; + $request->setParent($parent); + $requestParamHeaders['parent'] = $parent; + if (isset($optionalArgs['pageSize'])) { + $request->setPageSize($optionalArgs['pageSize']); + } + + if (isset($optionalArgs['pageToken'])) { + $request->setPageToken($optionalArgs['pageToken']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->getPagedListResponse('ListSkuGroups', $optionalArgs, ListSkuGroupsResponse::class, $request); + } + /** * Lists the SKUs for a product the reseller is authorized to sell. * diff --git a/Channel/src/V1/ListSkuGroupBillableSkusRequest.php b/Channel/src/V1/ListSkuGroupBillableSkusRequest.php new file mode 100644 index 000000000000..cabd1feba456 --- /dev/null +++ b/Channel/src/V1/ListSkuGroupBillableSkusRequest.php @@ -0,0 +1,178 @@ +google.cloud.channel.v1.ListSkuGroupBillableSkusRequest + */ +class ListSkuGroupBillableSkusRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. Resource name of the SKU group. + * Format: accounts/{account}/skuGroups/{sku_group}. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $parent = ''; + /** + * Optional. The maximum number of SKUs to return. The service may return + * fewer than this value. If unspecified, returns a maximum of 100000 SKUs. + * The maximum value is 100000; values above 100000 will be coerced to 100000. + * + * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $page_size = 0; + /** + * Optional. A token identifying a page of results beyond the first page. + * Obtained through + * [ListSkuGroupBillableSkus.next_page_token][] of the previous + * [CloudChannelService.ListSkuGroupBillableSkus][google.cloud.channel.v1.CloudChannelService.ListSkuGroupBillableSkus] + * call. + * + * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $page_token = ''; + + /** + * @param string $parent Required. Resource name of the SKU group. + * Format: accounts/{account}/skuGroups/{sku_group}. Please see + * {@see CloudChannelServiceClient::skuGroupName()} for help formatting this field. + * + * @return \Google\Cloud\Channel\V1\ListSkuGroupBillableSkusRequest + * + * @experimental + */ + public static function build(string $parent): self + { + return (new self()) + ->setParent($parent); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. Resource name of the SKU group. + * Format: accounts/{account}/skuGroups/{sku_group}. + * @type int $page_size + * Optional. The maximum number of SKUs to return. The service may return + * fewer than this value. If unspecified, returns a maximum of 100000 SKUs. + * The maximum value is 100000; values above 100000 will be coerced to 100000. + * @type string $page_token + * Optional. A token identifying a page of results beyond the first page. + * Obtained through + * [ListSkuGroupBillableSkus.next_page_token][] of the previous + * [CloudChannelService.ListSkuGroupBillableSkus][google.cloud.channel.v1.CloudChannelService.ListSkuGroupBillableSkus] + * call. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Channel\V1\Service::initOnce(); + parent::__construct($data); + } + + /** + * Required. Resource name of the SKU group. + * Format: accounts/{account}/skuGroups/{sku_group}. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * Required. Resource name of the SKU group. + * Format: accounts/{account}/skuGroups/{sku_group}. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setParent($var) + { + GPBUtil::checkString($var, True); + $this->parent = $var; + + return $this; + } + + /** + * Optional. The maximum number of SKUs to return. The service may return + * fewer than this value. If unspecified, returns a maximum of 100000 SKUs. + * The maximum value is 100000; values above 100000 will be coerced to 100000. + * + * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @return int + */ + public function getPageSize() + { + return $this->page_size; + } + + /** + * Optional. The maximum number of SKUs to return. The service may return + * fewer than this value. If unspecified, returns a maximum of 100000 SKUs. + * The maximum value is 100000; values above 100000 will be coerced to 100000. + * + * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @param int $var + * @return $this + */ + public function setPageSize($var) + { + GPBUtil::checkInt32($var); + $this->page_size = $var; + + return $this; + } + + /** + * Optional. A token identifying a page of results beyond the first page. + * Obtained through + * [ListSkuGroupBillableSkus.next_page_token][] of the previous + * [CloudChannelService.ListSkuGroupBillableSkus][google.cloud.channel.v1.CloudChannelService.ListSkuGroupBillableSkus] + * call. + * + * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @return string + */ + public function getPageToken() + { + return $this->page_token; + } + + /** + * Optional. A token identifying a page of results beyond the first page. + * Obtained through + * [ListSkuGroupBillableSkus.next_page_token][] of the previous + * [CloudChannelService.ListSkuGroupBillableSkus][google.cloud.channel.v1.CloudChannelService.ListSkuGroupBillableSkus] + * call. + * + * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @param string $var + * @return $this + */ + public function setPageToken($var) + { + GPBUtil::checkString($var, True); + $this->page_token = $var; + + return $this; + } + +} + diff --git a/Channel/src/V1/ListSkuGroupBillableSkusResponse.php b/Channel/src/V1/ListSkuGroupBillableSkusResponse.php new file mode 100644 index 000000000000..8d1cec950fd0 --- /dev/null +++ b/Channel/src/V1/ListSkuGroupBillableSkusResponse.php @@ -0,0 +1,109 @@ +google.cloud.channel.v1.ListSkuGroupBillableSkusResponse + */ +class ListSkuGroupBillableSkusResponse extends \Google\Protobuf\Internal\Message +{ + /** + * The list of billable SKUs in the requested SKU group. + * + * Generated from protobuf field repeated .google.cloud.channel.v1.BillableSku billable_skus = 1; + */ + private $billable_skus; + /** + * A token to retrieve the next page of results. + * Pass to [ListSkuGroupBillableSkus.page_token][] to obtain that + * page. + * + * Generated from protobuf field string next_page_token = 2; + */ + private $next_page_token = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\Google\Cloud\Channel\V1\BillableSku>|\Google\Protobuf\Internal\RepeatedField $billable_skus + * The list of billable SKUs in the requested SKU group. + * @type string $next_page_token + * A token to retrieve the next page of results. + * Pass to [ListSkuGroupBillableSkus.page_token][] to obtain that + * page. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Channel\V1\Service::initOnce(); + parent::__construct($data); + } + + /** + * The list of billable SKUs in the requested SKU group. + * + * Generated from protobuf field repeated .google.cloud.channel.v1.BillableSku billable_skus = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getBillableSkus() + { + return $this->billable_skus; + } + + /** + * The list of billable SKUs in the requested SKU group. + * + * Generated from protobuf field repeated .google.cloud.channel.v1.BillableSku billable_skus = 1; + * @param array<\Google\Cloud\Channel\V1\BillableSku>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setBillableSkus($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Channel\V1\BillableSku::class); + $this->billable_skus = $arr; + + return $this; + } + + /** + * A token to retrieve the next page of results. + * Pass to [ListSkuGroupBillableSkus.page_token][] to obtain that + * page. + * + * Generated from protobuf field string next_page_token = 2; + * @return string + */ + public function getNextPageToken() + { + return $this->next_page_token; + } + + /** + * A token to retrieve the next page of results. + * Pass to [ListSkuGroupBillableSkus.page_token][] to obtain that + * page. + * + * Generated from protobuf field string next_page_token = 2; + * @param string $var + * @return $this + */ + public function setNextPageToken($var) + { + GPBUtil::checkString($var, True); + $this->next_page_token = $var; + + return $this; + } + +} + diff --git a/Channel/src/V1/ListSkuGroupsRequest.php b/Channel/src/V1/ListSkuGroupsRequest.php new file mode 100644 index 000000000000..7f7c6617179b --- /dev/null +++ b/Channel/src/V1/ListSkuGroupsRequest.php @@ -0,0 +1,181 @@ +google.cloud.channel.v1.ListSkuGroupsRequest + */ +class ListSkuGroupsRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The resource name of the account from which to list SKU groups. + * Parent uses the format: accounts/{account}. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + private $parent = ''; + /** + * Optional. The maximum number of SKU groups to return. The service may + * return fewer than this value. If unspecified, returns a maximum of 1000 SKU + * groups. The maximum value is 1000; values above 1000 will be coerced to + * 1000. + * + * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $page_size = 0; + /** + * Optional. A token identifying a page of results beyond the first page. + * Obtained through + * [ListSkuGroups.next_page_token][] of the previous + * [CloudChannelService.ListSkuGroups][google.cloud.channel.v1.CloudChannelService.ListSkuGroups] + * call. + * + * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $page_token = ''; + + /** + * @param string $parent Required. The resource name of the account from which to list SKU groups. + * Parent uses the format: accounts/{account}. + * + * @return \Google\Cloud\Channel\V1\ListSkuGroupsRequest + * + * @experimental + */ + public static function build(string $parent): self + { + return (new self()) + ->setParent($parent); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. The resource name of the account from which to list SKU groups. + * Parent uses the format: accounts/{account}. + * @type int $page_size + * Optional. The maximum number of SKU groups to return. The service may + * return fewer than this value. If unspecified, returns a maximum of 1000 SKU + * groups. The maximum value is 1000; values above 1000 will be coerced to + * 1000. + * @type string $page_token + * Optional. A token identifying a page of results beyond the first page. + * Obtained through + * [ListSkuGroups.next_page_token][] of the previous + * [CloudChannelService.ListSkuGroups][google.cloud.channel.v1.CloudChannelService.ListSkuGroups] + * call. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Channel\V1\Service::initOnce(); + parent::__construct($data); + } + + /** + * Required. The resource name of the account from which to list SKU groups. + * Parent uses the format: accounts/{account}. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * Required. The resource name of the account from which to list SKU groups. + * Parent uses the format: accounts/{account}. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setParent($var) + { + GPBUtil::checkString($var, True); + $this->parent = $var; + + return $this; + } + + /** + * Optional. The maximum number of SKU groups to return. The service may + * return fewer than this value. If unspecified, returns a maximum of 1000 SKU + * groups. The maximum value is 1000; values above 1000 will be coerced to + * 1000. + * + * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @return int + */ + public function getPageSize() + { + return $this->page_size; + } + + /** + * Optional. The maximum number of SKU groups to return. The service may + * return fewer than this value. If unspecified, returns a maximum of 1000 SKU + * groups. The maximum value is 1000; values above 1000 will be coerced to + * 1000. + * + * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @param int $var + * @return $this + */ + public function setPageSize($var) + { + GPBUtil::checkInt32($var); + $this->page_size = $var; + + return $this; + } + + /** + * Optional. A token identifying a page of results beyond the first page. + * Obtained through + * [ListSkuGroups.next_page_token][] of the previous + * [CloudChannelService.ListSkuGroups][google.cloud.channel.v1.CloudChannelService.ListSkuGroups] + * call. + * + * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @return string + */ + public function getPageToken() + { + return $this->page_token; + } + + /** + * Optional. A token identifying a page of results beyond the first page. + * Obtained through + * [ListSkuGroups.next_page_token][] of the previous + * [CloudChannelService.ListSkuGroups][google.cloud.channel.v1.CloudChannelService.ListSkuGroups] + * call. + * + * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @param string $var + * @return $this + */ + public function setPageToken($var) + { + GPBUtil::checkString($var, True); + $this->page_token = $var; + + return $this; + } + +} + diff --git a/Channel/src/V1/ListSkuGroupsResponse.php b/Channel/src/V1/ListSkuGroupsResponse.php new file mode 100644 index 000000000000..6653a7b4d690 --- /dev/null +++ b/Channel/src/V1/ListSkuGroupsResponse.php @@ -0,0 +1,109 @@ +google.cloud.channel.v1.ListSkuGroupsResponse + */ +class ListSkuGroupsResponse extends \Google\Protobuf\Internal\Message +{ + /** + * The list of SKU groups requested. + * + * Generated from protobuf field repeated .google.cloud.channel.v1.SkuGroup sku_groups = 1; + */ + private $sku_groups; + /** + * A token to retrieve the next page of results. + * Pass to [ListSkuGroups.page_token][] to obtain that + * page. + * + * Generated from protobuf field string next_page_token = 2; + */ + private $next_page_token = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\Google\Cloud\Channel\V1\SkuGroup>|\Google\Protobuf\Internal\RepeatedField $sku_groups + * The list of SKU groups requested. + * @type string $next_page_token + * A token to retrieve the next page of results. + * Pass to [ListSkuGroups.page_token][] to obtain that + * page. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Channel\V1\Service::initOnce(); + parent::__construct($data); + } + + /** + * The list of SKU groups requested. + * + * Generated from protobuf field repeated .google.cloud.channel.v1.SkuGroup sku_groups = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getSkuGroups() + { + return $this->sku_groups; + } + + /** + * The list of SKU groups requested. + * + * Generated from protobuf field repeated .google.cloud.channel.v1.SkuGroup sku_groups = 1; + * @param array<\Google\Cloud\Channel\V1\SkuGroup>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setSkuGroups($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Channel\V1\SkuGroup::class); + $this->sku_groups = $arr; + + return $this; + } + + /** + * A token to retrieve the next page of results. + * Pass to [ListSkuGroups.page_token][] to obtain that + * page. + * + * Generated from protobuf field string next_page_token = 2; + * @return string + */ + public function getNextPageToken() + { + return $this->next_page_token; + } + + /** + * A token to retrieve the next page of results. + * Pass to [ListSkuGroups.page_token][] to obtain that + * page. + * + * Generated from protobuf field string next_page_token = 2; + * @param string $var + * @return $this + */ + public function setNextPageToken($var) + { + GPBUtil::checkString($var, True); + $this->next_page_token = $var; + + return $this; + } + +} + diff --git a/Channel/src/V1/SkuGroup.php b/Channel/src/V1/SkuGroup.php new file mode 100644 index 000000000000..adb547a65fc4 --- /dev/null +++ b/Channel/src/V1/SkuGroup.php @@ -0,0 +1,113 @@ +google.cloud.channel.v1.SkuGroup + */ +class SkuGroup extends \Google\Protobuf\Internal\Message +{ + /** + * Resource name of SKU group. Format: + * accounts/{account}/skuGroups/{sku_group}. + * Example: + * "accounts/C01234/skuGroups/3d50fd57-3157-4577-a5a9-a219b8490041". + * + * Generated from protobuf field string name = 1; + */ + private $name = ''; + /** + * Unique human readable identifier for the SKU group. + * + * Generated from protobuf field string display_name = 2; + */ + private $display_name = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Resource name of SKU group. Format: + * accounts/{account}/skuGroups/{sku_group}. + * Example: + * "accounts/C01234/skuGroups/3d50fd57-3157-4577-a5a9-a219b8490041". + * @type string $display_name + * Unique human readable identifier for the SKU group. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Channel\V1\Service::initOnce(); + parent::__construct($data); + } + + /** + * Resource name of SKU group. Format: + * accounts/{account}/skuGroups/{sku_group}. + * Example: + * "accounts/C01234/skuGroups/3d50fd57-3157-4577-a5a9-a219b8490041". + * + * Generated from protobuf field string name = 1; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Resource name of SKU group. Format: + * accounts/{account}/skuGroups/{sku_group}. + * Example: + * "accounts/C01234/skuGroups/3d50fd57-3157-4577-a5a9-a219b8490041". + * + * Generated from protobuf field string name = 1; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * Unique human readable identifier for the SKU group. + * + * Generated from protobuf field string display_name = 2; + * @return string + */ + public function getDisplayName() + { + return $this->display_name; + } + + /** + * Unique human readable identifier for the SKU group. + * + * Generated from protobuf field string display_name = 2; + * @param string $var + * @return $this + */ + public function setDisplayName($var) + { + GPBUtil::checkString($var, True); + $this->display_name = $var; + + return $this; + } + +} + diff --git a/Channel/src/V1/gapic_metadata.json b/Channel/src/V1/gapic_metadata.json index 7946f0fd5f57..dacbe6ad1881 100644 --- a/Channel/src/V1/gapic_metadata.json +++ b/Channel/src/V1/gapic_metadata.json @@ -184,6 +184,16 @@ "listPurchasableSkus" ] }, + "ListSkuGroupBillableSkus": { + "methods": [ + "listSkuGroupBillableSkus" + ] + }, + "ListSkuGroups": { + "methods": [ + "listSkuGroups" + ] + }, "ListSkus": { "methods": [ "listSkus" diff --git a/Channel/src/V1/resources/cloud_channel_service_client_config.json b/Channel/src/V1/resources/cloud_channel_service_client_config.json index 8c1b8868cdf4..40f71dfca7e2 100644 --- a/Channel/src/V1/resources/cloud_channel_service_client_config.json +++ b/Channel/src/V1/resources/cloud_channel_service_client_config.json @@ -188,6 +188,16 @@ "retry_codes_name": "retry_policy_1_codes", "retry_params_name": "retry_policy_1_params" }, + "ListSkuGroupBillableSkus": { + "timeout_millis": 60000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, + "ListSkuGroups": { + "timeout_millis": 60000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, "ListSkus": { "timeout_millis": 60000, "retry_codes_name": "retry_policy_1_codes", diff --git a/Channel/src/V1/resources/cloud_channel_service_descriptor_config.php b/Channel/src/V1/resources/cloud_channel_service_descriptor_config.php index e31ceb83dadc..3878249c56e8 100644 --- a/Channel/src/V1/resources/cloud_channel_service_descriptor_config.php +++ b/Channel/src/V1/resources/cloud_channel_service_descriptor_config.php @@ -572,6 +572,46 @@ ], ], ], + 'ListSkuGroupBillableSkus' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getBillableSkus', + ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Channel\V1\ListSkuGroupBillableSkusResponse', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'ListSkuGroups' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getSkuGroups', + ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Channel\V1\ListSkuGroupsResponse', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], 'ListSkus' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', @@ -747,6 +787,7 @@ 'entitlement' => 'accounts/{account}/customers/{customer}/entitlements/{entitlement}', 'offer' => 'accounts/{account}/offers/{offer}', 'product' => 'products/{product}', + 'skuGroup' => 'accounts/{account}/skuGroups/{sku_group}', ], ], ], diff --git a/Channel/src/V1/resources/cloud_channel_service_rest_client_config.php b/Channel/src/V1/resources/cloud_channel_service_rest_client_config.php index 94b7b90bbd8f..be73f7d1d2a5 100644 --- a/Channel/src/V1/resources/cloud_channel_service_rest_client_config.php +++ b/Channel/src/V1/resources/cloud_channel_service_rest_client_config.php @@ -373,6 +373,28 @@ ], ], ], + 'ListSkuGroupBillableSkus' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{parent=accounts/*/skuGroups/*}/billableSkus', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + 'ListSkuGroups' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{parent=accounts/*}/skuGroups', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], 'ListSkus' => [ 'method' => 'get', 'uriTemplate' => '/v1/{parent=products/*}/skus', diff --git a/Channel/tests/Unit/V1/Client/CloudChannelServiceClientTest.php b/Channel/tests/Unit/V1/Client/CloudChannelServiceClientTest.php index 7a5b22fc7ebf..f9373bbc9f1a 100644 --- a/Channel/tests/Unit/V1/Client/CloudChannelServiceClientTest.php +++ b/Channel/tests/Unit/V1/Client/CloudChannelServiceClientTest.php @@ -28,6 +28,7 @@ use Google\ApiCore\Testing\GeneratedTest; use Google\ApiCore\Testing\MockTransport; use Google\Cloud\Channel\V1\ActivateEntitlementRequest; +use Google\Cloud\Channel\V1\BillableSku; use Google\Cloud\Channel\V1\CancelEntitlementRequest; use Google\Cloud\Channel\V1\ChangeOfferRequest; use Google\Cloud\Channel\V1\ChangeParametersRequest; @@ -76,6 +77,10 @@ use Google\Cloud\Channel\V1\ListPurchasableOffersResponse; use Google\Cloud\Channel\V1\ListPurchasableSkusRequest; use Google\Cloud\Channel\V1\ListPurchasableSkusResponse; +use Google\Cloud\Channel\V1\ListSkuGroupBillableSkusRequest; +use Google\Cloud\Channel\V1\ListSkuGroupBillableSkusResponse; +use Google\Cloud\Channel\V1\ListSkuGroupsRequest; +use Google\Cloud\Channel\V1\ListSkuGroupsResponse; use Google\Cloud\Channel\V1\ListSkusRequest; use Google\Cloud\Channel\V1\ListSkusResponse; use Google\Cloud\Channel\V1\ListSubscribersRequest; @@ -97,6 +102,7 @@ use Google\Cloud\Channel\V1\RepricingAdjustment; use Google\Cloud\Channel\V1\RepricingConfig; use Google\Cloud\Channel\V1\Sku; +use Google\Cloud\Channel\V1\SkuGroup; use Google\Cloud\Channel\V1\StartPaidServiceRequest; use Google\Cloud\Channel\V1\SuspendEntitlementRequest; use Google\Cloud\Channel\V1\TransferEntitlementsRequest; @@ -2701,6 +2707,150 @@ public function listPurchasableSkusExceptionTest() $this->assertTrue($transport->isExhausted()); } + /** @test */ + public function listSkuGroupBillableSkusTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $billableSkusElement = new BillableSku(); + $billableSkus = [ + $billableSkusElement, + ]; + $expectedResponse = new ListSkuGroupBillableSkusResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setBillableSkus($billableSkus); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->skuGroupName('[ACCOUNT]', '[SKU_GROUP]'); + $request = (new ListSkuGroupBillableSkusRequest()) + ->setParent($formattedParent); + $response = $gapicClient->listSkuGroupBillableSkus($request); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getBillableSkus()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.channel.v1.CloudChannelService/ListSkuGroupBillableSkus', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listSkuGroupBillableSkusExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedParent = $gapicClient->skuGroupName('[ACCOUNT]', '[SKU_GROUP]'); + $request = (new ListSkuGroupBillableSkusRequest()) + ->setParent($formattedParent); + try { + $gapicClient->listSkuGroupBillableSkus($request); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listSkuGroupsTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $skuGroupsElement = new SkuGroup(); + $skuGroups = [ + $skuGroupsElement, + ]; + $expectedResponse = new ListSkuGroupsResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setSkuGroups($skuGroups); + $transport->addResponse($expectedResponse); + // Mock request + $parent = 'parent-995424086'; + $request = (new ListSkuGroupsRequest()) + ->setParent($parent); + $response = $gapicClient->listSkuGroups($request); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getSkuGroups()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.channel.v1.CloudChannelService/ListSkuGroups', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($parent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listSkuGroupsExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $parent = 'parent-995424086'; + $request = (new ListSkuGroupsRequest()) + ->setParent($parent); + try { + $gapicClient->listSkuGroups($request); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + /** @test */ public function listSkusTest() { diff --git a/Channel/tests/Unit/V1/CloudChannelServiceClientTest.php b/Channel/tests/Unit/V1/CloudChannelServiceClientTest.php index 898965f9845a..35f4cf7396ec 100644 --- a/Channel/tests/Unit/V1/CloudChannelServiceClientTest.php +++ b/Channel/tests/Unit/V1/CloudChannelServiceClientTest.php @@ -27,6 +27,7 @@ use Google\ApiCore\LongRunning\OperationsClient; use Google\ApiCore\Testing\GeneratedTest; use Google\ApiCore\Testing\MockTransport; +use Google\Cloud\Channel\V1\BillableSku; use Google\Cloud\Channel\V1\ChannelPartnerLink; use Google\Cloud\Channel\V1\ChannelPartnerLinkState; use Google\Cloud\Channel\V1\ChannelPartnerRepricingConfig; @@ -47,6 +48,8 @@ use Google\Cloud\Channel\V1\ListProductsResponse; use Google\Cloud\Channel\V1\ListPurchasableOffersResponse; use Google\Cloud\Channel\V1\ListPurchasableSkusResponse; +use Google\Cloud\Channel\V1\ListSkuGroupBillableSkusResponse; +use Google\Cloud\Channel\V1\ListSkuGroupsResponse; use Google\Cloud\Channel\V1\ListSkusResponse; use Google\Cloud\Channel\V1\ListSubscribersResponse; use Google\Cloud\Channel\V1\ListTransferableOffersResponse; @@ -61,6 +64,7 @@ use Google\Cloud\Channel\V1\RepricingAdjustment; use Google\Cloud\Channel\V1\RepricingConfig; use Google\Cloud\Channel\V1\Sku; +use Google\Cloud\Channel\V1\SkuGroup; use Google\Cloud\Channel\V1\TransferEntitlementsResponse; use Google\Cloud\Channel\V1\TransferableOffer; use Google\Cloud\Channel\V1\TransferableSku; @@ -2516,6 +2520,142 @@ public function listPurchasableSkusExceptionTest() $this->assertTrue($transport->isExhausted()); } + /** @test */ + public function listSkuGroupBillableSkusTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $billableSkusElement = new BillableSku(); + $billableSkus = [ + $billableSkusElement, + ]; + $expectedResponse = new ListSkuGroupBillableSkusResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setBillableSkus($billableSkus); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->skuGroupName('[ACCOUNT]', '[SKU_GROUP]'); + $response = $gapicClient->listSkuGroupBillableSkus($formattedParent); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getBillableSkus()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.channel.v1.CloudChannelService/ListSkuGroupBillableSkus', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listSkuGroupBillableSkusExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedParent = $gapicClient->skuGroupName('[ACCOUNT]', '[SKU_GROUP]'); + try { + $gapicClient->listSkuGroupBillableSkus($formattedParent); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listSkuGroupsTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $skuGroupsElement = new SkuGroup(); + $skuGroups = [ + $skuGroupsElement, + ]; + $expectedResponse = new ListSkuGroupsResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setSkuGroups($skuGroups); + $transport->addResponse($expectedResponse); + // Mock request + $parent = 'parent-995424086'; + $response = $gapicClient->listSkuGroups($parent); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getSkuGroups()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.channel.v1.CloudChannelService/ListSkuGroups', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($parent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listSkuGroupsExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $parent = 'parent-995424086'; + try { + $gapicClient->listSkuGroups($parent); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + /** @test */ public function listSkusTest() {