diff --git a/Quotas/.OwlBot.yaml b/Quotas/.OwlBot.yaml new file mode 100644 index 000000000000..5e3873535792 --- /dev/null +++ b/Quotas/.OwlBot.yaml @@ -0,0 +1,4 @@ +deep-copy-regex: + - source: /google/api/cloudquotas/(v1)/.*-php/(.*) + dest: /owl-bot-staging/Quotas/$1/$2 +api-name: Quotas diff --git a/Quotas/.gitattributes b/Quotas/.gitattributes new file mode 100644 index 000000000000..8119e7fcc1b2 --- /dev/null +++ b/Quotas/.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/Quotas/.github/pull_request_template.md b/Quotas/.github/pull_request_template.md new file mode 100644 index 000000000000..43490cb5c8da --- /dev/null +++ b/Quotas/.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 `Quotas/src`, and tests in `Quotas/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/Quotas/.repo-metadata.json b/Quotas/.repo-metadata.json new file mode 100644 index 000000000000..5b16182dcbc2 --- /dev/null +++ b/Quotas/.repo-metadata.json @@ -0,0 +1,8 @@ +{ + "language": "php", + "distribution_name": "google/api-cloudquotas", + "release_level": "preview", + "client_documentation": "https://cloud.google.com/php/docs/reference/api-cloudquotas/latest", + "library_type": "GAPIC_AUTO", + "api_shortname": "cloudquotas" +} diff --git a/Quotas/CONTRIBUTING.md b/Quotas/CONTRIBUTING.md new file mode 100644 index 000000000000..76ea811cacdb --- /dev/null +++ b/Quotas/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/Quotas/LICENSE b/Quotas/LICENSE new file mode 100644 index 000000000000..8f71f43fee3f --- /dev/null +++ b/Quotas/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/Quotas/README.md b/Quotas/README.md new file mode 100644 index 000000000000..4b646e8b3c88 --- /dev/null +++ b/Quotas/README.md @@ -0,0 +1,45 @@ +# Google Cloud Cloud Quotas for PHP + +> Idiomatic PHP client for [Google Cloud Cloud Quotas](https://cloud.google.com). + +[![Latest Stable Version](https://poser.pugx.org/google/api-cloudquotas/v/stable)](https://packagist.org/packages/google/api-cloudquotas) [![Packagist](https://img.shields.io/packagist/dm/google/api-cloudquotas.svg)](https://packagist.org/packages/google/api-cloudquotas) + +* [API documentation](https://cloud.google.com/php/docs/reference/api-cloudquotas/latest) + +**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/api-cloudquotas +``` + +> 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-api-cloudquotas/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://cloud.google.com/docs/quota/api-overview). diff --git a/Quotas/VERSION b/Quotas/VERSION new file mode 100644 index 000000000000..77d6f4ca2371 --- /dev/null +++ b/Quotas/VERSION @@ -0,0 +1 @@ +0.0.0 diff --git a/Quotas/composer.json b/Quotas/composer.json new file mode 100644 index 000000000000..2c6466cd25a4 --- /dev/null +++ b/Quotas/composer.json @@ -0,0 +1,30 @@ +{ + "name": "google/api-cloudquotas", + "description": "Google Cloud Cloud Quotas Client for PHP", + "license": "Apache-2.0", + "minimum-stability": "stable", + "autoload": { + "psr-4": { + "Google\\Cloud\\CloudQuotas\\": "src", + "GPBMetadata\\Google\\Api\\Cloudquotas\\": "metadata" + } + }, + "extra": { + "component": { + "id": "api-cloudquotas", + "path": "Quotas", + "target": "googleapis/php-api-cloudquotas" + } + }, + "require": { + "php": ">=7.4", + "google/gax": "^1.25.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/Quotas/metadata/V1/Cloudquotas.php b/Quotas/metadata/V1/Cloudquotas.php new file mode 100644 index 000000000000..7d699f15adb7 --- /dev/null +++ b/Quotas/metadata/V1/Cloudquotas.php @@ -0,0 +1,78 @@ +internalAddGeneratedFile( + ' +Ö" ++google/api/cloudquotas/v1/cloudquotas.protogoogle.api.cloudquotas.v1google/api/client.proto)google/api/cloudquotas/v1/resources.protogoogle/api/field_behavior.protogoogle/api/resource.proto google/protobuf/field_mask.proto"† +ListQuotaInfosRequest< +parent ( B,àAúA&$cloudquotas.googleapis.com/QuotaInfo + page_size (BàA + +page_token ( BàA"l +ListQuotaInfosResponse9 + quota_infos ( 2$.google.api.cloudquotas.v1.QuotaInfo +next_page_token ( "Q +GetQuotaInfoRequest: +name ( B,àAúA& +$cloudquotas.googleapis.com/QuotaInfo"¾ +ListQuotaPreferencesRequestB +parent ( B2àAúA,*cloudquotas.googleapis.com/QuotaPreference + page_size (BàA + +page_token ( BàA +filter ( BàA +order_by ( BàA"“ +ListQuotaPreferencesResponseE +quota_preferences ( 2*.google.api.cloudquotas.v1.QuotaPreference +next_page_token (  + unreachable ( "] +GetQuotaPreferenceRequest@ +name ( B2àAúA, +*cloudquotas.googleapis.com/QuotaPreference"š +CreateQuotaPreferenceRequestB +parent ( B2àAúA,*cloudquotas.googleapis.com/QuotaPreference +quota_preference_id ( BàAI +quota_preference ( 2*.google.api.cloudquotas.v1.QuotaPreferenceBàAI +ignore_safety_checks (2+.google.api.cloudquotas.v1.QuotaSafetyCheck"¢ +UpdateQuotaPreferenceRequest4 + update_mask ( 2.google.protobuf.FieldMaskBàAI +quota_preference ( 2*.google.api.cloudquotas.v1.QuotaPreferenceBàA + allow_missing (BàA + validate_only (BàAI +ignore_safety_checks (2+.google.api.cloudquotas.v1.QuotaSafetyCheck2¹ + CloudQuotasÁ +ListQuotaInfos0.google.api.cloudquotas.v1.ListQuotaInfosRequest1.google.api.cloudquotas.v1.ListQuotaInfosResponse"É‚Ó䓹9/v1/{parent=projects/*/locations/*/services/*}/quotaInfosZ@>/v1/{parent=organizations/*/locations/*/services/*}/quotaInfosZ:8/v1/{parent=folders/*/locations/*/services/*}/quotaInfosÚAparent® + GetQuotaInfo..google.api.cloudquotas.v1.GetQuotaInfoRequest$.google.api.cloudquotas.v1.QuotaInfo"Ç‚Ó䓹9/v1/{name=projects/*/locations/*/services/*/quotaInfos/*}Z@>/v1/{name=organizations/*/locations/*/services/*/quotaInfos/*}Z:8/v1/{name=folders/*/locations/*/services/*/quotaInfos/*}ÚAnameÄ +ListQuotaPreferences6.google.api.cloudquotas.v1.ListQuotaPreferencesRequest7.google.api.cloudquotas.v1.ListQuotaPreferencesResponse"º‚Ó䓪4/v1/{parent=projects/*/locations/*}/quotaPreferencesZ53/v1/{parent=folders/*/locations/*}/quotaPreferencesZ;9/v1/{parent=organizations/*/locations/*}/quotaPreferencesÚAparent± +GetQuotaPreference4.google.api.cloudquotas.v1.GetQuotaPreferenceRequest*.google.api.cloudquotas.v1.QuotaPreference"¸‚Ó䓪4/v1/{name=projects/*/locations/*/quotaPreferences/*}Z;9/v1/{name=organizations/*/locations/*/quotaPreferences/*}Z53/v1/{name=folders/*/locations/*/quotaPreferences/*}ÚAname® +CreateQuotaPreference7.google.api.cloudquotas.v1.CreateQuotaPreferenceRequest*.google.api.cloudquotas.v1.QuotaPreference"¯‚Óä“à"4/v1/{parent=projects/*/locations/*}/quotaPreferences:quota_preferenceZG"3/v1/{parent=folders/*/locations/*}/quotaPreferences:quota_preferenceZM"9/v1/{parent=organizations/*/locations/*}/quotaPreferences:quota_preferenceÚA+parent,quota_preference,quota_preference_idÚAparent,quota_preference¸ +UpdateQuotaPreference7.google.api.cloudquotas.v1.UpdateQuotaPreferenceRequest*.google.api.cloudquotas.v1.QuotaPreference"¹‚Óä““2E/v1/{quota_preference.name=projects/*/locations/*/quotaPreferences/*}:quota_preferenceZX2D/v1/{quota_preference.name=folders/*/locations/*/quotaPreferences/*}:quota_preferenceZ^2J/v1/{quota_preference.name=organizations/*/locations/*/quotaPreferences/*}:quota_preferenceÚAquota_preference,update_maskNÊAcloudquotas.googleapis.comÒA.https://www.googleapis.com/auth/cloud-platformBã +com.google.api.cloudquotas.v1BCloudquotasProtoPZAcloud.google.com/go/cloudquotas/apiv1/cloudquotaspb;cloudquotaspbªGoogle.Cloud.CloudQuotas.V1ÊGoogle\\Cloud\\CloudQuotas\\V1êGoogle::Cloud::CloudQuotas::V1êAà +"cloudquotas.googleapis.com/Service:projects/{project}/locations/{location}/services/{service}8folders/{folder}/locations/{location}/services/{service}Dorganizations/{organization}/locations/{location}/services/{service}êA¨ +#cloudquotas.googleapis.com/Location\'projects/{project}/locations/{location}%folders/{folder}/locations/{location}1organizations/{organization}/locations/{location}bproto3' + , true); + + static::$is_initialized = true; + } +} + diff --git a/Quotas/metadata/V1/Resources.php b/Quotas/metadata/V1/Resources.php new file mode 100644 index 000000000000..fb8de8332fd8 Binary files /dev/null and b/Quotas/metadata/V1/Resources.php differ diff --git a/Quotas/owlbot.py b/Quotas/owlbot.py new file mode 100644 index 000000000000..2f58a6080fcc --- /dev/null +++ b/Quotas/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}/Quotas").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/Quotas/phpunit.xml.dist b/Quotas/phpunit.xml.dist new file mode 100644 index 000000000000..f42ac1ac2fe3 --- /dev/null +++ b/Quotas/phpunit.xml.dist @@ -0,0 +1,16 @@ + + + + + src + + + src/V[!a-zA-Z]* + + + + + tests/Unit + + + diff --git a/Quotas/samples/V1/CloudQuotasClient/create_quota_preference.php b/Quotas/samples/V1/CloudQuotasClient/create_quota_preference.php new file mode 100644 index 000000000000..a9c0885addc2 --- /dev/null +++ b/Quotas/samples/V1/CloudQuotasClient/create_quota_preference.php @@ -0,0 +1,110 @@ +setPreferredValue($quotaPreferenceQuotaConfigPreferredValue); + $quotaPreference = (new QuotaPreference()) + ->setQuotaConfig($quotaPreferenceQuotaConfig) + ->setService($quotaPreferenceService) + ->setQuotaId($quotaPreferenceQuotaId) + ->setContactEmail($quotaPreferenceContactEmail); + $request = (new CreateQuotaPreferenceRequest()) + ->setParent($formattedParent) + ->setQuotaPreference($quotaPreference); + + // Call the API and handle any network failures. + try { + /** @var QuotaPreference $response */ + $response = $cloudQuotasClient->createQuotaPreference($request); + printf('Response data: %s' . PHP_EOL, $response->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 = CloudQuotasClient::locationName('[PROJECT]', '[LOCATION]'); + $quotaPreferenceQuotaConfigPreferredValue = 0; + $quotaPreferenceService = '[SERVICE]'; + $quotaPreferenceQuotaId = '[QUOTA_ID]'; + $quotaPreferenceContactEmail = '[CONTACT_EMAIL]'; + + create_quota_preference_sample( + $formattedParent, + $quotaPreferenceQuotaConfigPreferredValue, + $quotaPreferenceService, + $quotaPreferenceQuotaId, + $quotaPreferenceContactEmail + ); +} +// [END cloudquotas_v1_generated_CloudQuotas_CreateQuotaPreference_sync] diff --git a/Quotas/samples/V1/CloudQuotasClient/get_quota_info.php b/Quotas/samples/V1/CloudQuotasClient/get_quota_info.php new file mode 100644 index 000000000000..421cc24ce82b --- /dev/null +++ b/Quotas/samples/V1/CloudQuotasClient/get_quota_info.php @@ -0,0 +1,79 @@ +setName($formattedName); + + // Call the API and handle any network failures. + try { + /** @var QuotaInfo $response */ + $response = $cloudQuotasClient->getQuotaInfo($request); + printf('Response data: %s' . PHP_EOL, $response->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 +{ + $formattedName = CloudQuotasClient::quotaInfoName( + '[PROJECT]', + '[LOCATION]', + '[SERVICE]', + '[QUOTA_INFO]' + ); + + get_quota_info_sample($formattedName); +} +// [END cloudquotas_v1_generated_CloudQuotas_GetQuotaInfo_sync] diff --git a/Quotas/samples/V1/CloudQuotasClient/get_quota_preference.php b/Quotas/samples/V1/CloudQuotasClient/get_quota_preference.php new file mode 100644 index 000000000000..f1ebc27d8320 --- /dev/null +++ b/Quotas/samples/V1/CloudQuotasClient/get_quota_preference.php @@ -0,0 +1,78 @@ +setName($formattedName); + + // Call the API and handle any network failures. + try { + /** @var QuotaPreference $response */ + $response = $cloudQuotasClient->getQuotaPreference($request); + printf('Response data: %s' . PHP_EOL, $response->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 +{ + $formattedName = CloudQuotasClient::quotaPreferenceName( + '[PROJECT]', + '[LOCATION]', + '[QUOTA_PREFERENCE]' + ); + + get_quota_preference_sample($formattedName); +} +// [END cloudquotas_v1_generated_CloudQuotas_GetQuotaPreference_sync] diff --git a/Quotas/samples/V1/CloudQuotasClient/list_quota_infos.php b/Quotas/samples/V1/CloudQuotasClient/list_quota_infos.php new file mode 100644 index 000000000000..f42445d9c607 --- /dev/null +++ b/Quotas/samples/V1/CloudQuotasClient/list_quota_infos.php @@ -0,0 +1,83 @@ +setParent($formattedParent); + + // Call the API and handle any network failures. + try { + /** @var PagedListResponse $response */ + $response = $cloudQuotasClient->listQuotaInfos($request); + + /** @var QuotaInfo $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 = CloudQuotasClient::serviceName('[PROJECT]', '[LOCATION]', '[SERVICE]'); + + list_quota_infos_sample($formattedParent); +} +// [END cloudquotas_v1_generated_CloudQuotas_ListQuotaInfos_sync] diff --git a/Quotas/samples/V1/CloudQuotasClient/list_quota_preferences.php b/Quotas/samples/V1/CloudQuotasClient/list_quota_preferences.php new file mode 100644 index 000000000000..7c0da6ae7383 --- /dev/null +++ b/Quotas/samples/V1/CloudQuotasClient/list_quota_preferences.php @@ -0,0 +1,85 @@ +setParent($formattedParent); + + // Call the API and handle any network failures. + try { + /** @var PagedListResponse $response */ + $response = $cloudQuotasClient->listQuotaPreferences($request); + + /** @var QuotaPreference $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 = CloudQuotasClient::locationName('[PROJECT]', '[LOCATION]'); + + list_quota_preferences_sample($formattedParent); +} +// [END cloudquotas_v1_generated_CloudQuotas_ListQuotaPreferences_sync] diff --git a/Quotas/samples/V1/CloudQuotasClient/update_quota_preference.php b/Quotas/samples/V1/CloudQuotasClient/update_quota_preference.php new file mode 100644 index 000000000000..d41e973a1a9b --- /dev/null +++ b/Quotas/samples/V1/CloudQuotasClient/update_quota_preference.php @@ -0,0 +1,102 @@ +setPreferredValue($quotaPreferenceQuotaConfigPreferredValue); + $quotaPreference = (new QuotaPreference()) + ->setQuotaConfig($quotaPreferenceQuotaConfig) + ->setService($quotaPreferenceService) + ->setQuotaId($quotaPreferenceQuotaId) + ->setContactEmail($quotaPreferenceContactEmail); + $request = (new UpdateQuotaPreferenceRequest()) + ->setQuotaPreference($quotaPreference); + + // Call the API and handle any network failures. + try { + /** @var QuotaPreference $response */ + $response = $cloudQuotasClient->updateQuotaPreference($request); + printf('Response data: %s' . PHP_EOL, $response->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 +{ + $quotaPreferenceQuotaConfigPreferredValue = 0; + $quotaPreferenceService = '[SERVICE]'; + $quotaPreferenceQuotaId = '[QUOTA_ID]'; + $quotaPreferenceContactEmail = '[CONTACT_EMAIL]'; + + update_quota_preference_sample( + $quotaPreferenceQuotaConfigPreferredValue, + $quotaPreferenceService, + $quotaPreferenceQuotaId, + $quotaPreferenceContactEmail + ); +} +// [END cloudquotas_v1_generated_CloudQuotas_UpdateQuotaPreference_sync] diff --git a/Quotas/src/V1/Client/CloudQuotasClient.php b/Quotas/src/V1/Client/CloudQuotasClient.php new file mode 100644 index 000000000000..eee70bf2dedb --- /dev/null +++ b/Quotas/src/V1/Client/CloudQuotasClient.php @@ -0,0 +1,716 @@ + self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/cloud_quotas_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/cloud_quotas_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/cloud_quotas_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/cloud_quotas_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * folder_location resource. + * + * @param string $folder + * @param string $location + * + * @return string The formatted folder_location resource. + */ + public static function folderLocationName(string $folder, string $location): string + { + return self::getPathTemplate('folderLocation')->render([ + 'folder' => $folder, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * folder_location_quota_preference resource. + * + * @param string $folder + * @param string $location + * @param string $quotaPreference + * + * @return string The formatted folder_location_quota_preference resource. + */ + public static function folderLocationQuotaPreferenceName( + string $folder, + string $location, + string $quotaPreference + ): string { + return self::getPathTemplate('folderLocationQuotaPreference')->render([ + 'folder' => $folder, + 'location' => $location, + 'quota_preference' => $quotaPreference, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * folder_location_service resource. + * + * @param string $folder + * @param string $location + * @param string $service + * + * @return string The formatted folder_location_service resource. + */ + public static function folderLocationServiceName(string $folder, string $location, string $service): string + { + return self::getPathTemplate('folderLocationService')->render([ + 'folder' => $folder, + 'location' => $location, + 'service' => $service, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * folder_location_service_quota_info resource. + * + * @param string $folder + * @param string $location + * @param string $service + * @param string $quotaInfo + * + * @return string The formatted folder_location_service_quota_info resource. + */ + public static function folderLocationServiceQuotaInfoName( + string $folder, + string $location, + string $service, + string $quotaInfo + ): string { + return self::getPathTemplate('folderLocationServiceQuotaInfo')->render([ + 'folder' => $folder, + 'location' => $location, + 'service' => $service, + 'quota_info' => $quotaInfo, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_location resource. + * + * @param string $organization + * @param string $location + * + * @return string The formatted organization_location resource. + */ + public static function organizationLocationName(string $organization, string $location): string + { + return self::getPathTemplate('organizationLocation')->render([ + 'organization' => $organization, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_location_quota_preference resource. + * + * @param string $organization + * @param string $location + * @param string $quotaPreference + * + * @return string The formatted organization_location_quota_preference resource. + */ + public static function organizationLocationQuotaPreferenceName( + string $organization, + string $location, + string $quotaPreference + ): string { + return self::getPathTemplate('organizationLocationQuotaPreference')->render([ + 'organization' => $organization, + 'location' => $location, + 'quota_preference' => $quotaPreference, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_location_service resource. + * + * @param string $organization + * @param string $location + * @param string $service + * + * @return string The formatted organization_location_service resource. + */ + public static function organizationLocationServiceName( + string $organization, + string $location, + string $service + ): string { + return self::getPathTemplate('organizationLocationService')->render([ + 'organization' => $organization, + 'location' => $location, + 'service' => $service, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_location_service_quota_info resource. + * + * @param string $organization + * @param string $location + * @param string $service + * @param string $quotaInfo + * + * @return string The formatted organization_location_service_quota_info resource. + */ + public static function organizationLocationServiceQuotaInfoName( + string $organization, + string $location, + string $service, + string $quotaInfo + ): string { + return self::getPathTemplate('organizationLocationServiceQuotaInfo')->render([ + 'organization' => $organization, + 'location' => $location, + 'service' => $service, + 'quota_info' => $quotaInfo, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted project_location resource. + */ + public static function projectLocationName(string $project, string $location): string + { + return self::getPathTemplate('projectLocation')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_quota_preference resource. + * + * @param string $project + * @param string $location + * @param string $quotaPreference + * + * @return string The formatted project_location_quota_preference resource. + */ + public static function projectLocationQuotaPreferenceName( + string $project, + string $location, + string $quotaPreference + ): string { + return self::getPathTemplate('projectLocationQuotaPreference')->render([ + 'project' => $project, + 'location' => $location, + 'quota_preference' => $quotaPreference, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_service resource. + * + * @param string $project + * @param string $location + * @param string $service + * + * @return string The formatted project_location_service resource. + */ + public static function projectLocationServiceName(string $project, string $location, string $service): string + { + return self::getPathTemplate('projectLocationService')->render([ + 'project' => $project, + 'location' => $location, + 'service' => $service, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_service_quota_info resource. + * + * @param string $project + * @param string $location + * @param string $service + * @param string $quotaInfo + * + * @return string The formatted project_location_service_quota_info resource. + */ + public static function projectLocationServiceQuotaInfoName( + string $project, + string $location, + string $service, + string $quotaInfo + ): string { + return self::getPathTemplate('projectLocationServiceQuotaInfo')->render([ + 'project' => $project, + 'location' => $location, + 'service' => $service, + 'quota_info' => $quotaInfo, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a quota_info + * resource. + * + * @param string $project + * @param string $location + * @param string $service + * @param string $quotaInfo + * + * @return string The formatted quota_info resource. + */ + public static function quotaInfoName(string $project, string $location, string $service, string $quotaInfo): string + { + return self::getPathTemplate('quotaInfo')->render([ + 'project' => $project, + 'location' => $location, + 'service' => $service, + 'quota_info' => $quotaInfo, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * quota_preference resource. + * + * @param string $project + * @param string $location + * @param string $quotaPreference + * + * @return string The formatted quota_preference resource. + */ + public static function quotaPreferenceName(string $project, string $location, string $quotaPreference): string + { + return self::getPathTemplate('quotaPreference')->render([ + 'project' => $project, + 'location' => $location, + 'quota_preference' => $quotaPreference, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a service + * resource. + * + * @param string $project + * @param string $location + * @param string $service + * + * @return string The formatted service resource. + */ + public static function serviceName(string $project, string $location, string $service): string + { + return self::getPathTemplate('service')->render([ + 'project' => $project, + 'location' => $location, + 'service' => $service, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - folderLocation: folders/{folder}/locations/{location} + * - folderLocationQuotaPreference: folders/{folder}/locations/{location}/quotaPreferences/{quota_preference} + * - folderLocationService: folders/{folder}/locations/{location}/services/{service} + * - folderLocationServiceQuotaInfo: folders/{folder}/locations/{location}/services/{service}/quotaInfos/{quota_info} + * - location: projects/{project}/locations/{location} + * - organizationLocation: organizations/{organization}/locations/{location} + * - organizationLocationQuotaPreference: organizations/{organization}/locations/{location}/quotaPreferences/{quota_preference} + * - organizationLocationService: organizations/{organization}/locations/{location}/services/{service} + * - organizationLocationServiceQuotaInfo: organizations/{organization}/locations/{location}/services/{service}/quotaInfos/{quota_info} + * - projectLocation: projects/{project}/locations/{location} + * - projectLocationQuotaPreference: projects/{project}/locations/{location}/quotaPreferences/{quota_preference} + * - projectLocationService: projects/{project}/locations/{location}/services/{service} + * - projectLocationServiceQuotaInfo: projects/{project}/locations/{location}/services/{service}/quotaInfos/{quota_info} + * - quotaInfo: projects/{project}/locations/{location}/services/{service}/quotaInfos/{quota_info} + * - quotaPreference: projects/{project}/locations/{location}/quotaPreferences/{quota_preference} + * - service: projects/{project}/locations/{location}/services/{service} + * + * 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. + */ + 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 'cloudquotas.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 + */ + 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); + } + + /** + * Creates a new QuotaPreference that declares the desired value for a quota. + * + * The async variant is {@see CloudQuotasClient::createQuotaPreferenceAsync()} . + * + * @example samples/V1/CloudQuotasClient/create_quota_preference.php + * + * @param CreateQuotaPreferenceRequest $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 QuotaPreference + * + * @throws ApiException Thrown if the API call fails. + */ + public function createQuotaPreference( + CreateQuotaPreferenceRequest $request, + array $callOptions = [] + ): QuotaPreference { + return $this->startApiCall('CreateQuotaPreference', $request, $callOptions)->wait(); + } + + /** + * Retrieve the QuotaInfo of a quota for a project, folder or organization. + * + * The async variant is {@see CloudQuotasClient::getQuotaInfoAsync()} . + * + * @example samples/V1/CloudQuotasClient/get_quota_info.php + * + * @param GetQuotaInfoRequest $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 QuotaInfo + * + * @throws ApiException Thrown if the API call fails. + */ + public function getQuotaInfo(GetQuotaInfoRequest $request, array $callOptions = []): QuotaInfo + { + return $this->startApiCall('GetQuotaInfo', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single QuotaPreference. + * + * The async variant is {@see CloudQuotasClient::getQuotaPreferenceAsync()} . + * + * @example samples/V1/CloudQuotasClient/get_quota_preference.php + * + * @param GetQuotaPreferenceRequest $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 QuotaPreference + * + * @throws ApiException Thrown if the API call fails. + */ + public function getQuotaPreference(GetQuotaPreferenceRequest $request, array $callOptions = []): QuotaPreference + { + return $this->startApiCall('GetQuotaPreference', $request, $callOptions)->wait(); + } + + /** + * Lists QuotaInfos of all quotas for a given project, folder or organization. + * + * The async variant is {@see CloudQuotasClient::listQuotaInfosAsync()} . + * + * @example samples/V1/CloudQuotasClient/list_quota_infos.php + * + * @param ListQuotaInfosRequest $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 listQuotaInfos(ListQuotaInfosRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListQuotaInfos', $request, $callOptions); + } + + /** + * Lists QuotaPreferences in a given project, folder or organization. + * + * The async variant is {@see CloudQuotasClient::listQuotaPreferencesAsync()} . + * + * @example samples/V1/CloudQuotasClient/list_quota_preferences.php + * + * @param ListQuotaPreferencesRequest $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 listQuotaPreferences( + ListQuotaPreferencesRequest $request, + array $callOptions = [] + ): PagedListResponse { + return $this->startApiCall('ListQuotaPreferences', $request, $callOptions); + } + + /** + * Updates the parameters of a single QuotaPreference. It can updates the + * config in any states, not just the ones pending approval. + * + * The async variant is {@see CloudQuotasClient::updateQuotaPreferenceAsync()} . + * + * @example samples/V1/CloudQuotasClient/update_quota_preference.php + * + * @param UpdateQuotaPreferenceRequest $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 QuotaPreference + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateQuotaPreference( + UpdateQuotaPreferenceRequest $request, + array $callOptions = [] + ): QuotaPreference { + return $this->startApiCall('UpdateQuotaPreference', $request, $callOptions)->wait(); + } +} diff --git a/Quotas/src/V1/CreateQuotaPreferenceRequest.php b/Quotas/src/V1/CreateQuotaPreferenceRequest.php new file mode 100644 index 000000000000..097b3e386bf0 --- /dev/null +++ b/Quotas/src/V1/CreateQuotaPreferenceRequest.php @@ -0,0 +1,232 @@ +google.api.cloudquotas.v1.CreateQuotaPreferenceRequest + */ +class CreateQuotaPreferenceRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. Value for parent. + * Example: + * `projects/123/locations/global` + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $parent = ''; + /** + * Optional. Id of the requesting object, must be unique under its parent. + * If client does not set this field, the service will generate one. + * + * Generated from protobuf field string quota_preference_id = 2 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $quota_preference_id = ''; + /** + * Required. The resource being created + * + * Generated from protobuf field .google.api.cloudquotas.v1.QuotaPreference quota_preference = 3 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $quota_preference = null; + /** + * The list of quota safety checks to be ignored. + * + * Generated from protobuf field repeated .google.api.cloudquotas.v1.QuotaSafetyCheck ignore_safety_checks = 4; + */ + private $ignore_safety_checks; + + /** + * @param string $parent Required. Value for parent. + * + * Example: + * `projects/123/locations/global` + * Please see {@see CloudQuotasClient::locationName()} for help formatting this field. + * @param \Google\Cloud\CloudQuotas\V1\QuotaPreference $quotaPreference Required. The resource being created + * @param string $quotaPreferenceId Optional. Id of the requesting object, must be unique under its parent. + * If client does not set this field, the service will generate one. + * + * @return \Google\Cloud\CloudQuotas\V1\CreateQuotaPreferenceRequest + * + * @experimental + */ + public static function build(string $parent, \Google\Cloud\CloudQuotas\V1\QuotaPreference $quotaPreference, string $quotaPreferenceId): self + { + return (new self()) + ->setParent($parent) + ->setQuotaPreference($quotaPreference) + ->setQuotaPreferenceId($quotaPreferenceId); + } + + /** + * @param string $parent Required. Value for parent. + * + * Example: + * `projects/123/locations/global` + * Please see {@see CloudQuotasClient::locationName()} for help formatting this field. + * @param \Google\Cloud\CloudQuotas\V1\QuotaPreference $quotaPreference Required. The resource being created + * + * @return \Google\Cloud\CloudQuotas\V1\CreateQuotaPreferenceRequest + * + * @experimental + */ + public static function buildFromParentQuotaPreference(string $parent, \Google\Cloud\CloudQuotas\V1\QuotaPreference $quotaPreference): self + { + return (new self()) + ->setParent($parent) + ->setQuotaPreference($quotaPreference); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. Value for parent. + * Example: + * `projects/123/locations/global` + * @type string $quota_preference_id + * Optional. Id of the requesting object, must be unique under its parent. + * If client does not set this field, the service will generate one. + * @type \Google\Cloud\CloudQuotas\V1\QuotaPreference $quota_preference + * Required. The resource being created + * @type array|\Google\Protobuf\Internal\RepeatedField $ignore_safety_checks + * The list of quota safety checks to be ignored. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Api\Cloudquotas\V1\Cloudquotas::initOnce(); + parent::__construct($data); + } + + /** + * Required. Value for parent. + * Example: + * `projects/123/locations/global` + * + * 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. Value for parent. + * Example: + * `projects/123/locations/global` + * + * 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. Id of the requesting object, must be unique under its parent. + * If client does not set this field, the service will generate one. + * + * Generated from protobuf field string quota_preference_id = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @return string + */ + public function getQuotaPreferenceId() + { + return $this->quota_preference_id; + } + + /** + * Optional. Id of the requesting object, must be unique under its parent. + * If client does not set this field, the service will generate one. + * + * Generated from protobuf field string quota_preference_id = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @param string $var + * @return $this + */ + public function setQuotaPreferenceId($var) + { + GPBUtil::checkString($var, True); + $this->quota_preference_id = $var; + + return $this; + } + + /** + * Required. The resource being created + * + * Generated from protobuf field .google.api.cloudquotas.v1.QuotaPreference quota_preference = 3 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\CloudQuotas\V1\QuotaPreference|null + */ + public function getQuotaPreference() + { + return $this->quota_preference; + } + + public function hasQuotaPreference() + { + return isset($this->quota_preference); + } + + public function clearQuotaPreference() + { + unset($this->quota_preference); + } + + /** + * Required. The resource being created + * + * Generated from protobuf field .google.api.cloudquotas.v1.QuotaPreference quota_preference = 3 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\CloudQuotas\V1\QuotaPreference $var + * @return $this + */ + public function setQuotaPreference($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\CloudQuotas\V1\QuotaPreference::class); + $this->quota_preference = $var; + + return $this; + } + + /** + * The list of quota safety checks to be ignored. + * + * Generated from protobuf field repeated .google.api.cloudquotas.v1.QuotaSafetyCheck ignore_safety_checks = 4; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getIgnoreSafetyChecks() + { + return $this->ignore_safety_checks; + } + + /** + * The list of quota safety checks to be ignored. + * + * Generated from protobuf field repeated .google.api.cloudquotas.v1.QuotaSafetyCheck ignore_safety_checks = 4; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setIgnoreSafetyChecks($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::ENUM, \Google\Cloud\CloudQuotas\V1\QuotaSafetyCheck::class); + $this->ignore_safety_checks = $arr; + + return $this; + } + +} + diff --git a/Quotas/src/V1/DimensionsInfo.php b/Quotas/src/V1/DimensionsInfo.php new file mode 100644 index 000000000000..e762ea504de7 --- /dev/null +++ b/Quotas/src/V1/DimensionsInfo.php @@ -0,0 +1,186 @@ +google.api.cloudquotas.v1.DimensionsInfo + */ +class DimensionsInfo extends \Google\Protobuf\Internal\Message +{ + /** + * The map of dimensions for this dimensions info. The key of a map entry + * is "region", "zone" or the name of a service specific dimension, and the + * value of a map entry is the value of the dimension. If a dimension does + * not appear in the map of dimensions, the dimensions info applies to all + * the dimension values except for those that have another DimenisonInfo + * instance configured for the specific value. + * Example: {"provider" : "Foo Inc"} where "provider" is a service specific + * dimension of a quota. + * + * Generated from protobuf field map dimensions = 1; + */ + private $dimensions; + /** + * Quota details for the specified dimensions. + * + * Generated from protobuf field .google.api.cloudquotas.v1.QuotaDetails details = 2; + */ + protected $details = null; + /** + * The applicable regions or zones of this dimensions info. The field will be + * set to ['global'] for quotas that are not per region or per zone. + * Otherwise, it will be set to the list of locations this dimension info is + * applicable to. + * + * Generated from protobuf field repeated string applicable_locations = 3; + */ + private $applicable_locations; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array|\Google\Protobuf\Internal\MapField $dimensions + * The map of dimensions for this dimensions info. The key of a map entry + * is "region", "zone" or the name of a service specific dimension, and the + * value of a map entry is the value of the dimension. If a dimension does + * not appear in the map of dimensions, the dimensions info applies to all + * the dimension values except for those that have another DimenisonInfo + * instance configured for the specific value. + * Example: {"provider" : "Foo Inc"} where "provider" is a service specific + * dimension of a quota. + * @type \Google\Cloud\CloudQuotas\V1\QuotaDetails $details + * Quota details for the specified dimensions. + * @type array|\Google\Protobuf\Internal\RepeatedField $applicable_locations + * The applicable regions or zones of this dimensions info. The field will be + * set to ['global'] for quotas that are not per region or per zone. + * Otherwise, it will be set to the list of locations this dimension info is + * applicable to. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Api\Cloudquotas\V1\Resources::initOnce(); + parent::__construct($data); + } + + /** + * The map of dimensions for this dimensions info. The key of a map entry + * is "region", "zone" or the name of a service specific dimension, and the + * value of a map entry is the value of the dimension. If a dimension does + * not appear in the map of dimensions, the dimensions info applies to all + * the dimension values except for those that have another DimenisonInfo + * instance configured for the specific value. + * Example: {"provider" : "Foo Inc"} where "provider" is a service specific + * dimension of a quota. + * + * Generated from protobuf field map dimensions = 1; + * @return \Google\Protobuf\Internal\MapField + */ + public function getDimensions() + { + return $this->dimensions; + } + + /** + * The map of dimensions for this dimensions info. The key of a map entry + * is "region", "zone" or the name of a service specific dimension, and the + * value of a map entry is the value of the dimension. If a dimension does + * not appear in the map of dimensions, the dimensions info applies to all + * the dimension values except for those that have another DimenisonInfo + * instance configured for the specific value. + * Example: {"provider" : "Foo Inc"} where "provider" is a service specific + * dimension of a quota. + * + * Generated from protobuf field map dimensions = 1; + * @param array|\Google\Protobuf\Internal\MapField $var + * @return $this + */ + public function setDimensions($var) + { + $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::STRING); + $this->dimensions = $arr; + + return $this; + } + + /** + * Quota details for the specified dimensions. + * + * Generated from protobuf field .google.api.cloudquotas.v1.QuotaDetails details = 2; + * @return \Google\Cloud\CloudQuotas\V1\QuotaDetails|null + */ + public function getDetails() + { + return $this->details; + } + + public function hasDetails() + { + return isset($this->details); + } + + public function clearDetails() + { + unset($this->details); + } + + /** + * Quota details for the specified dimensions. + * + * Generated from protobuf field .google.api.cloudquotas.v1.QuotaDetails details = 2; + * @param \Google\Cloud\CloudQuotas\V1\QuotaDetails $var + * @return $this + */ + public function setDetails($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\CloudQuotas\V1\QuotaDetails::class); + $this->details = $var; + + return $this; + } + + /** + * The applicable regions or zones of this dimensions info. The field will be + * set to ['global'] for quotas that are not per region or per zone. + * Otherwise, it will be set to the list of locations this dimension info is + * applicable to. + * + * Generated from protobuf field repeated string applicable_locations = 3; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getApplicableLocations() + { + return $this->applicable_locations; + } + + /** + * The applicable regions or zones of this dimensions info. The field will be + * set to ['global'] for quotas that are not per region or per zone. + * Otherwise, it will be set to the list of locations this dimension info is + * applicable to. + * + * Generated from protobuf field repeated string applicable_locations = 3; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setApplicableLocations($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->applicable_locations = $arr; + + return $this; + } + +} + diff --git a/Quotas/src/V1/GetQuotaInfoRequest.php b/Quotas/src/V1/GetQuotaInfoRequest.php new file mode 100644 index 000000000000..d28953dfb23c --- /dev/null +++ b/Quotas/src/V1/GetQuotaInfoRequest.php @@ -0,0 +1,92 @@ +google.api.cloudquotas.v1.GetQuotaInfoRequest + */ +class GetQuotaInfoRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The resource name of the quota info. + * An example name: + * `projects/123/locations/global/services/compute.googleapis.com/quotaInfos/CpusPerProjectPerRegion` + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $name = ''; + + /** + * @param string $name Required. The resource name of the quota info. + * + * An example name: + * `projects/123/locations/global/services/compute.googleapis.com/quotaInfos/CpusPerProjectPerRegion` + * Please see {@see CloudQuotasClient::quotaInfoName()} for help formatting this field. + * + * @return \Google\Cloud\CloudQuotas\V1\GetQuotaInfoRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. The resource name of the quota info. + * An example name: + * `projects/123/locations/global/services/compute.googleapis.com/quotaInfos/CpusPerProjectPerRegion` + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Api\Cloudquotas\V1\Cloudquotas::initOnce(); + parent::__construct($data); + } + + /** + * Required. The resource name of the quota info. + * An example name: + * `projects/123/locations/global/services/compute.googleapis.com/quotaInfos/CpusPerProjectPerRegion` + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Required. The resource name of the quota info. + * An example name: + * `projects/123/locations/global/services/compute.googleapis.com/quotaInfos/CpusPerProjectPerRegion` + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + +} + diff --git a/Quotas/src/V1/GetQuotaPreferenceRequest.php b/Quotas/src/V1/GetQuotaPreferenceRequest.php new file mode 100644 index 000000000000..d4e3772f5680 --- /dev/null +++ b/Quotas/src/V1/GetQuotaPreferenceRequest.php @@ -0,0 +1,92 @@ +google.api.cloudquotas.v1.GetQuotaPreferenceRequest + */ +class GetQuotaPreferenceRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. Name of the resource + * Example name: + * `projects/123/locations/global/quota_preferences/my-config-for-us-east1` + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $name = ''; + + /** + * @param string $name Required. Name of the resource + * + * Example name: + * `projects/123/locations/global/quota_preferences/my-config-for-us-east1` + * Please see {@see CloudQuotasClient::quotaPreferenceName()} for help formatting this field. + * + * @return \Google\Cloud\CloudQuotas\V1\GetQuotaPreferenceRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. Name of the resource + * Example name: + * `projects/123/locations/global/quota_preferences/my-config-for-us-east1` + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Api\Cloudquotas\V1\Cloudquotas::initOnce(); + parent::__construct($data); + } + + /** + * Required. Name of the resource + * Example name: + * `projects/123/locations/global/quota_preferences/my-config-for-us-east1` + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Required. Name of the resource + * Example name: + * `projects/123/locations/global/quota_preferences/my-config-for-us-east1` + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + +} + diff --git a/Quotas/src/V1/ListQuotaInfosRequest.php b/Quotas/src/V1/ListQuotaInfosRequest.php new file mode 100644 index 000000000000..1620a7795fd9 --- /dev/null +++ b/Quotas/src/V1/ListQuotaInfosRequest.php @@ -0,0 +1,184 @@ +google.api.cloudquotas.v1.ListQuotaInfosRequest + */ +class ListQuotaInfosRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. Parent value of QuotaInfo resources. + * Listing across different resource containers (such as 'projects/-') is not + * allowed. + * Example names: + * `projects/123/locations/global/services/compute.googleapis.com` + * `folders/234/locations/global/services/compute.googleapis.com` + * `organizations/345/locations/global/services/compute.googleapis.com` + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $parent = ''; + /** + * Optional. Requested page size. Server may return fewer items than + * requested. If unspecified, server will pick an appropriate default. + * + * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $page_size = 0; + /** + * Optional. A token identifying a page of results the server should return. + * + * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $page_token = ''; + + /** + * @param string $parent Required. Parent value of QuotaInfo resources. + * Listing across different resource containers (such as 'projects/-') is not + * allowed. + * + * Example names: + * `projects/123/locations/global/services/compute.googleapis.com` + * `folders/234/locations/global/services/compute.googleapis.com` + * `organizations/345/locations/global/services/compute.googleapis.com` + * Please see {@see CloudQuotasClient::serviceName()} for help formatting this field. + * + * @return \Google\Cloud\CloudQuotas\V1\ListQuotaInfosRequest + * + * @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. Parent value of QuotaInfo resources. + * Listing across different resource containers (such as 'projects/-') is not + * allowed. + * Example names: + * `projects/123/locations/global/services/compute.googleapis.com` + * `folders/234/locations/global/services/compute.googleapis.com` + * `organizations/345/locations/global/services/compute.googleapis.com` + * @type int $page_size + * Optional. Requested page size. Server may return fewer items than + * requested. If unspecified, server will pick an appropriate default. + * @type string $page_token + * Optional. A token identifying a page of results the server should return. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Api\Cloudquotas\V1\Cloudquotas::initOnce(); + parent::__construct($data); + } + + /** + * Required. Parent value of QuotaInfo resources. + * Listing across different resource containers (such as 'projects/-') is not + * allowed. + * Example names: + * `projects/123/locations/global/services/compute.googleapis.com` + * `folders/234/locations/global/services/compute.googleapis.com` + * `organizations/345/locations/global/services/compute.googleapis.com` + * + * 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. Parent value of QuotaInfo resources. + * Listing across different resource containers (such as 'projects/-') is not + * allowed. + * Example names: + * `projects/123/locations/global/services/compute.googleapis.com` + * `folders/234/locations/global/services/compute.googleapis.com` + * `organizations/345/locations/global/services/compute.googleapis.com` + * + * 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. Requested page size. Server may return fewer items than + * requested. If unspecified, server will pick an appropriate default. + * + * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @return int + */ + public function getPageSize() + { + return $this->page_size; + } + + /** + * Optional. Requested page size. Server may return fewer items than + * requested. If unspecified, server will pick an appropriate default. + * + * 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 the server should return. + * + * 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 the server should return. + * + * 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/Quotas/src/V1/ListQuotaInfosResponse.php b/Quotas/src/V1/ListQuotaInfosResponse.php new file mode 100644 index 000000000000..0eefa66e027b --- /dev/null +++ b/Quotas/src/V1/ListQuotaInfosResponse.php @@ -0,0 +1,105 @@ +google.api.cloudquotas.v1.ListQuotaInfosResponse + */ +class ListQuotaInfosResponse extends \Google\Protobuf\Internal\Message +{ + /** + * The list of QuotaInfo + * + * Generated from protobuf field repeated .google.api.cloudquotas.v1.QuotaInfo quota_infos = 1; + */ + private $quota_infos; + /** + * 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\Cloud\CloudQuotas\V1\QuotaInfo>|\Google\Protobuf\Internal\RepeatedField $quota_infos + * The list of QuotaInfo + * @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\Api\Cloudquotas\V1\Cloudquotas::initOnce(); + parent::__construct($data); + } + + /** + * The list of QuotaInfo + * + * Generated from protobuf field repeated .google.api.cloudquotas.v1.QuotaInfo quota_infos = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getQuotaInfos() + { + return $this->quota_infos; + } + + /** + * The list of QuotaInfo + * + * Generated from protobuf field repeated .google.api.cloudquotas.v1.QuotaInfo quota_infos = 1; + * @param array<\Google\Cloud\CloudQuotas\V1\QuotaInfo>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setQuotaInfos($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\CloudQuotas\V1\QuotaInfo::class); + $this->quota_infos = $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/Quotas/src/V1/ListQuotaPreferencesRequest.php b/Quotas/src/V1/ListQuotaPreferencesRequest.php new file mode 100644 index 000000000000..47de59a37895 --- /dev/null +++ b/Quotas/src/V1/ListQuotaPreferencesRequest.php @@ -0,0 +1,298 @@ +google.api.cloudquotas.v1.ListQuotaPreferencesRequest + */ +class ListQuotaPreferencesRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. Parent value of QuotaPreference resources. + * Listing across different resource containers (such as 'projects/-') is not + * allowed. + * When the value starts with 'folders' or 'organizations', it lists the + * QuotaPreferences for org quotas in the container. It does not list the + * QuotaPreferences in the descendant projects of the container. + * Example parents: + * `projects/123/locations/global` + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $parent = ''; + /** + * Optional. Requested page size. Server may return fewer items than + * requested. If unspecified, server will pick an appropriate default. + * + * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $page_size = 0; + /** + * Optional. A token identifying a page of results the server should return. + * + * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $page_token = ''; + /** + * Optional. Filter result QuotaPreferences by their state, type, + * create/update time range. + * Example filters: + * `state=PENDING OR state=PENDING_PARTIALLY_GRANTED` + * `state=PENDING OR state=PENDING_PARTIALLY_GRANTED AND + * creation_time>2022-12-03T10:30:00` + * If no filter is provided, returns all pending quota preferences. + * + * Generated from protobuf field string filter = 4 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $filter = ''; + /** + * Optional. How to order of the results. By default, the results are ordered + * by create time. + * Example orders: + * `type` + * `state, create_time` + * + * Generated from protobuf field string order_by = 5 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $order_by = ''; + + /** + * @param string $parent Required. Parent value of QuotaPreference resources. + * Listing across different resource containers (such as 'projects/-') is not + * allowed. + * + * When the value starts with 'folders' or 'organizations', it lists the + * QuotaPreferences for org quotas in the container. It does not list the + * QuotaPreferences in the descendant projects of the container. + * + * Example parents: + * `projects/123/locations/global` + * Please see {@see CloudQuotasClient::locationName()} for help formatting this field. + * + * @return \Google\Cloud\CloudQuotas\V1\ListQuotaPreferencesRequest + * + * @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. Parent value of QuotaPreference resources. + * Listing across different resource containers (such as 'projects/-') is not + * allowed. + * When the value starts with 'folders' or 'organizations', it lists the + * QuotaPreferences for org quotas in the container. It does not list the + * QuotaPreferences in the descendant projects of the container. + * Example parents: + * `projects/123/locations/global` + * @type int $page_size + * Optional. Requested page size. Server may return fewer items than + * requested. If unspecified, server will pick an appropriate default. + * @type string $page_token + * Optional. A token identifying a page of results the server should return. + * @type string $filter + * Optional. Filter result QuotaPreferences by their state, type, + * create/update time range. + * Example filters: + * `state=PENDING OR state=PENDING_PARTIALLY_GRANTED` + * `state=PENDING OR state=PENDING_PARTIALLY_GRANTED AND + * creation_time>2022-12-03T10:30:00` + * If no filter is provided, returns all pending quota preferences. + * @type string $order_by + * Optional. How to order of the results. By default, the results are ordered + * by create time. + * Example orders: + * `type` + * `state, create_time` + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Api\Cloudquotas\V1\Cloudquotas::initOnce(); + parent::__construct($data); + } + + /** + * Required. Parent value of QuotaPreference resources. + * Listing across different resource containers (such as 'projects/-') is not + * allowed. + * When the value starts with 'folders' or 'organizations', it lists the + * QuotaPreferences for org quotas in the container. It does not list the + * QuotaPreferences in the descendant projects of the container. + * Example parents: + * `projects/123/locations/global` + * + * 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. Parent value of QuotaPreference resources. + * Listing across different resource containers (such as 'projects/-') is not + * allowed. + * When the value starts with 'folders' or 'organizations', it lists the + * QuotaPreferences for org quotas in the container. It does not list the + * QuotaPreferences in the descendant projects of the container. + * Example parents: + * `projects/123/locations/global` + * + * 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. Requested page size. Server may return fewer items than + * requested. If unspecified, server will pick an appropriate default. + * + * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @return int + */ + public function getPageSize() + { + return $this->page_size; + } + + /** + * Optional. Requested page size. Server may return fewer items than + * requested. If unspecified, server will pick an appropriate default. + * + * 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 the server should return. + * + * 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 the server should return. + * + * 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; + } + + /** + * Optional. Filter result QuotaPreferences by their state, type, + * create/update time range. + * Example filters: + * `state=PENDING OR state=PENDING_PARTIALLY_GRANTED` + * `state=PENDING OR state=PENDING_PARTIALLY_GRANTED AND + * creation_time>2022-12-03T10:30:00` + * If no filter is provided, returns all pending quota preferences. + * + * Generated from protobuf field string filter = 4 [(.google.api.field_behavior) = OPTIONAL]; + * @return string + */ + public function getFilter() + { + return $this->filter; + } + + /** + * Optional. Filter result QuotaPreferences by their state, type, + * create/update time range. + * Example filters: + * `state=PENDING OR state=PENDING_PARTIALLY_GRANTED` + * `state=PENDING OR state=PENDING_PARTIALLY_GRANTED AND + * creation_time>2022-12-03T10:30:00` + * If no filter is provided, returns all pending quota preferences. + * + * Generated from protobuf field string filter = 4 [(.google.api.field_behavior) = OPTIONAL]; + * @param string $var + * @return $this + */ + public function setFilter($var) + { + GPBUtil::checkString($var, True); + $this->filter = $var; + + return $this; + } + + /** + * Optional. How to order of the results. By default, the results are ordered + * by create time. + * Example orders: + * `type` + * `state, create_time` + * + * Generated from protobuf field string order_by = 5 [(.google.api.field_behavior) = OPTIONAL]; + * @return string + */ + public function getOrderBy() + { + return $this->order_by; + } + + /** + * Optional. How to order of the results. By default, the results are ordered + * by create time. + * Example orders: + * `type` + * `state, create_time` + * + * Generated from protobuf field string order_by = 5 [(.google.api.field_behavior) = OPTIONAL]; + * @param string $var + * @return $this + */ + public function setOrderBy($var) + { + GPBUtil::checkString($var, True); + $this->order_by = $var; + + return $this; + } + +} + diff --git a/Quotas/src/V1/ListQuotaPreferencesResponse.php b/Quotas/src/V1/ListQuotaPreferencesResponse.php new file mode 100644 index 000000000000..123679124c15 --- /dev/null +++ b/Quotas/src/V1/ListQuotaPreferencesResponse.php @@ -0,0 +1,139 @@ +google.api.cloudquotas.v1.ListQuotaPreferencesResponse + */ +class ListQuotaPreferencesResponse extends \Google\Protobuf\Internal\Message +{ + /** + * The list of QuotaPreference + * + * Generated from protobuf field repeated .google.api.cloudquotas.v1.QuotaPreference quota_preferences = 1; + */ + private $quota_preferences; + /** + * 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 = ''; + /** + * Locations that could not be reached. + * + * Generated from protobuf field repeated string unreachable = 3; + */ + private $unreachable; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\Google\Cloud\CloudQuotas\V1\QuotaPreference>|\Google\Protobuf\Internal\RepeatedField $quota_preferences + * The list of QuotaPreference + * @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. + * @type array|\Google\Protobuf\Internal\RepeatedField $unreachable + * Locations that could not be reached. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Api\Cloudquotas\V1\Cloudquotas::initOnce(); + parent::__construct($data); + } + + /** + * The list of QuotaPreference + * + * Generated from protobuf field repeated .google.api.cloudquotas.v1.QuotaPreference quota_preferences = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getQuotaPreferences() + { + return $this->quota_preferences; + } + + /** + * The list of QuotaPreference + * + * Generated from protobuf field repeated .google.api.cloudquotas.v1.QuotaPreference quota_preferences = 1; + * @param array<\Google\Cloud\CloudQuotas\V1\QuotaPreference>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setQuotaPreferences($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\CloudQuotas\V1\QuotaPreference::class); + $this->quota_preferences = $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; + } + + /** + * Locations that could not be reached. + * + * Generated from protobuf field repeated string unreachable = 3; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getUnreachable() + { + return $this->unreachable; + } + + /** + * Locations that could not be reached. + * + * Generated from protobuf field repeated string unreachable = 3; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setUnreachable($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->unreachable = $arr; + + return $this; + } + +} + diff --git a/Quotas/src/V1/QuotaConfig.php b/Quotas/src/V1/QuotaConfig.php new file mode 100644 index 000000000000..d04ad7929ab8 --- /dev/null +++ b/Quotas/src/V1/QuotaConfig.php @@ -0,0 +1,302 @@ +google.api.cloudquotas.v1.QuotaConfig + */ +class QuotaConfig extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The preferred value. Must be greater than or equal to -1. If set + * to -1, it means the value is "unlimited". + * + * Generated from protobuf field int64 preferred_value = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $preferred_value = 0; + /** + * Output only. Optional details about the state of this quota preference. + * + * Generated from protobuf field string state_detail = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $state_detail = ''; + /** + * Output only. Granted quota value. + * + * Generated from protobuf field .google.protobuf.Int64Value granted_value = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $granted_value = null; + /** + * Output only. The trace id that the Google Cloud uses to provision the + * requested quota. This trace id may be used by the client to contact Cloud + * support to track the state of a quota preference request. The trace id is + * only produced for increase requests and is unique for each request. The + * quota decrease requests do not have a trace id. + * + * Generated from protobuf field string trace_id = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $trace_id = ''; + /** + * The annotations map for clients to store small amounts of arbitrary data. + * Do not put PII or other sensitive information here. + * See https://google.aip.dev/128#annotations + * + * Generated from protobuf field map annotations = 5; + */ + private $annotations; + /** + * Output only. The origin of the quota preference request. + * + * Generated from protobuf field .google.api.cloudquotas.v1.QuotaConfig.Origin request_origin = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $request_origin = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int|string $preferred_value + * Required. The preferred value. Must be greater than or equal to -1. If set + * to -1, it means the value is "unlimited". + * @type string $state_detail + * Output only. Optional details about the state of this quota preference. + * @type \Google\Protobuf\Int64Value $granted_value + * Output only. Granted quota value. + * @type string $trace_id + * Output only. The trace id that the Google Cloud uses to provision the + * requested quota. This trace id may be used by the client to contact Cloud + * support to track the state of a quota preference request. The trace id is + * only produced for increase requests and is unique for each request. The + * quota decrease requests do not have a trace id. + * @type array|\Google\Protobuf\Internal\MapField $annotations + * The annotations map for clients to store small amounts of arbitrary data. + * Do not put PII or other sensitive information here. + * See https://google.aip.dev/128#annotations + * @type int $request_origin + * Output only. The origin of the quota preference request. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Api\Cloudquotas\V1\Resources::initOnce(); + parent::__construct($data); + } + + /** + * Required. The preferred value. Must be greater than or equal to -1. If set + * to -1, it means the value is "unlimited". + * + * Generated from protobuf field int64 preferred_value = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return int|string + */ + public function getPreferredValue() + { + return $this->preferred_value; + } + + /** + * Required. The preferred value. Must be greater than or equal to -1. If set + * to -1, it means the value is "unlimited". + * + * Generated from protobuf field int64 preferred_value = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param int|string $var + * @return $this + */ + public function setPreferredValue($var) + { + GPBUtil::checkInt64($var); + $this->preferred_value = $var; + + return $this; + } + + /** + * Output only. Optional details about the state of this quota preference. + * + * Generated from protobuf field string state_detail = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getStateDetail() + { + return $this->state_detail; + } + + /** + * Output only. Optional details about the state of this quota preference. + * + * Generated from protobuf field string state_detail = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setStateDetail($var) + { + GPBUtil::checkString($var, True); + $this->state_detail = $var; + + return $this; + } + + /** + * Output only. Granted quota value. + * + * Generated from protobuf field .google.protobuf.Int64Value granted_value = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Int64Value|null + */ + public function getGrantedValue() + { + return $this->granted_value; + } + + public function hasGrantedValue() + { + return isset($this->granted_value); + } + + public function clearGrantedValue() + { + unset($this->granted_value); + } + + /** + * Returns the unboxed value from getGrantedValue() + + * Output only. Granted quota value. + * + * Generated from protobuf field .google.protobuf.Int64Value granted_value = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return int|string|null + */ + public function getGrantedValueUnwrapped() + { + return $this->readWrapperValue("granted_value"); + } + + /** + * Output only. Granted quota value. + * + * Generated from protobuf field .google.protobuf.Int64Value granted_value = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Protobuf\Int64Value $var + * @return $this + */ + public function setGrantedValue($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Int64Value::class); + $this->granted_value = $var; + + return $this; + } + + /** + * Sets the field by wrapping a primitive type in a Google\Protobuf\Int64Value object. + + * Output only. Granted quota value. + * + * Generated from protobuf field .google.protobuf.Int64Value granted_value = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param int|string|null $var + * @return $this + */ + public function setGrantedValueUnwrapped($var) + { + $this->writeWrapperValue("granted_value", $var); + return $this;} + + /** + * Output only. The trace id that the Google Cloud uses to provision the + * requested quota. This trace id may be used by the client to contact Cloud + * support to track the state of a quota preference request. The trace id is + * only produced for increase requests and is unique for each request. The + * quota decrease requests do not have a trace id. + * + * Generated from protobuf field string trace_id = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getTraceId() + { + return $this->trace_id; + } + + /** + * Output only. The trace id that the Google Cloud uses to provision the + * requested quota. This trace id may be used by the client to contact Cloud + * support to track the state of a quota preference request. The trace id is + * only produced for increase requests and is unique for each request. The + * quota decrease requests do not have a trace id. + * + * Generated from protobuf field string trace_id = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setTraceId($var) + { + GPBUtil::checkString($var, True); + $this->trace_id = $var; + + return $this; + } + + /** + * The annotations map for clients to store small amounts of arbitrary data. + * Do not put PII or other sensitive information here. + * See https://google.aip.dev/128#annotations + * + * Generated from protobuf field map annotations = 5; + * @return \Google\Protobuf\Internal\MapField + */ + public function getAnnotations() + { + return $this->annotations; + } + + /** + * The annotations map for clients to store small amounts of arbitrary data. + * Do not put PII or other sensitive information here. + * See https://google.aip.dev/128#annotations + * + * Generated from protobuf field map annotations = 5; + * @param array|\Google\Protobuf\Internal\MapField $var + * @return $this + */ + public function setAnnotations($var) + { + $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::STRING); + $this->annotations = $arr; + + return $this; + } + + /** + * Output only. The origin of the quota preference request. + * + * Generated from protobuf field .google.api.cloudquotas.v1.QuotaConfig.Origin request_origin = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return int + */ + public function getRequestOrigin() + { + return $this->request_origin; + } + + /** + * Output only. The origin of the quota preference request. + * + * Generated from protobuf field .google.api.cloudquotas.v1.QuotaConfig.Origin request_origin = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param int $var + * @return $this + */ + public function setRequestOrigin($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\CloudQuotas\V1\QuotaConfig\Origin::class); + $this->request_origin = $var; + + return $this; + } + +} + diff --git a/Quotas/src/V1/QuotaConfig/Origin.php b/Quotas/src/V1/QuotaConfig/Origin.php new file mode 100644 index 000000000000..659448dc0e81 --- /dev/null +++ b/Quotas/src/V1/QuotaConfig/Origin.php @@ -0,0 +1,62 @@ +google.api.cloudquotas.v1.QuotaConfig.Origin + */ +class Origin +{ + /** + * The unspecified value. + * + * Generated from protobuf enum ORIGIN_UNSPECIFIED = 0; + */ + const ORIGIN_UNSPECIFIED = 0; + /** + * Created through Cloud Console. + * + * Generated from protobuf enum CLOUD_CONSOLE = 1; + */ + const CLOUD_CONSOLE = 1; + /** + * Generated by automatic quota adjustment. + * + * Generated from protobuf enum AUTO_ADJUSTER = 2; + */ + const AUTO_ADJUSTER = 2; + + private static $valueToName = [ + self::ORIGIN_UNSPECIFIED => 'ORIGIN_UNSPECIFIED', + self::CLOUD_CONSOLE => 'CLOUD_CONSOLE', + self::AUTO_ADJUSTER => 'AUTO_ADJUSTER', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + + diff --git a/Quotas/src/V1/QuotaDetails.php b/Quotas/src/V1/QuotaDetails.php new file mode 100644 index 000000000000..2162ae832009 --- /dev/null +++ b/Quotas/src/V1/QuotaDetails.php @@ -0,0 +1,67 @@ +google.api.cloudquotas.v1.QuotaDetails + */ +class QuotaDetails extends \Google\Protobuf\Internal\Message +{ + /** + * The value currently in effect and being enforced. + * + * Generated from protobuf field int64 value = 1; + */ + protected $value = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int|string $value + * The value currently in effect and being enforced. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Api\Cloudquotas\V1\Resources::initOnce(); + parent::__construct($data); + } + + /** + * The value currently in effect and being enforced. + * + * Generated from protobuf field int64 value = 1; + * @return int|string + */ + public function getValue() + { + return $this->value; + } + + /** + * The value currently in effect and being enforced. + * + * Generated from protobuf field int64 value = 1; + * @param int|string $var + * @return $this + */ + public function setValue($var) + { + GPBUtil::checkInt64($var); + $this->value = $var; + + return $this; + } + +} + diff --git a/Quotas/src/V1/QuotaIncreaseEligibility.php b/Quotas/src/V1/QuotaIncreaseEligibility.php new file mode 100644 index 000000000000..daf06c473eb6 --- /dev/null +++ b/Quotas/src/V1/QuotaIncreaseEligibility.php @@ -0,0 +1,109 @@ +google.api.cloudquotas.v1.QuotaIncreaseEligibility + */ +class QuotaIncreaseEligibility extends \Google\Protobuf\Internal\Message +{ + /** + * Whether a higher quota value can be requested for the quota. + * + * Generated from protobuf field bool is_eligible = 1; + */ + protected $is_eligible = false; + /** + * The reason of why it is ineligible to request increased value of the quota. + * If the is_eligible field is true, it defaults to + * INELIGIBILITY_REASON_UNSPECIFIED. + * + * Generated from protobuf field .google.api.cloudquotas.v1.QuotaIncreaseEligibility.IneligibilityReason ineligibility_reason = 2; + */ + protected $ineligibility_reason = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type bool $is_eligible + * Whether a higher quota value can be requested for the quota. + * @type int $ineligibility_reason + * The reason of why it is ineligible to request increased value of the quota. + * If the is_eligible field is true, it defaults to + * INELIGIBILITY_REASON_UNSPECIFIED. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Api\Cloudquotas\V1\Resources::initOnce(); + parent::__construct($data); + } + + /** + * Whether a higher quota value can be requested for the quota. + * + * Generated from protobuf field bool is_eligible = 1; + * @return bool + */ + public function getIsEligible() + { + return $this->is_eligible; + } + + /** + * Whether a higher quota value can be requested for the quota. + * + * Generated from protobuf field bool is_eligible = 1; + * @param bool $var + * @return $this + */ + public function setIsEligible($var) + { + GPBUtil::checkBool($var); + $this->is_eligible = $var; + + return $this; + } + + /** + * The reason of why it is ineligible to request increased value of the quota. + * If the is_eligible field is true, it defaults to + * INELIGIBILITY_REASON_UNSPECIFIED. + * + * Generated from protobuf field .google.api.cloudquotas.v1.QuotaIncreaseEligibility.IneligibilityReason ineligibility_reason = 2; + * @return int + */ + public function getIneligibilityReason() + { + return $this->ineligibility_reason; + } + + /** + * The reason of why it is ineligible to request increased value of the quota. + * If the is_eligible field is true, it defaults to + * INELIGIBILITY_REASON_UNSPECIFIED. + * + * Generated from protobuf field .google.api.cloudquotas.v1.QuotaIncreaseEligibility.IneligibilityReason ineligibility_reason = 2; + * @param int $var + * @return $this + */ + public function setIneligibilityReason($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\CloudQuotas\V1\QuotaIncreaseEligibility\IneligibilityReason::class); + $this->ineligibility_reason = $var; + + return $this; + } + +} + diff --git a/Quotas/src/V1/QuotaIncreaseEligibility/IneligibilityReason.php b/Quotas/src/V1/QuotaIncreaseEligibility/IneligibilityReason.php new file mode 100644 index 000000000000..d69785a42381 --- /dev/null +++ b/Quotas/src/V1/QuotaIncreaseEligibility/IneligibilityReason.php @@ -0,0 +1,63 @@ +google.api.cloudquotas.v1.QuotaIncreaseEligibility.IneligibilityReason + */ +class IneligibilityReason +{ + /** + * Default value when is_eligible is true. + * + * Generated from protobuf enum INELIGIBILITY_REASON_UNSPECIFIED = 0; + */ + const INELIGIBILITY_REASON_UNSPECIFIED = 0; + /** + * The container is not linked with a valid billing account. + * + * Generated from protobuf enum NO_VALID_BILLING_ACCOUNT = 1; + */ + const NO_VALID_BILLING_ACCOUNT = 1; + /** + * Other reasons. + * + * Generated from protobuf enum OTHER = 2; + */ + const OTHER = 2; + + private static $valueToName = [ + self::INELIGIBILITY_REASON_UNSPECIFIED => 'INELIGIBILITY_REASON_UNSPECIFIED', + self::NO_VALID_BILLING_ACCOUNT => 'NO_VALID_BILLING_ACCOUNT', + self::OTHER => 'OTHER', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + + diff --git a/Quotas/src/V1/QuotaInfo.php b/Quotas/src/V1/QuotaInfo.php new file mode 100644 index 000000000000..99c972e954c9 --- /dev/null +++ b/Quotas/src/V1/QuotaInfo.php @@ -0,0 +1,672 @@ +google.api.cloudquotas.v1.QuotaInfo + */ +class QuotaInfo extends \Google\Protobuf\Internal\Message +{ + /** + * Resource name of this QuotaInfo. + * The ID component following "locations/" must be "global". + * Example: + * `projects/123/locations/global/services/compute.googleapis.com/quotaInfos/CpusPerProjectPerRegion` + * + * Generated from protobuf field string name = 1; + */ + protected $name = ''; + /** + * The id of the quota, which is unquie within the service. + * Example: `CpusPerProjectPerRegion` + * + * Generated from protobuf field string quota_id = 2; + */ + protected $quota_id = ''; + /** + * The metric of the quota. It specifies the resources consumption the quota + * is defined for. + * Example: `compute.googleapis.com/cpus` + * + * Generated from protobuf field string metric = 3; + */ + protected $metric = ''; + /** + * The name of the service in which the quota is defined. + * Example: `compute.googleapis.com` + * + * Generated from protobuf field string service = 4; + */ + protected $service = ''; + /** + * Whether this is a precise quota. A precise quota is tracked with absolute + * precision. In contrast, an imprecise quota is not tracked with precision. + * + * Generated from protobuf field bool is_precise = 5; + */ + protected $is_precise = false; + /** + * The reset time interval for the quota. Refresh interval applies to rate + * quota only. + * Example: "minute" for per minute, "day" for per day, or "10 seconds" for + * every 10 seconds. + * + * Generated from protobuf field string refresh_interval = 6; + */ + protected $refresh_interval = ''; + /** + * The container type of the QuotaInfo. + * + * Generated from protobuf field .google.api.cloudquotas.v1.QuotaInfo.ContainerType container_type = 7; + */ + protected $container_type = 0; + /** + * The dimensions the quota is defined on. + * + * Generated from protobuf field repeated string dimensions = 8; + */ + private $dimensions; + /** + * The display name of the quota metric + * + * Generated from protobuf field string metric_display_name = 9; + */ + protected $metric_display_name = ''; + /** + * The display name of the quota. + * + * Generated from protobuf field string quota_display_name = 10; + */ + protected $quota_display_name = ''; + /** + * The unit in which the metric value is reported, e.g., "MByte". + * + * Generated from protobuf field string metric_unit = 11; + */ + protected $metric_unit = ''; + /** + * Whether it is eligible to request a higher quota value for this quota. + * + * Generated from protobuf field .google.api.cloudquotas.v1.QuotaIncreaseEligibility quota_increase_eligibility = 12; + */ + protected $quota_increase_eligibility = null; + /** + * Whether the quota value is fixed or adjustable + * + * Generated from protobuf field bool is_fixed = 13; + */ + protected $is_fixed = false; + /** + * The collection of dimensions info ordered by their dimensions from more + * specific ones to less specific ones. + * + * Generated from protobuf field repeated .google.api.cloudquotas.v1.DimensionsInfo dimensions_infos = 14; + */ + private $dimensions_infos; + /** + * Whether the quota is a concurrent quota. Concurrent quotas are enforced + * on the total number of concurrent operations in flight at any given time. + * + * Generated from protobuf field bool is_concurrent = 15; + */ + protected $is_concurrent = false; + /** + * URI to the page where the user can request more quotas for the cloud + * service, such as + * https://docs.google.com/spreadsheet/viewform?formkey=abc123&entry_0={email}&entry_1={id}. + * Google Developers Console UI replace {email} with the current + * user's e-mail, {id} with the current project number, or organization ID + * with "organizations/" prefix. For example, + * https://docs.google.com/spreadsheet/viewform?formkey=abc123&entry_0=johndoe@gmail.com&entry_1=25463754, + * or + * https://docs.google.com/spreadsheet/viewform?formkey=abc123&entry_0=johndoe@gmail.com&entry_1=organizations/26474422. + * + * Generated from protobuf field string service_request_quota_uri = 17; + */ + protected $service_request_quota_uri = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Resource name of this QuotaInfo. + * The ID component following "locations/" must be "global". + * Example: + * `projects/123/locations/global/services/compute.googleapis.com/quotaInfos/CpusPerProjectPerRegion` + * @type string $quota_id + * The id of the quota, which is unquie within the service. + * Example: `CpusPerProjectPerRegion` + * @type string $metric + * The metric of the quota. It specifies the resources consumption the quota + * is defined for. + * Example: `compute.googleapis.com/cpus` + * @type string $service + * The name of the service in which the quota is defined. + * Example: `compute.googleapis.com` + * @type bool $is_precise + * Whether this is a precise quota. A precise quota is tracked with absolute + * precision. In contrast, an imprecise quota is not tracked with precision. + * @type string $refresh_interval + * The reset time interval for the quota. Refresh interval applies to rate + * quota only. + * Example: "minute" for per minute, "day" for per day, or "10 seconds" for + * every 10 seconds. + * @type int $container_type + * The container type of the QuotaInfo. + * @type array|\Google\Protobuf\Internal\RepeatedField $dimensions + * The dimensions the quota is defined on. + * @type string $metric_display_name + * The display name of the quota metric + * @type string $quota_display_name + * The display name of the quota. + * @type string $metric_unit + * The unit in which the metric value is reported, e.g., "MByte". + * @type \Google\Cloud\CloudQuotas\V1\QuotaIncreaseEligibility $quota_increase_eligibility + * Whether it is eligible to request a higher quota value for this quota. + * @type bool $is_fixed + * Whether the quota value is fixed or adjustable + * @type array<\Google\Cloud\CloudQuotas\V1\DimensionsInfo>|\Google\Protobuf\Internal\RepeatedField $dimensions_infos + * The collection of dimensions info ordered by their dimensions from more + * specific ones to less specific ones. + * @type bool $is_concurrent + * Whether the quota is a concurrent quota. Concurrent quotas are enforced + * on the total number of concurrent operations in flight at any given time. + * @type string $service_request_quota_uri + * URI to the page where the user can request more quotas for the cloud + * service, such as + * https://docs.google.com/spreadsheet/viewform?formkey=abc123&entry_0={email}&entry_1={id}. + * Google Developers Console UI replace {email} with the current + * user's e-mail, {id} with the current project number, or organization ID + * with "organizations/" prefix. For example, + * https://docs.google.com/spreadsheet/viewform?formkey=abc123&entry_0=johndoe@gmail.com&entry_1=25463754, + * or + * https://docs.google.com/spreadsheet/viewform?formkey=abc123&entry_0=johndoe@gmail.com&entry_1=organizations/26474422. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Api\Cloudquotas\V1\Resources::initOnce(); + parent::__construct($data); + } + + /** + * Resource name of this QuotaInfo. + * The ID component following "locations/" must be "global". + * Example: + * `projects/123/locations/global/services/compute.googleapis.com/quotaInfos/CpusPerProjectPerRegion` + * + * Generated from protobuf field string name = 1; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Resource name of this QuotaInfo. + * The ID component following "locations/" must be "global". + * Example: + * `projects/123/locations/global/services/compute.googleapis.com/quotaInfos/CpusPerProjectPerRegion` + * + * 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; + } + + /** + * The id of the quota, which is unquie within the service. + * Example: `CpusPerProjectPerRegion` + * + * Generated from protobuf field string quota_id = 2; + * @return string + */ + public function getQuotaId() + { + return $this->quota_id; + } + + /** + * The id of the quota, which is unquie within the service. + * Example: `CpusPerProjectPerRegion` + * + * Generated from protobuf field string quota_id = 2; + * @param string $var + * @return $this + */ + public function setQuotaId($var) + { + GPBUtil::checkString($var, True); + $this->quota_id = $var; + + return $this; + } + + /** + * The metric of the quota. It specifies the resources consumption the quota + * is defined for. + * Example: `compute.googleapis.com/cpus` + * + * Generated from protobuf field string metric = 3; + * @return string + */ + public function getMetric() + { + return $this->metric; + } + + /** + * The metric of the quota. It specifies the resources consumption the quota + * is defined for. + * Example: `compute.googleapis.com/cpus` + * + * Generated from protobuf field string metric = 3; + * @param string $var + * @return $this + */ + public function setMetric($var) + { + GPBUtil::checkString($var, True); + $this->metric = $var; + + return $this; + } + + /** + * The name of the service in which the quota is defined. + * Example: `compute.googleapis.com` + * + * Generated from protobuf field string service = 4; + * @return string + */ + public function getService() + { + return $this->service; + } + + /** + * The name of the service in which the quota is defined. + * Example: `compute.googleapis.com` + * + * Generated from protobuf field string service = 4; + * @param string $var + * @return $this + */ + public function setService($var) + { + GPBUtil::checkString($var, True); + $this->service = $var; + + return $this; + } + + /** + * Whether this is a precise quota. A precise quota is tracked with absolute + * precision. In contrast, an imprecise quota is not tracked with precision. + * + * Generated from protobuf field bool is_precise = 5; + * @return bool + */ + public function getIsPrecise() + { + return $this->is_precise; + } + + /** + * Whether this is a precise quota. A precise quota is tracked with absolute + * precision. In contrast, an imprecise quota is not tracked with precision. + * + * Generated from protobuf field bool is_precise = 5; + * @param bool $var + * @return $this + */ + public function setIsPrecise($var) + { + GPBUtil::checkBool($var); + $this->is_precise = $var; + + return $this; + } + + /** + * The reset time interval for the quota. Refresh interval applies to rate + * quota only. + * Example: "minute" for per minute, "day" for per day, or "10 seconds" for + * every 10 seconds. + * + * Generated from protobuf field string refresh_interval = 6; + * @return string + */ + public function getRefreshInterval() + { + return $this->refresh_interval; + } + + /** + * The reset time interval for the quota. Refresh interval applies to rate + * quota only. + * Example: "minute" for per minute, "day" for per day, or "10 seconds" for + * every 10 seconds. + * + * Generated from protobuf field string refresh_interval = 6; + * @param string $var + * @return $this + */ + public function setRefreshInterval($var) + { + GPBUtil::checkString($var, True); + $this->refresh_interval = $var; + + return $this; + } + + /** + * The container type of the QuotaInfo. + * + * Generated from protobuf field .google.api.cloudquotas.v1.QuotaInfo.ContainerType container_type = 7; + * @return int + */ + public function getContainerType() + { + return $this->container_type; + } + + /** + * The container type of the QuotaInfo. + * + * Generated from protobuf field .google.api.cloudquotas.v1.QuotaInfo.ContainerType container_type = 7; + * @param int $var + * @return $this + */ + public function setContainerType($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\CloudQuotas\V1\QuotaInfo\ContainerType::class); + $this->container_type = $var; + + return $this; + } + + /** + * The dimensions the quota is defined on. + * + * Generated from protobuf field repeated string dimensions = 8; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getDimensions() + { + return $this->dimensions; + } + + /** + * The dimensions the quota is defined on. + * + * Generated from protobuf field repeated string dimensions = 8; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setDimensions($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->dimensions = $arr; + + return $this; + } + + /** + * The display name of the quota metric + * + * Generated from protobuf field string metric_display_name = 9; + * @return string + */ + public function getMetricDisplayName() + { + return $this->metric_display_name; + } + + /** + * The display name of the quota metric + * + * Generated from protobuf field string metric_display_name = 9; + * @param string $var + * @return $this + */ + public function setMetricDisplayName($var) + { + GPBUtil::checkString($var, True); + $this->metric_display_name = $var; + + return $this; + } + + /** + * The display name of the quota. + * + * Generated from protobuf field string quota_display_name = 10; + * @return string + */ + public function getQuotaDisplayName() + { + return $this->quota_display_name; + } + + /** + * The display name of the quota. + * + * Generated from protobuf field string quota_display_name = 10; + * @param string $var + * @return $this + */ + public function setQuotaDisplayName($var) + { + GPBUtil::checkString($var, True); + $this->quota_display_name = $var; + + return $this; + } + + /** + * The unit in which the metric value is reported, e.g., "MByte". + * + * Generated from protobuf field string metric_unit = 11; + * @return string + */ + public function getMetricUnit() + { + return $this->metric_unit; + } + + /** + * The unit in which the metric value is reported, e.g., "MByte". + * + * Generated from protobuf field string metric_unit = 11; + * @param string $var + * @return $this + */ + public function setMetricUnit($var) + { + GPBUtil::checkString($var, True); + $this->metric_unit = $var; + + return $this; + } + + /** + * Whether it is eligible to request a higher quota value for this quota. + * + * Generated from protobuf field .google.api.cloudquotas.v1.QuotaIncreaseEligibility quota_increase_eligibility = 12; + * @return \Google\Cloud\CloudQuotas\V1\QuotaIncreaseEligibility|null + */ + public function getQuotaIncreaseEligibility() + { + return $this->quota_increase_eligibility; + } + + public function hasQuotaIncreaseEligibility() + { + return isset($this->quota_increase_eligibility); + } + + public function clearQuotaIncreaseEligibility() + { + unset($this->quota_increase_eligibility); + } + + /** + * Whether it is eligible to request a higher quota value for this quota. + * + * Generated from protobuf field .google.api.cloudquotas.v1.QuotaIncreaseEligibility quota_increase_eligibility = 12; + * @param \Google\Cloud\CloudQuotas\V1\QuotaIncreaseEligibility $var + * @return $this + */ + public function setQuotaIncreaseEligibility($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\CloudQuotas\V1\QuotaIncreaseEligibility::class); + $this->quota_increase_eligibility = $var; + + return $this; + } + + /** + * Whether the quota value is fixed or adjustable + * + * Generated from protobuf field bool is_fixed = 13; + * @return bool + */ + public function getIsFixed() + { + return $this->is_fixed; + } + + /** + * Whether the quota value is fixed or adjustable + * + * Generated from protobuf field bool is_fixed = 13; + * @param bool $var + * @return $this + */ + public function setIsFixed($var) + { + GPBUtil::checkBool($var); + $this->is_fixed = $var; + + return $this; + } + + /** + * The collection of dimensions info ordered by their dimensions from more + * specific ones to less specific ones. + * + * Generated from protobuf field repeated .google.api.cloudquotas.v1.DimensionsInfo dimensions_infos = 14; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getDimensionsInfos() + { + return $this->dimensions_infos; + } + + /** + * The collection of dimensions info ordered by their dimensions from more + * specific ones to less specific ones. + * + * Generated from protobuf field repeated .google.api.cloudquotas.v1.DimensionsInfo dimensions_infos = 14; + * @param array<\Google\Cloud\CloudQuotas\V1\DimensionsInfo>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setDimensionsInfos($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\CloudQuotas\V1\DimensionsInfo::class); + $this->dimensions_infos = $arr; + + return $this; + } + + /** + * Whether the quota is a concurrent quota. Concurrent quotas are enforced + * on the total number of concurrent operations in flight at any given time. + * + * Generated from protobuf field bool is_concurrent = 15; + * @return bool + */ + public function getIsConcurrent() + { + return $this->is_concurrent; + } + + /** + * Whether the quota is a concurrent quota. Concurrent quotas are enforced + * on the total number of concurrent operations in flight at any given time. + * + * Generated from protobuf field bool is_concurrent = 15; + * @param bool $var + * @return $this + */ + public function setIsConcurrent($var) + { + GPBUtil::checkBool($var); + $this->is_concurrent = $var; + + return $this; + } + + /** + * URI to the page where the user can request more quotas for the cloud + * service, such as + * https://docs.google.com/spreadsheet/viewform?formkey=abc123&entry_0={email}&entry_1={id}. + * Google Developers Console UI replace {email} with the current + * user's e-mail, {id} with the current project number, or organization ID + * with "organizations/" prefix. For example, + * https://docs.google.com/spreadsheet/viewform?formkey=abc123&entry_0=johndoe@gmail.com&entry_1=25463754, + * or + * https://docs.google.com/spreadsheet/viewform?formkey=abc123&entry_0=johndoe@gmail.com&entry_1=organizations/26474422. + * + * Generated from protobuf field string service_request_quota_uri = 17; + * @return string + */ + public function getServiceRequestQuotaUri() + { + return $this->service_request_quota_uri; + } + + /** + * URI to the page where the user can request more quotas for the cloud + * service, such as + * https://docs.google.com/spreadsheet/viewform?formkey=abc123&entry_0={email}&entry_1={id}. + * Google Developers Console UI replace {email} with the current + * user's e-mail, {id} with the current project number, or organization ID + * with "organizations/" prefix. For example, + * https://docs.google.com/spreadsheet/viewform?formkey=abc123&entry_0=johndoe@gmail.com&entry_1=25463754, + * or + * https://docs.google.com/spreadsheet/viewform?formkey=abc123&entry_0=johndoe@gmail.com&entry_1=organizations/26474422. + * + * Generated from protobuf field string service_request_quota_uri = 17; + * @param string $var + * @return $this + */ + public function setServiceRequestQuotaUri($var) + { + GPBUtil::checkString($var, True); + $this->service_request_quota_uri = $var; + + return $this; + } + +} + diff --git a/Quotas/src/V1/QuotaInfo/ContainerType.php b/Quotas/src/V1/QuotaInfo/ContainerType.php new file mode 100644 index 000000000000..cb224d9e68c2 --- /dev/null +++ b/Quotas/src/V1/QuotaInfo/ContainerType.php @@ -0,0 +1,69 @@ +google.api.cloudquotas.v1.QuotaInfo.ContainerType + */ +class ContainerType +{ + /** + * Unspecified container type. + * + * Generated from protobuf enum CONTAINER_TYPE_UNSPECIFIED = 0; + */ + const CONTAINER_TYPE_UNSPECIFIED = 0; + /** + * consumer project + * + * Generated from protobuf enum PROJECT = 1; + */ + const PROJECT = 1; + /** + * folder + * + * Generated from protobuf enum FOLDER = 2; + */ + const FOLDER = 2; + /** + * organization + * + * Generated from protobuf enum ORGANIZATION = 3; + */ + const ORGANIZATION = 3; + + private static $valueToName = [ + self::CONTAINER_TYPE_UNSPECIFIED => 'CONTAINER_TYPE_UNSPECIFIED', + self::PROJECT => 'PROJECT', + self::FOLDER => 'FOLDER', + self::ORGANIZATION => 'ORGANIZATION', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + + diff --git a/Quotas/src/V1/QuotaPreference.php b/Quotas/src/V1/QuotaPreference.php new file mode 100644 index 000000000000..1623ecb2bb3d --- /dev/null +++ b/Quotas/src/V1/QuotaPreference.php @@ -0,0 +1,535 @@ +google.api.cloudquotas.v1.QuotaPreference + */ +class QuotaPreference extends \Google\Protobuf\Internal\Message +{ + /** + * Required except in the CREATE requests. + * The resource name of the quota preference. + * The ID component following "locations/" must be "global". + * Example: + * `projects/123/locations/global/quotaPreferences/my-config-for-us-east1` + * + * Generated from protobuf field string name = 1; + */ + protected $name = ''; + /** + * The dimensions that this quota preference applies to. The key of the map + * entry is the name of a dimension, such as "region", "zone", "network_id", + * and the value of the map entry is the dimension value. + * If a dimension is missing from the map of dimensions, the quota preference + * applies to all the dimension values except for those that have other quota + * preferences configured for the specific value. + * NOTE: QuotaPreferences can only be applied across all values of "user" and + * "resource" dimension. Do not set values for "user" or "resource" in the + * dimension map. + * Example: {"provider", "Foo Inc"} where "provider" is a service specific + * dimension. + * + * Generated from protobuf field map dimensions = 2; + */ + private $dimensions; + /** + * Required. Preferred quota configuration. + * + * Generated from protobuf field .google.api.cloudquotas.v1.QuotaConfig quota_config = 3 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $quota_config = null; + /** + * Optional. The current etag of the quota preference. If an etag is provided + * on update and does not match the current server's etag of the quota + * preference, the request will be blocked and an ABORTED error will be + * returned. See https://google.aip.dev/134#etags for more details on etags. + * + * Generated from protobuf field string etag = 4 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $etag = ''; + /** + * Output only. Create time stamp + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $create_time = null; + /** + * Output only. Update time stamp + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $update_time = null; + /** + * Required. The name of the service to which the quota preference is applied. + * + * Generated from protobuf field string service = 7 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $service = ''; + /** + * Required. The id of the quota to which the quota preference is applied. A + * quota name is unique in the service. Example: `CpusPerProjectPerRegion` + * + * Generated from protobuf field string quota_id = 8 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $quota_id = ''; + /** + * Output only. Is the quota preference pending Google Cloud approval and + * fulfillment. + * + * Generated from protobuf field bool reconciling = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $reconciling = false; + /** + * The reason / justification for this quota preference. + * + * Generated from protobuf field string justification = 11; + */ + protected $justification = ''; + /** + * Required. Input only. An email address that can be used for quota related + * communication between the Google Cloud and the user in case the Google + * Cloud needs further information to make a decision on whether the user + * preferred quota can be granted. + * The Google account for the email address must have quota update permission + * for the project, folder or organization this quota preference is for. + * + * Generated from protobuf field string contact_email = 12 [(.google.api.field_behavior) = INPUT_ONLY, (.google.api.field_behavior) = REQUIRED]; + */ + protected $contact_email = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required except in the CREATE requests. + * The resource name of the quota preference. + * The ID component following "locations/" must be "global". + * Example: + * `projects/123/locations/global/quotaPreferences/my-config-for-us-east1` + * @type array|\Google\Protobuf\Internal\MapField $dimensions + * The dimensions that this quota preference applies to. The key of the map + * entry is the name of a dimension, such as "region", "zone", "network_id", + * and the value of the map entry is the dimension value. + * If a dimension is missing from the map of dimensions, the quota preference + * applies to all the dimension values except for those that have other quota + * preferences configured for the specific value. + * NOTE: QuotaPreferences can only be applied across all values of "user" and + * "resource" dimension. Do not set values for "user" or "resource" in the + * dimension map. + * Example: {"provider", "Foo Inc"} where "provider" is a service specific + * dimension. + * @type \Google\Cloud\CloudQuotas\V1\QuotaConfig $quota_config + * Required. Preferred quota configuration. + * @type string $etag + * Optional. The current etag of the quota preference. If an etag is provided + * on update and does not match the current server's etag of the quota + * preference, the request will be blocked and an ABORTED error will be + * returned. See https://google.aip.dev/134#etags for more details on etags. + * @type \Google\Protobuf\Timestamp $create_time + * Output only. Create time stamp + * @type \Google\Protobuf\Timestamp $update_time + * Output only. Update time stamp + * @type string $service + * Required. The name of the service to which the quota preference is applied. + * @type string $quota_id + * Required. The id of the quota to which the quota preference is applied. A + * quota name is unique in the service. Example: `CpusPerProjectPerRegion` + * @type bool $reconciling + * Output only. Is the quota preference pending Google Cloud approval and + * fulfillment. + * @type string $justification + * The reason / justification for this quota preference. + * @type string $contact_email + * Required. Input only. An email address that can be used for quota related + * communication between the Google Cloud and the user in case the Google + * Cloud needs further information to make a decision on whether the user + * preferred quota can be granted. + * The Google account for the email address must have quota update permission + * for the project, folder or organization this quota preference is for. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Api\Cloudquotas\V1\Resources::initOnce(); + parent::__construct($data); + } + + /** + * Required except in the CREATE requests. + * The resource name of the quota preference. + * The ID component following "locations/" must be "global". + * Example: + * `projects/123/locations/global/quotaPreferences/my-config-for-us-east1` + * + * Generated from protobuf field string name = 1; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Required except in the CREATE requests. + * The resource name of the quota preference. + * The ID component following "locations/" must be "global". + * Example: + * `projects/123/locations/global/quotaPreferences/my-config-for-us-east1` + * + * 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; + } + + /** + * The dimensions that this quota preference applies to. The key of the map + * entry is the name of a dimension, such as "region", "zone", "network_id", + * and the value of the map entry is the dimension value. + * If a dimension is missing from the map of dimensions, the quota preference + * applies to all the dimension values except for those that have other quota + * preferences configured for the specific value. + * NOTE: QuotaPreferences can only be applied across all values of "user" and + * "resource" dimension. Do not set values for "user" or "resource" in the + * dimension map. + * Example: {"provider", "Foo Inc"} where "provider" is a service specific + * dimension. + * + * Generated from protobuf field map dimensions = 2; + * @return \Google\Protobuf\Internal\MapField + */ + public function getDimensions() + { + return $this->dimensions; + } + + /** + * The dimensions that this quota preference applies to. The key of the map + * entry is the name of a dimension, such as "region", "zone", "network_id", + * and the value of the map entry is the dimension value. + * If a dimension is missing from the map of dimensions, the quota preference + * applies to all the dimension values except for those that have other quota + * preferences configured for the specific value. + * NOTE: QuotaPreferences can only be applied across all values of "user" and + * "resource" dimension. Do not set values for "user" or "resource" in the + * dimension map. + * Example: {"provider", "Foo Inc"} where "provider" is a service specific + * dimension. + * + * Generated from protobuf field map dimensions = 2; + * @param array|\Google\Protobuf\Internal\MapField $var + * @return $this + */ + public function setDimensions($var) + { + $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::STRING); + $this->dimensions = $arr; + + return $this; + } + + /** + * Required. Preferred quota configuration. + * + * Generated from protobuf field .google.api.cloudquotas.v1.QuotaConfig quota_config = 3 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\CloudQuotas\V1\QuotaConfig|null + */ + public function getQuotaConfig() + { + return $this->quota_config; + } + + public function hasQuotaConfig() + { + return isset($this->quota_config); + } + + public function clearQuotaConfig() + { + unset($this->quota_config); + } + + /** + * Required. Preferred quota configuration. + * + * Generated from protobuf field .google.api.cloudquotas.v1.QuotaConfig quota_config = 3 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\CloudQuotas\V1\QuotaConfig $var + * @return $this + */ + public function setQuotaConfig($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\CloudQuotas\V1\QuotaConfig::class); + $this->quota_config = $var; + + return $this; + } + + /** + * Optional. The current etag of the quota preference. If an etag is provided + * on update and does not match the current server's etag of the quota + * preference, the request will be blocked and an ABORTED error will be + * returned. See https://google.aip.dev/134#etags for more details on etags. + * + * Generated from protobuf field string etag = 4 [(.google.api.field_behavior) = OPTIONAL]; + * @return string + */ + public function getEtag() + { + return $this->etag; + } + + /** + * Optional. The current etag of the quota preference. If an etag is provided + * on update and does not match the current server's etag of the quota + * preference, the request will be blocked and an ABORTED error will be + * returned. See https://google.aip.dev/134#etags for more details on etags. + * + * Generated from protobuf field string etag = 4 [(.google.api.field_behavior) = OPTIONAL]; + * @param string $var + * @return $this + */ + public function setEtag($var) + { + GPBUtil::checkString($var, True); + $this->etag = $var; + + return $this; + } + + /** + * Output only. Create time stamp + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Timestamp|null + */ + public function getCreateTime() + { + return $this->create_time; + } + + public function hasCreateTime() + { + return isset($this->create_time); + } + + public function clearCreateTime() + { + unset($this->create_time); + } + + /** + * Output only. Create time stamp + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setCreateTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->create_time = $var; + + return $this; + } + + /** + * Output only. Update time stamp + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Timestamp|null + */ + public function getUpdateTime() + { + return $this->update_time; + } + + public function hasUpdateTime() + { + return isset($this->update_time); + } + + public function clearUpdateTime() + { + unset($this->update_time); + } + + /** + * Output only. Update time stamp + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setUpdateTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->update_time = $var; + + return $this; + } + + /** + * Required. The name of the service to which the quota preference is applied. + * + * Generated from protobuf field string service = 7 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getService() + { + return $this->service; + } + + /** + * Required. The name of the service to which the quota preference is applied. + * + * Generated from protobuf field string service = 7 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setService($var) + { + GPBUtil::checkString($var, True); + $this->service = $var; + + return $this; + } + + /** + * Required. The id of the quota to which the quota preference is applied. A + * quota name is unique in the service. Example: `CpusPerProjectPerRegion` + * + * Generated from protobuf field string quota_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getQuotaId() + { + return $this->quota_id; + } + + /** + * Required. The id of the quota to which the quota preference is applied. A + * quota name is unique in the service. Example: `CpusPerProjectPerRegion` + * + * Generated from protobuf field string quota_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setQuotaId($var) + { + GPBUtil::checkString($var, True); + $this->quota_id = $var; + + return $this; + } + + /** + * Output only. Is the quota preference pending Google Cloud approval and + * fulfillment. + * + * Generated from protobuf field bool reconciling = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return bool + */ + public function getReconciling() + { + return $this->reconciling; + } + + /** + * Output only. Is the quota preference pending Google Cloud approval and + * fulfillment. + * + * Generated from protobuf field bool reconciling = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param bool $var + * @return $this + */ + public function setReconciling($var) + { + GPBUtil::checkBool($var); + $this->reconciling = $var; + + return $this; + } + + /** + * The reason / justification for this quota preference. + * + * Generated from protobuf field string justification = 11; + * @return string + */ + public function getJustification() + { + return $this->justification; + } + + /** + * The reason / justification for this quota preference. + * + * Generated from protobuf field string justification = 11; + * @param string $var + * @return $this + */ + public function setJustification($var) + { + GPBUtil::checkString($var, True); + $this->justification = $var; + + return $this; + } + + /** + * Required. Input only. An email address that can be used for quota related + * communication between the Google Cloud and the user in case the Google + * Cloud needs further information to make a decision on whether the user + * preferred quota can be granted. + * The Google account for the email address must have quota update permission + * for the project, folder or organization this quota preference is for. + * + * Generated from protobuf field string contact_email = 12 [(.google.api.field_behavior) = INPUT_ONLY, (.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getContactEmail() + { + return $this->contact_email; + } + + /** + * Required. Input only. An email address that can be used for quota related + * communication between the Google Cloud and the user in case the Google + * Cloud needs further information to make a decision on whether the user + * preferred quota can be granted. + * The Google account for the email address must have quota update permission + * for the project, folder or organization this quota preference is for. + * + * Generated from protobuf field string contact_email = 12 [(.google.api.field_behavior) = INPUT_ONLY, (.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setContactEmail($var) + { + GPBUtil::checkString($var, True); + $this->contact_email = $var; + + return $this; + } + +} + diff --git a/Quotas/src/V1/QuotaSafetyCheck.php b/Quotas/src/V1/QuotaSafetyCheck.php new file mode 100644 index 000000000000..659dd6869ac3 --- /dev/null +++ b/Quotas/src/V1/QuotaSafetyCheck.php @@ -0,0 +1,63 @@ +google.api.cloudquotas.v1.QuotaSafetyCheck + */ +class QuotaSafetyCheck +{ + /** + * Unspecified quota safety check. + * + * Generated from protobuf enum QUOTA_SAFETY_CHECK_UNSPECIFIED = 0; + */ + const QUOTA_SAFETY_CHECK_UNSPECIFIED = 0; + /** + * Validates that a quota mutation would not cause the consumer's effective + * limit to be lower than the consumer's quota usage. + * + * Generated from protobuf enum QUOTA_DECREASE_BELOW_USAGE = 1; + */ + const QUOTA_DECREASE_BELOW_USAGE = 1; + /** + * Validates that a quota mutation would not cause the consumer's effective + * limit to decrease by more than 10 percent. + * + * Generated from protobuf enum QUOTA_DECREASE_PERCENTAGE_TOO_HIGH = 2; + */ + const QUOTA_DECREASE_PERCENTAGE_TOO_HIGH = 2; + + private static $valueToName = [ + self::QUOTA_SAFETY_CHECK_UNSPECIFIED => 'QUOTA_SAFETY_CHECK_UNSPECIFIED', + self::QUOTA_DECREASE_BELOW_USAGE => 'QUOTA_DECREASE_BELOW_USAGE', + self::QUOTA_DECREASE_PERCENTAGE_TOO_HIGH => 'QUOTA_DECREASE_PERCENTAGE_TOO_HIGH', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + diff --git a/Quotas/src/V1/UpdateQuotaPreferenceRequest.php b/Quotas/src/V1/UpdateQuotaPreferenceRequest.php new file mode 100644 index 000000000000..adb2aaf264fa --- /dev/null +++ b/Quotas/src/V1/UpdateQuotaPreferenceRequest.php @@ -0,0 +1,270 @@ +google.api.cloudquotas.v1.UpdateQuotaPreferenceRequest + */ +class UpdateQuotaPreferenceRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Optional. Field mask is used to specify the fields to be overwritten in the + * QuotaPreference resource by the update. + * The fields specified in the update_mask are relative to the resource, not + * the full request. A field will be overwritten if it is in the mask. If the + * user does not provide a mask then all fields will be overwritten. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 1 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $update_mask = null; + /** + * Required. The resource being updated + * + * Generated from protobuf field .google.api.cloudquotas.v1.QuotaPreference quota_preference = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $quota_preference = null; + /** + * Optional. If set to true, and the quota preference is not found, a new one + * will be created. In this situation, `update_mask` is ignored. + * + * Generated from protobuf field bool allow_missing = 3 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $allow_missing = false; + /** + * Optional. If set to true, validate the request, but do not actually update. + * Note that a request being valid does not mean that the request is + * guaranteed to be fulfilled. + * + * Generated from protobuf field bool validate_only = 4 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $validate_only = false; + /** + * The list of quota safety checks to be ignored. + * + * Generated from protobuf field repeated .google.api.cloudquotas.v1.QuotaSafetyCheck ignore_safety_checks = 5; + */ + private $ignore_safety_checks; + + /** + * @param \Google\Cloud\CloudQuotas\V1\QuotaPreference $quotaPreference Required. The resource being updated + * @param \Google\Protobuf\FieldMask $updateMask Optional. Field mask is used to specify the fields to be overwritten in the + * QuotaPreference resource by the update. + * The fields specified in the update_mask are relative to the resource, not + * the full request. A field will be overwritten if it is in the mask. If the + * user does not provide a mask then all fields will be overwritten. + * + * @return \Google\Cloud\CloudQuotas\V1\UpdateQuotaPreferenceRequest + * + * @experimental + */ + public static function build(\Google\Cloud\CloudQuotas\V1\QuotaPreference $quotaPreference, \Google\Protobuf\FieldMask $updateMask): self + { + return (new self()) + ->setQuotaPreference($quotaPreference) + ->setUpdateMask($updateMask); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Protobuf\FieldMask $update_mask + * Optional. Field mask is used to specify the fields to be overwritten in the + * QuotaPreference resource by the update. + * The fields specified in the update_mask are relative to the resource, not + * the full request. A field will be overwritten if it is in the mask. If the + * user does not provide a mask then all fields will be overwritten. + * @type \Google\Cloud\CloudQuotas\V1\QuotaPreference $quota_preference + * Required. The resource being updated + * @type bool $allow_missing + * Optional. If set to true, and the quota preference is not found, a new one + * will be created. In this situation, `update_mask` is ignored. + * @type bool $validate_only + * Optional. If set to true, validate the request, but do not actually update. + * Note that a request being valid does not mean that the request is + * guaranteed to be fulfilled. + * @type array|\Google\Protobuf\Internal\RepeatedField $ignore_safety_checks + * The list of quota safety checks to be ignored. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Api\Cloudquotas\V1\Cloudquotas::initOnce(); + parent::__construct($data); + } + + /** + * Optional. Field mask is used to specify the fields to be overwritten in the + * QuotaPreference resource by the update. + * The fields specified in the update_mask are relative to the resource, not + * the full request. A field will be overwritten if it is in the mask. If the + * user does not provide a mask then all fields will be overwritten. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 1 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Protobuf\FieldMask|null + */ + public function getUpdateMask() + { + return $this->update_mask; + } + + public function hasUpdateMask() + { + return isset($this->update_mask); + } + + public function clearUpdateMask() + { + unset($this->update_mask); + } + + /** + * Optional. Field mask is used to specify the fields to be overwritten in the + * QuotaPreference resource by the update. + * The fields specified in the update_mask are relative to the resource, not + * the full request. A field will be overwritten if it is in the mask. If the + * user does not provide a mask then all fields will be overwritten. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 1 [(.google.api.field_behavior) = OPTIONAL]; + * @param \Google\Protobuf\FieldMask $var + * @return $this + */ + public function setUpdateMask($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\FieldMask::class); + $this->update_mask = $var; + + return $this; + } + + /** + * Required. The resource being updated + * + * Generated from protobuf field .google.api.cloudquotas.v1.QuotaPreference quota_preference = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\CloudQuotas\V1\QuotaPreference|null + */ + public function getQuotaPreference() + { + return $this->quota_preference; + } + + public function hasQuotaPreference() + { + return isset($this->quota_preference); + } + + public function clearQuotaPreference() + { + unset($this->quota_preference); + } + + /** + * Required. The resource being updated + * + * Generated from protobuf field .google.api.cloudquotas.v1.QuotaPreference quota_preference = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\CloudQuotas\V1\QuotaPreference $var + * @return $this + */ + public function setQuotaPreference($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\CloudQuotas\V1\QuotaPreference::class); + $this->quota_preference = $var; + + return $this; + } + + /** + * Optional. If set to true, and the quota preference is not found, a new one + * will be created. In this situation, `update_mask` is ignored. + * + * Generated from protobuf field bool allow_missing = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @return bool + */ + public function getAllowMissing() + { + return $this->allow_missing; + } + + /** + * Optional. If set to true, and the quota preference is not found, a new one + * will be created. In this situation, `update_mask` is ignored. + * + * Generated from protobuf field bool allow_missing = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @param bool $var + * @return $this + */ + public function setAllowMissing($var) + { + GPBUtil::checkBool($var); + $this->allow_missing = $var; + + return $this; + } + + /** + * Optional. If set to true, validate the request, but do not actually update. + * Note that a request being valid does not mean that the request is + * guaranteed to be fulfilled. + * + * Generated from protobuf field bool validate_only = 4 [(.google.api.field_behavior) = OPTIONAL]; + * @return bool + */ + public function getValidateOnly() + { + return $this->validate_only; + } + + /** + * Optional. If set to true, validate the request, but do not actually update. + * Note that a request being valid does not mean that the request is + * guaranteed to be fulfilled. + * + * Generated from protobuf field bool validate_only = 4 [(.google.api.field_behavior) = OPTIONAL]; + * @param bool $var + * @return $this + */ + public function setValidateOnly($var) + { + GPBUtil::checkBool($var); + $this->validate_only = $var; + + return $this; + } + + /** + * The list of quota safety checks to be ignored. + * + * Generated from protobuf field repeated .google.api.cloudquotas.v1.QuotaSafetyCheck ignore_safety_checks = 5; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getIgnoreSafetyChecks() + { + return $this->ignore_safety_checks; + } + + /** + * The list of quota safety checks to be ignored. + * + * Generated from protobuf field repeated .google.api.cloudquotas.v1.QuotaSafetyCheck ignore_safety_checks = 5; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setIgnoreSafetyChecks($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::ENUM, \Google\Cloud\CloudQuotas\V1\QuotaSafetyCheck::class); + $this->ignore_safety_checks = $arr; + + return $this; + } + +} + diff --git a/Quotas/src/V1/gapic_metadata.json b/Quotas/src/V1/gapic_metadata.json new file mode 100644 index 000000000000..79ee8e757dba --- /dev/null +++ b/Quotas/src/V1/gapic_metadata.json @@ -0,0 +1,48 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services\/RPCs to the corresponding library clients\/methods", + "language": "php", + "protoPackage": "google.api.cloudquotas.v1", + "libraryPackage": "Google\\Cloud\\CloudQuotas\\V1", + "services": { + "CloudQuotas": { + "clients": { + "grpc": { + "libraryClient": "CloudQuotasGapicClient", + "rpcs": { + "CreateQuotaPreference": { + "methods": [ + "createQuotaPreference" + ] + }, + "GetQuotaInfo": { + "methods": [ + "getQuotaInfo" + ] + }, + "GetQuotaPreference": { + "methods": [ + "getQuotaPreference" + ] + }, + "ListQuotaInfos": { + "methods": [ + "listQuotaInfos" + ] + }, + "ListQuotaPreferences": { + "methods": [ + "listQuotaPreferences" + ] + }, + "UpdateQuotaPreference": { + "methods": [ + "updateQuotaPreference" + ] + } + } + } + } + } + } +} \ No newline at end of file diff --git a/Quotas/src/V1/resources/cloud_quotas_client_config.json b/Quotas/src/V1/resources/cloud_quotas_client_config.json new file mode 100644 index 000000000000..ae40b97f70f5 --- /dev/null +++ b/Quotas/src/V1/resources/cloud_quotas_client_config.json @@ -0,0 +1,64 @@ +{ + "interfaces": { + "google.api.cloudquotas.v1.CloudQuotas": { + "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": { + "CreateQuotaPreference": { + "timeout_millis": 60000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, + "GetQuotaInfo": { + "timeout_millis": 60000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, + "GetQuotaPreference": { + "timeout_millis": 60000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, + "ListQuotaInfos": { + "timeout_millis": 60000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, + "ListQuotaPreferences": { + "timeout_millis": 60000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, + "UpdateQuotaPreference": { + "timeout_millis": 60000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + } + } + } + } +} diff --git a/Quotas/src/V1/resources/cloud_quotas_descriptor_config.php b/Quotas/src/V1/resources/cloud_quotas_descriptor_config.php new file mode 100644 index 000000000000..b7d647da8de5 --- /dev/null +++ b/Quotas/src/V1/resources/cloud_quotas_descriptor_config.php @@ -0,0 +1,115 @@ + [ + 'google.api.cloudquotas.v1.CloudQuotas' => [ + 'CreateQuotaPreference' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\CloudQuotas\V1\QuotaPreference', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'GetQuotaInfo' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\CloudQuotas\V1\QuotaInfo', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], + 'GetQuotaPreference' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\CloudQuotas\V1\QuotaPreference', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], + 'ListQuotaInfos' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getQuotaInfos', + ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\CloudQuotas\V1\ListQuotaInfosResponse', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'ListQuotaPreferences' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getQuotaPreferences', + ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\CloudQuotas\V1\ListQuotaPreferencesResponse', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'UpdateQuotaPreference' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\CloudQuotas\V1\QuotaPreference', + 'headerParams' => [ + [ + 'keyName' => 'quota_preference.name', + 'fieldAccessors' => [ + 'getQuotaPreference', + 'getName', + ], + ], + ], + ], + 'templateMap' => [ + 'folderLocation' => 'folders/{folder}/locations/{location}', + 'folderLocationQuotaPreference' => 'folders/{folder}/locations/{location}/quotaPreferences/{quota_preference}', + 'folderLocationService' => 'folders/{folder}/locations/{location}/services/{service}', + 'folderLocationServiceQuotaInfo' => 'folders/{folder}/locations/{location}/services/{service}/quotaInfos/{quota_info}', + 'location' => 'projects/{project}/locations/{location}', + 'organizationLocation' => 'organizations/{organization}/locations/{location}', + 'organizationLocationQuotaPreference' => 'organizations/{organization}/locations/{location}/quotaPreferences/{quota_preference}', + 'organizationLocationService' => 'organizations/{organization}/locations/{location}/services/{service}', + 'organizationLocationServiceQuotaInfo' => 'organizations/{organization}/locations/{location}/services/{service}/quotaInfos/{quota_info}', + 'projectLocation' => 'projects/{project}/locations/{location}', + 'projectLocationQuotaPreference' => 'projects/{project}/locations/{location}/quotaPreferences/{quota_preference}', + 'projectLocationService' => 'projects/{project}/locations/{location}/services/{service}', + 'projectLocationServiceQuotaInfo' => 'projects/{project}/locations/{location}/services/{service}/quotaInfos/{quota_info}', + 'quotaInfo' => 'projects/{project}/locations/{location}/services/{service}/quotaInfos/{quota_info}', + 'quotaPreference' => 'projects/{project}/locations/{location}/quotaPreferences/{quota_preference}', + 'service' => 'projects/{project}/locations/{location}/services/{service}', + ], + ], + ], +]; diff --git a/Quotas/src/V1/resources/cloud_quotas_rest_client_config.php b/Quotas/src/V1/resources/cloud_quotas_rest_client_config.php new file mode 100644 index 000000000000..05ae394975e0 --- /dev/null +++ b/Quotas/src/V1/resources/cloud_quotas_rest_client_config.php @@ -0,0 +1,142 @@ + [ + 'google.api.cloudquotas.v1.CloudQuotas' => [ + 'CreateQuotaPreference' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{parent=projects/*/locations/*}/quotaPreferences', + 'body' => 'quota_preference', + 'additionalBindings' => [ + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{parent=folders/*/locations/*}/quotaPreferences', + 'body' => 'quota_preference', + ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{parent=organizations/*/locations/*}/quotaPreferences', + 'body' => 'quota_preference', + ], + ], + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + 'GetQuotaInfo' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/locations/*/services/*/quotaInfos/*}', + 'additionalBindings' => [ + [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=organizations/*/locations/*/services/*/quotaInfos/*}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=folders/*/locations/*/services/*/quotaInfos/*}', + ], + ], + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'GetQuotaPreference' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/locations/*/quotaPreferences/*}', + 'additionalBindings' => [ + [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=organizations/*/locations/*/quotaPreferences/*}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=folders/*/locations/*/quotaPreferences/*}', + ], + ], + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'ListQuotaInfos' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{parent=projects/*/locations/*/services/*}/quotaInfos', + 'additionalBindings' => [ + [ + 'method' => 'get', + 'uriTemplate' => '/v1/{parent=organizations/*/locations/*/services/*}/quotaInfos', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1/{parent=folders/*/locations/*/services/*}/quotaInfos', + ], + ], + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + 'ListQuotaPreferences' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{parent=projects/*/locations/*}/quotaPreferences', + 'additionalBindings' => [ + [ + 'method' => 'get', + 'uriTemplate' => '/v1/{parent=folders/*/locations/*}/quotaPreferences', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1/{parent=organizations/*/locations/*}/quotaPreferences', + ], + ], + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + 'UpdateQuotaPreference' => [ + 'method' => 'patch', + 'uriTemplate' => '/v1/{quota_preference.name=projects/*/locations/*/quotaPreferences/*}', + 'body' => 'quota_preference', + 'additionalBindings' => [ + [ + 'method' => 'patch', + 'uriTemplate' => '/v1/{quota_preference.name=folders/*/locations/*/quotaPreferences/*}', + 'body' => 'quota_preference', + ], + [ + 'method' => 'patch', + 'uriTemplate' => '/v1/{quota_preference.name=organizations/*/locations/*/quotaPreferences/*}', + 'body' => 'quota_preference', + ], + ], + 'placeholders' => [ + 'quota_preference.name' => [ + 'getters' => [ + 'getQuotaPreference', + 'getName', + ], + ], + ], + ], + ], + ], + 'numericEnums' => true, +]; diff --git a/Quotas/tests/Unit/V1/Client/CloudQuotasClientTest.php b/Quotas/tests/Unit/V1/Client/CloudQuotasClientTest.php new file mode 100644 index 000000000000..8408287238b9 --- /dev/null +++ b/Quotas/tests/Unit/V1/Client/CloudQuotasClientTest.php @@ -0,0 +1,636 @@ +getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); + } + + /** @return CloudQuotasClient */ + private function createClient(array $options = []) + { + $options += [ + 'credentials' => $this->createCredentials(), + ]; + return new CloudQuotasClient($options); + } + + /** @test */ + public function createQuotaPreferenceTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name = 'name3373707'; + $etag = 'etag3123477'; + $service = 'service1984153269'; + $quotaId = 'quotaId-879230910'; + $reconciling = false; + $justification = 'justification1864993522'; + $contactEmail = 'contactEmail947010237'; + $expectedResponse = new QuotaPreference(); + $expectedResponse->setName($name); + $expectedResponse->setEtag($etag); + $expectedResponse->setService($service); + $expectedResponse->setQuotaId($quotaId); + $expectedResponse->setReconciling($reconciling); + $expectedResponse->setJustification($justification); + $expectedResponse->setContactEmail($contactEmail); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); + $quotaPreference = new QuotaPreference(); + $quotaPreferenceQuotaConfig = new QuotaConfig(); + $quotaConfigPreferredValue = 557434902; + $quotaPreferenceQuotaConfig->setPreferredValue($quotaConfigPreferredValue); + $quotaPreference->setQuotaConfig($quotaPreferenceQuotaConfig); + $quotaPreferenceService = 'quotaPreferenceService-1057995326'; + $quotaPreference->setService($quotaPreferenceService); + $quotaPreferenceQuotaId = 'quotaPreferenceQuotaId1917192384'; + $quotaPreference->setQuotaId($quotaPreferenceQuotaId); + $quotaPreferenceContactEmail = 'quotaPreferenceContactEmail-1724666769'; + $quotaPreference->setContactEmail($quotaPreferenceContactEmail); + $request = (new CreateQuotaPreferenceRequest()) + ->setParent($formattedParent) + ->setQuotaPreference($quotaPreference); + $response = $gapicClient->createQuotaPreference($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.api.cloudquotas.v1.CloudQuotas/CreateQuotaPreference', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualRequestObject->getQuotaPreference(); + $this->assertProtobufEquals($quotaPreference, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function createQuotaPreferenceExceptionTest() + { + $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->locationName('[PROJECT]', '[LOCATION]'); + $quotaPreference = new QuotaPreference(); + $quotaPreferenceQuotaConfig = new QuotaConfig(); + $quotaConfigPreferredValue = 557434902; + $quotaPreferenceQuotaConfig->setPreferredValue($quotaConfigPreferredValue); + $quotaPreference->setQuotaConfig($quotaPreferenceQuotaConfig); + $quotaPreferenceService = 'quotaPreferenceService-1057995326'; + $quotaPreference->setService($quotaPreferenceService); + $quotaPreferenceQuotaId = 'quotaPreferenceQuotaId1917192384'; + $quotaPreference->setQuotaId($quotaPreferenceQuotaId); + $quotaPreferenceContactEmail = 'quotaPreferenceContactEmail-1724666769'; + $quotaPreference->setContactEmail($quotaPreferenceContactEmail); + $request = (new CreateQuotaPreferenceRequest()) + ->setParent($formattedParent) + ->setQuotaPreference($quotaPreference); + try { + $gapicClient->createQuotaPreference($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 getQuotaInfoTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name2 = 'name2-1052831874'; + $quotaId = 'quotaId-879230910'; + $metric = 'metric-1077545552'; + $service = 'service1984153269'; + $isPrecise = true; + $refreshInterval = 'refreshInterval1816824233'; + $metricDisplayName = 'metricDisplayName900625943'; + $quotaDisplayName = 'quotaDisplayName-1616924081'; + $metricUnit = 'metricUnit-1737381197'; + $isFixed = false; + $isConcurrent = true; + $serviceRequestQuotaUri = 'serviceRequestQuotaUri-773207445'; + $expectedResponse = new QuotaInfo(); + $expectedResponse->setName($name2); + $expectedResponse->setQuotaId($quotaId); + $expectedResponse->setMetric($metric); + $expectedResponse->setService($service); + $expectedResponse->setIsPrecise($isPrecise); + $expectedResponse->setRefreshInterval($refreshInterval); + $expectedResponse->setMetricDisplayName($metricDisplayName); + $expectedResponse->setQuotaDisplayName($quotaDisplayName); + $expectedResponse->setMetricUnit($metricUnit); + $expectedResponse->setIsFixed($isFixed); + $expectedResponse->setIsConcurrent($isConcurrent); + $expectedResponse->setServiceRequestQuotaUri($serviceRequestQuotaUri); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->quotaInfoName('[PROJECT]', '[LOCATION]', '[SERVICE]', '[QUOTA_INFO]'); + $request = (new GetQuotaInfoRequest())->setName($formattedName); + $response = $gapicClient->getQuotaInfo($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.api.cloudquotas.v1.CloudQuotas/GetQuotaInfo', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getQuotaInfoExceptionTest() + { + $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 + $formattedName = $gapicClient->quotaInfoName('[PROJECT]', '[LOCATION]', '[SERVICE]', '[QUOTA_INFO]'); + $request = (new GetQuotaInfoRequest())->setName($formattedName); + try { + $gapicClient->getQuotaInfo($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 getQuotaPreferenceTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name2 = 'name2-1052831874'; + $etag = 'etag3123477'; + $service = 'service1984153269'; + $quotaId = 'quotaId-879230910'; + $reconciling = false; + $justification = 'justification1864993522'; + $contactEmail = 'contactEmail947010237'; + $expectedResponse = new QuotaPreference(); + $expectedResponse->setName($name2); + $expectedResponse->setEtag($etag); + $expectedResponse->setService($service); + $expectedResponse->setQuotaId($quotaId); + $expectedResponse->setReconciling($reconciling); + $expectedResponse->setJustification($justification); + $expectedResponse->setContactEmail($contactEmail); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->quotaPreferenceName('[PROJECT]', '[LOCATION]', '[QUOTA_PREFERENCE]'); + $request = (new GetQuotaPreferenceRequest())->setName($formattedName); + $response = $gapicClient->getQuotaPreference($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.api.cloudquotas.v1.CloudQuotas/GetQuotaPreference', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getQuotaPreferenceExceptionTest() + { + $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 + $formattedName = $gapicClient->quotaPreferenceName('[PROJECT]', '[LOCATION]', '[QUOTA_PREFERENCE]'); + $request = (new GetQuotaPreferenceRequest())->setName($formattedName); + try { + $gapicClient->getQuotaPreference($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 listQuotaInfosTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $quotaInfosElement = new QuotaInfo(); + $quotaInfos = [$quotaInfosElement]; + $expectedResponse = new ListQuotaInfosResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setQuotaInfos($quotaInfos); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->serviceName('[PROJECT]', '[LOCATION]', '[SERVICE]'); + $request = (new ListQuotaInfosRequest())->setParent($formattedParent); + $response = $gapicClient->listQuotaInfos($request); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getQuotaInfos()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.api.cloudquotas.v1.CloudQuotas/ListQuotaInfos', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listQuotaInfosExceptionTest() + { + $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->serviceName('[PROJECT]', '[LOCATION]', '[SERVICE]'); + $request = (new ListQuotaInfosRequest())->setParent($formattedParent); + try { + $gapicClient->listQuotaInfos($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 listQuotaPreferencesTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $quotaPreferencesElement = new QuotaPreference(); + $quotaPreferences = [$quotaPreferencesElement]; + $expectedResponse = new ListQuotaPreferencesResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setQuotaPreferences($quotaPreferences); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); + $request = (new ListQuotaPreferencesRequest())->setParent($formattedParent); + $response = $gapicClient->listQuotaPreferences($request); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getQuotaPreferences()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.api.cloudquotas.v1.CloudQuotas/ListQuotaPreferences', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listQuotaPreferencesExceptionTest() + { + $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->locationName('[PROJECT]', '[LOCATION]'); + $request = (new ListQuotaPreferencesRequest())->setParent($formattedParent); + try { + $gapicClient->listQuotaPreferences($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 updateQuotaPreferenceTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name = 'name3373707'; + $etag = 'etag3123477'; + $service = 'service1984153269'; + $quotaId = 'quotaId-879230910'; + $reconciling = false; + $justification = 'justification1864993522'; + $contactEmail = 'contactEmail947010237'; + $expectedResponse = new QuotaPreference(); + $expectedResponse->setName($name); + $expectedResponse->setEtag($etag); + $expectedResponse->setService($service); + $expectedResponse->setQuotaId($quotaId); + $expectedResponse->setReconciling($reconciling); + $expectedResponse->setJustification($justification); + $expectedResponse->setContactEmail($contactEmail); + $transport->addResponse($expectedResponse); + // Mock request + $quotaPreference = new QuotaPreference(); + $quotaPreferenceQuotaConfig = new QuotaConfig(); + $quotaConfigPreferredValue = 557434902; + $quotaPreferenceQuotaConfig->setPreferredValue($quotaConfigPreferredValue); + $quotaPreference->setQuotaConfig($quotaPreferenceQuotaConfig); + $quotaPreferenceService = 'quotaPreferenceService-1057995326'; + $quotaPreference->setService($quotaPreferenceService); + $quotaPreferenceQuotaId = 'quotaPreferenceQuotaId1917192384'; + $quotaPreference->setQuotaId($quotaPreferenceQuotaId); + $quotaPreferenceContactEmail = 'quotaPreferenceContactEmail-1724666769'; + $quotaPreference->setContactEmail($quotaPreferenceContactEmail); + $request = (new UpdateQuotaPreferenceRequest())->setQuotaPreference($quotaPreference); + $response = $gapicClient->updateQuotaPreference($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.api.cloudquotas.v1.CloudQuotas/UpdateQuotaPreference', $actualFuncCall); + $actualValue = $actualRequestObject->getQuotaPreference(); + $this->assertProtobufEquals($quotaPreference, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function updateQuotaPreferenceExceptionTest() + { + $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 + $quotaPreference = new QuotaPreference(); + $quotaPreferenceQuotaConfig = new QuotaConfig(); + $quotaConfigPreferredValue = 557434902; + $quotaPreferenceQuotaConfig->setPreferredValue($quotaConfigPreferredValue); + $quotaPreference->setQuotaConfig($quotaPreferenceQuotaConfig); + $quotaPreferenceService = 'quotaPreferenceService-1057995326'; + $quotaPreference->setService($quotaPreferenceService); + $quotaPreferenceQuotaId = 'quotaPreferenceQuotaId1917192384'; + $quotaPreference->setQuotaId($quotaPreferenceQuotaId); + $quotaPreferenceContactEmail = 'quotaPreferenceContactEmail-1724666769'; + $quotaPreference->setContactEmail($quotaPreferenceContactEmail); + $request = (new UpdateQuotaPreferenceRequest())->setQuotaPreference($quotaPreference); + try { + $gapicClient->updateQuotaPreference($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 createQuotaPreferenceAsyncTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name = 'name3373707'; + $etag = 'etag3123477'; + $service = 'service1984153269'; + $quotaId = 'quotaId-879230910'; + $reconciling = false; + $justification = 'justification1864993522'; + $contactEmail = 'contactEmail947010237'; + $expectedResponse = new QuotaPreference(); + $expectedResponse->setName($name); + $expectedResponse->setEtag($etag); + $expectedResponse->setService($service); + $expectedResponse->setQuotaId($quotaId); + $expectedResponse->setReconciling($reconciling); + $expectedResponse->setJustification($justification); + $expectedResponse->setContactEmail($contactEmail); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); + $quotaPreference = new QuotaPreference(); + $quotaPreferenceQuotaConfig = new QuotaConfig(); + $quotaConfigPreferredValue = 557434902; + $quotaPreferenceQuotaConfig->setPreferredValue($quotaConfigPreferredValue); + $quotaPreference->setQuotaConfig($quotaPreferenceQuotaConfig); + $quotaPreferenceService = 'quotaPreferenceService-1057995326'; + $quotaPreference->setService($quotaPreferenceService); + $quotaPreferenceQuotaId = 'quotaPreferenceQuotaId1917192384'; + $quotaPreference->setQuotaId($quotaPreferenceQuotaId); + $quotaPreferenceContactEmail = 'quotaPreferenceContactEmail-1724666769'; + $quotaPreference->setContactEmail($quotaPreferenceContactEmail); + $request = (new CreateQuotaPreferenceRequest()) + ->setParent($formattedParent) + ->setQuotaPreference($quotaPreference); + $response = $gapicClient->createQuotaPreferenceAsync($request)->wait(); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.api.cloudquotas.v1.CloudQuotas/CreateQuotaPreference', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualRequestObject->getQuotaPreference(); + $this->assertProtobufEquals($quotaPreference, $actualValue); + $this->assertTrue($transport->isExhausted()); + } +} diff --git a/composer.json b/composer.json index c7d4985c40df..d54766d9f7d7 100644 --- a/composer.json +++ b/composer.json @@ -72,6 +72,7 @@ "google/access-context-manager": "0.4.5", "google/analytics-admin": "0.19.0", "google/analytics-data": "0.12.0", + "google/api-cloudquotas": "0.0.0", "google/apps-meet": "0.0.0", "google/cloud-access-approval": "1.1.3", "google/cloud-advisorynotifications": "0.6.0", @@ -247,6 +248,7 @@ "GPBMetadata\\Google\\Analytics\\Admin\\": "AnalyticsAdmin/metadata", "GPBMetadata\\Google\\Analytics\\Data\\": "AnalyticsData/metadata", "GPBMetadata\\Google\\Api\\Apikeys\\": "ApiKeys/metadata", + "GPBMetadata\\Google\\Api\\Cloudquotas\\": "Quotas/metadata", "GPBMetadata\\Google\\Api\\Servicecontrol\\": "ServiceControl/metadata", "GPBMetadata\\Google\\Api\\Servicemanagement\\": "ServiceManagement/metadata", "GPBMetadata\\Google\\Api\\Serviceusage\\": "ServiceUsage/metadata", @@ -463,6 +465,7 @@ "Google\\Cloud\\CertificateManager\\": "CertificateManager/src", "Google\\Cloud\\Channel\\": "Channel/src", "Google\\Cloud\\CloudDms\\": "Dms/src", + "Google\\Cloud\\CloudQuotas\\": "Quotas/src", "Google\\Cloud\\Commerce\\Consumer\\Procurement\\": "CommerceConsumerProcurement/src", "Google\\Cloud\\Compute\\": "Compute/src", "Google\\Cloud\\ConfidentialComputing\\": "ConfidentialComputing/src",