diff --git a/README.md b/README.md index 16512dac933c..5a4dcaddc390 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,7 @@ This client supports the following Google Cloud Platform services at an [Alpha]( * [Google Cloud Web Security Scanner](#google-cloud-web-security-scanner-alpha) (Alpha) * [Google Stackdriver Debugger](#google-stackdriver-debugger-alpha) (Alpha) * [Google Stackdriver Trace](#google-stackdriver-trace-alpha) (Alpha) +* [Secret Manager](#secret-manager-alpha) (Alpha) If you need support for other Google APIs, please check out the [Google APIs Client Library for PHP](https://github.com/google/google-api-php-client). @@ -1581,6 +1582,49 @@ foreach($traceClient->traces() as $trace) { $ composer require google/cloud-trace ``` +## Secret Manager (Alpha) + +- [API Documentation](http://googleapis.github.io/google-cloud-php/#/docs/latest/secretmanager/readme) +- [Official Documentation](https://cloud.google.com/secret-manager/docs/) + +#### Preview + +```php +require 'vendor/autoload.php'; + +use Google\Cloud\SecretManager\V1beta1\Replication; +use Google\Cloud\SecretManager\V1beta1\Replication\Automatic; +use Google\Cloud\SecretManager\V1beta1\Secret; +use Google\Cloud\SecretManager\V1beta1\SecretManagerServiceClient; + +$client = new SecretManagerServiceClient(); + +$secret = $client->createSecret( + SecretManagerServiceClient::projectName('[MY_PROJECT_ID]'), + '[MY_SECRET_ID]', + [ + 'secret' => new Secret([ + 'replication' => new Replication([ + 'automatic' => new Automatic() + ]) + ]) + ] +); + +printf( + 'Created secret: %s' . PHP_EOL, + $secret->getName() +); +``` + +#### google/cloud-secret-manager + +[Secret Manager](https://github.com/googleapis/google-cloud-php-secret-manager) can be installed separately by requiring the [`google/cloud-secret-manager`](https://packagist.org/packages/google/cloud-secret-manager) composer package: + +``` +$ composer require google/cloud-secret-manager +``` + ## Caching Access Tokens By default the library will use a simple in-memory caching implementation, however it is possible to override this behavior by passing a [PSR-6](http://www.php-fig.org/psr/psr-6/) caching implementation in to the desired client. diff --git a/SecretManager/.gitattributes b/SecretManager/.gitattributes new file mode 100644 index 000000000000..d43b60862bcf --- /dev/null +++ b/SecretManager/.gitattributes @@ -0,0 +1,3 @@ +/*.xml.dist export-ignore +/tests export-ignore +/.github export-ignore diff --git a/SecretManager/.github/pull_request_template.md b/SecretManager/.github/pull_request_template.md new file mode 100644 index 000000000000..17d53e0d08ea --- /dev/null +++ b/SecretManager/.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 `SecretManager/src`, and tests in `SecretManager/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/SecretManager/CONTRIBUTING.md b/SecretManager/CONTRIBUTING.md new file mode 100644 index 000000000000..f8be6dae8e22 --- /dev/null +++ b/SecretManager/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/master/CONTRIBUTING.md) +file in the main Google Cloud PHP repository. diff --git a/SecretManager/LICENSE b/SecretManager/LICENSE new file mode 100644 index 000000000000..8f71f43fee3f --- /dev/null +++ b/SecretManager/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/SecretManager/README.md b/SecretManager/README.md new file mode 100644 index 000000000000..215e0d4b4fe2 --- /dev/null +++ b/SecretManager/README.md @@ -0,0 +1,73 @@ +# Secret Manager for PHP + +> Idiomatic PHP client for [Secret Manager](https://cloud.google.com/secret-manager). + +[![Latest Stable Version](https://poser.pugx.org/google/cloud-secret-manager/v/stable)](https://packagist.org/packages/google/cloud-secret-manager) [![Packagist](https://img.shields.io/packagist/dm/google/cloud-secret-manager.svg)](https://packagist.org/packages/google/cloud-secret-manager) + +* [API documentation](http://googleapis.github.io/google-cloud-php/#/docs/cloud-secret-manager/latest/secretmanager/readme) + +**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 to install just this component: + +```sh +$ composer require google/cloud-secret-manager +``` + +Or to install the entire suite of components at once: + +```sh +$ composer require google/cloud +``` + +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/master/AUTHENTICATION.md) for more information +on authenticating your client. Once authenticated, you'll be ready to start making requests. + +### Sample + +```php +require 'vendor/autoload.php'; + +use Google\Cloud\SecretManager\V1beta1\Replication; +use Google\Cloud\SecretManager\V1beta1\Replication\Automatic; +use Google\Cloud\SecretManager\V1beta1\Secret; +use Google\Cloud\SecretManager\V1beta1\SecretManagerServiceClient; + +$client = new SecretManagerServiceClient(); + +$secret = $client->createSecret( + SecretManagerServiceClient::projectName('[MY_PROJECT_ID]'), + '[MY_SECRET_ID]', + [ + 'secret' => new Secret([ + 'replication' => new Replication([ + 'automatic' => new Automatic() + ]) + ]) + ] +); + +printf( + 'Created secret: %s' . PHP_EOL, + $secret->getName() +); +``` + +### 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/secret-manager/docs). diff --git a/SecretManager/composer.json b/SecretManager/composer.json new file mode 100644 index 000000000000..37ce59510e41 --- /dev/null +++ b/SecretManager/composer.json @@ -0,0 +1,37 @@ +{ + "name": "google/cloud-secret-manager", + "description": "Secret Manager Client for PHP", + "license": "Apache-2.0", + "minimum-stability": "stable", + "autoload": { + "psr-4": { + "Google\\Cloud\\SecretManager\\": "src", + "GPBMetadata\\Google\\Cloud\\Secrets\\": "metadata" + } + }, + "autoload-dev": { + "psr-4": { + "Google\\Cloud\\SecretManager\\Tests\\": "tests" + } + }, + "extra": { + "component": { + "id": "cloud-secret-manager", + "path": "SecretManager", + "entry": null, + "target": "googleapis/google-cloud-php-secret-manager.git" + } + }, + "require": { + "google/gax": "^1.2.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.8|^5.0", + "google/cloud-core": "^1.31", + "phpdocumentor/reflection": "^3.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/SecretManager/metadata/V1Beta1/Resources.php b/SecretManager/metadata/V1Beta1/Resources.php new file mode 100644 index 000000000000..7e3dc880494d --- /dev/null +++ b/SecretManager/metadata/V1Beta1/Resources.php @@ -0,0 +1,79 @@ +internalAddGeneratedFile(hex2bin( + "0a8d0c0a2c676f6f676c652f636c6f75642f736563726574732f76316265" . + "7461312f7265736f75726365732e70726f746f121c676f6f676c652e636c" . + "6f75642e736563726574732e763162657461311a19676f6f676c652f6170" . + "692f7265736f757263652e70726f746f1a1f676f6f676c652f70726f746f" . + "6275662f74696d657374616d702e70726f746f1a1c676f6f676c652f6170" . + "692f616e6e6f746174696f6e732e70726f746f22d9020a06536563726574" . + "12110a046e616d651801200128094203e0410312460a0b7265706c696361" . + "74696f6e18022001280b32292e676f6f676c652e636c6f75642e73656372" . + "6574732e763162657461312e5265706c69636174696f6e4206e04105e041" . + "0212340a0b6372656174655f74696d6518032001280b321a2e676f6f676c" . + "652e70726f746f6275662e54696d657374616d704203e0410312400a066c" . + "6162656c7318042003280b32302e676f6f676c652e636c6f75642e736563" . + "726574732e763162657461312e5365637265742e4c6162656c73456e7472" . + "791a2d0a0b4c6162656c73456e747279120b0a036b657918012001280912" . + "0d0a0576616c75651802200128093a0238013a4dea414a0a237365637265" . + "746d616e616765722e676f6f676c65617069732e636f6d2f536563726574" . + "122370726f6a656374732f7b70726f6a6563747d2f736563726574732f7b" . + "7365637265747d2290030a0d53656372657456657273696f6e12110a046e" . + "616d651801200128094203e0410312340a0b6372656174655f74696d6518" . + "022001280b321a2e676f6f676c652e70726f746f6275662e54696d657374" . + "616d704203e0410312350a0c64657374726f795f74696d6518032001280b" . + "321a2e676f6f676c652e70726f746f6275662e54696d657374616d704203" . + "e0410312450a05737461746518042001280e32312e676f6f676c652e636c" . + "6f75642e736563726574732e763162657461312e53656372657456657273" . + "696f6e2e53746174654203e0410322480a05537461746512150a11535441" . + "54455f554e5350454349464945441000120b0a07454e41424c4544100112" . + "0c0a0844495341424c45441002120d0a0944455354524f59454410033a6e" . + "ea416b0a2a7365637265746d616e616765722e676f6f676c65617069732e" . + "636f6d2f53656372657456657273696f6e123d70726f6a656374732f7b70" . + "726f6a6563747d2f736563726574732f7b7365637265747d2f7665727369" . + "6f6e732f7b7365637265745f76657273696f6e7d22c5020a0b5265706c69" . + "636174696f6e12480a096175746f6d6174696318012001280b32332e676f" . + "6f676c652e636c6f75642e736563726574732e763162657461312e526570" . + "6c69636174696f6e2e4175746f6d617469634800124d0a0c757365725f6d" . + "616e6167656418022001280b32352e676f6f676c652e636c6f75642e7365" . + "63726574732e763162657461312e5265706c69636174696f6e2e55736572" . + "4d616e6167656448001a0b0a094175746f6d617469631a80010a0b557365" . + "724d616e6167656412540a087265706c6963617318012003280b323d2e67" . + "6f6f676c652e636c6f75642e736563726574732e763162657461312e5265" . + "706c69636174696f6e2e557365724d616e616765642e5265706c69636142" . + "03e041021a1b0a075265706c69636112100a086c6f636174696f6e180120" . + "012809420d0a0b7265706c69636174696f6e221d0a0d5365637265745061" . + "796c6f6164120c0a046461746118012001280c4286020a26636f6d2e676f" . + "6f676c652e636c6f75642e7365637265746d616e616765722e7631626574" . + "6131420e5265736f757263657350726f746f50015a4f676f6f676c652e67" . + "6f6c616e672e6f72672f67656e70726f746f2f676f6f676c65617069732f" . + "636c6f75642f7365637265746d616e616765722f763162657461313b7365" . + "637265746d616e61676572f80101a2020347534daa0222476f6f676c652e" . + "436c6f75642e5365637265744d616e616765722e56314265746131ca0222" . + "476f6f676c655c436c6f75645c5365637265744d616e616765725c563162" . + "65746131ea0225476f6f676c653a3a436c6f75643a3a5365637265744d61" . + "6e616765723a3a56316265746131620670726f746f33" + ), true); + + static::$is_initialized = true; + } +} + diff --git a/SecretManager/metadata/V1Beta1/Service.php b/SecretManager/metadata/V1Beta1/Service.php new file mode 100644 index 000000000000..85b9c0db0616 --- /dev/null +++ b/SecretManager/metadata/V1Beta1/Service.php @@ -0,0 +1,207 @@ +internalAddGeneratedFile(hex2bin( + "0ae9280a2a676f6f676c652f636c6f75642f736563726574732f76316265" . + "7461312f736572766963652e70726f746f121c676f6f676c652e636c6f75" . + "642e736563726574732e763162657461311a17676f6f676c652f6170692f" . + "636c69656e742e70726f746f1a1f676f6f676c652f6170692f6669656c64" . + "5f6265686176696f722e70726f746f1a19676f6f676c652f6170692f7265" . + "736f757263652e70726f746f1a2c676f6f676c652f636c6f75642f736563" . + "726574732f763162657461312f7265736f75726365732e70726f746f1a1e" . + "676f6f676c652f69616d2f76312f69616d5f706f6c6963792e70726f746f" . + "1a1a676f6f676c652f69616d2f76312f706f6c6963792e70726f746f1a1b" . + "676f6f676c652f70726f746f6275662f656d7074792e70726f746f1a2067" . + "6f6f676c652f70726f746f6275662f6669656c645f6d61736b2e70726f74" . + "6f228a010a124c697374536563726574735265717565737412430a067061" . + "72656e741801200128094233e04102fa412d0a2b636c6f75647265736f75" . + "7263656d616e616765722e676f6f676c65617069732e636f6d2f50726f6a" . + "65637412160a09706167655f73697a651802200128054203e0410112170a" . + "0a706167655f746f6b656e1803200128094203e0410122790a134c697374" . + "53656372657473526573706f6e736512350a077365637265747318012003" . + "280b32242e676f6f676c652e636c6f75642e736563726574732e76316265" . + "7461312e53656372657412170a0f6e6578745f706167655f746f6b656e18" . + "022001280912120a0a746f74616c5f73697a6518032001280522a8010a13" . + "4372656174655365637265745265717565737412430a06706172656e7418" . + "01200128094233e04102fa412d0a2b636c6f75647265736f757263656d61" . + "6e616765722e676f6f676c65617069732e636f6d2f50726f6a6563741216" . + "0a097365637265745f69641802200128094203e0410212340a0673656372" . + "657418032001280b32242e676f6f676c652e636c6f75642e736563726574" . + "732e763162657461312e5365637265742299010a17416464536563726574" . + "56657273696f6e52657175657374123b0a06706172656e74180120012809" . + "422be04102fa41250a237365637265746d616e616765722e676f6f676c65" . + "617069732e636f6d2f53656372657412410a077061796c6f616418022001" . + "280b322b2e676f6f676c652e636c6f75642e736563726574732e76316265" . + "7461312e5365637265745061796c6f61644203e04102224d0a1047657453" . + "65637265745265717565737412390a046e616d65180120012809422be041" . + "02fa41250a237365637265746d616e616765722e676f6f676c6561706973" . + "2e636f6d2f5365637265742289010a194c69737453656372657456657273" . + "696f6e7352657175657374123b0a06706172656e74180120012809422be0" . + "4102fa41250a237365637265746d616e616765722e676f6f676c65617069" . + "732e636f6d2f53656372657412160a09706167655f73697a651802200128" . + "054203e0410112170a0a706167655f746f6b656e1803200128094203e041" . + "012288010a1a4c69737453656372657456657273696f6e73526573706f6e" . + "7365123d0a0876657273696f6e7318012003280b322b2e676f6f676c652e" . + "636c6f75642e736563726574732e763162657461312e5365637265745665" . + "7273696f6e12170a0f6e6578745f706167655f746f6b656e180220012809" . + "12120a0a746f74616c5f73697a65180320012805225b0a17476574536563" . + "72657456657273696f6e5265717565737412400a046e616d651801200128" . + "094232e04102fa412c0a2a7365637265746d616e616765722e676f6f676c" . + "65617069732e636f6d2f53656372657456657273696f6e2286010a135570" . + "646174655365637265745265717565737412390a06736563726574180120" . + "01280b32242e676f6f676c652e636c6f75642e736563726574732e763162" . + "657461312e5365637265744203e0410212340a0b7570646174655f6d6173" . + "6b18022001280b321a2e676f6f676c652e70726f746f6275662e4669656c" . + "644d61736b4203e04102225e0a1a41636365737353656372657456657273" . + "696f6e5265717565737412400a046e616d651801200128094232e04102fa" . + "412c0a2a7365637265746d616e616765722e676f6f676c65617069732e63" . + "6f6d2f53656372657456657273696f6e229a010a1b416363657373536563" . + "72657456657273696f6e526573706f6e7365123d0a046e616d6518012001" . + "2809422ffa412c0a2a7365637265746d616e616765722e676f6f676c6561" . + "7069732e636f6d2f53656372657456657273696f6e123c0a077061796c6f" . + "616418022001280b322b2e676f6f676c652e636c6f75642e736563726574" . + "732e763162657461312e5365637265745061796c6f616422500a1344656c" . + "6574655365637265745265717565737412390a046e616d65180120012809" . + "422be04102fa41250a237365637265746d616e616765722e676f6f676c65" . + "617069732e636f6d2f536563726574225f0a1b44697361626c6553656372" . + "657456657273696f6e5265717565737412400a046e616d65180120012809" . + "4232e04102fa412c0a2a7365637265746d616e616765722e676f6f676c65" . + "617069732e636f6d2f53656372657456657273696f6e225e0a1a456e6162" . + "6c6553656372657456657273696f6e5265717565737412400a046e616d65" . + "1801200128094232e04102fa412c0a2a7365637265746d616e616765722e" . + "676f6f676c65617069732e636f6d2f53656372657456657273696f6e225f" . + "0a1b44657374726f7953656372657456657273696f6e5265717565737412" . + "400a046e616d651801200128094232e04102fa412c0a2a7365637265746d" . + "616e616765722e676f6f676c65617069732e636f6d2f5365637265745665" . + "7273696f6e3283160a145365637265744d616e6167657253657276696365" . + "12a9010a0b4c6973745365637265747312302e676f6f676c652e636c6f75" . + "642e736563726574732e763162657461312e4c6973745365637265747352" . + "6571756573741a312e676f6f676c652e636c6f75642e736563726574732e" . + "763162657461312e4c69737453656372657473526573706f6e7365223582" . + "d3e493022612242f763162657461312f7b706172656e743d70726f6a6563" . + "74732f2a7d2f73656372657473da4106706172656e7412b7010a0c437265" . + "61746553656372657412312e676f6f676c652e636c6f75642e7365637265" . + "74732e763162657461312e43726561746553656372657452657175657374" . + "1a242e676f6f676c652e636c6f75642e736563726574732e763162657461" . + "312e536563726574224e82d3e493022e22242f763162657461312f7b7061" . + "72656e743d70726f6a656374732f2a7d2f736563726574733a0673656372" . + "6574da4117706172656e742c7365637265745f69642c73656372657412c5" . + "010a1041646453656372657456657273696f6e12352e676f6f676c652e63" . + "6c6f75642e736563726574732e763162657461312e416464536563726574" . + "56657273696f6e526571756573741a2b2e676f6f676c652e636c6f75642e" . + "736563726574732e763162657461312e53656372657456657273696f6e22" . + "4d82d3e493023622312f763162657461312f7b706172656e743d70726f6a" . + "656374732f2a2f736563726574732f2a7d3a61646456657273696f6e3a01" . + "2ada410e706172656e742c7061796c6f61641296010a0947657453656372" . + "6574122e2e676f6f676c652e636c6f75642e736563726574732e76316265" . + "7461312e476574536563726574526571756573741a242e676f6f676c652e" . + "636c6f75642e736563726574732e763162657461312e5365637265742233" . + "82d3e493022612242f763162657461312f7b6e616d653d70726f6a656374" . + "732f2a2f736563726574732f2a7dda41046e616d6512b9010a0c55706461" . + "746553656372657412312e676f6f676c652e636c6f75642e736563726574" . + "732e763162657461312e557064617465536563726574526571756573741a" . + "242e676f6f676c652e636c6f75642e736563726574732e76316265746131" . + "2e536563726574225082d3e4930235322b2f763162657461312f7b736563" . + "7265742e6e616d653d70726f6a656374732f2a2f736563726574732f2a7d" . + "3a06736563726574da41127365637265742c7570646174655f6d61736b12" . + "8e010a0c44656c65746553656372657412312e676f6f676c652e636c6f75" . + "642e736563726574732e763162657461312e44656c657465536563726574" . + "526571756573741a162e676f6f676c652e70726f746f6275662e456d7074" . + "79223382d3e49302262a242f763162657461312f7b6e616d653d70726f6a" . + "656374732f2a2f736563726574732f2a7dda41046e616d6512c9010a124c" . + "69737453656372657456657273696f6e7312372e676f6f676c652e636c6f" . + "75642e736563726574732e763162657461312e4c69737453656372657456" . + "657273696f6e73526571756573741a382e676f6f676c652e636c6f75642e" . + "736563726574732e763162657461312e4c69737453656372657456657273" . + "696f6e73526573706f6e7365224082d3e4930231122f2f76316265746131" . + "2f7b706172656e743d70726f6a656374732f2a2f736563726574732f2a7d" . + "2f76657273696f6e73da4106706172656e7412b6010a1047657453656372" . + "657456657273696f6e12352e676f6f676c652e636c6f75642e7365637265" . + "74732e763162657461312e47657453656372657456657273696f6e526571" . + "756573741a2b2e676f6f676c652e636c6f75642e736563726574732e7631" . + "62657461312e53656372657456657273696f6e223e82d3e4930231122f2f" . + "763162657461312f7b6e616d653d70726f6a656374732f2a2f7365637265" . + "74732f2a2f76657273696f6e732f2a7dda41046e616d6512d1010a134163" . + "6365737353656372657456657273696f6e12382e676f6f676c652e636c6f" . + "75642e736563726574732e763162657461312e4163636573735365637265" . + "7456657273696f6e526571756573741a392e676f6f676c652e636c6f7564" . + "2e736563726574732e763162657461312e41636365737353656372657456" . + "657273696f6e526573706f6e7365224582d3e493023812362f7631626574" . + "61312f7b6e616d653d70726f6a656374732f2a2f736563726574732f2a2f" . + "76657273696f6e732f2a7d3a616363657373da41046e616d6512c9010a14" . + "44697361626c6553656372657456657273696f6e12392e676f6f676c652e" . + "636c6f75642e736563726574732e763162657461312e44697361626c6553" . + "656372657456657273696f6e526571756573741a2b2e676f6f676c652e63" . + "6c6f75642e736563726574732e763162657461312e536563726574566572" . + "73696f6e224982d3e493023c22372f763162657461312f7b6e616d653d70" . + "726f6a656374732f2a2f736563726574732f2a2f76657273696f6e732f2a" . + "7d3a64697361626c653a012ada41046e616d6512c6010a13456e61626c65" . + "53656372657456657273696f6e12382e676f6f676c652e636c6f75642e73" . + "6563726574732e763162657461312e456e61626c65536563726574566572" . + "73696f6e526571756573741a2b2e676f6f676c652e636c6f75642e736563" . + "726574732e763162657461312e53656372657456657273696f6e224882d3" . + "e493023b22362f763162657461312f7b6e616d653d70726f6a656374732f" . + "2a2f736563726574732f2a2f76657273696f6e732f2a7d3a656e61626c65" . + "3a012ada41046e616d6512c9010a1444657374726f795365637265745665" . + "7273696f6e12392e676f6f676c652e636c6f75642e736563726574732e76" . + "3162657461312e44657374726f7953656372657456657273696f6e526571" . + "756573741a2b2e676f6f676c652e636c6f75642e736563726574732e7631" . + "62657461312e53656372657456657273696f6e224982d3e493023c22372f" . + "763162657461312f7b6e616d653d70726f6a656374732f2a2f7365637265" . + "74732f2a2f76657273696f6e732f2a7d3a64657374726f793a012ada4104" . + "6e616d65128b010a0c53657449616d506f6c69637912222e676f6f676c65" . + "2e69616d2e76312e53657449616d506f6c696379526571756573741a152e" . + "676f6f676c652e69616d2e76312e506f6c696379224082d3e493023a2235" . + "2f763162657461312f7b7265736f757263653d70726f6a656374732f2a2f" . + "736563726574732f2a7d3a73657449616d506f6c6963793a012a1288010a" . + "0c47657449616d506f6c69637912222e676f6f676c652e69616d2e76312e" . + "47657449616d506f6c696379526571756573741a152e676f6f676c652e69" . + "616d2e76312e506f6c696379223d82d3e493023712352f76316265746131" . + "2f7b7265736f757263653d70726f6a656374732f2a2f736563726574732f" . + "2a7d3a67657449616d506f6c69637912b1010a125465737449616d506572" . + "6d697373696f6e7312282e676f6f676c652e69616d2e76312e5465737449" . + "616d5065726d697373696f6e73526571756573741a292e676f6f676c652e" . + "69616d2e76312e5465737449616d5065726d697373696f6e73526573706f" . + "6e7365224682d3e4930240223b2f763162657461312f7b7265736f757263" . + "653d70726f6a656374732f2a2f736563726574732f2a7d3a746573744961" . + "6d5065726d697373696f6e733a012a1a50ca411c7365637265746d616e61" . + "6765722e676f6f676c65617069732e636f6dd2412e68747470733a2f2f77" . + "77772e676f6f676c65617069732e636f6d2f617574682f636c6f75642d70" . + "6c6174666f726d4284020a26636f6d2e676f6f676c652e636c6f75642e73" . + "65637265746d616e616765722e76316265746131420c5365727669636550" . + "726f746f50015a4f676f6f676c652e676f6c616e672e6f72672f67656e70" . + "726f746f2f676f6f676c65617069732f636c6f75642f7365637265746d61" . + "6e616765722f763162657461313b7365637265746d616e61676572f80101" . + "a2020347534daa0222476f6f676c652e436c6f75642e5365637265744d61" . + "6e616765722e56314265746131ca0222476f6f676c655c436c6f75645c53" . + "65637265744d616e616765725c56316265746131ea0225476f6f676c653a" . + "3a436c6f75643a3a5365637265744d616e616765723a3a56316265746131" . + "620670726f746f33" + ), true); + + static::$is_initialized = true; + } +} + diff --git a/SecretManager/phpunit.xml.dist b/SecretManager/phpunit.xml.dist new file mode 100644 index 000000000000..1c2b8f6b56d2 --- /dev/null +++ b/SecretManager/phpunit.xml.dist @@ -0,0 +1,16 @@ + + + + + tests/Unit + + + + + src + + src/V[!a-zA-Z]* + + + + diff --git a/SecretManager/src/V1beta1/AccessSecretVersionRequest.php b/SecretManager/src/V1beta1/AccessSecretVersionRequest.php new file mode 100644 index 000000000000..1b9e613374ac --- /dev/null +++ b/SecretManager/src/V1beta1/AccessSecretVersionRequest.php @@ -0,0 +1,71 @@ +google.cloud.secrets.v1beta1.AccessSecretVersionRequest + */ +class AccessSecretVersionRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The resource name of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] in the format + * `projects/*/secrets/*/versions/*`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $name = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. The resource name of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] in the format + * `projects/*/secrets/*/versions/*`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Secrets\V1Beta1\Service::initOnce(); + parent::__construct($data); + } + + /** + * Required. The resource name of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] in the format + * `projects/*/secrets/*/versions/*`. + * + * 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 [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] in the format + * `projects/*/secrets/*/versions/*`. + * + * 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/SecretManager/src/V1beta1/AccessSecretVersionResponse.php b/SecretManager/src/V1beta1/AccessSecretVersionResponse.php new file mode 100644 index 000000000000..40ad35f85ffe --- /dev/null +++ b/SecretManager/src/V1beta1/AccessSecretVersionResponse.php @@ -0,0 +1,105 @@ +google.cloud.secrets.v1beta1.AccessSecretVersionResponse + */ +class AccessSecretVersionResponse extends \Google\Protobuf\Internal\Message +{ + /** + * The resource name of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] in the format + * `projects/*/secrets/*/versions/*`. + * + * Generated from protobuf field string name = 1 [(.google.api.resource_reference) = { + */ + private $name = ''; + /** + * Secret payload + * + * Generated from protobuf field .google.cloud.secrets.v1beta1.SecretPayload payload = 2; + */ + private $payload = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * The resource name of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] in the format + * `projects/*/secrets/*/versions/*`. + * @type \Google\Cloud\SecretManager\V1beta1\SecretPayload $payload + * Secret payload + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Secrets\V1Beta1\Service::initOnce(); + parent::__construct($data); + } + + /** + * The resource name of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] in the format + * `projects/*/secrets/*/versions/*`. + * + * Generated from protobuf field string name = 1 [(.google.api.resource_reference) = { + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * The resource name of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] in the format + * `projects/*/secrets/*/versions/*`. + * + * Generated from protobuf field string name = 1 [(.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * Secret payload + * + * Generated from protobuf field .google.cloud.secrets.v1beta1.SecretPayload payload = 2; + * @return \Google\Cloud\SecretManager\V1beta1\SecretPayload + */ + public function getPayload() + { + return $this->payload; + } + + /** + * Secret payload + * + * Generated from protobuf field .google.cloud.secrets.v1beta1.SecretPayload payload = 2; + * @param \Google\Cloud\SecretManager\V1beta1\SecretPayload $var + * @return $this + */ + public function setPayload($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\SecretManager\V1beta1\SecretPayload::class); + $this->payload = $var; + + return $this; + } + +} + diff --git a/SecretManager/src/V1beta1/AddSecretVersionRequest.php b/SecretManager/src/V1beta1/AddSecretVersionRequest.php new file mode 100644 index 000000000000..786966c8b4c5 --- /dev/null +++ b/SecretManager/src/V1beta1/AddSecretVersionRequest.php @@ -0,0 +1,105 @@ +google.cloud.secrets.v1beta1.AddSecretVersionRequest + */ +class AddSecretVersionRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The resource name of the [Secret][google.cloud.secrets.v1beta1.Secret] to associate with the + * [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] in the format `projects/*/secrets/*`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $parent = ''; + /** + * Required. The secret payload of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. + * + * Generated from protobuf field .google.cloud.secrets.v1beta1.SecretPayload payload = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + private $payload = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. The resource name of the [Secret][google.cloud.secrets.v1beta1.Secret] to associate with the + * [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] in the format `projects/*/secrets/*`. + * @type \Google\Cloud\SecretManager\V1beta1\SecretPayload $payload + * Required. The secret payload of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Secrets\V1Beta1\Service::initOnce(); + parent::__construct($data); + } + + /** + * Required. The resource name of the [Secret][google.cloud.secrets.v1beta1.Secret] to associate with the + * [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] in the format `projects/*/secrets/*`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * Required. The resource name of the [Secret][google.cloud.secrets.v1beta1.Secret] to associate with the + * [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] in the format `projects/*/secrets/*`. + * + * 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; + } + + /** + * Required. The secret payload of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. + * + * Generated from protobuf field .google.cloud.secrets.v1beta1.SecretPayload payload = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\SecretManager\V1beta1\SecretPayload + */ + public function getPayload() + { + return $this->payload; + } + + /** + * Required. The secret payload of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. + * + * Generated from protobuf field .google.cloud.secrets.v1beta1.SecretPayload payload = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\SecretManager\V1beta1\SecretPayload $var + * @return $this + */ + public function setPayload($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\SecretManager\V1beta1\SecretPayload::class); + $this->payload = $var; + + return $this; + } + +} + diff --git a/SecretManager/src/V1beta1/CreateSecretRequest.php b/SecretManager/src/V1beta1/CreateSecretRequest.php new file mode 100644 index 000000000000..8534548fa093 --- /dev/null +++ b/SecretManager/src/V1beta1/CreateSecretRequest.php @@ -0,0 +1,139 @@ +google.cloud.secrets.v1beta1.CreateSecretRequest + */ +class CreateSecretRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The resource name of the project to associate with the + * [Secret][google.cloud.secrets.v1beta1.Secret], in the format `projects/*`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $parent = ''; + /** + * Required. This must be unique within the project. + * + * Generated from protobuf field string secret_id = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + private $secret_id = ''; + /** + * A [Secret][google.cloud.secrets.v1beta1.Secret] with initial field values. + * + * Generated from protobuf field .google.cloud.secrets.v1beta1.Secret secret = 3; + */ + private $secret = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. The resource name of the project to associate with the + * [Secret][google.cloud.secrets.v1beta1.Secret], in the format `projects/*`. + * @type string $secret_id + * Required. This must be unique within the project. + * @type \Google\Cloud\SecretManager\V1beta1\Secret $secret + * A [Secret][google.cloud.secrets.v1beta1.Secret] with initial field values. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Secrets\V1Beta1\Service::initOnce(); + parent::__construct($data); + } + + /** + * Required. The resource name of the project to associate with the + * [Secret][google.cloud.secrets.v1beta1.Secret], in the format `projects/*`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * Required. The resource name of the project to associate with the + * [Secret][google.cloud.secrets.v1beta1.Secret], in the format `projects/*`. + * + * 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; + } + + /** + * Required. This must be unique within the project. + * + * Generated from protobuf field string secret_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getSecretId() + { + return $this->secret_id; + } + + /** + * Required. This must be unique within the project. + * + * Generated from protobuf field string secret_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setSecretId($var) + { + GPBUtil::checkString($var, True); + $this->secret_id = $var; + + return $this; + } + + /** + * A [Secret][google.cloud.secrets.v1beta1.Secret] with initial field values. + * + * Generated from protobuf field .google.cloud.secrets.v1beta1.Secret secret = 3; + * @return \Google\Cloud\SecretManager\V1beta1\Secret + */ + public function getSecret() + { + return $this->secret; + } + + /** + * A [Secret][google.cloud.secrets.v1beta1.Secret] with initial field values. + * + * Generated from protobuf field .google.cloud.secrets.v1beta1.Secret secret = 3; + * @param \Google\Cloud\SecretManager\V1beta1\Secret $var + * @return $this + */ + public function setSecret($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\SecretManager\V1beta1\Secret::class); + $this->secret = $var; + + return $this; + } + +} + diff --git a/SecretManager/src/V1beta1/DeleteSecretRequest.php b/SecretManager/src/V1beta1/DeleteSecretRequest.php new file mode 100644 index 000000000000..194cfbcf8a87 --- /dev/null +++ b/SecretManager/src/V1beta1/DeleteSecretRequest.php @@ -0,0 +1,71 @@ +google.cloud.secrets.v1beta1.DeleteSecretRequest + */ +class DeleteSecretRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The resource name of the [Secret][google.cloud.secrets.v1beta1.Secret] to delete in the format + * `projects/*/secrets/*`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $name = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. The resource name of the [Secret][google.cloud.secrets.v1beta1.Secret] to delete in the format + * `projects/*/secrets/*`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Secrets\V1Beta1\Service::initOnce(); + parent::__construct($data); + } + + /** + * Required. The resource name of the [Secret][google.cloud.secrets.v1beta1.Secret] to delete in the format + * `projects/*/secrets/*`. + * + * 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 [Secret][google.cloud.secrets.v1beta1.Secret] to delete in the format + * `projects/*/secrets/*`. + * + * 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/SecretManager/src/V1beta1/DestroySecretVersionRequest.php b/SecretManager/src/V1beta1/DestroySecretVersionRequest.php new file mode 100644 index 000000000000..b7aa7baf338f --- /dev/null +++ b/SecretManager/src/V1beta1/DestroySecretVersionRequest.php @@ -0,0 +1,71 @@ +google.cloud.secrets.v1beta1.DestroySecretVersionRequest + */ +class DestroySecretVersionRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The resource name of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to destroy in the format + * `projects/*/secrets/*/versions/*`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $name = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. The resource name of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to destroy in the format + * `projects/*/secrets/*/versions/*`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Secrets\V1Beta1\Service::initOnce(); + parent::__construct($data); + } + + /** + * Required. The resource name of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to destroy in the format + * `projects/*/secrets/*/versions/*`. + * + * 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 [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to destroy in the format + * `projects/*/secrets/*/versions/*`. + * + * 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/SecretManager/src/V1beta1/DisableSecretVersionRequest.php b/SecretManager/src/V1beta1/DisableSecretVersionRequest.php new file mode 100644 index 000000000000..1c2bf340488a --- /dev/null +++ b/SecretManager/src/V1beta1/DisableSecretVersionRequest.php @@ -0,0 +1,71 @@ +google.cloud.secrets.v1beta1.DisableSecretVersionRequest + */ +class DisableSecretVersionRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The resource name of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to disable in the format + * `projects/*/secrets/*/versions/*`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $name = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. The resource name of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to disable in the format + * `projects/*/secrets/*/versions/*`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Secrets\V1Beta1\Service::initOnce(); + parent::__construct($data); + } + + /** + * Required. The resource name of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to disable in the format + * `projects/*/secrets/*/versions/*`. + * + * 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 [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to disable in the format + * `projects/*/secrets/*/versions/*`. + * + * 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/SecretManager/src/V1beta1/EnableSecretVersionRequest.php b/SecretManager/src/V1beta1/EnableSecretVersionRequest.php new file mode 100644 index 000000000000..c34a69a68c63 --- /dev/null +++ b/SecretManager/src/V1beta1/EnableSecretVersionRequest.php @@ -0,0 +1,71 @@ +google.cloud.secrets.v1beta1.EnableSecretVersionRequest + */ +class EnableSecretVersionRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The resource name of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to enable in the format + * `projects/*/secrets/*/versions/*`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $name = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. The resource name of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to enable in the format + * `projects/*/secrets/*/versions/*`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Secrets\V1Beta1\Service::initOnce(); + parent::__construct($data); + } + + /** + * Required. The resource name of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to enable in the format + * `projects/*/secrets/*/versions/*`. + * + * 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 [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to enable in the format + * `projects/*/secrets/*/versions/*`. + * + * 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/SecretManager/src/V1beta1/Gapic/SecretManagerServiceGapicClient.php b/SecretManager/src/V1beta1/Gapic/SecretManagerServiceGapicClient.php new file mode 100644 index 000000000000..faf9b3a1b99d --- /dev/null +++ b/SecretManager/src/V1beta1/Gapic/SecretManagerServiceGapicClient.php @@ -0,0 +1,1245 @@ +projectName('[PROJECT]'); + * // Iterate over pages of elements + * $pagedResponse = $secretManagerServiceClient->listSecrets($formattedParent); + * foreach ($pagedResponse->iteratePages() as $page) { + * foreach ($page as $element) { + * // doSomethingWith($element); + * } + * } + * + * + * // Alternatively: + * + * // Iterate through all elements + * $pagedResponse = $secretManagerServiceClient->listSecrets($formattedParent); + * foreach ($pagedResponse->iterateAllElements() as $element) { + * // doSomethingWith($element); + * } + * } finally { + * $secretManagerServiceClient->close(); + * } + * ``` + * + * Many parameters require resource names to be formatted in a particular way. To assist + * with these names, this class includes a format method for each type of name, and additionally + * a parseName method to extract the individual identifiers contained within formatted names + * that are returned by the API. + * + * @experimental + */ +class SecretManagerServiceGapicClient +{ + use GapicClientTrait; + + /** + * The name of the service. + */ + const SERVICE_NAME = 'google.cloud.secrets.v1beta1.SecretManagerService'; + + /** + * The default address of the service. + */ + const SERVICE_ADDRESS = 'secretmanager.googleapis.com'; + + /** + * The default port of the service. + */ + const DEFAULT_SERVICE_PORT = 443; + + /** + * The name of the code generator, to be included in the agent header. + */ + const CODEGEN_NAME = 'gapic'; + + /** + * The default scopes required by the service. + */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + private static $projectNameTemplate; + private static $secretNameTemplate; + private static $secretVersionNameTemplate; + private static $pathTemplateMap; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS.':'.self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__.'/../resources/secret_manager_service_client_config.json', + 'descriptorsConfigPath' => __DIR__.'/../resources/secret_manager_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__.'/../resources/secret_manager_service_grpc_config.json', + 'credentialsConfig' => [ + 'scopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__.'/../resources/secret_manager_service_rest_client_config.php', + ], + ], + ]; + } + + private static function getProjectNameTemplate() + { + if (null == self::$projectNameTemplate) { + self::$projectNameTemplate = new PathTemplate('projects/{project}'); + } + + return self::$projectNameTemplate; + } + + private static function getSecretNameTemplate() + { + if (null == self::$secretNameTemplate) { + self::$secretNameTemplate = new PathTemplate('projects/{project}/secrets/{secret}'); + } + + return self::$secretNameTemplate; + } + + private static function getSecretVersionNameTemplate() + { + if (null == self::$secretVersionNameTemplate) { + self::$secretVersionNameTemplate = new PathTemplate('projects/{project}/secrets/{secret}/versions/{secret_version}'); + } + + return self::$secretVersionNameTemplate; + } + + private static function getPathTemplateMap() + { + if (null == self::$pathTemplateMap) { + self::$pathTemplateMap = [ + 'project' => self::getProjectNameTemplate(), + 'secret' => self::getSecretNameTemplate(), + 'secretVersion' => self::getSecretVersionNameTemplate(), + ]; + } + + return self::$pathTemplateMap; + } + + /** + * Formats a string containing the fully-qualified path to represent + * a project resource. + * + * @param string $project + * + * @return string The formatted project resource. + * @experimental + */ + public static function projectName($project) + { + return self::getProjectNameTemplate()->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent + * a secret resource. + * + * @param string $project + * @param string $secret + * + * @return string The formatted secret resource. + * @experimental + */ + public static function secretName($project, $secret) + { + return self::getSecretNameTemplate()->render([ + 'project' => $project, + 'secret' => $secret, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent + * a secret_version resource. + * + * @param string $project + * @param string $secret + * @param string $secretVersion + * + * @return string The formatted secret_version resource. + * @experimental + */ + public static function secretVersionName($project, $secret, $secretVersion) + { + return self::getSecretVersionNameTemplate()->render([ + 'project' => $project, + 'secret' => $secret, + 'secret_version' => $secretVersion, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - project: projects/{project} + * - secret: projects/{project}/secrets/{secret} + * - secretVersion: projects/{project}/secrets/{secret}/versions/{secret_version}. + * + * The optional $template argument can be supplied to specify a particular pattern, and must + * match one of the templates listed above. If no $template argument is provided, or if the + * $template argument does not match one of the templates listed, then parseName will check + * each of the supported templates, and return the first match. + * + * @param string $formattedName The formatted name string + * @param string $template Optional name of template to match + * + * @return array An associative array from name component IDs to component values. + * + * @throws ValidationException If $formattedName could not be matched. + * @experimental + */ + public static function parseName($formattedName, $template = null) + { + $templateMap = self::getPathTemplateMap(); + + if ($template) { + if (!isset($templateMap[$template])) { + throw new ValidationException("Template name $template does not exist"); + } + + return $templateMap[$template]->match($formattedName); + } + + foreach ($templateMap as $templateName => $pathTemplate) { + try { + return $pathTemplate->match($formattedName); + } catch (ValidationException $ex) { + // Swallow the exception to continue trying other path templates + } + } + throw new ValidationException("Input did not match any known format. Input: $formattedName"); + } + + /** + * Constructor. + * + * @param array $options { + * Optional. Options for configuring the service API wrapper. + * + * @type string $serviceAddress + * **Deprecated**. This option will be removed in a future major release. Please + * utilize the `$apiEndpoint` option instead. + * @type string $apiEndpoint + * The address of the API remote host. May optionally include the port, formatted + * as ":". Default 'secretmanager.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. + * } + * + * @throws ValidationException + * @experimental + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** + * Lists [Secrets][google.cloud.secrets.v1beta1.Secret]. + * + * Sample code: + * ``` + * $secretManagerServiceClient = new SecretManagerServiceClient(); + * try { + * $formattedParent = $secretManagerServiceClient->projectName('[PROJECT]'); + * // Iterate over pages of elements + * $pagedResponse = $secretManagerServiceClient->listSecrets($formattedParent); + * foreach ($pagedResponse->iteratePages() as $page) { + * foreach ($page as $element) { + * // doSomethingWith($element); + * } + * } + * + * + * // Alternatively: + * + * // Iterate through all elements + * $pagedResponse = $secretManagerServiceClient->listSecrets($formattedParent); + * foreach ($pagedResponse->iterateAllElements() as $element) { + * // doSomethingWith($element); + * } + * } finally { + * $secretManagerServiceClient->close(); + * } + * ``` + * + * @param string $parent Required. The resource name of the project associated with the + * [Secrets][google.cloud.secrets.v1beta1.Secret], in the format `projects/*`. + * @param array $optionalArgs { + * Optional. + * + * @type int $pageSize + * The maximum number of resources contained in the underlying API + * response. The API may return fewer values in a page, even if + * there are additional values to be retrieved. + * @type string $pageToken + * A page token is used to specify a page of values to be returned. + * If no page token is specified (the default), the first page + * of values will be returned. Any page token used here must have + * been generated by a previous call to the API. + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\ApiCore\PagedListResponse + * + * @throws ApiException if the remote call fails + * @experimental + */ + public function listSecrets($parent, array $optionalArgs = []) + { + $request = new ListSecretsRequest(); + $request->setParent($parent); + if (isset($optionalArgs['pageSize'])) { + $request->setPageSize($optionalArgs['pageSize']); + } + if (isset($optionalArgs['pageToken'])) { + $request->setPageToken($optionalArgs['pageToken']); + } + + $requestParams = new RequestParamsHeaderDescriptor([ + 'parent' => $request->getParent(), + ]); + $optionalArgs['headers'] = isset($optionalArgs['headers']) + ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) + : $requestParams->getHeader(); + + return $this->getPagedListResponse( + 'ListSecrets', + $optionalArgs, + ListSecretsResponse::class, + $request + ); + } + + /** + * Creates a new [Secret][google.cloud.secrets.v1beta1.Secret] containing no [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion]. + * + * Sample code: + * ``` + * $secretManagerServiceClient = new SecretManagerServiceClient(); + * try { + * $formattedParent = $secretManagerServiceClient->projectName('[PROJECT]'); + * $secretId = ''; + * $response = $secretManagerServiceClient->createSecret($formattedParent, $secretId); + * } finally { + * $secretManagerServiceClient->close(); + * } + * ``` + * + * @param string $parent Required. The resource name of the project to associate with the + * [Secret][google.cloud.secrets.v1beta1.Secret], in the format `projects/*`. + * @param string $secretId Required. This must be unique within the project. + * @param array $optionalArgs { + * Optional. + * + * @type Secret $secret + * A [Secret][google.cloud.secrets.v1beta1.Secret] with initial field values. + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\SecretManager\V1beta1\Secret + * + * @throws ApiException if the remote call fails + * @experimental + */ + public function createSecret($parent, $secretId, array $optionalArgs = []) + { + $request = new CreateSecretRequest(); + $request->setParent($parent); + $request->setSecretId($secretId); + if (isset($optionalArgs['secret'])) { + $request->setSecret($optionalArgs['secret']); + } + + $requestParams = new RequestParamsHeaderDescriptor([ + 'parent' => $request->getParent(), + ]); + $optionalArgs['headers'] = isset($optionalArgs['headers']) + ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) + : $requestParams->getHeader(); + + return $this->startCall( + 'CreateSecret', + Secret::class, + $optionalArgs, + $request + )->wait(); + } + + /** + * Creates a new [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] containing secret data and attaches + * it to an existing [Secret][google.cloud.secrets.v1beta1.Secret]. + * + * Sample code: + * ``` + * $secretManagerServiceClient = new SecretManagerServiceClient(); + * try { + * $formattedParent = $secretManagerServiceClient->secretName('[PROJECT]', '[SECRET]'); + * $payload = new SecretPayload(); + * $response = $secretManagerServiceClient->addSecretVersion($formattedParent, $payload); + * } finally { + * $secretManagerServiceClient->close(); + * } + * ``` + * + * @param string $parent Required. The resource name of the [Secret][google.cloud.secrets.v1beta1.Secret] to associate with the + * [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] in the format `projects/*/secrets/*`. + * @param SecretPayload $payload Required. The secret payload of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. + * @param array $optionalArgs { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\SecretManager\V1beta1\SecretVersion + * + * @throws ApiException if the remote call fails + * @experimental + */ + public function addSecretVersion($parent, $payload, array $optionalArgs = []) + { + $request = new AddSecretVersionRequest(); + $request->setParent($parent); + $request->setPayload($payload); + + $requestParams = new RequestParamsHeaderDescriptor([ + 'parent' => $request->getParent(), + ]); + $optionalArgs['headers'] = isset($optionalArgs['headers']) + ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) + : $requestParams->getHeader(); + + return $this->startCall( + 'AddSecretVersion', + SecretVersion::class, + $optionalArgs, + $request + )->wait(); + } + + /** + * Gets metadata for a given [Secret][google.cloud.secrets.v1beta1.Secret]. + * + * Sample code: + * ``` + * $secretManagerServiceClient = new SecretManagerServiceClient(); + * try { + * $formattedName = $secretManagerServiceClient->secretName('[PROJECT]', '[SECRET]'); + * $response = $secretManagerServiceClient->getSecret($formattedName); + * } finally { + * $secretManagerServiceClient->close(); + * } + * ``` + * + * @param string $name Required. The resource name of the [Secret][google.cloud.secrets.v1beta1.Secret], in the format `projects/*/secrets/*`. + * @param array $optionalArgs { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\SecretManager\V1beta1\Secret + * + * @throws ApiException if the remote call fails + * @experimental + */ + public function getSecret($name, array $optionalArgs = []) + { + $request = new GetSecretRequest(); + $request->setName($name); + + $requestParams = new RequestParamsHeaderDescriptor([ + 'name' => $request->getName(), + ]); + $optionalArgs['headers'] = isset($optionalArgs['headers']) + ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) + : $requestParams->getHeader(); + + return $this->startCall( + 'GetSecret', + Secret::class, + $optionalArgs, + $request + )->wait(); + } + + /** + * Updates metadata of an existing [Secret][google.cloud.secrets.v1beta1.Secret]. + * + * Sample code: + * ``` + * $secretManagerServiceClient = new SecretManagerServiceClient(); + * try { + * $secret = new Secret(); + * $updateMask = new FieldMask(); + * $response = $secretManagerServiceClient->updateSecret($secret, $updateMask); + * } finally { + * $secretManagerServiceClient->close(); + * } + * ``` + * + * @param Secret $secret Required. [Secret][google.cloud.secrets.v1beta1.Secret] with updated field values. + * @param FieldMask $updateMask Required. Specifies the fields to be updated. + * @param array $optionalArgs { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\SecretManager\V1beta1\Secret + * + * @throws ApiException if the remote call fails + * @experimental + */ + public function updateSecret($secret, $updateMask, array $optionalArgs = []) + { + $request = new UpdateSecretRequest(); + $request->setSecret($secret); + $request->setUpdateMask($updateMask); + + $requestParams = new RequestParamsHeaderDescriptor([ + 'secret.name' => $request->getSecret()->getName(), + ]); + $optionalArgs['headers'] = isset($optionalArgs['headers']) + ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) + : $requestParams->getHeader(); + + return $this->startCall( + 'UpdateSecret', + Secret::class, + $optionalArgs, + $request + )->wait(); + } + + /** + * Deletes a [Secret][google.cloud.secrets.v1beta1.Secret]. + * + * Sample code: + * ``` + * $secretManagerServiceClient = new SecretManagerServiceClient(); + * try { + * $formattedName = $secretManagerServiceClient->secretName('[PROJECT]', '[SECRET]'); + * $secretManagerServiceClient->deleteSecret($formattedName); + * } finally { + * $secretManagerServiceClient->close(); + * } + * ``` + * + * @param string $name Required. The resource name of the [Secret][google.cloud.secrets.v1beta1.Secret] to delete in the format + * `projects/*/secrets/*`. + * @param array $optionalArgs { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @throws ApiException if the remote call fails + * @experimental + */ + public function deleteSecret($name, array $optionalArgs = []) + { + $request = new DeleteSecretRequest(); + $request->setName($name); + + $requestParams = new RequestParamsHeaderDescriptor([ + 'name' => $request->getName(), + ]); + $optionalArgs['headers'] = isset($optionalArgs['headers']) + ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) + : $requestParams->getHeader(); + + return $this->startCall( + 'DeleteSecret', + GPBEmpty::class, + $optionalArgs, + $request + )->wait(); + } + + /** + * Lists [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion]. This call does not return secret + * data. + * + * Sample code: + * ``` + * $secretManagerServiceClient = new SecretManagerServiceClient(); + * try { + * $formattedParent = $secretManagerServiceClient->secretName('[PROJECT]', '[SECRET]'); + * // Iterate over pages of elements + * $pagedResponse = $secretManagerServiceClient->listSecretVersions($formattedParent); + * foreach ($pagedResponse->iteratePages() as $page) { + * foreach ($page as $element) { + * // doSomethingWith($element); + * } + * } + * + * + * // Alternatively: + * + * // Iterate through all elements + * $pagedResponse = $secretManagerServiceClient->listSecretVersions($formattedParent); + * foreach ($pagedResponse->iterateAllElements() as $element) { + * // doSomethingWith($element); + * } + * } finally { + * $secretManagerServiceClient->close(); + * } + * ``` + * + * @param string $parent Required. The resource name of the [Secret][google.cloud.secrets.v1beta1.Secret] associated with the + * [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion] to list, in the format + * `projects/*/secrets/*`. + * @param array $optionalArgs { + * Optional. + * + * @type int $pageSize + * The maximum number of resources contained in the underlying API + * response. The API may return fewer values in a page, even if + * there are additional values to be retrieved. + * @type string $pageToken + * A page token is used to specify a page of values to be returned. + * If no page token is specified (the default), the first page + * of values will be returned. Any page token used here must have + * been generated by a previous call to the API. + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\ApiCore\PagedListResponse + * + * @throws ApiException if the remote call fails + * @experimental + */ + public function listSecretVersions($parent, array $optionalArgs = []) + { + $request = new ListSecretVersionsRequest(); + $request->setParent($parent); + if (isset($optionalArgs['pageSize'])) { + $request->setPageSize($optionalArgs['pageSize']); + } + if (isset($optionalArgs['pageToken'])) { + $request->setPageToken($optionalArgs['pageToken']); + } + + $requestParams = new RequestParamsHeaderDescriptor([ + 'parent' => $request->getParent(), + ]); + $optionalArgs['headers'] = isset($optionalArgs['headers']) + ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) + : $requestParams->getHeader(); + + return $this->getPagedListResponse( + 'ListSecretVersions', + $optionalArgs, + ListSecretVersionsResponse::class, + $request + ); + } + + /** + * Gets metadata for a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. + * + * `projects/*/secrets/*/versions/latest` is an alias to the `latest` + * [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. + * + * Sample code: + * ``` + * $secretManagerServiceClient = new SecretManagerServiceClient(); + * try { + * $formattedName = $secretManagerServiceClient->secretVersionName('[PROJECT]', '[SECRET]', '[SECRET_VERSION]'); + * $response = $secretManagerServiceClient->getSecretVersion($formattedName); + * } finally { + * $secretManagerServiceClient->close(); + * } + * ``` + * + * @param string $name Required. The resource name of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] in the format + * `projects/*/secrets/*/versions/*`. + * `projects/*/secrets/*/versions/latest` is an alias to the `latest` + * [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. + * @param array $optionalArgs { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\SecretManager\V1beta1\SecretVersion + * + * @throws ApiException if the remote call fails + * @experimental + */ + public function getSecretVersion($name, array $optionalArgs = []) + { + $request = new GetSecretVersionRequest(); + $request->setName($name); + + $requestParams = new RequestParamsHeaderDescriptor([ + 'name' => $request->getName(), + ]); + $optionalArgs['headers'] = isset($optionalArgs['headers']) + ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) + : $requestParams->getHeader(); + + return $this->startCall( + 'GetSecretVersion', + SecretVersion::class, + $optionalArgs, + $request + )->wait(); + } + + /** + * Accesses a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. This call returns the secret data. + * + * `projects/*/secrets/*/versions/latest` is an alias to the `latest` + * [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. + * + * Sample code: + * ``` + * $secretManagerServiceClient = new SecretManagerServiceClient(); + * try { + * $formattedName = $secretManagerServiceClient->secretVersionName('[PROJECT]', '[SECRET]', '[SECRET_VERSION]'); + * $response = $secretManagerServiceClient->accessSecretVersion($formattedName); + * } finally { + * $secretManagerServiceClient->close(); + * } + * ``` + * + * @param string $name Required. The resource name of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] in the format + * `projects/*/secrets/*/versions/*`. + * @param array $optionalArgs { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\SecretManager\V1beta1\AccessSecretVersionResponse + * + * @throws ApiException if the remote call fails + * @experimental + */ + public function accessSecretVersion($name, array $optionalArgs = []) + { + $request = new AccessSecretVersionRequest(); + $request->setName($name); + + $requestParams = new RequestParamsHeaderDescriptor([ + 'name' => $request->getName(), + ]); + $optionalArgs['headers'] = isset($optionalArgs['headers']) + ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) + : $requestParams->getHeader(); + + return $this->startCall( + 'AccessSecretVersion', + AccessSecretVersionResponse::class, + $optionalArgs, + $request + )->wait(); + } + + /** + * Disables a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. + * + * Sets the [state][google.cloud.secrets.v1beta1.SecretVersion.state] of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to + * [DISABLED][google.cloud.secrets.v1beta1.SecretVersion.State.DISABLED]. + * + * Sample code: + * ``` + * $secretManagerServiceClient = new SecretManagerServiceClient(); + * try { + * $formattedName = $secretManagerServiceClient->secretVersionName('[PROJECT]', '[SECRET]', '[SECRET_VERSION]'); + * $response = $secretManagerServiceClient->disableSecretVersion($formattedName); + * } finally { + * $secretManagerServiceClient->close(); + * } + * ``` + * + * @param string $name Required. The resource name of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to disable in the format + * `projects/*/secrets/*/versions/*`. + * @param array $optionalArgs { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\SecretManager\V1beta1\SecretVersion + * + * @throws ApiException if the remote call fails + * @experimental + */ + public function disableSecretVersion($name, array $optionalArgs = []) + { + $request = new DisableSecretVersionRequest(); + $request->setName($name); + + $requestParams = new RequestParamsHeaderDescriptor([ + 'name' => $request->getName(), + ]); + $optionalArgs['headers'] = isset($optionalArgs['headers']) + ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) + : $requestParams->getHeader(); + + return $this->startCall( + 'DisableSecretVersion', + SecretVersion::class, + $optionalArgs, + $request + )->wait(); + } + + /** + * Enables a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. + * + * Sets the [state][google.cloud.secrets.v1beta1.SecretVersion.state] of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to + * [ENABLED][google.cloud.secrets.v1beta1.SecretVersion.State.ENABLED]. + * + * Sample code: + * ``` + * $secretManagerServiceClient = new SecretManagerServiceClient(); + * try { + * $formattedName = $secretManagerServiceClient->secretVersionName('[PROJECT]', '[SECRET]', '[SECRET_VERSION]'); + * $response = $secretManagerServiceClient->enableSecretVersion($formattedName); + * } finally { + * $secretManagerServiceClient->close(); + * } + * ``` + * + * @param string $name Required. The resource name of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to enable in the format + * `projects/*/secrets/*/versions/*`. + * @param array $optionalArgs { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\SecretManager\V1beta1\SecretVersion + * + * @throws ApiException if the remote call fails + * @experimental + */ + public function enableSecretVersion($name, array $optionalArgs = []) + { + $request = new EnableSecretVersionRequest(); + $request->setName($name); + + $requestParams = new RequestParamsHeaderDescriptor([ + 'name' => $request->getName(), + ]); + $optionalArgs['headers'] = isset($optionalArgs['headers']) + ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) + : $requestParams->getHeader(); + + return $this->startCall( + 'EnableSecretVersion', + SecretVersion::class, + $optionalArgs, + $request + )->wait(); + } + + /** + * Destroys a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. + * + * Sets the [state][google.cloud.secrets.v1beta1.SecretVersion.state] of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to + * [DESTROYED][google.cloud.secrets.v1beta1.SecretVersion.State.DESTROYED] and irrevocably destroys the + * secret data. + * + * Sample code: + * ``` + * $secretManagerServiceClient = new SecretManagerServiceClient(); + * try { + * $formattedName = $secretManagerServiceClient->secretVersionName('[PROJECT]', '[SECRET]', '[SECRET_VERSION]'); + * $response = $secretManagerServiceClient->destroySecretVersion($formattedName); + * } finally { + * $secretManagerServiceClient->close(); + * } + * ``` + * + * @param string $name Required. The resource name of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to destroy in the format + * `projects/*/secrets/*/versions/*`. + * @param array $optionalArgs { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\SecretManager\V1beta1\SecretVersion + * + * @throws ApiException if the remote call fails + * @experimental + */ + public function destroySecretVersion($name, array $optionalArgs = []) + { + $request = new DestroySecretVersionRequest(); + $request->setName($name); + + $requestParams = new RequestParamsHeaderDescriptor([ + 'name' => $request->getName(), + ]); + $optionalArgs['headers'] = isset($optionalArgs['headers']) + ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) + : $requestParams->getHeader(); + + return $this->startCall( + 'DestroySecretVersion', + SecretVersion::class, + $optionalArgs, + $request + )->wait(); + } + + /** + * Sets the access control policy on the specified secret. Replaces any + * existing policy. + * + * Permissions on [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion] are enforced according + * to the policy set on the associated [Secret][google.cloud.secrets.v1beta1.Secret]. + * + * Sample code: + * ``` + * $secretManagerServiceClient = new SecretManagerServiceClient(); + * try { + * $resource = ''; + * $policy = new Policy(); + * $response = $secretManagerServiceClient->setIamPolicy($resource, $policy); + * } finally { + * $secretManagerServiceClient->close(); + * } + * ``` + * + * @param string $resource REQUIRED: The resource for which the policy is being specified. + * See the operation documentation for the appropriate value for this field. + * @param Policy $policy REQUIRED: The complete policy to be applied to the `resource`. The size of + * the policy is limited to a few 10s of KB. An empty policy is a + * valid policy but certain Cloud Platform services (such as Projects) + * might reject them. + * @param array $optionalArgs { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\Iam\V1\Policy + * + * @throws ApiException if the remote call fails + * @experimental + */ + public function setIamPolicy($resource, $policy, array $optionalArgs = []) + { + $request = new SetIamPolicyRequest(); + $request->setResource($resource); + $request->setPolicy($policy); + + $requestParams = new RequestParamsHeaderDescriptor([ + 'resource' => $request->getResource(), + ]); + $optionalArgs['headers'] = isset($optionalArgs['headers']) + ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) + : $requestParams->getHeader(); + + return $this->startCall( + 'SetIamPolicy', + Policy::class, + $optionalArgs, + $request + )->wait(); + } + + /** + * Gets the access control policy for a secret. + * Returns empty policy if the secret exists and does not have a policy set. + * + * Sample code: + * ``` + * $secretManagerServiceClient = new SecretManagerServiceClient(); + * try { + * $resource = ''; + * $response = $secretManagerServiceClient->getIamPolicy($resource); + * } finally { + * $secretManagerServiceClient->close(); + * } + * ``` + * + * @param string $resource REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param array $optionalArgs { + * Optional. + * + * @type GetPolicyOptions $options + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\Iam\V1\Policy + * + * @throws ApiException if the remote call fails + * @experimental + */ + public function getIamPolicy($resource, array $optionalArgs = []) + { + $request = new GetIamPolicyRequest(); + $request->setResource($resource); + if (isset($optionalArgs['options'])) { + $request->setOptions($optionalArgs['options']); + } + + $requestParams = new RequestParamsHeaderDescriptor([ + 'resource' => $request->getResource(), + ]); + $optionalArgs['headers'] = isset($optionalArgs['headers']) + ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) + : $requestParams->getHeader(); + + return $this->startCall( + 'GetIamPolicy', + Policy::class, + $optionalArgs, + $request + )->wait(); + } + + /** + * Returns permissions that a caller has for the specified secret. + * If the secret does not exist, this call returns an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building permission-aware + * UIs and command-line tools, not for authorization checking. This operation + * may "fail open" without warning. + * + * Sample code: + * ``` + * $secretManagerServiceClient = new SecretManagerServiceClient(); + * try { + * $resource = ''; + * $permissions = []; + * $response = $secretManagerServiceClient->testIamPermissions($resource, $permissions); + * } finally { + * $secretManagerServiceClient->close(); + * } + * ``` + * + * @param string $resource REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param string[] $permissions The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see + * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). + * @param array $optionalArgs { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\Iam\V1\TestIamPermissionsResponse + * + * @throws ApiException if the remote call fails + * @experimental + */ + public function testIamPermissions($resource, $permissions, array $optionalArgs = []) + { + $request = new TestIamPermissionsRequest(); + $request->setResource($resource); + $request->setPermissions($permissions); + + $requestParams = new RequestParamsHeaderDescriptor([ + 'resource' => $request->getResource(), + ]); + $optionalArgs['headers'] = isset($optionalArgs['headers']) + ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) + : $requestParams->getHeader(); + + return $this->startCall( + 'TestIamPermissions', + TestIamPermissionsResponse::class, + $optionalArgs, + $request + )->wait(); + } +} diff --git a/SecretManager/src/V1beta1/GetSecretRequest.php b/SecretManager/src/V1beta1/GetSecretRequest.php new file mode 100644 index 000000000000..bc2ad2abda51 --- /dev/null +++ b/SecretManager/src/V1beta1/GetSecretRequest.php @@ -0,0 +1,67 @@ +google.cloud.secrets.v1beta1.GetSecretRequest + */ +class GetSecretRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The resource name of the [Secret][google.cloud.secrets.v1beta1.Secret], in the format `projects/*/secrets/*`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $name = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. The resource name of the [Secret][google.cloud.secrets.v1beta1.Secret], in the format `projects/*/secrets/*`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Secrets\V1Beta1\Service::initOnce(); + parent::__construct($data); + } + + /** + * Required. The resource name of the [Secret][google.cloud.secrets.v1beta1.Secret], in the format `projects/*/secrets/*`. + * + * 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 [Secret][google.cloud.secrets.v1beta1.Secret], in the format `projects/*/secrets/*`. + * + * 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/SecretManager/src/V1beta1/GetSecretVersionRequest.php b/SecretManager/src/V1beta1/GetSecretVersionRequest.php new file mode 100644 index 000000000000..c1dc1a0d939c --- /dev/null +++ b/SecretManager/src/V1beta1/GetSecretVersionRequest.php @@ -0,0 +1,79 @@ +google.cloud.secrets.v1beta1.GetSecretVersionRequest + */ +class GetSecretVersionRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The resource name of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] in the format + * `projects/*/secrets/*/versions/*`. + * `projects/*/secrets/*/versions/latest` is an alias to the `latest` + * [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $name = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. The resource name of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] in the format + * `projects/*/secrets/*/versions/*`. + * `projects/*/secrets/*/versions/latest` is an alias to the `latest` + * [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Secrets\V1Beta1\Service::initOnce(); + parent::__construct($data); + } + + /** + * Required. The resource name of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] in the format + * `projects/*/secrets/*/versions/*`. + * `projects/*/secrets/*/versions/latest` is an alias to the `latest` + * [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. + * + * 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 [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] in the format + * `projects/*/secrets/*/versions/*`. + * `projects/*/secrets/*/versions/latest` is an alias to the `latest` + * [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. + * + * 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/SecretManager/src/V1beta1/ListSecretVersionsRequest.php b/SecretManager/src/V1beta1/ListSecretVersionsRequest.php new file mode 100644 index 000000000000..3088a36a6714 --- /dev/null +++ b/SecretManager/src/V1beta1/ListSecretVersionsRequest.php @@ -0,0 +1,155 @@ +google.cloud.secrets.v1beta1.ListSecretVersionsRequest + */ +class ListSecretVersionsRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The resource name of the [Secret][google.cloud.secrets.v1beta1.Secret] associated with the + * [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion] to list, in the format + * `projects/*/secrets/*`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $parent = ''; + /** + * Optional. The maximum number of results to be returned in a single page. If + * set to 0, the server decides the number of results to return. If the + * number is greater than 25000, it is capped at 25000. + * + * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $page_size = 0; + /** + * Optional. Pagination token, returned earlier via + * ListSecretVersionsResponse.next_page_token][]. + * + * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $page_token = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. The resource name of the [Secret][google.cloud.secrets.v1beta1.Secret] associated with the + * [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion] to list, in the format + * `projects/*/secrets/*`. + * @type int $page_size + * Optional. The maximum number of results to be returned in a single page. If + * set to 0, the server decides the number of results to return. If the + * number is greater than 25000, it is capped at 25000. + * @type string $page_token + * Optional. Pagination token, returned earlier via + * ListSecretVersionsResponse.next_page_token][]. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Secrets\V1Beta1\Service::initOnce(); + parent::__construct($data); + } + + /** + * Required. The resource name of the [Secret][google.cloud.secrets.v1beta1.Secret] associated with the + * [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion] to list, in the format + * `projects/*/secrets/*`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * Required. The resource name of the [Secret][google.cloud.secrets.v1beta1.Secret] associated with the + * [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion] to list, in the format + * `projects/*/secrets/*`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setParent($var) + { + GPBUtil::checkString($var, True); + $this->parent = $var; + + return $this; + } + + /** + * Optional. The maximum number of results to be returned in a single page. If + * set to 0, the server decides the number of results to return. If the + * number is greater than 25000, it is capped at 25000. + * + * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @return int + */ + public function getPageSize() + { + return $this->page_size; + } + + /** + * Optional. The maximum number of results to be returned in a single page. If + * set to 0, the server decides the number of results to return. If the + * number is greater than 25000, it is capped at 25000. + * + * 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. Pagination token, returned earlier via + * ListSecretVersionsResponse.next_page_token][]. + * + * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @return string + */ + public function getPageToken() + { + return $this->page_token; + } + + /** + * Optional. Pagination token, returned earlier via + * ListSecretVersionsResponse.next_page_token][]. + * + * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @param string $var + * @return $this + */ + public function setPageToken($var) + { + GPBUtil::checkString($var, True); + $this->page_token = $var; + + return $this; + } + +} + diff --git a/SecretManager/src/V1beta1/ListSecretVersionsResponse.php b/SecretManager/src/V1beta1/ListSecretVersionsResponse.php new file mode 100644 index 000000000000..8f5e9fd52ebb --- /dev/null +++ b/SecretManager/src/V1beta1/ListSecretVersionsResponse.php @@ -0,0 +1,143 @@ +google.cloud.secrets.v1beta1.ListSecretVersionsResponse + */ +class ListSecretVersionsResponse extends \Google\Protobuf\Internal\Message +{ + /** + * The list of [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion] sorted in reverse by + * create_time (newest first). + * + * Generated from protobuf field repeated .google.cloud.secrets.v1beta1.SecretVersion versions = 1; + */ + private $versions; + /** + * A token to retrieve the next page of results. Pass this value in + * [ListSecretVersionsRequest.page_token][google.cloud.secrets.v1beta1.ListSecretVersionsRequest.page_token] to retrieve the next page. + * + * Generated from protobuf field string next_page_token = 2; + */ + private $next_page_token = ''; + /** + * The total number of [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion]. + * + * Generated from protobuf field int32 total_size = 3; + */ + private $total_size = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\SecretManager\V1beta1\SecretVersion[]|\Google\Protobuf\Internal\RepeatedField $versions + * The list of [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion] sorted in reverse by + * create_time (newest first). + * @type string $next_page_token + * A token to retrieve the next page of results. Pass this value in + * [ListSecretVersionsRequest.page_token][google.cloud.secrets.v1beta1.ListSecretVersionsRequest.page_token] to retrieve the next page. + * @type int $total_size + * The total number of [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion]. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Secrets\V1Beta1\Service::initOnce(); + parent::__construct($data); + } + + /** + * The list of [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion] sorted in reverse by + * create_time (newest first). + * + * Generated from protobuf field repeated .google.cloud.secrets.v1beta1.SecretVersion versions = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getVersions() + { + return $this->versions; + } + + /** + * The list of [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion] sorted in reverse by + * create_time (newest first). + * + * Generated from protobuf field repeated .google.cloud.secrets.v1beta1.SecretVersion versions = 1; + * @param \Google\Cloud\SecretManager\V1beta1\SecretVersion[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setVersions($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\SecretManager\V1beta1\SecretVersion::class); + $this->versions = $arr; + + return $this; + } + + /** + * A token to retrieve the next page of results. Pass this value in + * [ListSecretVersionsRequest.page_token][google.cloud.secrets.v1beta1.ListSecretVersionsRequest.page_token] to retrieve the next page. + * + * Generated from protobuf field string next_page_token = 2; + * @return string + */ + public function getNextPageToken() + { + return $this->next_page_token; + } + + /** + * A token to retrieve the next page of results. Pass this value in + * [ListSecretVersionsRequest.page_token][google.cloud.secrets.v1beta1.ListSecretVersionsRequest.page_token] to retrieve the next page. + * + * Generated from protobuf field string next_page_token = 2; + * @param string $var + * @return $this + */ + public function setNextPageToken($var) + { + GPBUtil::checkString($var, True); + $this->next_page_token = $var; + + return $this; + } + + /** + * The total number of [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion]. + * + * Generated from protobuf field int32 total_size = 3; + * @return int + */ + public function getTotalSize() + { + return $this->total_size; + } + + /** + * The total number of [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion]. + * + * Generated from protobuf field int32 total_size = 3; + * @param int $var + * @return $this + */ + public function setTotalSize($var) + { + GPBUtil::checkInt32($var); + $this->total_size = $var; + + return $this; + } + +} + diff --git a/SecretManager/src/V1beta1/ListSecretsRequest.php b/SecretManager/src/V1beta1/ListSecretsRequest.php new file mode 100644 index 000000000000..cb6e0bead8e5 --- /dev/null +++ b/SecretManager/src/V1beta1/ListSecretsRequest.php @@ -0,0 +1,151 @@ +google.cloud.secrets.v1beta1.ListSecretsRequest + */ +class ListSecretsRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The resource name of the project associated with the + * [Secrets][google.cloud.secrets.v1beta1.Secret], in the format `projects/*`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $parent = ''; + /** + * Optional. The maximum number of results to be returned in a single page. If + * set to 0, the server decides the number of results to return. If the + * number is greater than 25000, it is capped at 25000. + * + * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $page_size = 0; + /** + * Optional. Pagination token, returned earlier via + * [ListSecretsResponse.next_page_token][google.cloud.secrets.v1beta1.ListSecretsResponse.next_page_token]. + * + * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $page_token = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. The resource name of the project associated with the + * [Secrets][google.cloud.secrets.v1beta1.Secret], in the format `projects/*`. + * @type int $page_size + * Optional. The maximum number of results to be returned in a single page. If + * set to 0, the server decides the number of results to return. If the + * number is greater than 25000, it is capped at 25000. + * @type string $page_token + * Optional. Pagination token, returned earlier via + * [ListSecretsResponse.next_page_token][google.cloud.secrets.v1beta1.ListSecretsResponse.next_page_token]. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Secrets\V1Beta1\Service::initOnce(); + parent::__construct($data); + } + + /** + * Required. The resource name of the project associated with the + * [Secrets][google.cloud.secrets.v1beta1.Secret], in the format `projects/*`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * Required. The resource name of the project associated with the + * [Secrets][google.cloud.secrets.v1beta1.Secret], in the format `projects/*`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setParent($var) + { + GPBUtil::checkString($var, True); + $this->parent = $var; + + return $this; + } + + /** + * Optional. The maximum number of results to be returned in a single page. If + * set to 0, the server decides the number of results to return. If the + * number is greater than 25000, it is capped at 25000. + * + * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @return int + */ + public function getPageSize() + { + return $this->page_size; + } + + /** + * Optional. The maximum number of results to be returned in a single page. If + * set to 0, the server decides the number of results to return. If the + * number is greater than 25000, it is capped at 25000. + * + * 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. Pagination token, returned earlier via + * [ListSecretsResponse.next_page_token][google.cloud.secrets.v1beta1.ListSecretsResponse.next_page_token]. + * + * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @return string + */ + public function getPageToken() + { + return $this->page_token; + } + + /** + * Optional. Pagination token, returned earlier via + * [ListSecretsResponse.next_page_token][google.cloud.secrets.v1beta1.ListSecretsResponse.next_page_token]. + * + * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @param string $var + * @return $this + */ + public function setPageToken($var) + { + GPBUtil::checkString($var, True); + $this->page_token = $var; + + return $this; + } + +} + diff --git a/SecretManager/src/V1beta1/ListSecretsResponse.php b/SecretManager/src/V1beta1/ListSecretsResponse.php new file mode 100644 index 000000000000..7e1b72c8ee6c --- /dev/null +++ b/SecretManager/src/V1beta1/ListSecretsResponse.php @@ -0,0 +1,143 @@ +google.cloud.secrets.v1beta1.ListSecretsResponse + */ +class ListSecretsResponse extends \Google\Protobuf\Internal\Message +{ + /** + * The list of [Secrets][google.cloud.secrets.v1beta1.Secret] sorted in reverse by create_time (newest + * first). + * + * Generated from protobuf field repeated .google.cloud.secrets.v1beta1.Secret secrets = 1; + */ + private $secrets; + /** + * A token to retrieve the next page of results. Pass this value in + * [ListSecretsRequest.page_token][google.cloud.secrets.v1beta1.ListSecretsRequest.page_token] to retrieve the next page. + * + * Generated from protobuf field string next_page_token = 2; + */ + private $next_page_token = ''; + /** + * The total number of [Secrets][google.cloud.secrets.v1beta1.Secret]. + * + * Generated from protobuf field int32 total_size = 3; + */ + private $total_size = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\SecretManager\V1beta1\Secret[]|\Google\Protobuf\Internal\RepeatedField $secrets + * The list of [Secrets][google.cloud.secrets.v1beta1.Secret] sorted in reverse by create_time (newest + * first). + * @type string $next_page_token + * A token to retrieve the next page of results. Pass this value in + * [ListSecretsRequest.page_token][google.cloud.secrets.v1beta1.ListSecretsRequest.page_token] to retrieve the next page. + * @type int $total_size + * The total number of [Secrets][google.cloud.secrets.v1beta1.Secret]. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Secrets\V1Beta1\Service::initOnce(); + parent::__construct($data); + } + + /** + * The list of [Secrets][google.cloud.secrets.v1beta1.Secret] sorted in reverse by create_time (newest + * first). + * + * Generated from protobuf field repeated .google.cloud.secrets.v1beta1.Secret secrets = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getSecrets() + { + return $this->secrets; + } + + /** + * The list of [Secrets][google.cloud.secrets.v1beta1.Secret] sorted in reverse by create_time (newest + * first). + * + * Generated from protobuf field repeated .google.cloud.secrets.v1beta1.Secret secrets = 1; + * @param \Google\Cloud\SecretManager\V1beta1\Secret[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setSecrets($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\SecretManager\V1beta1\Secret::class); + $this->secrets = $arr; + + return $this; + } + + /** + * A token to retrieve the next page of results. Pass this value in + * [ListSecretsRequest.page_token][google.cloud.secrets.v1beta1.ListSecretsRequest.page_token] to retrieve the next page. + * + * Generated from protobuf field string next_page_token = 2; + * @return string + */ + public function getNextPageToken() + { + return $this->next_page_token; + } + + /** + * A token to retrieve the next page of results. Pass this value in + * [ListSecretsRequest.page_token][google.cloud.secrets.v1beta1.ListSecretsRequest.page_token] to retrieve the next page. + * + * Generated from protobuf field string next_page_token = 2; + * @param string $var + * @return $this + */ + public function setNextPageToken($var) + { + GPBUtil::checkString($var, True); + $this->next_page_token = $var; + + return $this; + } + + /** + * The total number of [Secrets][google.cloud.secrets.v1beta1.Secret]. + * + * Generated from protobuf field int32 total_size = 3; + * @return int + */ + public function getTotalSize() + { + return $this->total_size; + } + + /** + * The total number of [Secrets][google.cloud.secrets.v1beta1.Secret]. + * + * Generated from protobuf field int32 total_size = 3; + * @param int $var + * @return $this + */ + public function setTotalSize($var) + { + GPBUtil::checkInt32($var); + $this->total_size = $var; + + return $this; + } + +} + diff --git a/SecretManager/src/V1beta1/README.md b/SecretManager/src/V1beta1/README.md new file mode 100644 index 000000000000..77ec2acfa6af --- /dev/null +++ b/SecretManager/src/V1beta1/README.md @@ -0,0 +1,31 @@ +# Secret Manager V1beta1 generated client for PHP + +### Sample + +```php +require 'vendor/autoload.php'; + +use Google\Cloud\SecretManager\V1beta1\Replication; +use Google\Cloud\SecretManager\V1beta1\Replication\Automatic; +use Google\Cloud\SecretManager\V1beta1\Secret; +use Google\Cloud\SecretManager\V1beta1\SecretManagerServiceClient; + +$client = new SecretManagerServiceClient(); + +$secret = $client->createSecret( + SecretManagerServiceClient::projectName('[MY_PROJECT_ID]'), + '[MY_SECRET_ID]', + [ + 'secret' => new Secret([ + 'replication' => new Replication([ + 'automatic' => new Automatic() + ]) + ]) + ] +); + +printf( + 'Created secret: %s' . PHP_EOL, + $secret->getName() +); +``` diff --git a/SecretManager/src/V1beta1/Replication.php b/SecretManager/src/V1beta1/Replication.php new file mode 100644 index 000000000000..27379e8b4894 --- /dev/null +++ b/SecretManager/src/V1beta1/Replication.php @@ -0,0 +1,98 @@ +google.cloud.secrets.v1beta1.Replication + */ +class Replication extends \Google\Protobuf\Internal\Message +{ + protected $replication; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\SecretManager\V1beta1\Replication\Automatic $automatic + * The [Secret][google.cloud.secrets.v1beta1.Secret] will automatically be replicated without any restrictions. + * @type \Google\Cloud\SecretManager\V1beta1\Replication\UserManaged $user_managed + * The [Secret][google.cloud.secrets.v1beta1.Secret] will only be replicated into the locations specified. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Secrets\V1Beta1\Resources::initOnce(); + parent::__construct($data); + } + + /** + * The [Secret][google.cloud.secrets.v1beta1.Secret] will automatically be replicated without any restrictions. + * + * Generated from protobuf field .google.cloud.secrets.v1beta1.Replication.Automatic automatic = 1; + * @return \Google\Cloud\SecretManager\V1beta1\Replication\Automatic + */ + public function getAutomatic() + { + return $this->readOneof(1); + } + + /** + * The [Secret][google.cloud.secrets.v1beta1.Secret] will automatically be replicated without any restrictions. + * + * Generated from protobuf field .google.cloud.secrets.v1beta1.Replication.Automatic automatic = 1; + * @param \Google\Cloud\SecretManager\V1beta1\Replication\Automatic $var + * @return $this + */ + public function setAutomatic($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\SecretManager\V1beta1\Replication_Automatic::class); + $this->writeOneof(1, $var); + + return $this; + } + + /** + * The [Secret][google.cloud.secrets.v1beta1.Secret] will only be replicated into the locations specified. + * + * Generated from protobuf field .google.cloud.secrets.v1beta1.Replication.UserManaged user_managed = 2; + * @return \Google\Cloud\SecretManager\V1beta1\Replication\UserManaged + */ + public function getUserManaged() + { + return $this->readOneof(2); + } + + /** + * The [Secret][google.cloud.secrets.v1beta1.Secret] will only be replicated into the locations specified. + * + * Generated from protobuf field .google.cloud.secrets.v1beta1.Replication.UserManaged user_managed = 2; + * @param \Google\Cloud\SecretManager\V1beta1\Replication\UserManaged $var + * @return $this + */ + public function setUserManaged($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\SecretManager\V1beta1\Replication_UserManaged::class); + $this->writeOneof(2, $var); + + return $this; + } + + /** + * @return string + */ + public function getReplication() + { + return $this->whichOneof("replication"); + } + +} + diff --git a/SecretManager/src/V1beta1/Replication/Automatic.php b/SecretManager/src/V1beta1/Replication/Automatic.php new file mode 100644 index 000000000000..e2d47f5c6494 --- /dev/null +++ b/SecretManager/src/V1beta1/Replication/Automatic.php @@ -0,0 +1,37 @@ +google.cloud.secrets.v1beta1.Replication.Automatic + */ +class Automatic extends \Google\Protobuf\Internal\Message +{ + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Secrets\V1Beta1\Resources::initOnce(); + parent::__construct($data); + } + +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(Automatic::class, \Google\Cloud\SecretManager\V1beta1\Replication_Automatic::class); + diff --git a/SecretManager/src/V1beta1/Replication/UserManaged.php b/SecretManager/src/V1beta1/Replication/UserManaged.php new file mode 100644 index 000000000000..157755461e0b --- /dev/null +++ b/SecretManager/src/V1beta1/Replication/UserManaged.php @@ -0,0 +1,75 @@ +google.cloud.secrets.v1beta1.Replication.UserManaged + */ +class UserManaged extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The list of Replicas for this [Secret][google.cloud.secrets.v1beta1.Secret]. + * Cannot be empty. + * + * Generated from protobuf field repeated .google.cloud.secrets.v1beta1.Replication.UserManaged.Replica replicas = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + private $replicas; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\SecretManager\V1beta1\Replication\UserManaged\Replica[]|\Google\Protobuf\Internal\RepeatedField $replicas + * Required. The list of Replicas for this [Secret][google.cloud.secrets.v1beta1.Secret]. + * Cannot be empty. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Secrets\V1Beta1\Resources::initOnce(); + parent::__construct($data); + } + + /** + * Required. The list of Replicas for this [Secret][google.cloud.secrets.v1beta1.Secret]. + * Cannot be empty. + * + * Generated from protobuf field repeated .google.cloud.secrets.v1beta1.Replication.UserManaged.Replica replicas = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getReplicas() + { + return $this->replicas; + } + + /** + * Required. The list of Replicas for this [Secret][google.cloud.secrets.v1beta1.Secret]. + * Cannot be empty. + * + * Generated from protobuf field repeated .google.cloud.secrets.v1beta1.Replication.UserManaged.Replica replicas = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\SecretManager\V1beta1\Replication\UserManaged\Replica[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setReplicas($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\SecretManager\V1beta1\Replication\UserManaged\Replica::class); + $this->replicas = $arr; + + return $this; + } + +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(UserManaged::class, \Google\Cloud\SecretManager\V1beta1\Replication_UserManaged::class); + diff --git a/SecretManager/src/V1beta1/Replication/UserManaged/Replica.php b/SecretManager/src/V1beta1/Replication/UserManaged/Replica.php new file mode 100644 index 000000000000..7bcf0dfba880 --- /dev/null +++ b/SecretManager/src/V1beta1/Replication/UserManaged/Replica.php @@ -0,0 +1,74 @@ +google.cloud.secrets.v1beta1.Replication.UserManaged.Replica + */ +class Replica extends \Google\Protobuf\Internal\Message +{ + /** + * The canonical IDs of the location to replicate data. + * For example: `"us-east1"`. + * + * Generated from protobuf field string location = 1; + */ + private $location = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $location + * The canonical IDs of the location to replicate data. + * For example: `"us-east1"`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Secrets\V1Beta1\Resources::initOnce(); + parent::__construct($data); + } + + /** + * The canonical IDs of the location to replicate data. + * For example: `"us-east1"`. + * + * Generated from protobuf field string location = 1; + * @return string + */ + public function getLocation() + { + return $this->location; + } + + /** + * The canonical IDs of the location to replicate data. + * For example: `"us-east1"`. + * + * Generated from protobuf field string location = 1; + * @param string $var + * @return $this + */ + public function setLocation($var) + { + GPBUtil::checkString($var, True); + $this->location = $var; + + return $this; + } + +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(Replica::class, \Google\Cloud\SecretManager\V1beta1\Replication_UserManaged_Replica::class); + diff --git a/SecretManager/src/V1beta1/Replication_Automatic.php b/SecretManager/src/V1beta1/Replication_Automatic.php new file mode 100644 index 000000000000..b0425d8555d1 --- /dev/null +++ b/SecretManager/src/V1beta1/Replication_Automatic.php @@ -0,0 +1,16 @@ +google.cloud.secrets.v1beta1.Secret + */ +class Secret extends \Google\Protobuf\Internal\Message +{ + /** + * Output only. The resource name of the [Secret][google.cloud.secrets.v1beta1.Secret] in the format `projects/*/secrets/*`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $name = ''; + /** + * Required. Immutable. The replication policy of the secret data attached to the [Secret][google.cloud.secrets.v1beta1.Secret]. + * The replication policy cannot be changed after the Secret has been created. + * + * Generated from protobuf field .google.cloud.secrets.v1beta1.Replication replication = 2 [(.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = REQUIRED]; + */ + private $replication = null; + /** + * Output only. The time at which the [Secret][google.cloud.secrets.v1beta1.Secret] was created. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $create_time = null; + /** + * The labels assigned to this Secret. + * Label keys must be between 1 and 63 characters long, have a UTF-8 encoding + * of maximum 128 bytes, and must conform to the following PCRE regular + * expression: `[\p{Ll}\p{Lo}][\p{Ll}\p{Lo}\p{N}_-]{0,62}` + * Label values must be between 0 and 63 characters long, have a UTF-8 + * encoding of maximum 128 bytes, and must conform to the following PCRE + * regular expression: `[\p{Ll}\p{Lo}\p{N}_-]{0,63}` + * No more than 64 labels can be assigned to a given resource. + * + * Generated from protobuf field map labels = 4; + */ + private $labels; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Output only. The resource name of the [Secret][google.cloud.secrets.v1beta1.Secret] in the format `projects/*/secrets/*`. + * @type \Google\Cloud\SecretManager\V1beta1\Replication $replication + * Required. Immutable. The replication policy of the secret data attached to the [Secret][google.cloud.secrets.v1beta1.Secret]. + * The replication policy cannot be changed after the Secret has been created. + * @type \Google\Protobuf\Timestamp $create_time + * Output only. The time at which the [Secret][google.cloud.secrets.v1beta1.Secret] was created. + * @type array|\Google\Protobuf\Internal\MapField $labels + * The labels assigned to this Secret. + * Label keys must be between 1 and 63 characters long, have a UTF-8 encoding + * of maximum 128 bytes, and must conform to the following PCRE regular + * expression: `[\p{Ll}\p{Lo}][\p{Ll}\p{Lo}\p{N}_-]{0,62}` + * Label values must be between 0 and 63 characters long, have a UTF-8 + * encoding of maximum 128 bytes, and must conform to the following PCRE + * regular expression: `[\p{Ll}\p{Lo}\p{N}_-]{0,63}` + * No more than 64 labels can be assigned to a given resource. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Secrets\V1Beta1\Resources::initOnce(); + parent::__construct($data); + } + + /** + * Output only. The resource name of the [Secret][google.cloud.secrets.v1beta1.Secret] in the format `projects/*/secrets/*`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Output only. The resource name of the [Secret][google.cloud.secrets.v1beta1.Secret] in the format `projects/*/secrets/*`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * Required. Immutable. The replication policy of the secret data attached to the [Secret][google.cloud.secrets.v1beta1.Secret]. + * The replication policy cannot be changed after the Secret has been created. + * + * Generated from protobuf field .google.cloud.secrets.v1beta1.Replication replication = 2 [(.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\SecretManager\V1beta1\Replication + */ + public function getReplication() + { + return $this->replication; + } + + /** + * Required. Immutable. The replication policy of the secret data attached to the [Secret][google.cloud.secrets.v1beta1.Secret]. + * The replication policy cannot be changed after the Secret has been created. + * + * Generated from protobuf field .google.cloud.secrets.v1beta1.Replication replication = 2 [(.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\SecretManager\V1beta1\Replication $var + * @return $this + */ + public function setReplication($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\SecretManager\V1beta1\Replication::class); + $this->replication = $var; + + return $this; + } + + /** + * Output only. The time at which the [Secret][google.cloud.secrets.v1beta1.Secret] was created. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Timestamp + */ + public function getCreateTime() + { + return $this->create_time; + } + + /** + * Output only. The time at which the [Secret][google.cloud.secrets.v1beta1.Secret] was created. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 3 [(.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; + } + + /** + * The labels assigned to this Secret. + * Label keys must be between 1 and 63 characters long, have a UTF-8 encoding + * of maximum 128 bytes, and must conform to the following PCRE regular + * expression: `[\p{Ll}\p{Lo}][\p{Ll}\p{Lo}\p{N}_-]{0,62}` + * Label values must be between 0 and 63 characters long, have a UTF-8 + * encoding of maximum 128 bytes, and must conform to the following PCRE + * regular expression: `[\p{Ll}\p{Lo}\p{N}_-]{0,63}` + * No more than 64 labels can be assigned to a given resource. + * + * Generated from protobuf field map labels = 4; + * @return \Google\Protobuf\Internal\MapField + */ + public function getLabels() + { + return $this->labels; + } + + /** + * The labels assigned to this Secret. + * Label keys must be between 1 and 63 characters long, have a UTF-8 encoding + * of maximum 128 bytes, and must conform to the following PCRE regular + * expression: `[\p{Ll}\p{Lo}][\p{Ll}\p{Lo}\p{N}_-]{0,62}` + * Label values must be between 0 and 63 characters long, have a UTF-8 + * encoding of maximum 128 bytes, and must conform to the following PCRE + * regular expression: `[\p{Ll}\p{Lo}\p{N}_-]{0,63}` + * No more than 64 labels can be assigned to a given resource. + * + * Generated from protobuf field map labels = 4; + * @param array|\Google\Protobuf\Internal\MapField $var + * @return $this + */ + public function setLabels($var) + { + $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::STRING); + $this->labels = $arr; + + return $this; + } + +} + diff --git a/SecretManager/src/V1beta1/SecretManagerServiceClient.php b/SecretManager/src/V1beta1/SecretManagerServiceClient.php new file mode 100644 index 000000000000..f609a0c69a69 --- /dev/null +++ b/SecretManager/src/V1beta1/SecretManagerServiceClient.php @@ -0,0 +1,38 @@ +_simpleRequest('/google.cloud.secrets.v1beta1.SecretManagerService/ListSecrets', + $argument, + ['\Google\Cloud\SecretManager\V1beta1\ListSecretsResponse', 'decode'], + $metadata, $options); + } + + /** + * Creates a new [Secret][google.cloud.secrets.v1beta1.Secret] containing no [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion]. + * @param \Google\Cloud\SecretManager\V1beta1\CreateSecretRequest $argument input argument + * @param array $metadata metadata + * @param array $options call options + */ + public function CreateSecret(\Google\Cloud\SecretManager\V1beta1\CreateSecretRequest $argument, + $metadata = [], $options = []) { + return $this->_simpleRequest('/google.cloud.secrets.v1beta1.SecretManagerService/CreateSecret', + $argument, + ['\Google\Cloud\SecretManager\V1beta1\Secret', 'decode'], + $metadata, $options); + } + + /** + * Creates a new [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] containing secret data and attaches + * it to an existing [Secret][google.cloud.secrets.v1beta1.Secret]. + * @param \Google\Cloud\SecretManager\V1beta1\AddSecretVersionRequest $argument input argument + * @param array $metadata metadata + * @param array $options call options + */ + public function AddSecretVersion(\Google\Cloud\SecretManager\V1beta1\AddSecretVersionRequest $argument, + $metadata = [], $options = []) { + return $this->_simpleRequest('/google.cloud.secrets.v1beta1.SecretManagerService/AddSecretVersion', + $argument, + ['\Google\Cloud\SecretManager\V1beta1\SecretVersion', 'decode'], + $metadata, $options); + } + + /** + * Gets metadata for a given [Secret][google.cloud.secrets.v1beta1.Secret]. + * @param \Google\Cloud\SecretManager\V1beta1\GetSecretRequest $argument input argument + * @param array $metadata metadata + * @param array $options call options + */ + public function GetSecret(\Google\Cloud\SecretManager\V1beta1\GetSecretRequest $argument, + $metadata = [], $options = []) { + return $this->_simpleRequest('/google.cloud.secrets.v1beta1.SecretManagerService/GetSecret', + $argument, + ['\Google\Cloud\SecretManager\V1beta1\Secret', 'decode'], + $metadata, $options); + } + + /** + * Updates metadata of an existing [Secret][google.cloud.secrets.v1beta1.Secret]. + * @param \Google\Cloud\SecretManager\V1beta1\UpdateSecretRequest $argument input argument + * @param array $metadata metadata + * @param array $options call options + */ + public function UpdateSecret(\Google\Cloud\SecretManager\V1beta1\UpdateSecretRequest $argument, + $metadata = [], $options = []) { + return $this->_simpleRequest('/google.cloud.secrets.v1beta1.SecretManagerService/UpdateSecret', + $argument, + ['\Google\Cloud\SecretManager\V1beta1\Secret', 'decode'], + $metadata, $options); + } + + /** + * Deletes a [Secret][google.cloud.secrets.v1beta1.Secret]. + * @param \Google\Cloud\SecretManager\V1beta1\DeleteSecretRequest $argument input argument + * @param array $metadata metadata + * @param array $options call options + */ + public function DeleteSecret(\Google\Cloud\SecretManager\V1beta1\DeleteSecretRequest $argument, + $metadata = [], $options = []) { + return $this->_simpleRequest('/google.cloud.secrets.v1beta1.SecretManagerService/DeleteSecret', + $argument, + ['\Google\Protobuf\GPBEmpty', 'decode'], + $metadata, $options); + } + + /** + * Lists [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion]. This call does not return secret + * data. + * @param \Google\Cloud\SecretManager\V1beta1\ListSecretVersionsRequest $argument input argument + * @param array $metadata metadata + * @param array $options call options + */ + public function ListSecretVersions(\Google\Cloud\SecretManager\V1beta1\ListSecretVersionsRequest $argument, + $metadata = [], $options = []) { + return $this->_simpleRequest('/google.cloud.secrets.v1beta1.SecretManagerService/ListSecretVersions', + $argument, + ['\Google\Cloud\SecretManager\V1beta1\ListSecretVersionsResponse', 'decode'], + $metadata, $options); + } + + /** + * Gets metadata for a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. + * + * `projects/*/secrets/*/versions/latest` is an alias to the `latest` + * [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. + * @param \Google\Cloud\SecretManager\V1beta1\GetSecretVersionRequest $argument input argument + * @param array $metadata metadata + * @param array $options call options + */ + public function GetSecretVersion(\Google\Cloud\SecretManager\V1beta1\GetSecretVersionRequest $argument, + $metadata = [], $options = []) { + return $this->_simpleRequest('/google.cloud.secrets.v1beta1.SecretManagerService/GetSecretVersion', + $argument, + ['\Google\Cloud\SecretManager\V1beta1\SecretVersion', 'decode'], + $metadata, $options); + } + + /** + * Accesses a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. This call returns the secret data. + * + * `projects/*/secrets/*/versions/latest` is an alias to the `latest` + * [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. + * @param \Google\Cloud\SecretManager\V1beta1\AccessSecretVersionRequest $argument input argument + * @param array $metadata metadata + * @param array $options call options + */ + public function AccessSecretVersion(\Google\Cloud\SecretManager\V1beta1\AccessSecretVersionRequest $argument, + $metadata = [], $options = []) { + return $this->_simpleRequest('/google.cloud.secrets.v1beta1.SecretManagerService/AccessSecretVersion', + $argument, + ['\Google\Cloud\SecretManager\V1beta1\AccessSecretVersionResponse', 'decode'], + $metadata, $options); + } + + /** + * Disables a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. + * + * Sets the [state][google.cloud.secrets.v1beta1.SecretVersion.state] of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to + * [DISABLED][google.cloud.secrets.v1beta1.SecretVersion.State.DISABLED]. + * @param \Google\Cloud\SecretManager\V1beta1\DisableSecretVersionRequest $argument input argument + * @param array $metadata metadata + * @param array $options call options + */ + public function DisableSecretVersion(\Google\Cloud\SecretManager\V1beta1\DisableSecretVersionRequest $argument, + $metadata = [], $options = []) { + return $this->_simpleRequest('/google.cloud.secrets.v1beta1.SecretManagerService/DisableSecretVersion', + $argument, + ['\Google\Cloud\SecretManager\V1beta1\SecretVersion', 'decode'], + $metadata, $options); + } + + /** + * Enables a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. + * + * Sets the [state][google.cloud.secrets.v1beta1.SecretVersion.state] of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to + * [ENABLED][google.cloud.secrets.v1beta1.SecretVersion.State.ENABLED]. + * @param \Google\Cloud\SecretManager\V1beta1\EnableSecretVersionRequest $argument input argument + * @param array $metadata metadata + * @param array $options call options + */ + public function EnableSecretVersion(\Google\Cloud\SecretManager\V1beta1\EnableSecretVersionRequest $argument, + $metadata = [], $options = []) { + return $this->_simpleRequest('/google.cloud.secrets.v1beta1.SecretManagerService/EnableSecretVersion', + $argument, + ['\Google\Cloud\SecretManager\V1beta1\SecretVersion', 'decode'], + $metadata, $options); + } + + /** + * Destroys a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. + * + * Sets the [state][google.cloud.secrets.v1beta1.SecretVersion.state] of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to + * [DESTROYED][google.cloud.secrets.v1beta1.SecretVersion.State.DESTROYED] and irrevocably destroys the + * secret data. + * @param \Google\Cloud\SecretManager\V1beta1\DestroySecretVersionRequest $argument input argument + * @param array $metadata metadata + * @param array $options call options + */ + public function DestroySecretVersion(\Google\Cloud\SecretManager\V1beta1\DestroySecretVersionRequest $argument, + $metadata = [], $options = []) { + return $this->_simpleRequest('/google.cloud.secrets.v1beta1.SecretManagerService/DestroySecretVersion', + $argument, + ['\Google\Cloud\SecretManager\V1beta1\SecretVersion', 'decode'], + $metadata, $options); + } + + /** + * Sets the access control policy on the specified secret. Replaces any + * existing policy. + * + * Permissions on [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion] are enforced according + * to the policy set on the associated [Secret][google.cloud.secrets.v1beta1.Secret]. + * @param \Google\Cloud\Iam\V1\SetIamPolicyRequest $argument input argument + * @param array $metadata metadata + * @param array $options call options + */ + public function SetIamPolicy(\Google\Cloud\Iam\V1\SetIamPolicyRequest $argument, + $metadata = [], $options = []) { + return $this->_simpleRequest('/google.cloud.secrets.v1beta1.SecretManagerService/SetIamPolicy', + $argument, + ['\Google\Cloud\Iam\V1\Policy', 'decode'], + $metadata, $options); + } + + /** + * Gets the access control policy for a secret. + * Returns empty policy if the secret exists and does not have a policy set. + * @param \Google\Cloud\Iam\V1\GetIamPolicyRequest $argument input argument + * @param array $metadata metadata + * @param array $options call options + */ + public function GetIamPolicy(\Google\Cloud\Iam\V1\GetIamPolicyRequest $argument, + $metadata = [], $options = []) { + return $this->_simpleRequest('/google.cloud.secrets.v1beta1.SecretManagerService/GetIamPolicy', + $argument, + ['\Google\Cloud\Iam\V1\Policy', 'decode'], + $metadata, $options); + } + + /** + * Returns permissions that a caller has for the specified secret. + * If the secret does not exist, this call returns an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building permission-aware + * UIs and command-line tools, not for authorization checking. This operation + * may "fail open" without warning. + * @param \Google\Cloud\Iam\V1\TestIamPermissionsRequest $argument input argument + * @param array $metadata metadata + * @param array $options call options + */ + public function TestIamPermissions(\Google\Cloud\Iam\V1\TestIamPermissionsRequest $argument, + $metadata = [], $options = []) { + return $this->_simpleRequest('/google.cloud.secrets.v1beta1.SecretManagerService/TestIamPermissions', + $argument, + ['\Google\Cloud\Iam\V1\TestIamPermissionsResponse', 'decode'], + $metadata, $options); + } + +} diff --git a/SecretManager/src/V1beta1/SecretPayload.php b/SecretManager/src/V1beta1/SecretPayload.php new file mode 100644 index 000000000000..bf5de718f460 --- /dev/null +++ b/SecretManager/src/V1beta1/SecretPayload.php @@ -0,0 +1,68 @@ +google.cloud.secrets.v1beta1.SecretPayload + */ +class SecretPayload extends \Google\Protobuf\Internal\Message +{ + /** + * The secret data. Must be no larger than 64KiB. + * + * Generated from protobuf field bytes data = 1; + */ + private $data = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $data + * The secret data. Must be no larger than 64KiB. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Secrets\V1Beta1\Resources::initOnce(); + parent::__construct($data); + } + + /** + * The secret data. Must be no larger than 64KiB. + * + * Generated from protobuf field bytes data = 1; + * @return string + */ + public function getData() + { + return $this->data; + } + + /** + * The secret data. Must be no larger than 64KiB. + * + * Generated from protobuf field bytes data = 1; + * @param string $var + * @return $this + */ + public function setData($var) + { + GPBUtil::checkString($var, False); + $this->data = $var; + + return $this; + } + +} + diff --git a/SecretManager/src/V1beta1/SecretVersion.php b/SecretManager/src/V1beta1/SecretVersion.php new file mode 100644 index 000000000000..887a4d151a3b --- /dev/null +++ b/SecretManager/src/V1beta1/SecretVersion.php @@ -0,0 +1,189 @@ +google.cloud.secrets.v1beta1.SecretVersion + */ +class SecretVersion extends \Google\Protobuf\Internal\Message +{ + /** + * Output only. The resource name of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] in the + * format `projects/*/secrets/*/versions/*`. + * [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] IDs in a [Secret][google.cloud.secrets.v1beta1.Secret] start at 1 and + * are incremented for each subsequent version of the secret. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $name = ''; + /** + * Output only. The time at which the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] was created. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $create_time = null; + /** + * Output only. The time this [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] was destroyed. + * Only present if [state][google.cloud.secrets.v1beta1.SecretVersion.state] is + * [DESTROYED][google.cloud.secrets.v1beta1.SecretVersion.State.DESTROYED]. + * + * Generated from protobuf field .google.protobuf.Timestamp destroy_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $destroy_time = null; + /** + * Output only. The current state of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. + * + * Generated from protobuf field .google.cloud.secrets.v1beta1.SecretVersion.State state = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $state = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Output only. The resource name of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] in the + * format `projects/*/secrets/*/versions/*`. + * [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] IDs in a [Secret][google.cloud.secrets.v1beta1.Secret] start at 1 and + * are incremented for each subsequent version of the secret. + * @type \Google\Protobuf\Timestamp $create_time + * Output only. The time at which the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] was created. + * @type \Google\Protobuf\Timestamp $destroy_time + * Output only. The time this [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] was destroyed. + * Only present if [state][google.cloud.secrets.v1beta1.SecretVersion.state] is + * [DESTROYED][google.cloud.secrets.v1beta1.SecretVersion.State.DESTROYED]. + * @type int $state + * Output only. The current state of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Secrets\V1Beta1\Resources::initOnce(); + parent::__construct($data); + } + + /** + * Output only. The resource name of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] in the + * format `projects/*/secrets/*/versions/*`. + * [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] IDs in a [Secret][google.cloud.secrets.v1beta1.Secret] start at 1 and + * are incremented for each subsequent version of the secret. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Output only. The resource name of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] in the + * format `projects/*/secrets/*/versions/*`. + * [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] IDs in a [Secret][google.cloud.secrets.v1beta1.Secret] start at 1 and + * are incremented for each subsequent version of the secret. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * Output only. The time at which the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] was created. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Timestamp + */ + public function getCreateTime() + { + return $this->create_time; + } + + /** + * Output only. The time at which the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] was created. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 2 [(.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. The time this [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] was destroyed. + * Only present if [state][google.cloud.secrets.v1beta1.SecretVersion.state] is + * [DESTROYED][google.cloud.secrets.v1beta1.SecretVersion.State.DESTROYED]. + * + * Generated from protobuf field .google.protobuf.Timestamp destroy_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Timestamp + */ + public function getDestroyTime() + { + return $this->destroy_time; + } + + /** + * Output only. The time this [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] was destroyed. + * Only present if [state][google.cloud.secrets.v1beta1.SecretVersion.state] is + * [DESTROYED][google.cloud.secrets.v1beta1.SecretVersion.State.DESTROYED]. + * + * Generated from protobuf field .google.protobuf.Timestamp destroy_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setDestroyTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->destroy_time = $var; + + return $this; + } + + /** + * Output only. The current state of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. + * + * Generated from protobuf field .google.cloud.secrets.v1beta1.SecretVersion.State state = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return int + */ + public function getState() + { + return $this->state; + } + + /** + * Output only. The current state of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. + * + * Generated from protobuf field .google.cloud.secrets.v1beta1.SecretVersion.State state = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param int $var + * @return $this + */ + public function setState($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\SecretManager\V1beta1\SecretVersion_State::class); + $this->state = $var; + + return $this; + } + +} + diff --git a/SecretManager/src/V1beta1/SecretVersion/State.php b/SecretManager/src/V1beta1/SecretVersion/State.php new file mode 100644 index 000000000000..6fe19da80e38 --- /dev/null +++ b/SecretManager/src/V1beta1/SecretVersion/State.php @@ -0,0 +1,74 @@ +google.cloud.secrets.v1beta1.SecretVersion.State + */ +class State +{ + /** + * Not specified. This value is unused and invalid. + * + * Generated from protobuf enum STATE_UNSPECIFIED = 0; + */ + const STATE_UNSPECIFIED = 0; + /** + * The [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] may be accessed. + * + * Generated from protobuf enum ENABLED = 1; + */ + const ENABLED = 1; + /** + * The [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] may not be accessed, but the secret data + * is still available and can be placed back into the [ENABLED][google.cloud.secrets.v1beta1.SecretVersion.State.ENABLED] + * state. + * + * Generated from protobuf enum DISABLED = 2; + */ + const DISABLED = 2; + /** + * The [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] is destroyed and the secret data is no longer + * stored. A version may not leave this state once entered. + * + * Generated from protobuf enum DESTROYED = 3; + */ + const DESTROYED = 3; + + private static $valueToName = [ + self::STATE_UNSPECIFIED => 'STATE_UNSPECIFIED', + self::ENABLED => 'ENABLED', + self::DISABLED => 'DISABLED', + self::DESTROYED => 'DESTROYED', + ]; + + 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); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(State::class, \Google\Cloud\SecretManager\V1beta1\SecretVersion_State::class); + diff --git a/SecretManager/src/V1beta1/SecretVersion_State.php b/SecretManager/src/V1beta1/SecretVersion_State.php new file mode 100644 index 000000000000..9f6e0e5119be --- /dev/null +++ b/SecretManager/src/V1beta1/SecretVersion_State.php @@ -0,0 +1,16 @@ +google.cloud.secrets.v1beta1.UpdateSecretRequest + */ +class UpdateSecretRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. [Secret][google.cloud.secrets.v1beta1.Secret] with updated field values. + * + * Generated from protobuf field .google.cloud.secrets.v1beta1.Secret secret = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + private $secret = null; + /** + * Required. Specifies the fields to be updated. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + private $update_mask = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\SecretManager\V1beta1\Secret $secret + * Required. [Secret][google.cloud.secrets.v1beta1.Secret] with updated field values. + * @type \Google\Protobuf\FieldMask $update_mask + * Required. Specifies the fields to be updated. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Secrets\V1Beta1\Service::initOnce(); + parent::__construct($data); + } + + /** + * Required. [Secret][google.cloud.secrets.v1beta1.Secret] with updated field values. + * + * Generated from protobuf field .google.cloud.secrets.v1beta1.Secret secret = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\SecretManager\V1beta1\Secret + */ + public function getSecret() + { + return $this->secret; + } + + /** + * Required. [Secret][google.cloud.secrets.v1beta1.Secret] with updated field values. + * + * Generated from protobuf field .google.cloud.secrets.v1beta1.Secret secret = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\SecretManager\V1beta1\Secret $var + * @return $this + */ + public function setSecret($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\SecretManager\V1beta1\Secret::class); + $this->secret = $var; + + return $this; + } + + /** + * Required. Specifies the fields to be updated. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Protobuf\FieldMask + */ + public function getUpdateMask() + { + return $this->update_mask; + } + + /** + * Required. Specifies the fields to be updated. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Protobuf\FieldMask $var + * @return $this + */ + public function setUpdateMask($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\FieldMask::class); + $this->update_mask = $var; + + return $this; + } + +} + diff --git a/SecretManager/src/V1beta1/resources/secret_manager_service_client_config.json b/SecretManager/src/V1beta1/resources/secret_manager_service_client_config.json new file mode 100644 index 000000000000..b36f5d792b6c --- /dev/null +++ b/SecretManager/src/V1beta1/resources/secret_manager_service_client_config.json @@ -0,0 +1,101 @@ +{ + "interfaces": { + "google.cloud.secrets.v1beta1.SecretManagerService": { + "retry_codes": { + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "non_idempotent": [] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 20000, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 20000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "ListSecrets": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "CreateSecret": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "AddSecretVersion": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetSecret": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "UpdateSecret": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteSecret": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListSecretVersions": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetSecretVersion": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "AccessSecretVersion": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "DisableSecretVersion": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "EnableSecretVersion": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DestroySecretVersion": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetIamPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetIamPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "TestIamPermissions": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/SecretManager/src/V1beta1/resources/secret_manager_service_descriptor_config.php b/SecretManager/src/V1beta1/resources/secret_manager_service_descriptor_config.php new file mode 100644 index 000000000000..b4c0872ad4f4 --- /dev/null +++ b/SecretManager/src/V1beta1/resources/secret_manager_service_descriptor_config.php @@ -0,0 +1,28 @@ + [ + 'google.cloud.secrets.v1beta1.SecretManagerService' => [ + 'ListSecrets' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getSecrets', + ], + ], + 'ListSecretVersions' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getVersions', + ], + ], + ], + ], +]; diff --git a/SecretManager/src/V1beta1/resources/secret_manager_service_rest_client_config.php b/SecretManager/src/V1beta1/resources/secret_manager_service_rest_client_config.php new file mode 100644 index 000000000000..42039ec51117 --- /dev/null +++ b/SecretManager/src/V1beta1/resources/secret_manager_service_rest_client_config.php @@ -0,0 +1,182 @@ + [ + 'google.cloud.secrets.v1beta1.SecretManagerService' => [ + 'ListSecrets' => [ + 'method' => 'get', + 'uriTemplate' => '/v1beta1/{parent=projects/*}/secrets', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + 'CreateSecret' => [ + 'method' => 'post', + 'uriTemplate' => '/v1beta1/{parent=projects/*}/secrets', + 'body' => 'secret', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + 'AddSecretVersion' => [ + 'method' => 'post', + 'uriTemplate' => '/v1beta1/{parent=projects/*/secrets/*}:addVersion', + 'body' => '*', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + 'GetSecret' => [ + 'method' => 'get', + 'uriTemplate' => '/v1beta1/{name=projects/*/secrets/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'UpdateSecret' => [ + 'method' => 'patch', + 'uriTemplate' => '/v1beta1/{secret.name=projects/*/secrets/*}', + 'body' => 'secret', + 'placeholders' => [ + 'secret.name' => [ + 'getters' => [ + 'getSecret', + 'getName', + ], + ], + ], + ], + 'DeleteSecret' => [ + 'method' => 'delete', + 'uriTemplate' => '/v1beta1/{name=projects/*/secrets/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'ListSecretVersions' => [ + 'method' => 'get', + 'uriTemplate' => '/v1beta1/{parent=projects/*/secrets/*}/versions', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + 'GetSecretVersion' => [ + 'method' => 'get', + 'uriTemplate' => '/v1beta1/{name=projects/*/secrets/*/versions/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'AccessSecretVersion' => [ + 'method' => 'get', + 'uriTemplate' => '/v1beta1/{name=projects/*/secrets/*/versions/*}:access', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'DisableSecretVersion' => [ + 'method' => 'post', + 'uriTemplate' => '/v1beta1/{name=projects/*/secrets/*/versions/*}:disable', + 'body' => '*', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'EnableSecretVersion' => [ + 'method' => 'post', + 'uriTemplate' => '/v1beta1/{name=projects/*/secrets/*/versions/*}:enable', + 'body' => '*', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'DestroySecretVersion' => [ + 'method' => 'post', + 'uriTemplate' => '/v1beta1/{name=projects/*/secrets/*/versions/*}:destroy', + 'body' => '*', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'SetIamPolicy' => [ + 'method' => 'post', + 'uriTemplate' => '/v1beta1/{resource=projects/*/secrets/*}:setIamPolicy', + 'body' => '*', + 'placeholders' => [ + 'resource' => [ + 'getters' => [ + 'getResource', + ], + ], + ], + ], + 'GetIamPolicy' => [ + 'method' => 'get', + 'uriTemplate' => '/v1beta1/{resource=projects/*/secrets/*}:getIamPolicy', + 'placeholders' => [ + 'resource' => [ + 'getters' => [ + 'getResource', + ], + ], + ], + ], + 'TestIamPermissions' => [ + 'method' => 'post', + 'uriTemplate' => '/v1beta1/{resource=projects/*/secrets/*}:testIamPermissions', + 'body' => '*', + 'placeholders' => [ + 'resource' => [ + 'getters' => [ + 'getResource', + ], + ], + ], + ], + ], + ], +]; diff --git a/SecretManager/synth.metadata b/SecretManager/synth.metadata new file mode 100644 index 000000000000..4bbcc7b99692 --- /dev/null +++ b/SecretManager/synth.metadata @@ -0,0 +1,32 @@ +{ + "updateTime": "2020-01-15T18:49:17.216780Z", + "sources": [ + { + "generator": { + "name": "artman", + "version": "0.44.0", + "dockerImage": "googleapis/artman@sha256:10a6d0342b8d62544810ac5ad86c3b21049ec0696608ac60175da8e513234344" + } + }, + { + "git": { + "name": "googleapis", + "remote": "https://github.com/googleapis/googleapis.git", + "sha": "50b0e8286ac988b0593bd890eb31fef6ea2f5767", + "internalRef": "289876944" + } + } + ], + "destinations": [ + { + "client": { + "source": "googleapis", + "apiName": "secrets", + "apiVersion": "v1beta1", + "language": "php", + "generator": "gapic", + "config": "google/cloud/secrets/artman_secretmanager_v1beta1.yaml" + } + } + ] +} \ No newline at end of file diff --git a/SecretManager/synth.py b/SecretManager/synth.py new file mode 100644 index 000000000000..d8efa4f983b9 --- /dev/null +++ b/SecretManager/synth.py @@ -0,0 +1,94 @@ +# Copyright 2020 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 os +import synthtool as s +import synthtool.gcp as gcp +import logging + +logging.basicConfig(level=logging.DEBUG) + +gapic = gcp.GAPICGenerator() +common = gcp.CommonTemplates() + +library = gapic.php_library( + service='secrets', + version='v1beta1', + config_path=f'/google/cloud/secrets/artman_secretmanager_v1beta1.yaml', + artman_output_name=f'google-cloud-secretmanager-v1beta1') + +# copy all src +s.move(library / f'src/V1beta1') + +# copy proto files to src also +s.move(library / f'proto/src/Google/Cloud/SecretManager', f'src/') +s.move(library / f'tests/') + +# copy GPBMetadata file to metadata +s.move(library / f'proto/src/GPBMetadata/Google/Cloud/Secrets', f'metadata/') + +# document and utilize apiEndpoint instead of serviceAddress +s.replace( + "**/Gapic/*GapicClient.php", + r"'serviceAddress' =>", + r"'apiEndpoint' =>") +s.replace( + "**/Gapic/*GapicClient.php", + r"@type string \$serviceAddress\n\s+\*\s+The address", + r"""@type string $serviceAddress + * **Deprecated**. This option will be removed in a future major release. Please + * utilize the `$apiEndpoint` option instead. + * @type string $apiEndpoint + * The address""") +s.replace( + "**/Gapic/*GapicClient.php", + r"\$transportConfig, and any \$serviceAddress", + r"$transportConfig, and any `$apiEndpoint`") + +# prevent proto messages from being marked final +s.replace( + "src/V*/**/*.php", + r"final class", + r"class") + +# Replace "Unwrapped" with "Value" for method names. +s.replace( + "src/V*/**/*.php", + r"public function ([s|g]\w{3,})Unwrapped", + r"public function \1Value" +) + +# fix year +s.replace( + 'src/**/**/*.php', + r'Copyright \d{4}', + r'Copyright 2020') +s.replace( + 'tests/**/**/*Test.php', + r'Copyright \d{4}', + r'Copyright 2020') + +# # Use new namespace in the doc sample. See +# # https://github.com/googleapis/gapic-generator/issues/2141 +# s.replace( +# 'src/V1/Gapic/SecretCenterGapicClient.php', +# r'Finding_State', +# r'Finding\\State') +# Change the wording for the deprecation warning. +s.replace( + 'src/*/*_*.php', + r'will be removed in the next major release', + 'will be removed in a future release') diff --git a/SecretManager/tests/Unit/V1beta1/SecretManagerServiceClientTest.php b/SecretManager/tests/Unit/V1beta1/SecretManagerServiceClientTest.php new file mode 100644 index 000000000000..92055622917a --- /dev/null +++ b/SecretManager/tests/Unit/V1beta1/SecretManagerServiceClientTest.php @@ -0,0 +1,1214 @@ +getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); + } + + /** + * @return SecretManagerServiceClient + */ + private function createClient(array $options = []) + { + $options += [ + 'credentials' => $this->createCredentials(), + ]; + + return new SecretManagerServiceClient($options); + } + + /** + * @test + */ + public function listSecretsTest() + { + $transport = $this->createTransport(); + $client = $this->createClient(['transport' => $transport]); + + $this->assertTrue($transport->isExhausted()); + + // Mock response + $nextPageToken = ''; + $totalSize = 705419236; + $secretsElement = new Secret(); + $secrets = [$secretsElement]; + $expectedResponse = new ListSecretsResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setTotalSize($totalSize); + $expectedResponse->setSecrets($secrets); + $transport->addResponse($expectedResponse); + + // Mock request + $formattedParent = $client->projectName('[PROJECT]'); + + $response = $client->listSecrets($formattedParent); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getSecrets()[0], $resources[0]); + + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.secrets.v1beta1.SecretManagerService/ListSecrets', $actualFuncCall); + + $actualValue = $actualRequestObject->getParent(); + + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function listSecretsExceptionTest() + { + $transport = $this->createTransport(); + $client = $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 = $client->projectName('[PROJECT]'); + + try { + $client->listSecrets($formattedParent); + // If the $client 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 createSecretTest() + { + $transport = $this->createTransport(); + $client = $this->createClient(['transport' => $transport]); + + $this->assertTrue($transport->isExhausted()); + + // Mock response + $name = 'name3373707'; + $expectedResponse = new Secret(); + $expectedResponse->setName($name); + $transport->addResponse($expectedResponse); + + // Mock request + $formattedParent = $client->projectName('[PROJECT]'); + $secretId = 'secretId-739547894'; + + $response = $client->createSecret($formattedParent, $secretId); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.secrets.v1beta1.SecretManagerService/CreateSecret', $actualFuncCall); + + $actualValue = $actualRequestObject->getParent(); + + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualRequestObject->getSecretId(); + + $this->assertProtobufEquals($secretId, $actualValue); + + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function createSecretExceptionTest() + { + $transport = $this->createTransport(); + $client = $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 = $client->projectName('[PROJECT]'); + $secretId = 'secretId-739547894'; + + try { + $client->createSecret($formattedParent, $secretId); + // If the $client 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 addSecretVersionTest() + { + $transport = $this->createTransport(); + $client = $this->createClient(['transport' => $transport]); + + $this->assertTrue($transport->isExhausted()); + + // Mock response + $name = 'name3373707'; + $expectedResponse = new SecretVersion(); + $expectedResponse->setName($name); + $transport->addResponse($expectedResponse); + + // Mock request + $formattedParent = $client->secretName('[PROJECT]', '[SECRET]'); + $payload = new SecretPayload(); + + $response = $client->addSecretVersion($formattedParent, $payload); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.secrets.v1beta1.SecretManagerService/AddSecretVersion', $actualFuncCall); + + $actualValue = $actualRequestObject->getParent(); + + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualRequestObject->getPayload(); + + $this->assertProtobufEquals($payload, $actualValue); + + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function addSecretVersionExceptionTest() + { + $transport = $this->createTransport(); + $client = $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 = $client->secretName('[PROJECT]', '[SECRET]'); + $payload = new SecretPayload(); + + try { + $client->addSecretVersion($formattedParent, $payload); + // If the $client 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 getSecretTest() + { + $transport = $this->createTransport(); + $client = $this->createClient(['transport' => $transport]); + + $this->assertTrue($transport->isExhausted()); + + // Mock response + $name2 = 'name2-1052831874'; + $expectedResponse = new Secret(); + $expectedResponse->setName($name2); + $transport->addResponse($expectedResponse); + + // Mock request + $formattedName = $client->secretName('[PROJECT]', '[SECRET]'); + + $response = $client->getSecret($formattedName); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.secrets.v1beta1.SecretManagerService/GetSecret', $actualFuncCall); + + $actualValue = $actualRequestObject->getName(); + + $this->assertProtobufEquals($formattedName, $actualValue); + + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function getSecretExceptionTest() + { + $transport = $this->createTransport(); + $client = $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 = $client->secretName('[PROJECT]', '[SECRET]'); + + try { + $client->getSecret($formattedName); + // If the $client 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 updateSecretTest() + { + $transport = $this->createTransport(); + $client = $this->createClient(['transport' => $transport]); + + $this->assertTrue($transport->isExhausted()); + + // Mock response + $name = 'name3373707'; + $expectedResponse = new Secret(); + $expectedResponse->setName($name); + $transport->addResponse($expectedResponse); + + // Mock request + $secret = new Secret(); + $updateMask = new FieldMask(); + + $response = $client->updateSecret($secret, $updateMask); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.secrets.v1beta1.SecretManagerService/UpdateSecret', $actualFuncCall); + + $actualValue = $actualRequestObject->getSecret(); + + $this->assertProtobufEquals($secret, $actualValue); + $actualValue = $actualRequestObject->getUpdateMask(); + + $this->assertProtobufEquals($updateMask, $actualValue); + + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function updateSecretExceptionTest() + { + $transport = $this->createTransport(); + $client = $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 + $secret = new Secret(); + $updateMask = new FieldMask(); + + try { + $client->updateSecret($secret, $updateMask); + // If the $client 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 deleteSecretTest() + { + $transport = $this->createTransport(); + $client = $this->createClient(['transport' => $transport]); + + $this->assertTrue($transport->isExhausted()); + + // Mock response + $expectedResponse = new GPBEmpty(); + $transport->addResponse($expectedResponse); + + // Mock request + $formattedName = $client->secretName('[PROJECT]', '[SECRET]'); + + $client->deleteSecret($formattedName); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.secrets.v1beta1.SecretManagerService/DeleteSecret', $actualFuncCall); + + $actualValue = $actualRequestObject->getName(); + + $this->assertProtobufEquals($formattedName, $actualValue); + + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function deleteSecretExceptionTest() + { + $transport = $this->createTransport(); + $client = $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 = $client->secretName('[PROJECT]', '[SECRET]'); + + try { + $client->deleteSecret($formattedName); + // If the $client 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 listSecretVersionsTest() + { + $transport = $this->createTransport(); + $client = $this->createClient(['transport' => $transport]); + + $this->assertTrue($transport->isExhausted()); + + // Mock response + $nextPageToken = ''; + $totalSize = 705419236; + $versionsElement = new SecretVersion(); + $versions = [$versionsElement]; + $expectedResponse = new ListSecretVersionsResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setTotalSize($totalSize); + $expectedResponse->setVersions($versions); + $transport->addResponse($expectedResponse); + + // Mock request + $formattedParent = $client->secretName('[PROJECT]', '[SECRET]'); + + $response = $client->listSecretVersions($formattedParent); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getVersions()[0], $resources[0]); + + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.secrets.v1beta1.SecretManagerService/ListSecretVersions', $actualFuncCall); + + $actualValue = $actualRequestObject->getParent(); + + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function listSecretVersionsExceptionTest() + { + $transport = $this->createTransport(); + $client = $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 = $client->secretName('[PROJECT]', '[SECRET]'); + + try { + $client->listSecretVersions($formattedParent); + // If the $client 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 getSecretVersionTest() + { + $transport = $this->createTransport(); + $client = $this->createClient(['transport' => $transport]); + + $this->assertTrue($transport->isExhausted()); + + // Mock response + $name2 = 'name2-1052831874'; + $expectedResponse = new SecretVersion(); + $expectedResponse->setName($name2); + $transport->addResponse($expectedResponse); + + // Mock request + $formattedName = $client->secretVersionName('[PROJECT]', '[SECRET]', '[SECRET_VERSION]'); + + $response = $client->getSecretVersion($formattedName); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.secrets.v1beta1.SecretManagerService/GetSecretVersion', $actualFuncCall); + + $actualValue = $actualRequestObject->getName(); + + $this->assertProtobufEquals($formattedName, $actualValue); + + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function getSecretVersionExceptionTest() + { + $transport = $this->createTransport(); + $client = $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 = $client->secretVersionName('[PROJECT]', '[SECRET]', '[SECRET_VERSION]'); + + try { + $client->getSecretVersion($formattedName); + // If the $client 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 accessSecretVersionTest() + { + $transport = $this->createTransport(); + $client = $this->createClient(['transport' => $transport]); + + $this->assertTrue($transport->isExhausted()); + + // Mock response + $name2 = 'name2-1052831874'; + $expectedResponse = new AccessSecretVersionResponse(); + $expectedResponse->setName($name2); + $transport->addResponse($expectedResponse); + + // Mock request + $formattedName = $client->secretVersionName('[PROJECT]', '[SECRET]', '[SECRET_VERSION]'); + + $response = $client->accessSecretVersion($formattedName); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.secrets.v1beta1.SecretManagerService/AccessSecretVersion', $actualFuncCall); + + $actualValue = $actualRequestObject->getName(); + + $this->assertProtobufEquals($formattedName, $actualValue); + + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function accessSecretVersionExceptionTest() + { + $transport = $this->createTransport(); + $client = $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 = $client->secretVersionName('[PROJECT]', '[SECRET]', '[SECRET_VERSION]'); + + try { + $client->accessSecretVersion($formattedName); + // If the $client 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 disableSecretVersionTest() + { + $transport = $this->createTransport(); + $client = $this->createClient(['transport' => $transport]); + + $this->assertTrue($transport->isExhausted()); + + // Mock response + $name2 = 'name2-1052831874'; + $expectedResponse = new SecretVersion(); + $expectedResponse->setName($name2); + $transport->addResponse($expectedResponse); + + // Mock request + $formattedName = $client->secretVersionName('[PROJECT]', '[SECRET]', '[SECRET_VERSION]'); + + $response = $client->disableSecretVersion($formattedName); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.secrets.v1beta1.SecretManagerService/DisableSecretVersion', $actualFuncCall); + + $actualValue = $actualRequestObject->getName(); + + $this->assertProtobufEquals($formattedName, $actualValue); + + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function disableSecretVersionExceptionTest() + { + $transport = $this->createTransport(); + $client = $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 = $client->secretVersionName('[PROJECT]', '[SECRET]', '[SECRET_VERSION]'); + + try { + $client->disableSecretVersion($formattedName); + // If the $client 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 enableSecretVersionTest() + { + $transport = $this->createTransport(); + $client = $this->createClient(['transport' => $transport]); + + $this->assertTrue($transport->isExhausted()); + + // Mock response + $name2 = 'name2-1052831874'; + $expectedResponse = new SecretVersion(); + $expectedResponse->setName($name2); + $transport->addResponse($expectedResponse); + + // Mock request + $formattedName = $client->secretVersionName('[PROJECT]', '[SECRET]', '[SECRET_VERSION]'); + + $response = $client->enableSecretVersion($formattedName); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.secrets.v1beta1.SecretManagerService/EnableSecretVersion', $actualFuncCall); + + $actualValue = $actualRequestObject->getName(); + + $this->assertProtobufEquals($formattedName, $actualValue); + + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function enableSecretVersionExceptionTest() + { + $transport = $this->createTransport(); + $client = $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 = $client->secretVersionName('[PROJECT]', '[SECRET]', '[SECRET_VERSION]'); + + try { + $client->enableSecretVersion($formattedName); + // If the $client 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 destroySecretVersionTest() + { + $transport = $this->createTransport(); + $client = $this->createClient(['transport' => $transport]); + + $this->assertTrue($transport->isExhausted()); + + // Mock response + $name2 = 'name2-1052831874'; + $expectedResponse = new SecretVersion(); + $expectedResponse->setName($name2); + $transport->addResponse($expectedResponse); + + // Mock request + $formattedName = $client->secretVersionName('[PROJECT]', '[SECRET]', '[SECRET_VERSION]'); + + $response = $client->destroySecretVersion($formattedName); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.secrets.v1beta1.SecretManagerService/DestroySecretVersion', $actualFuncCall); + + $actualValue = $actualRequestObject->getName(); + + $this->assertProtobufEquals($formattedName, $actualValue); + + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function destroySecretVersionExceptionTest() + { + $transport = $this->createTransport(); + $client = $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 = $client->secretVersionName('[PROJECT]', '[SECRET]', '[SECRET_VERSION]'); + + try { + $client->destroySecretVersion($formattedName); + // If the $client 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 setIamPolicyTest() + { + $transport = $this->createTransport(); + $client = $this->createClient(['transport' => $transport]); + + $this->assertTrue($transport->isExhausted()); + + // Mock response + $version = 351608024; + $etag = '21'; + $expectedResponse = new Policy(); + $expectedResponse->setVersion($version); + $expectedResponse->setEtag($etag); + $transport->addResponse($expectedResponse); + + // Mock request + $resource = 'resource-341064690'; + $policy = new Policy(); + + $response = $client->setIamPolicy($resource, $policy); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.secrets.v1beta1.SecretManagerService/SetIamPolicy', $actualFuncCall); + + $actualValue = $actualRequestObject->getResource(); + + $this->assertProtobufEquals($resource, $actualValue); + $actualValue = $actualRequestObject->getPolicy(); + + $this->assertProtobufEquals($policy, $actualValue); + + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function setIamPolicyExceptionTest() + { + $transport = $this->createTransport(); + $client = $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 + $resource = 'resource-341064690'; + $policy = new Policy(); + + try { + $client->setIamPolicy($resource, $policy); + // If the $client 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 getIamPolicyTest() + { + $transport = $this->createTransport(); + $client = $this->createClient(['transport' => $transport]); + + $this->assertTrue($transport->isExhausted()); + + // Mock response + $version = 351608024; + $etag = '21'; + $expectedResponse = new Policy(); + $expectedResponse->setVersion($version); + $expectedResponse->setEtag($etag); + $transport->addResponse($expectedResponse); + + // Mock request + $resource = 'resource-341064690'; + + $response = $client->getIamPolicy($resource); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.secrets.v1beta1.SecretManagerService/GetIamPolicy', $actualFuncCall); + + $actualValue = $actualRequestObject->getResource(); + + $this->assertProtobufEquals($resource, $actualValue); + + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function getIamPolicyExceptionTest() + { + $transport = $this->createTransport(); + $client = $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 + $resource = 'resource-341064690'; + + try { + $client->getIamPolicy($resource); + // If the $client 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 testIamPermissionsTest() + { + $transport = $this->createTransport(); + $client = $this->createClient(['transport' => $transport]); + + $this->assertTrue($transport->isExhausted()); + + // Mock response + $expectedResponse = new TestIamPermissionsResponse(); + $transport->addResponse($expectedResponse); + + // Mock request + $resource = 'resource-341064690'; + $permissions = []; + + $response = $client->testIamPermissions($resource, $permissions); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.secrets.v1beta1.SecretManagerService/TestIamPermissions', $actualFuncCall); + + $actualValue = $actualRequestObject->getResource(); + + $this->assertProtobufEquals($resource, $actualValue); + $actualValue = $actualRequestObject->getPermissions(); + + $this->assertProtobufEquals($permissions, $actualValue); + + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function testIamPermissionsExceptionTest() + { + $transport = $this->createTransport(); + $client = $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 + $resource = 'resource-341064690'; + $permissions = []; + + try { + $client->testIamPermissions($resource, $permissions); + // If the $client 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()); + } +} diff --git a/composer.json b/composer.json index cd3432e10294..d18a38f41ce0 100644 --- a/composer.json +++ b/composer.json @@ -93,6 +93,7 @@ "google/cloud-pubsub": "1.19.0", "google/cloud-redis": "0.11.0", "google/cloud-scheduler": "1.1.0", + "google/cloud-secret-manager": "master", "google/cloud-security-center": "0.2.0", "google/cloud-spanner": "1.23.0", "google/cloud-speech": "0.29.0", @@ -113,6 +114,41 @@ }, "autoload": { "psr-4": { + "GPBMetadata\\Google\\": "CommonProtos/metadata", + "GPBMetadata\\Google\\Bigtable\\": "Bigtable/metadata", + "GPBMetadata\\Google\\Cloud\\Asset\\": "Asset/metadata", + "GPBMetadata\\Google\\Cloud\\Automl\\": "AutoMl/metadata", + "GPBMetadata\\Google\\Cloud\\Bigquery\\Datatransfer\\": "BigQueryDataTransfer/metadata", + "GPBMetadata\\Google\\Cloud\\Dataproc\\": "Dataproc/metadata", + "GPBMetadata\\Google\\Cloud\\Dialogflow\\": "Dialogflow/metadata", + "GPBMetadata\\Google\\Cloud\\Iot\\": "Iot/metadata", + "GPBMetadata\\Google\\Cloud\\Kms\\": "Kms/metadata", + "GPBMetadata\\Google\\Cloud\\Language\\": "Language/metadata", + "GPBMetadata\\Google\\Cloud\\Oslogin\\": "OsLogin/metadata", + "GPBMetadata\\Google\\Cloud\\Redis\\": "Redis/metadata", + "GPBMetadata\\Google\\Cloud\\Scheduler\\": "Scheduler/metadata", + "GPBMetadata\\Google\\Cloud\\Secrets\\": "SecretManager/metadata", + "GPBMetadata\\Google\\Cloud\\Securitycenter\\": "SecurityCenter/metadata", + "GPBMetadata\\Google\\Cloud\\Speech\\": "Speech/metadata", + "GPBMetadata\\Google\\Cloud\\Talent\\": "Talent/metadata", + "GPBMetadata\\Google\\Cloud\\Tasks\\": "Tasks/metadata", + "GPBMetadata\\Google\\Cloud\\Texttospeech\\": "TextToSpeech/metadata", + "GPBMetadata\\Google\\Cloud\\Translate\\": "Translate/metadata", + "GPBMetadata\\Google\\Cloud\\Videointelligence\\": "VideoIntelligence/metadata", + "GPBMetadata\\Google\\Cloud\\Vision\\": "Vision/metadata", + "GPBMetadata\\Google\\Cloud\\Webrisk\\": "WebRisk/metadata", + "GPBMetadata\\Google\\Cloud\\Websecurityscanner\\": "WebSecurityScanner/metadata", + "GPBMetadata\\Google\\Container\\": "Container/metadata", + "GPBMetadata\\Google\\Datastore\\": "Datastore/metadata", + "GPBMetadata\\Google\\Devtools\\Clouddebugger\\": "Debugger/metadata", + "GPBMetadata\\Google\\Devtools\\Clouderrorreporting\\": "ErrorReporting/metadata", + "GPBMetadata\\Google\\Devtools\\Cloudtrace\\": "Trace/metadata", + "GPBMetadata\\Google\\Firestore\\": "Firestore/metadata", + "GPBMetadata\\Google\\Logging\\": "Logging/metadata", + "GPBMetadata\\Google\\Monitoring\\": "Monitoring/metadata", + "GPBMetadata\\Google\\Privacy\\Dlp\\": "Dlp/metadata", + "GPBMetadata\\Google\\Pubsub\\": "PubSub/metadata", + "GPBMetadata\\Google\\Spanner\\": "Spanner/metadata", "Google\\Cloud\\": [ "src", "CommonProtos/src" @@ -140,6 +176,7 @@ "Google\\Cloud\\PubSub\\": "PubSub/src", "Google\\Cloud\\Redis\\": "Redis/src", "Google\\Cloud\\Scheduler\\": "Scheduler/src", + "Google\\Cloud\\SecretManager\\": "SecretManager/src", "Google\\Cloud\\SecurityCenter\\": "SecurityCenter/src", "Google\\Cloud\\Spanner\\": "Spanner/src", "Google\\Cloud\\Speech\\": "Speech/src", @@ -152,58 +189,23 @@ "Google\\Cloud\\VideoIntelligence\\": "VideoIntelligence/src", "Google\\Cloud\\Vision\\": "Vision/src", "Google\\Cloud\\WebRisk\\": "WebRisk/src", - "Google\\Cloud\\WebSecurityScanner\\": "WebSecurityScanner/src", - "GPBMetadata\\Google\\": "CommonProtos/metadata", - "GPBMetadata\\Google\\Bigtable\\": "Bigtable/metadata", - "GPBMetadata\\Google\\Container\\": "Container/metadata", - "GPBMetadata\\Google\\Cloud\\Asset\\": "Asset/metadata", - "GPBMetadata\\Google\\Cloud\\Automl\\": "AutoMl/metadata", - "GPBMetadata\\Google\\Cloud\\Bigquery\\Datatransfer\\": "BigQueryDataTransfer/metadata", - "GPBMetadata\\Google\\Cloud\\Dataproc\\": "Dataproc/metadata", - "GPBMetadata\\Google\\Cloud\\Dialogflow\\": "Dialogflow/metadata", - "GPBMetadata\\Google\\Cloud\\Iot\\": "Iot/metadata", - "GPBMetadata\\Google\\Cloud\\Kms\\": "Kms/metadata", - "GPBMetadata\\Google\\Cloud\\Language\\": "Language/metadata", - "GPBMetadata\\Google\\Cloud\\Oslogin\\": "OsLogin/metadata", - "GPBMetadata\\Google\\Cloud\\Redis\\": "Redis/metadata", - "GPBMetadata\\Google\\Cloud\\Scheduler\\": "Scheduler/metadata", - "GPBMetadata\\Google\\Cloud\\Securitycenter\\": "SecurityCenter/metadata", - "GPBMetadata\\Google\\Cloud\\Speech\\": "Speech/metadata", - "GPBMetadata\\Google\\Cloud\\Talent\\": "Talent/metadata", - "GPBMetadata\\Google\\Cloud\\Tasks\\": "Tasks/metadata", - "GPBMetadata\\Google\\Cloud\\Texttospeech\\": "TextToSpeech/metadata", - "GPBMetadata\\Google\\Cloud\\Translate\\": "Translate/metadata", - "GPBMetadata\\Google\\Cloud\\Videointelligence\\": "VideoIntelligence/metadata", - "GPBMetadata\\Google\\Cloud\\Vision\\": "Vision/metadata", - "GPBMetadata\\Google\\Cloud\\Webrisk\\": "WebRisk/metadata", - "GPBMetadata\\Google\\Cloud\\Websecurityscanner\\": "WebSecurityScanner/metadata", - "GPBMetadata\\Google\\Datastore\\": "Datastore/metadata", - "GPBMetadata\\Google\\Devtools\\Clouddebugger\\": "Debugger/metadata", - "GPBMetadata\\Google\\Devtools\\Clouderrorreporting\\": "ErrorReporting/metadata", - "GPBMetadata\\Google\\Devtools\\Cloudtrace\\": "Trace/metadata", - "GPBMetadata\\Google\\Firestore\\": "Firestore/metadata", - "GPBMetadata\\Google\\Logging\\": "Logging/metadata", - "GPBMetadata\\Google\\Monitoring\\": "Monitoring/metadata", - "GPBMetadata\\Google\\Privacy\\Dlp\\": "Dlp/metadata", - "GPBMetadata\\Google\\Pubsub\\": "PubSub/metadata", - "GPBMetadata\\Google\\Spanner\\": "Spanner/metadata" + "Google\\Cloud\\WebSecurityScanner\\": "WebSecurityScanner/src" } }, "autoload-dev": { "psr-4": { - "Google\\Cloud\\Dev\\": "dev/src", - "Google\\Cloud\\Tests\\": "tests", - "Google\\Cloud\\CommonProtos\\Tests\\": "CommonProtos/tests", "Google\\Cloud\\Asset\\Tests\\": "Asset/tests", "Google\\Cloud\\AutoMl\\Tests\\": "AutoMl/tests", - "Google\\Cloud\\BigQuery\\Tests\\": "BigQuery/tests", "Google\\Cloud\\BigQuery\\DataTransfer\\Tests\\": "BigQueryDataTransfer/tests", + "Google\\Cloud\\BigQuery\\Tests\\": "BigQuery/tests", "Google\\Cloud\\Bigtable\\Tests\\": "Bigtable/tests", + "Google\\Cloud\\CommonProtos\\Tests\\": "CommonProtos/tests", "Google\\Cloud\\Container\\Tests\\": "Container/tests", "Google\\Cloud\\Core\\Tests\\": "Core/tests", "Google\\Cloud\\Dataproc\\Tests\\": "Dataproc/tests", "Google\\Cloud\\Datastore\\Tests\\": "Datastore/tests", "Google\\Cloud\\Debugger\\Tests\\": "Debugger/tests", + "Google\\Cloud\\Dev\\": "dev/src", "Google\\Cloud\\Dialogflow\\Tests\\": "Dialogflow/tests", "Google\\Cloud\\Dlp\\Tests\\": "Dlp/tests", "Google\\Cloud\\ErrorReporting\\Tests\\": "ErrorReporting/tests", @@ -217,12 +219,14 @@ "Google\\Cloud\\PubSub\\Tests\\": "PubSub/tests", "Google\\Cloud\\Redis\\Tests\\": "Redis/tests", "Google\\Cloud\\Scheduler\\Tests\\": "Scheduler/tests", + "Google\\Cloud\\SecretManager\\Tests\\": "SecretManager/tests", "Google\\Cloud\\SecurityCenter\\Tests\\": "SecurityCenter/tests", "Google\\Cloud\\Spanner\\Tests\\": "Spanner/tests", "Google\\Cloud\\Speech\\Tests\\": "Speech/tests", "Google\\Cloud\\Storage\\Tests\\": "Storage/tests", "Google\\Cloud\\Talent\\Tests\\": "Talent/tests", "Google\\Cloud\\Tasks\\Tests\\": "Tasks/tests", + "Google\\Cloud\\Tests\\": "tests", "Google\\Cloud\\TextToSpeech\\Tests\\": "TextToSpeech/tests", "Google\\Cloud\\Trace\\Tests\\": "Trace/tests", "Google\\Cloud\\Translate\\Tests\\": "Translate/tests", diff --git a/docs/contents/cloud-secret-manager.json b/docs/contents/cloud-secret-manager.json new file mode 100644 index 000000000000..1cb5e57aa124 --- /dev/null +++ b/docs/contents/cloud-secret-manager.json @@ -0,0 +1,24 @@ +{ + "title": "SecretManager", + "defaultService": "secretmanager\/readme", + "services": [ + { + "title": "Overview", + "type": "secretmanager\/readme" + }, + { + "title": "v1beta1", + "type": "secretmanager\/v1beta1\/readme", + "nav": [ + { + "title": "SecretManagerClient", + "type": "secretmanager\/v1beta1\/secretmanagerserviceclient" + } + ], + "patterns": [ + "secretmanager\/v1beta1\/\\w{1,}" + ] + } + ], + "pattern": "secretmanager\/\\w{1,}" +} diff --git a/docs/contents/cloud-security-center.json b/docs/contents/cloud-security-center.json index 844195333145..a5676f1e229e 100644 --- a/docs/contents/cloud-security-center.json +++ b/docs/contents/cloud-security-center.json @@ -7,7 +7,7 @@ "type": "securitycenter\/readme" }, { - "title": "v1beta1", + "title": "v1", "type": "securitycenter\/v1\/readme", "nav": [ { diff --git a/docs/contents/google-cloud.json b/docs/contents/google-cloud.json index 753f70cba4d2..749dad26ec60 100644 --- a/docs/contents/google-cloud.json +++ b/docs/contents/google-cloud.json @@ -30,6 +30,7 @@ "cloud-pubsub", "cloud-redis", "cloud-scheduler", + "cloud-secret-manager", "cloud-security-center", "cloud-spanner", "cloud-speech", diff --git a/docs/manifest.json b/docs/manifest.json index c876a7e0483b..a65d914b1e53 100644 --- a/docs/manifest.json +++ b/docs/manifest.json @@ -1225,6 +1225,14 @@ "master" ] }, + { + "id": "cloud-secret-manager", + "name": "google/cloud-secret-manager", + "defaultService": "secretmanager/readme", + "versions": [ + "master" + ] + }, { "id": "cloud-security-center", "name": "google/cloud-security-center",