From b3aafaf490e9eb4b8d18ded8ef8d82b0390bf71b Mon Sep 17 00:00:00 2001 From: Yash Sahu <54198301+yash30201@users.noreply.github.com> Date: Thu, 21 Mar 2024 20:56:37 +0530 Subject: [PATCH] feat: Introduce ShoppingMerchantQuota (#7167) --- ShoppingMerchantQuota/.OwlBot.yaml | 4 + ShoppingMerchantQuota/.gitattributes | 8 + .../.github/pull_request_template.md | 24 ++ ShoppingMerchantQuota/.repo-metadata.json | 8 + ShoppingMerchantQuota/CONTRIBUTING.md | 10 + ShoppingMerchantQuota/LICENSE | 202 ++++++++++++++ ShoppingMerchantQuota/README.md | 45 ++++ ShoppingMerchantQuota/VERSION | 1 + ShoppingMerchantQuota/composer.json | 30 +++ .../metadata/V1Beta/Quota.php | 58 +++++ ShoppingMerchantQuota/owlbot.py | 62 +++++ ShoppingMerchantQuota/phpunit.xml.dist | 16 ++ .../QuotaServiceClient/list_quota_groups.php | 78 ++++++ .../src/V1beta/Client/QuotaServiceClient.php | 246 ++++++++++++++++++ .../src/V1beta/ListQuotaGroupsRequest.php | 162 ++++++++++++ .../src/V1beta/ListQuotaGroupsResponse.php | 117 +++++++++ .../src/V1beta/MethodDetails.php | 173 ++++++++++++ .../src/V1beta/QuotaGroup.php | 221 ++++++++++++++++ .../src/V1beta/gapic_metadata.json | 23 ++ .../quota_service_client_config.json | 39 +++ .../quota_service_descriptor_config.php | 31 +++ .../quota_service_rest_client_config.php | 20 ++ .../V1beta/Client/QuotaServiceClientTest.php | 170 ++++++++++++ composer.json | 3 + 24 files changed, 1751 insertions(+) create mode 100644 ShoppingMerchantQuota/.OwlBot.yaml create mode 100644 ShoppingMerchantQuota/.gitattributes create mode 100644 ShoppingMerchantQuota/.github/pull_request_template.md create mode 100644 ShoppingMerchantQuota/.repo-metadata.json create mode 100644 ShoppingMerchantQuota/CONTRIBUTING.md create mode 100644 ShoppingMerchantQuota/LICENSE create mode 100644 ShoppingMerchantQuota/README.md create mode 100644 ShoppingMerchantQuota/VERSION create mode 100644 ShoppingMerchantQuota/composer.json create mode 100644 ShoppingMerchantQuota/metadata/V1Beta/Quota.php create mode 100644 ShoppingMerchantQuota/owlbot.py create mode 100644 ShoppingMerchantQuota/phpunit.xml.dist create mode 100644 ShoppingMerchantQuota/samples/V1beta/QuotaServiceClient/list_quota_groups.php create mode 100644 ShoppingMerchantQuota/src/V1beta/Client/QuotaServiceClient.php create mode 100644 ShoppingMerchantQuota/src/V1beta/ListQuotaGroupsRequest.php create mode 100644 ShoppingMerchantQuota/src/V1beta/ListQuotaGroupsResponse.php create mode 100644 ShoppingMerchantQuota/src/V1beta/MethodDetails.php create mode 100644 ShoppingMerchantQuota/src/V1beta/QuotaGroup.php create mode 100644 ShoppingMerchantQuota/src/V1beta/gapic_metadata.json create mode 100644 ShoppingMerchantQuota/src/V1beta/resources/quota_service_client_config.json create mode 100644 ShoppingMerchantQuota/src/V1beta/resources/quota_service_descriptor_config.php create mode 100644 ShoppingMerchantQuota/src/V1beta/resources/quota_service_rest_client_config.php create mode 100644 ShoppingMerchantQuota/tests/Unit/V1beta/Client/QuotaServiceClientTest.php diff --git a/ShoppingMerchantQuota/.OwlBot.yaml b/ShoppingMerchantQuota/.OwlBot.yaml new file mode 100644 index 000000000000..ae68735c8fdb --- /dev/null +++ b/ShoppingMerchantQuota/.OwlBot.yaml @@ -0,0 +1,4 @@ +deep-copy-regex: + - source: /google/shopping/merchant/quota/(v1beta)/.*-php/(.*) + dest: /owl-bot-staging/ShoppingMerchantQuota/$1/$2 +api-name: ShoppingMerchantQuota diff --git a/ShoppingMerchantQuota/.gitattributes b/ShoppingMerchantQuota/.gitattributes new file mode 100644 index 000000000000..8119e7fcc1b2 --- /dev/null +++ b/ShoppingMerchantQuota/.gitattributes @@ -0,0 +1,8 @@ +/*.xml.dist export-ignore +/.OwlBot.yaml export-ignore +/.github export-ignore +/.repo-metadata.json export-ignore +/owlbot.py export-ignore +/src/**/gapic_metadata.json export-ignore +/samples export-ignore +/tests export-ignore diff --git a/ShoppingMerchantQuota/.github/pull_request_template.md b/ShoppingMerchantQuota/.github/pull_request_template.md new file mode 100644 index 000000000000..fea327327d83 --- /dev/null +++ b/ShoppingMerchantQuota/.github/pull_request_template.md @@ -0,0 +1,24 @@ +**PLEASE READ THIS ENTIRE MESSAGE** + +Hello, and thank you for your contribution! Please note that this repository is +a read-only split of `googleapis/google-cloud-php`. As such, we are +unable to accept pull requests to this repository. + +We welcome your pull request and would be happy to consider it for inclusion in +our library if you follow these steps: + +* Clone the parent client library repository: + +```sh +$ git clone git@github.com:googleapis/google-cloud-php.git +``` + +* Move your changes into the correct location in that library. Library code +belongs in `ShoppingMerchantQuota/src`, and tests in `ShoppingMerchantQuota/tests`. + +* Push the changes in a new branch to a fork, and open a new pull request +[here](https://github.com/googleapis/google-cloud-php). + +Thanks again, and we look forward to seeing your proposed change! + +The Google Cloud PHP team diff --git a/ShoppingMerchantQuota/.repo-metadata.json b/ShoppingMerchantQuota/.repo-metadata.json new file mode 100644 index 000000000000..9926c4c8c270 --- /dev/null +++ b/ShoppingMerchantQuota/.repo-metadata.json @@ -0,0 +1,8 @@ +{ + "language": "php", + "distribution_name": "google/shopping-merchant-quota", + "release_level": "preview", + "client_documentation": "https://cloud.google.com/php/docs/reference/shopping-merchant-quota/latest", + "library_type": "GAPIC_AUTO", + "api_shortname": "merchantapi" +} diff --git a/ShoppingMerchantQuota/CONTRIBUTING.md b/ShoppingMerchantQuota/CONTRIBUTING.md new file mode 100644 index 000000000000..76ea811cacdb --- /dev/null +++ b/ShoppingMerchantQuota/CONTRIBUTING.md @@ -0,0 +1,10 @@ +# How to Contribute + +We'd love to accept your patches and contributions to this project. We accept +and review pull requests against the main +[Google Cloud PHP](https://github.com/googleapis/google-cloud-php) +repository, which contains all of our client libraries. You will also need to +sign a Contributor License Agreement. For more details about how to contribute, +see the +[CONTRIBUTING.md](https://github.com/googleapis/google-cloud-php/blob/main/CONTRIBUTING.md) +file in the main Google Cloud PHP repository. diff --git a/ShoppingMerchantQuota/LICENSE b/ShoppingMerchantQuota/LICENSE new file mode 100644 index 000000000000..8f71f43fee3f --- /dev/null +++ b/ShoppingMerchantQuota/LICENSE @@ -0,0 +1,202 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + 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. + diff --git a/ShoppingMerchantQuota/README.md b/ShoppingMerchantQuota/README.md new file mode 100644 index 000000000000..50f4e9ab379f --- /dev/null +++ b/ShoppingMerchantQuota/README.md @@ -0,0 +1,45 @@ +# Google Shopping Merchant Quota for PHP + +> Idiomatic PHP client for [Google Shopping Merchant Quota](https://developers.google.com/merchant/api). + +[![Latest Stable Version](https://poser.pugx.org/google/shopping-merchant-quota/v/stable)](https://packagist.org/packages/google/shopping-merchant-quota) [![Packagist](https://img.shields.io/packagist/dm/google/shopping-merchant-quota.svg)](https://packagist.org/packages/google/shopping-merchant-quota) + +* [API documentation](https://developers.google.com/merchant/api/reference/rpc/google.shopping.merchant.quota.v1beta) + +**NOTE:** This repository is part of [Google Cloud PHP](https://github.com/googleapis/google-cloud-php). Any +support requests, bug reports, or development contributions should be directed to +that project. + +### Installation + +To begin, install the preferred dependency manager for PHP, [Composer](https://getcomposer.org/). + +Now, install this component: + +```sh +$ composer require google/shopping-merchant-quota +``` + +> Browse the complete list of [Google Cloud APIs](https://cloud.google.com/php/docs/reference) +> for PHP + +This component supports both REST over HTTP/1.1 and gRPC. In order to take advantage of the benefits +offered by gRPC (such as streaming methods) please see our +[gRPC installation guide](https://cloud.google.com/php/grpc). + +### Authentication + +Please see our [Authentication guide](https://github.com/googleapis/google-cloud-php/blob/main/AUTHENTICATION.md) for more information +on authenticating your client. Once authenticated, you'll be ready to start making requests. + +### Sample + +See the [samples directory](https://github.com/googleapis/php-shopping-merchant-quota/tree/main/samples) for a canonical list of samples. + +### Version + +This component is considered alpha. As such, it is still a work-in-progress and is more likely to get backwards-incompatible updates. + +### Next Steps + +1. Understand the [official documentation](https://developers.google.com/merchant/api). diff --git a/ShoppingMerchantQuota/VERSION b/ShoppingMerchantQuota/VERSION new file mode 100644 index 000000000000..77d6f4ca2371 --- /dev/null +++ b/ShoppingMerchantQuota/VERSION @@ -0,0 +1 @@ +0.0.0 diff --git a/ShoppingMerchantQuota/composer.json b/ShoppingMerchantQuota/composer.json new file mode 100644 index 000000000000..3c295b0f1ffd --- /dev/null +++ b/ShoppingMerchantQuota/composer.json @@ -0,0 +1,30 @@ +{ + "name": "google/shopping-merchant-quota", + "description": "Google Shopping Merchant Quota Client for PHP", + "license": "Apache-2.0", + "minimum-stability": "stable", + "autoload": { + "psr-4": { + "Google\\Shopping\\Merchant\\Quota\\": "src", + "GPBMetadata\\Google\\Shopping\\Merchant\\Quota\\": "metadata" + } + }, + "extra": { + "component": { + "id": "shopping-merchant-quota", + "path": "ShoppingMerchantQuota", + "target": "googleapis/php-shopping-merchant-quota" + } + }, + "require": { + "php": "^8.0", + "google/gax": "^1.30.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.0" + }, + "suggest": { + "ext-grpc": "Enables use of gRPC, a universal high-performance RPC framework created by Google.", + "ext-protobuf": "Provides a significant increase in throughput over the pure PHP protobuf implementation. See https://cloud.google.com/php/grpc for installation instructions." + } +} diff --git a/ShoppingMerchantQuota/metadata/V1Beta/Quota.php b/ShoppingMerchantQuota/metadata/V1Beta/Quota.php new file mode 100644 index 000000000000..ffaad6f7b275 --- /dev/null +++ b/ShoppingMerchantQuota/metadata/V1Beta/Quota.php @@ -0,0 +1,58 @@ +internalAddGeneratedFile( + ' +» + +1google/shopping/merchant/quota/v1beta/quota.proto%google.shopping.merchant.quota.v1betagoogle/api/client.protogoogle/api/field_behavior.protogoogle/api/resource.proto"¯ + +QuotaGroup +name ( BàA + quota_usage (BàA + quota_limit (BàA +quota_minute_limit (BàAQ +method_details ( 24.google.shopping.merchant.quota.v1beta.MethodDetailsBàA:fêAc +%merchantapi.googleapis.com/QuotaGroup!accounts/{account}/groups/{group}* quotaGroups2 +quotaGroup"b + MethodDetails +method ( BàA +version ( BàA +subapi ( BàA +path ( BàA"ˆ +ListQuotaGroupsRequest= +parent ( B-àAúA\'%merchantapi.googleapis.com/QuotaGroup + page_size (BàA + +page_token ( BàA"{ +ListQuotaGroupsResponseG + quota_groups ( 21.google.shopping.merchant.quota.v1beta.QuotaGroup +next_page_token ( 2¥ + QuotaServiceË +ListQuotaGroups=.google.shopping.merchant.quota.v1beta.ListQuotaGroupsRequest>.google.shopping.merchant.quota.v1beta.ListQuotaGroupsResponse"9ÚAparent‚Óä“*(/quota/v1beta/{parent=accounts/*}/quotasGÊAmerchantapi.googleapis.comÒA\'https://www.googleapis.com/auth/contentB» +)com.google.shopping.merchant.quota.v1betaB +QuotaProtoPZEcloud.google.com/go/shopping/merchant/quota/apiv1beta/quotapb;quotapbêA8 +"merchantapi.googleapis.com/Accountaccounts/{account}bproto3' + , true); + + static::$is_initialized = true; + } +} + diff --git a/ShoppingMerchantQuota/owlbot.py b/ShoppingMerchantQuota/owlbot.py new file mode 100644 index 000000000000..547aa8be66f2 --- /dev/null +++ b/ShoppingMerchantQuota/owlbot.py @@ -0,0 +1,62 @@ +# Copyright 2023 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. + +"""This script is used to synthesize generated parts of this library.""" + +import logging +from pathlib import Path +import subprocess + +import synthtool as s +from synthtool.languages import php +from synthtool import _tracked_paths + +logging.basicConfig(level=logging.DEBUG) + +src = Path(f"../{php.STAGING_DIR}/ShoppingMerchantQuota").resolve() +dest = Path().resolve() + +# Added so that we can pass copy_excludes in the owlbot_main() call +_tracked_paths.add(src) + +php.owlbot_main( + src=src, + dest=dest, + copy_excludes=[ + src / "**/[A-Z]*_*.php", + ] +) + +# remove class_alias code +s.replace( + "src/V*/**/*.php", + r"^// Adding a class alias for backwards compatibility with the previous class name.$" + + "\n" + + r"^class_alias\(.*\);$" + + "\n", + '') + +# format generated clients +subprocess.run([ + 'npm', + 'exec', + '--yes', + '--package=@prettier/plugin-php@^0.16', + '--', + 'prettier', + '**/Client/*', + '--write', + '--parser=php', + '--single-quote', + '--print-width=120']) diff --git a/ShoppingMerchantQuota/phpunit.xml.dist b/ShoppingMerchantQuota/phpunit.xml.dist new file mode 100644 index 000000000000..5c34c25410dd --- /dev/null +++ b/ShoppingMerchantQuota/phpunit.xml.dist @@ -0,0 +1,16 @@ + + + + + src + + + src/V[!a-zA-Z]* + + + + + tests/Unit + + + diff --git a/ShoppingMerchantQuota/samples/V1beta/QuotaServiceClient/list_quota_groups.php b/ShoppingMerchantQuota/samples/V1beta/QuotaServiceClient/list_quota_groups.php new file mode 100644 index 000000000000..4ab0d82ee4fc --- /dev/null +++ b/ShoppingMerchantQuota/samples/V1beta/QuotaServiceClient/list_quota_groups.php @@ -0,0 +1,78 @@ +setParent($formattedParent); + + // Call the API and handle any network failures. + try { + /** @var PagedListResponse $response */ + $response = $quotaServiceClient->listQuotaGroups($request); + + /** @var QuotaGroup $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 = QuotaServiceClient::accountName('[ACCOUNT]'); + + list_quota_groups_sample($formattedParent); +} +// [END merchantapi_v1beta_generated_QuotaService_ListQuotaGroups_sync] diff --git a/ShoppingMerchantQuota/src/V1beta/Client/QuotaServiceClient.php b/ShoppingMerchantQuota/src/V1beta/Client/QuotaServiceClient.php new file mode 100644 index 000000000000..4ae59b5794ba --- /dev/null +++ b/ShoppingMerchantQuota/src/V1beta/Client/QuotaServiceClient.php @@ -0,0 +1,246 @@ + self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/quota_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/quota_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/quota_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/quota_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a account + * resource. + * + * @param string $account + * + * @return string The formatted account resource. + * + * @experimental + */ + public static function accountName(string $account): string + { + return self::getPathTemplate('account')->render([ + 'account' => $account, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - account: accounts/{account} + * + * 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 + * provided, or if the $template argument does not match one of the templates + * listed, then parseName will check each of the supported templates, and return + * the first match. + * + * @param string $formattedName The formatted name string + * @param string $template Optional name of template to match + * + * @return array An associative array from name component IDs to component values. + * + * @throws ValidationException If $formattedName could not be matched. + * + * @experimental + */ + public static function parseName(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * Constructor. + * + * @param array $options { + * Optional. Options for configuring the service API wrapper. + * + * @type string $apiEndpoint + * The address of the API remote host. May optionally include the port, formatted + * as ":". Default 'merchantapi.googleapis.com:443'. + * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials + * The credentials to be used by the client to authorize API calls. This option + * accepts either a path to a credentials file, or a decoded credentials file as a + * PHP array. + * *Advanced usage*: In addition, this option can also accept a pre-constructed + * {@see \Google\Auth\FetchAuthTokenInterface} object or + * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these + * objects are provided, any settings in $credentialsConfig will be ignored. + * @type array $credentialsConfig + * Options used to configure credentials, including auth token caching, for the + * client. For a full list of supporting configuration options, see + * {@see \Google\ApiCore\CredentialsWrapper::build()} . + * @type bool $disableRetries + * Determines whether or not retries defined by the client configuration should be + * disabled. Defaults to `false`. + * @type string|array $clientConfig + * Client method configuration, including retry settings. This option can be either + * a path to a JSON file, or a PHP array containing the decoded JSON data. By + * default this settings points to the default client config file, which is + * provided in the resources folder. + * @type string|TransportInterface $transport + * The transport used for executing network requests. May be either the string + * `rest` or `grpc`. Defaults to `grpc` if gRPC support is detected on the system. + * *Advanced usage*: Additionally, it is possible to pass in an already + * instantiated {@see \Google\ApiCore\Transport\TransportInterface} object. Note + * that when this object is provided, any settings in $transportConfig, and any + * $apiEndpoint setting, will be ignored. + * @type array $transportConfig + * Configuration options that will be used to construct the transport. Options for + * each supported transport type should be passed in a key for that transport. For + * example: + * $transportConfig = [ + * 'grpc' => [...], + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\GrpcTransport::build()} and + * {@see \Google\ApiCore\Transport\RestTransport::build()} methods for the + * supported options. + * @type callable $clientCertSource + * A callable which returns the client cert as a string. This can be used to + * provide a certificate and private key to the transport layer for mTLS. + * } + * + * @throws ValidationException + * + * @experimental + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Lists the daily call quota and usage per group for your Merchant + * Center account. + * + * The async variant is {@see QuotaServiceClient::listQuotaGroupsAsync()} . + * + * @example samples/V1beta/QuotaServiceClient/list_quota_groups.php + * + * @param ListQuotaGroupsRequest $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. + * + * @experimental + */ + public function listQuotaGroups(ListQuotaGroupsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListQuotaGroups', $request, $callOptions); + } +} diff --git a/ShoppingMerchantQuota/src/V1beta/ListQuotaGroupsRequest.php b/ShoppingMerchantQuota/src/V1beta/ListQuotaGroupsRequest.php new file mode 100644 index 000000000000..71d450ad288a --- /dev/null +++ b/ShoppingMerchantQuota/src/V1beta/ListQuotaGroupsRequest.php @@ -0,0 +1,162 @@ +google.shopping.merchant.quota.v1beta.ListQuotaGroupsRequest + */ +class ListQuotaGroupsRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The merchant account who owns the collection of method quotas + * Format: accounts/{account} + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $parent = ''; + /** + * Optional. The maximum number of quotas to return in the response, used + * for paging. Defaults to 500; values above 1000 will be coerced to 1000. + * + * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $page_size = 0; + /** + * Optional. Token (if provided) to retrieve the subsequent page. All other + * parameters must match the original call that provided the page token. + * + * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $page_token = ''; + + /** + * @param string $parent Required. The merchant account who owns the collection of method quotas + * Format: accounts/{account} + * Please see {@see QuotaServiceClient::accountName()} for help formatting this field. + * + * @return \Google\Shopping\Merchant\Quota\V1beta\ListQuotaGroupsRequest + * + * @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 merchant account who owns the collection of method quotas + * Format: accounts/{account} + * @type int $page_size + * Optional. The maximum number of quotas to return in the response, used + * for paging. Defaults to 500; values above 1000 will be coerced to 1000. + * @type string $page_token + * Optional. Token (if provided) to retrieve the subsequent page. All other + * parameters must match the original call that provided the page token. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Shopping\Merchant\Quota\V1Beta\Quota::initOnce(); + parent::__construct($data); + } + + /** + * Required. The merchant account who owns the collection of method quotas + * Format: accounts/{account} + * + * 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. The merchant account who owns the collection of method quotas + * Format: accounts/{account} + * + * 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 quotas to return in the response, used + * for paging. Defaults to 500; 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 quotas to return in the response, used + * for paging. Defaults to 500; 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. Token (if provided) to retrieve the subsequent page. All other + * parameters must match the original call that provided the page token. + * + * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @return string + */ + public function getPageToken() + { + return $this->page_token; + } + + /** + * Optional. Token (if provided) to retrieve the subsequent page. All other + * parameters must match the original call that provided the page token. + * + * 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/ShoppingMerchantQuota/src/V1beta/ListQuotaGroupsResponse.php b/ShoppingMerchantQuota/src/V1beta/ListQuotaGroupsResponse.php new file mode 100644 index 000000000000..e286dc8732f7 --- /dev/null +++ b/ShoppingMerchantQuota/src/V1beta/ListQuotaGroupsResponse.php @@ -0,0 +1,117 @@ +google.shopping.merchant.quota.v1beta.ListQuotaGroupsResponse + */ +class ListQuotaGroupsResponse extends \Google\Protobuf\Internal\Message +{ + /** + * The methods, current quota usage and limits per each group. The quota is + * shared between all methods in the group. The groups are sorted in + * descending order based on + * [quotaUsage][google.shopping.merchant.quota.v1main.QuotaGroup.quota_usage]. + * + * Generated from protobuf field repeated .google.shopping.merchant.quota.v1beta.QuotaGroup quota_groups = 1; + */ + private $quota_groups; + /** + * A token, which can be sent as `page_token` to retrieve the next page. + * If this field is omitted, there are no subsequent pages. + * + * Generated from protobuf field string next_page_token = 2; + */ + protected $next_page_token = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\Google\Shopping\Merchant\Quota\V1beta\QuotaGroup>|\Google\Protobuf\Internal\RepeatedField $quota_groups + * The methods, current quota usage and limits per each group. The quota is + * shared between all methods in the group. The groups are sorted in + * descending order based on + * [quotaUsage][google.shopping.merchant.quota.v1main.QuotaGroup.quota_usage]. + * @type string $next_page_token + * A token, which can be sent as `page_token` to retrieve the next page. + * If this field is omitted, there are no subsequent pages. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Shopping\Merchant\Quota\V1Beta\Quota::initOnce(); + parent::__construct($data); + } + + /** + * The methods, current quota usage and limits per each group. The quota is + * shared between all methods in the group. The groups are sorted in + * descending order based on + * [quotaUsage][google.shopping.merchant.quota.v1main.QuotaGroup.quota_usage]. + * + * Generated from protobuf field repeated .google.shopping.merchant.quota.v1beta.QuotaGroup quota_groups = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getQuotaGroups() + { + return $this->quota_groups; + } + + /** + * The methods, current quota usage and limits per each group. The quota is + * shared between all methods in the group. The groups are sorted in + * descending order based on + * [quotaUsage][google.shopping.merchant.quota.v1main.QuotaGroup.quota_usage]. + * + * Generated from protobuf field repeated .google.shopping.merchant.quota.v1beta.QuotaGroup quota_groups = 1; + * @param array<\Google\Shopping\Merchant\Quota\V1beta\QuotaGroup>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setQuotaGroups($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Shopping\Merchant\Quota\V1beta\QuotaGroup::class); + $this->quota_groups = $arr; + + return $this; + } + + /** + * A token, which can be sent as `page_token` to retrieve the next page. + * If this field is omitted, there are no subsequent pages. + * + * Generated from protobuf field string next_page_token = 2; + * @return string + */ + public function getNextPageToken() + { + return $this->next_page_token; + } + + /** + * A token, which can be sent as `page_token` to retrieve the next page. + * If this field is omitted, there are no subsequent pages. + * + * 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/ShoppingMerchantQuota/src/V1beta/MethodDetails.php b/ShoppingMerchantQuota/src/V1beta/MethodDetails.php new file mode 100644 index 000000000000..d05d3da8ebc1 --- /dev/null +++ b/ShoppingMerchantQuota/src/V1beta/MethodDetails.php @@ -0,0 +1,173 @@ +google.shopping.merchant.quota.v1beta.MethodDetails + */ +class MethodDetails extends \Google\Protobuf\Internal\Message +{ + /** + * Output only. The name of the method for example `products.list`. + * + * Generated from protobuf field string method = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $method = ''; + /** + * Output only. The API version that the method belongs to. + * + * Generated from protobuf field string version = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $version = ''; + /** + * Output only. The sub-API that the method belongs to. + * + * Generated from protobuf field string subapi = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $subapi = ''; + /** + * Output only. The path for the method such as + * `products/v1/productInputs.insert` + * + * Generated from protobuf field string path = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $path = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $method + * Output only. The name of the method for example `products.list`. + * @type string $version + * Output only. The API version that the method belongs to. + * @type string $subapi + * Output only. The sub-API that the method belongs to. + * @type string $path + * Output only. The path for the method such as + * `products/v1/productInputs.insert` + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Shopping\Merchant\Quota\V1Beta\Quota::initOnce(); + parent::__construct($data); + } + + /** + * Output only. The name of the method for example `products.list`. + * + * Generated from protobuf field string method = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getMethod() + { + return $this->method; + } + + /** + * Output only. The name of the method for example `products.list`. + * + * Generated from protobuf field string method = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setMethod($var) + { + GPBUtil::checkString($var, True); + $this->method = $var; + + return $this; + } + + /** + * Output only. The API version that the method belongs to. + * + * Generated from protobuf field string version = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getVersion() + { + return $this->version; + } + + /** + * Output only. The API version that the method belongs to. + * + * Generated from protobuf field string version = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setVersion($var) + { + GPBUtil::checkString($var, True); + $this->version = $var; + + return $this; + } + + /** + * Output only. The sub-API that the method belongs to. + * + * Generated from protobuf field string subapi = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getSubapi() + { + return $this->subapi; + } + + /** + * Output only. The sub-API that the method belongs to. + * + * Generated from protobuf field string subapi = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setSubapi($var) + { + GPBUtil::checkString($var, True); + $this->subapi = $var; + + return $this; + } + + /** + * Output only. The path for the method such as + * `products/v1/productInputs.insert` + * + * Generated from protobuf field string path = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getPath() + { + return $this->path; + } + + /** + * Output only. The path for the method such as + * `products/v1/productInputs.insert` + * + * Generated from protobuf field string path = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setPath($var) + { + GPBUtil::checkString($var, True); + $this->path = $var; + + return $this; + } + +} + diff --git a/ShoppingMerchantQuota/src/V1beta/QuotaGroup.php b/ShoppingMerchantQuota/src/V1beta/QuotaGroup.php new file mode 100644 index 000000000000..27331c353896 --- /dev/null +++ b/ShoppingMerchantQuota/src/V1beta/QuotaGroup.php @@ -0,0 +1,221 @@ +google.shopping.merchant.quota.v1beta.QuotaGroup + */ +class QuotaGroup extends \Google\Protobuf\Internal\Message +{ + /** + * Identifier. The resource name of the quota group. + * Format: accounts/{account}/quotas/{group} + * Note: There is no guarantee on the format of {group} + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = IDENTIFIER]; + */ + protected $name = ''; + /** + * Output only. The current quota usage, meaning the number of calls already + * made on a given day to the methods in the group. The daily quota limits + * reset at at 12:00 PM midday UTC. + * + * Generated from protobuf field int64 quota_usage = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $quota_usage = 0; + /** + * Output only. The maximum number of calls allowed per day for the group. + * + * Generated from protobuf field int64 quota_limit = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $quota_limit = 0; + /** + * Output only. The maximum number of calls allowed per minute for the group. + * + * Generated from protobuf field int64 quota_minute_limit = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $quota_minute_limit = 0; + /** + * Output only. List of all methods group quota applies to. + * + * Generated from protobuf field repeated .google.shopping.merchant.quota.v1beta.MethodDetails method_details = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $method_details; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Identifier. The resource name of the quota group. + * Format: accounts/{account}/quotas/{group} + * Note: There is no guarantee on the format of {group} + * @type int|string $quota_usage + * Output only. The current quota usage, meaning the number of calls already + * made on a given day to the methods in the group. The daily quota limits + * reset at at 12:00 PM midday UTC. + * @type int|string $quota_limit + * Output only. The maximum number of calls allowed per day for the group. + * @type int|string $quota_minute_limit + * Output only. The maximum number of calls allowed per minute for the group. + * @type array<\Google\Shopping\Merchant\Quota\V1beta\MethodDetails>|\Google\Protobuf\Internal\RepeatedField $method_details + * Output only. List of all methods group quota applies to. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Shopping\Merchant\Quota\V1Beta\Quota::initOnce(); + parent::__construct($data); + } + + /** + * Identifier. The resource name of the quota group. + * Format: accounts/{account}/quotas/{group} + * Note: There is no guarantee on the format of {group} + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = IDENTIFIER]; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Identifier. The resource name of the quota group. + * Format: accounts/{account}/quotas/{group} + * Note: There is no guarantee on the format of {group} + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = IDENTIFIER]; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * Output only. The current quota usage, meaning the number of calls already + * made on a given day to the methods in the group. The daily quota limits + * reset at at 12:00 PM midday UTC. + * + * Generated from protobuf field int64 quota_usage = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return int|string + */ + public function getQuotaUsage() + { + return $this->quota_usage; + } + + /** + * Output only. The current quota usage, meaning the number of calls already + * made on a given day to the methods in the group. The daily quota limits + * reset at at 12:00 PM midday UTC. + * + * Generated from protobuf field int64 quota_usage = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param int|string $var + * @return $this + */ + public function setQuotaUsage($var) + { + GPBUtil::checkInt64($var); + $this->quota_usage = $var; + + return $this; + } + + /** + * Output only. The maximum number of calls allowed per day for the group. + * + * Generated from protobuf field int64 quota_limit = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return int|string + */ + public function getQuotaLimit() + { + return $this->quota_limit; + } + + /** + * Output only. The maximum number of calls allowed per day for the group. + * + * Generated from protobuf field int64 quota_limit = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param int|string $var + * @return $this + */ + public function setQuotaLimit($var) + { + GPBUtil::checkInt64($var); + $this->quota_limit = $var; + + return $this; + } + + /** + * Output only. The maximum number of calls allowed per minute for the group. + * + * Generated from protobuf field int64 quota_minute_limit = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return int|string + */ + public function getQuotaMinuteLimit() + { + return $this->quota_minute_limit; + } + + /** + * Output only. The maximum number of calls allowed per minute for the group. + * + * Generated from protobuf field int64 quota_minute_limit = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param int|string $var + * @return $this + */ + public function setQuotaMinuteLimit($var) + { + GPBUtil::checkInt64($var); + $this->quota_minute_limit = $var; + + return $this; + } + + /** + * Output only. List of all methods group quota applies to. + * + * Generated from protobuf field repeated .google.shopping.merchant.quota.v1beta.MethodDetails method_details = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getMethodDetails() + { + return $this->method_details; + } + + /** + * Output only. List of all methods group quota applies to. + * + * Generated from protobuf field repeated .google.shopping.merchant.quota.v1beta.MethodDetails method_details = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param array<\Google\Shopping\Merchant\Quota\V1beta\MethodDetails>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setMethodDetails($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Shopping\Merchant\Quota\V1beta\MethodDetails::class); + $this->method_details = $arr; + + return $this; + } + +} + diff --git a/ShoppingMerchantQuota/src/V1beta/gapic_metadata.json b/ShoppingMerchantQuota/src/V1beta/gapic_metadata.json new file mode 100644 index 000000000000..7ab42ff39d78 --- /dev/null +++ b/ShoppingMerchantQuota/src/V1beta/gapic_metadata.json @@ -0,0 +1,23 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services\/RPCs to the corresponding library clients\/methods", + "language": "php", + "protoPackage": "google.shopping.merchant.quota.v1beta", + "libraryPackage": "Google\\Shopping\\Merchant\\Quota\\V1beta", + "services": { + "QuotaService": { + "clients": { + "grpc": { + "libraryClient": "QuotaServiceGapicClient", + "rpcs": { + "ListQuotaGroups": { + "methods": [ + "listQuotaGroups" + ] + } + } + } + } + } + } +} \ No newline at end of file diff --git a/ShoppingMerchantQuota/src/V1beta/resources/quota_service_client_config.json b/ShoppingMerchantQuota/src/V1beta/resources/quota_service_client_config.json new file mode 100644 index 000000000000..7c013dfc565c --- /dev/null +++ b/ShoppingMerchantQuota/src/V1beta/resources/quota_service_client_config.json @@ -0,0 +1,39 @@ +{ + "interfaces": { + "google.shopping.merchant.quota.v1beta.QuotaService": { + "retry_codes": { + "no_retry_codes": [], + "retry_policy_1_codes": [ + "UNAVAILABLE" + ] + }, + "retry_params": { + "no_retry_params": { + "initial_retry_delay_millis": 0, + "retry_delay_multiplier": 0.0, + "max_retry_delay_millis": 0, + "initial_rpc_timeout_millis": 0, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 0, + "total_timeout_millis": 0 + }, + "retry_policy_1_params": { + "initial_retry_delay_millis": 1000, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 10000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 60000 + } + }, + "methods": { + "ListQuotaGroups": { + "timeout_millis": 60000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + } + } + } + } +} diff --git a/ShoppingMerchantQuota/src/V1beta/resources/quota_service_descriptor_config.php b/ShoppingMerchantQuota/src/V1beta/resources/quota_service_descriptor_config.php new file mode 100644 index 000000000000..b364a5aa428e --- /dev/null +++ b/ShoppingMerchantQuota/src/V1beta/resources/quota_service_descriptor_config.php @@ -0,0 +1,31 @@ + [ + 'google.shopping.merchant.quota.v1beta.QuotaService' => [ + 'ListQuotaGroups' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getQuotaGroups', + ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Shopping\Merchant\Quota\V1beta\ListQuotaGroupsResponse', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'templateMap' => [ + 'account' => 'accounts/{account}', + ], + ], + ], +]; diff --git a/ShoppingMerchantQuota/src/V1beta/resources/quota_service_rest_client_config.php b/ShoppingMerchantQuota/src/V1beta/resources/quota_service_rest_client_config.php new file mode 100644 index 000000000000..e15ea7e3ca80 --- /dev/null +++ b/ShoppingMerchantQuota/src/V1beta/resources/quota_service_rest_client_config.php @@ -0,0 +1,20 @@ + [ + 'google.shopping.merchant.quota.v1beta.QuotaService' => [ + 'ListQuotaGroups' => [ + 'method' => 'get', + 'uriTemplate' => '/quota/v1beta/{parent=accounts/*}/quotas', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + ], + ], + 'numericEnums' => true, +]; diff --git a/ShoppingMerchantQuota/tests/Unit/V1beta/Client/QuotaServiceClientTest.php b/ShoppingMerchantQuota/tests/Unit/V1beta/Client/QuotaServiceClientTest.php new file mode 100644 index 000000000000..8bf1b875bd72 --- /dev/null +++ b/ShoppingMerchantQuota/tests/Unit/V1beta/Client/QuotaServiceClientTest.php @@ -0,0 +1,170 @@ +getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); + } + + /** @return QuotaServiceClient */ + private function createClient(array $options = []) + { + $options += [ + 'credentials' => $this->createCredentials(), + ]; + return new QuotaServiceClient($options); + } + + /** @test */ + public function listQuotaGroupsTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $quotaGroupsElement = new QuotaGroup(); + $quotaGroups = [$quotaGroupsElement]; + $expectedResponse = new ListQuotaGroupsResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setQuotaGroups($quotaGroups); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->accountName('[ACCOUNT]'); + $request = (new ListQuotaGroupsRequest())->setParent($formattedParent); + $response = $gapicClient->listQuotaGroups($request); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getQuotaGroups()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.shopping.merchant.quota.v1beta.QuotaService/ListQuotaGroups', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listQuotaGroupsExceptionTest() + { + $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->accountName('[ACCOUNT]'); + $request = (new ListQuotaGroupsRequest())->setParent($formattedParent); + try { + $gapicClient->listQuotaGroups($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 listQuotaGroupsAsyncTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $quotaGroupsElement = new QuotaGroup(); + $quotaGroups = [$quotaGroupsElement]; + $expectedResponse = new ListQuotaGroupsResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setQuotaGroups($quotaGroups); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->accountName('[ACCOUNT]'); + $request = (new ListQuotaGroupsRequest())->setParent($formattedParent); + $response = $gapicClient->listQuotaGroupsAsync($request)->wait(); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getQuotaGroups()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.shopping.merchant.quota.v1beta.QuotaService/ListQuotaGroups', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } +} diff --git a/composer.json b/composer.json index ca9daa0bb7fa..7e0bab229b96 100644 --- a/composer.json +++ b/composer.json @@ -239,6 +239,7 @@ "google/shopping-common-protos": "0.2.1", "google/shopping-css": "0.2.2", "google/shopping-merchant-inventories": "0.3.2", + "google/shopping-merchant-quota": "0.0.0", "google/shopping-merchant-reports": "0.6.2" }, "suggest": { @@ -418,6 +419,7 @@ "GPBMetadata\\Google\\Rpc\\": "CommonProtos/metadata/Rpc", "GPBMetadata\\Google\\Shopping\\Css\\": "ShoppingCss/metadata", "GPBMetadata\\Google\\Shopping\\Merchant\\Inventories\\": "ShoppingMerchantInventories/metadata", + "GPBMetadata\\Google\\Shopping\\Merchant\\Quota\\": "ShoppingMerchantQuota/metadata", "GPBMetadata\\Google\\Shopping\\Merchant\\Reports\\": "ShoppingMerchantReports/metadata", "GPBMetadata\\Google\\Shopping\\Type\\": "ShoppingCommonProtos/metadata/Type", "GPBMetadata\\Google\\Spanner\\": "Spanner/metadata", @@ -597,6 +599,7 @@ "Google\\LongRunning\\": "LongRunning/src/LongRunning", "Google\\Shopping\\Css\\": "ShoppingCss/src", "Google\\Shopping\\Merchant\\Inventories\\": "ShoppingMerchantInventories/src", + "Google\\Shopping\\Merchant\\Quota\\": "ShoppingMerchantQuota/src", "Google\\Shopping\\Merchant\\Reports\\": "ShoppingMerchantReports/src", "Google\\Shopping\\Type\\": "ShoppingCommonProtos/src/Type", "Grafeas\\": "Grafeas/src"