From da5808821d697f4a8ea2638ab50b20b08ee89d98 Mon Sep 17 00:00:00 2001 From: hectorhammett Date: Wed, 11 Dec 2024 23:36:48 +0000 Subject: [PATCH] Add the memory store component --- .repo-metadata-full.json | 8 + Memorystore/.OwlBot.yaml | 4 + Memorystore/.gitattributes | 7 + Memorystore/.github/pull_request_template.md | 24 + Memorystore/CONTRIBUTING.md | 10 + Memorystore/LICENSE | 202 ++++ Memorystore/README.md | 50 + Memorystore/VERSION | 1 + Memorystore/composer.json | 30 + Memorystore/metadata/V1/Memorystore.php | Bin 0 -> 10235 bytes Memorystore/owlbot.py | 56 ++ Memorystore/phpunit.xml.dist | 16 + .../V1/MemorystoreClient/create_instance.php | 123 +++ .../V1/MemorystoreClient/delete_instance.php | 81 ++ .../get_certificate_authority.php | 73 ++ .../V1/MemorystoreClient/get_instance.php | 72 ++ .../V1/MemorystoreClient/get_location.php | 57 ++ .../V1/MemorystoreClient/list_instances.php | 72 ++ .../V1/MemorystoreClient/list_locations.php | 60 ++ .../V1/MemorystoreClient/update_instance.php | 102 ++ Memorystore/src/V1/CertificateAuthority.php | 117 +++ .../ManagedCertificateAuthority.php | 68 ++ .../ManagedCertificateAuthority/CertChain.php | 68 ++ .../src/V1/Client/MemorystoreClient.php | 584 +++++++++++ Memorystore/src/V1/ConnectionType.php | 68 ++ Memorystore/src/V1/CreateInstanceRequest.php | 279 ++++++ Memorystore/src/V1/DeleteInstanceRequest.php | 160 +++ Memorystore/src/V1/DiscoveryEndpoint.php | 143 +++ .../src/V1/GetCertificateAuthorityRequest.php | 91 ++ Memorystore/src/V1/GetInstanceRequest.php | 86 ++ Memorystore/src/V1/Instance.php | 881 +++++++++++++++++ .../src/V1/Instance/AuthorizationMode.php | 62 ++ .../src/V1/Instance/ConnectionDetail.php | 112 +++ .../src/V1/Instance/InstanceEndpoint.php | 74 ++ Memorystore/src/V1/Instance/Mode.php | 62 ++ Memorystore/src/V1/Instance/NodeType.php | 78 ++ Memorystore/src/V1/Instance/State.php | 76 ++ Memorystore/src/V1/Instance/StateInfo.php | 76 ++ .../src/V1/Instance/StateInfo/UpdateInfo.php | 122 +++ .../src/V1/Instance/TransitEncryptionMode.php | 62 ++ Memorystore/src/V1/ListInstancesRequest.php | 230 +++++ Memorystore/src/V1/ListInstancesResponse.php | 147 +++ Memorystore/src/V1/NodeConfig.php | 67 ++ Memorystore/src/V1/OperationMetadata.php | 307 ++++++ Memorystore/src/V1/PersistenceConfig.php | 155 +++ .../src/V1/PersistenceConfig/AOFConfig.php | 68 ++ .../AOFConfig/AppendFsync.php | 72 ++ .../V1/PersistenceConfig/PersistenceMode.php | 69 ++ .../src/V1/PersistenceConfig/RDBConfig.php | 120 +++ .../RDBConfig/SnapshotPeriod.php | 76 ++ Memorystore/src/V1/PscAutoConnection.php | 394 ++++++++ Memorystore/src/V1/PscConnection.php | 349 +++++++ Memorystore/src/V1/PscConnectionStatus.php | 61 ++ Memorystore/src/V1/UpdateInstanceRequest.php | 215 +++++ Memorystore/src/V1/ZoneDistributionConfig.php | 105 ++ .../ZoneDistributionMode.php | 63 ++ Memorystore/src/V1/gapic_metadata.json | 58 ++ .../resources/memorystore_client_config.json | 84 ++ .../memorystore_descriptor_config.php | 163 ++++ .../memorystore_rest_client_config.php | 171 ++++ .../Unit/V1/Client/MemorystoreClientTest.php | 911 ++++++++++++++++++ composer.json | 3 + 62 files changed, 8205 insertions(+) create mode 100644 Memorystore/.OwlBot.yaml create mode 100644 Memorystore/.gitattributes create mode 100644 Memorystore/.github/pull_request_template.md create mode 100644 Memorystore/CONTRIBUTING.md create mode 100644 Memorystore/LICENSE create mode 100644 Memorystore/README.md create mode 100644 Memorystore/VERSION create mode 100644 Memorystore/composer.json create mode 100644 Memorystore/metadata/V1/Memorystore.php create mode 100644 Memorystore/owlbot.py create mode 100644 Memorystore/phpunit.xml.dist create mode 100644 Memorystore/samples/V1/MemorystoreClient/create_instance.php create mode 100644 Memorystore/samples/V1/MemorystoreClient/delete_instance.php create mode 100644 Memorystore/samples/V1/MemorystoreClient/get_certificate_authority.php create mode 100644 Memorystore/samples/V1/MemorystoreClient/get_instance.php create mode 100644 Memorystore/samples/V1/MemorystoreClient/get_location.php create mode 100644 Memorystore/samples/V1/MemorystoreClient/list_instances.php create mode 100644 Memorystore/samples/V1/MemorystoreClient/list_locations.php create mode 100644 Memorystore/samples/V1/MemorystoreClient/update_instance.php create mode 100644 Memorystore/src/V1/CertificateAuthority.php create mode 100644 Memorystore/src/V1/CertificateAuthority/ManagedCertificateAuthority.php create mode 100644 Memorystore/src/V1/CertificateAuthority/ManagedCertificateAuthority/CertChain.php create mode 100644 Memorystore/src/V1/Client/MemorystoreClient.php create mode 100644 Memorystore/src/V1/ConnectionType.php create mode 100644 Memorystore/src/V1/CreateInstanceRequest.php create mode 100644 Memorystore/src/V1/DeleteInstanceRequest.php create mode 100644 Memorystore/src/V1/DiscoveryEndpoint.php create mode 100644 Memorystore/src/V1/GetCertificateAuthorityRequest.php create mode 100644 Memorystore/src/V1/GetInstanceRequest.php create mode 100644 Memorystore/src/V1/Instance.php create mode 100644 Memorystore/src/V1/Instance/AuthorizationMode.php create mode 100644 Memorystore/src/V1/Instance/ConnectionDetail.php create mode 100644 Memorystore/src/V1/Instance/InstanceEndpoint.php create mode 100644 Memorystore/src/V1/Instance/Mode.php create mode 100644 Memorystore/src/V1/Instance/NodeType.php create mode 100644 Memorystore/src/V1/Instance/State.php create mode 100644 Memorystore/src/V1/Instance/StateInfo.php create mode 100644 Memorystore/src/V1/Instance/StateInfo/UpdateInfo.php create mode 100644 Memorystore/src/V1/Instance/TransitEncryptionMode.php create mode 100644 Memorystore/src/V1/ListInstancesRequest.php create mode 100644 Memorystore/src/V1/ListInstancesResponse.php create mode 100644 Memorystore/src/V1/NodeConfig.php create mode 100644 Memorystore/src/V1/OperationMetadata.php create mode 100644 Memorystore/src/V1/PersistenceConfig.php create mode 100644 Memorystore/src/V1/PersistenceConfig/AOFConfig.php create mode 100644 Memorystore/src/V1/PersistenceConfig/AOFConfig/AppendFsync.php create mode 100644 Memorystore/src/V1/PersistenceConfig/PersistenceMode.php create mode 100644 Memorystore/src/V1/PersistenceConfig/RDBConfig.php create mode 100644 Memorystore/src/V1/PersistenceConfig/RDBConfig/SnapshotPeriod.php create mode 100644 Memorystore/src/V1/PscAutoConnection.php create mode 100644 Memorystore/src/V1/PscConnection.php create mode 100644 Memorystore/src/V1/PscConnectionStatus.php create mode 100644 Memorystore/src/V1/UpdateInstanceRequest.php create mode 100644 Memorystore/src/V1/ZoneDistributionConfig.php create mode 100644 Memorystore/src/V1/ZoneDistributionConfig/ZoneDistributionMode.php create mode 100644 Memorystore/src/V1/gapic_metadata.json create mode 100644 Memorystore/src/V1/resources/memorystore_client_config.json create mode 100644 Memorystore/src/V1/resources/memorystore_descriptor_config.php create mode 100644 Memorystore/src/V1/resources/memorystore_rest_client_config.php create mode 100644 Memorystore/tests/Unit/V1/Client/MemorystoreClientTest.php diff --git a/.repo-metadata-full.json b/.repo-metadata-full.json index e5f8c12aa5ff..42cd28982a89 100644 --- a/.repo-metadata-full.json +++ b/.repo-metadata-full.json @@ -910,6 +910,14 @@ "library_type": "GAPIC_AUTO", "api_shortname": "memcache" }, + "Memorystore": { + "language": "php", + "distribution_name": "google/cloud-memorystore", + "release_level": "preview", + "client_documentation": "https://cloud.google.com/php/docs/reference/cloud-memorystore/latest", + "library_type": "GAPIC_AUTO", + "api_shortname": "memorystore" + }, "MigrationCenter": { "language": "php", "distribution_name": "google/cloud-migrationcenter", diff --git a/Memorystore/.OwlBot.yaml b/Memorystore/.OwlBot.yaml new file mode 100644 index 000000000000..8e50e5c3b1c7 --- /dev/null +++ b/Memorystore/.OwlBot.yaml @@ -0,0 +1,4 @@ +deep-copy-regex: + - source: /google/cloud/memorystore/(v1)/.*-php/(.*) + dest: /owl-bot-staging/Memorystore/$1/$2 +api-name: Memorystore diff --git a/Memorystore/.gitattributes b/Memorystore/.gitattributes new file mode 100644 index 000000000000..4bf0fe6f415b --- /dev/null +++ b/Memorystore/.gitattributes @@ -0,0 +1,7 @@ +/*.xml.dist export-ignore +/.OwlBot.yaml export-ignore +/.github export-ignore +/owlbot.py export-ignore +/src/**/gapic_metadata.json export-ignore +/samples export-ignore +/tests export-ignore diff --git a/Memorystore/.github/pull_request_template.md b/Memorystore/.github/pull_request_template.md new file mode 100644 index 000000000000..d47ef6443478 --- /dev/null +++ b/Memorystore/.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 `Memorystore/src`, and tests in `Memorystore/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/Memorystore/CONTRIBUTING.md b/Memorystore/CONTRIBUTING.md new file mode 100644 index 000000000000..76ea811cacdb --- /dev/null +++ b/Memorystore/CONTRIBUTING.md @@ -0,0 +1,10 @@ +# How to Contribute + +We'd love to accept your patches and contributions to this project. We accept +and review pull requests against the main +[Google Cloud PHP](https://github.com/googleapis/google-cloud-php) +repository, which contains all of our client libraries. You will also need to +sign a Contributor License Agreement. For more details about how to contribute, +see the +[CONTRIBUTING.md](https://github.com/googleapis/google-cloud-php/blob/main/CONTRIBUTING.md) +file in the main Google Cloud PHP repository. diff --git a/Memorystore/LICENSE b/Memorystore/LICENSE new file mode 100644 index 000000000000..8f71f43fee3f --- /dev/null +++ b/Memorystore/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/Memorystore/README.md b/Memorystore/README.md new file mode 100644 index 000000000000..904020b1f9bc --- /dev/null +++ b/Memorystore/README.md @@ -0,0 +1,50 @@ +# Google Cloud Memorystore for PHP + +> Idiomatic PHP client for [Google Cloud Memorystore](https://cloud.google.com/memorystore). + +[![Latest Stable Version](https://poser.pugx.org/google/cloud-memorystore/v/stable)](https://packagist.org/packages/google/cloud-memorystore) [![Packagist](https://img.shields.io/packagist/dm/google/cloud-memorystore.svg)](https://packagist.org/packages/google/cloud-memorystore) + +* [API documentation](https://cloud.google.com/php/docs/reference/cloud-memorystore/latest) + +**NOTE:** This repository is part of [Google Cloud PHP](https://github.com/googleapis/google-cloud-php). Any +support requests, bug reports, or development contributions should be directed to +that project. + +### Installation + +To begin, install the preferred dependency manager for PHP, [Composer](https://getcomposer.org/). + +Now, install this component: + +```sh +$ composer require google/cloud-memorystore +``` + +> Browse the complete list of [Google Cloud APIs](https://cloud.google.com/php/docs/reference) +> for PHP + +This component supports both REST over HTTP/1.1 and gRPC. In order to take advantage of the benefits +offered by gRPC (such as streaming methods) please see our +[gRPC installation guide](https://cloud.google.com/php/grpc). + +### Authentication + +Please see our [Authentication guide](https://github.com/googleapis/google-cloud-php/blob/main/AUTHENTICATION.md) for more information +on authenticating your client. Once authenticated, you'll be ready to start making requests. + +### Sample + +See the [samples directory](https://github.com/googleapis/google-cloud-php-memorystore/tree/main/samples) for a canonical list of samples. + +### Debugging + +Please see our [Debugging guide](https://github.com/googleapis/google-cloud-php/blob/main/DEBUG.md) +for more information about the debugging tools. + +### 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/memorystore/docs/valkey). diff --git a/Memorystore/VERSION b/Memorystore/VERSION new file mode 100644 index 000000000000..77d6f4ca2371 --- /dev/null +++ b/Memorystore/VERSION @@ -0,0 +1 @@ +0.0.0 diff --git a/Memorystore/composer.json b/Memorystore/composer.json new file mode 100644 index 000000000000..f5984d5f63f1 --- /dev/null +++ b/Memorystore/composer.json @@ -0,0 +1,30 @@ +{ + "name": "google/cloud-memorystore", + "description": "Google Cloud Memorystore Client for PHP", + "license": "Apache-2.0", + "minimum-stability": "stable", + "autoload": { + "psr-4": { + "Google\\Cloud\\Memorystore\\": "src", + "GPBMetadata\\Google\\Cloud\\Memorystore\\": "metadata" + } + }, + "extra": { + "component": { + "id": "cloud-memorystore", + "path": "Memorystore", + "target": "googleapis/google-cloud-php-memorystore" + } + }, + "require": { + "php": "^8.0", + "google/gax": "^1.36.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.0" + }, + "suggest": { + "ext-grpc": "Enables use of gRPC, a universal high-performance RPC framework created by Google.", + "ext-protobuf": "Provides a significant increase in throughput over the pure PHP protobuf implementation. See https://cloud.google.com/php/grpc for installation instructions." + } +} diff --git a/Memorystore/metadata/V1/Memorystore.php b/Memorystore/metadata/V1/Memorystore.php new file mode 100644 index 0000000000000000000000000000000000000000..2b5a2da239fac7173b5cd93c7f344ffd9ab097ff GIT binary patch literal 10235 zcmds7&2JmW6*oyq79VX|8c8-yB{oCHv7^Lf%mn$Mny_eqF9@+v8dTQ?m+5+t%XwX9twhN)l^%RyXr@%(apq`+_e;>Ke%_Rr?qWW*AkSVsdOzbiD9e#dN*u1q=3LUb3NL-qQf$*&V;=TiBveBDI__aW*(?)0C2LP%#*s#q&OD)A6{objexj_T8G+ zJ+}@qXO#xiHLXy`Ig4(c@)r5=yXYQghbz3d!*+eZHza?y1hYjAy@K_E%)=BdWwAga za5bC@eJRY6*C5h16|ANbrHln}C6bA!xagb*N|o|lOQ}MXs%Kykbf`j;QLVyES8gd? zD>jt~;W5|UV@5eFOSv@|KPX*@TYd1*2>4NAhrUk6|eu=H-} zu^A?P`WRejG2onH5bCL&*hyp&&PC8PUw!(Q&u4?P0df&en~H&@UY6Q=PqSmQxM!Lv zuzuplfdF|Qh}^SxbW{C^CAze$ca&I|sr1HV!U%r)GLq+J&^})Z)1(9EY*W@O)s_^k zZSEPgl<*UPop58a6Plcf=ac-h7nIgQiFw#YPIzTin)gpbPOHS-in=K zeou`(yWrA^4jH#}5yBd3DA{|45aLQBWaAhWP{;D)!(&$423%n)ymHH4>t$awPu zEngl85Md^96qsiUY+f15lp3QidWd`vVjt-!IC{%A)mD$iiNlaEhOdt0cMpltV;-%; z+l|9(u-s9)3gb#^l)?}UMugnzDxKH@o-oUEB0zJZ35$l+mM|}L>K2V}w_=ME#7)g= zV?O98fI~*jAEe1pfp9+r&ofr9k5$UEy!*o+iUD#HrdY1VQTk|RWinPQacKF9|0@7t zR*YyFA-BC!%8C&!&5=xYGM*ln)CQ}@UR_#05&ua5p#PLS55$&DgnW`eW9ezECWUxS zdI1)lU4ylYwgqP&^;2#M7Nmpha_3;leLO&)n}I2+UAzNx!zRU25%Ie^a2)^ion1gw zu69`{#eWxox#1O3hJ_KK#aiK!Sw9?E>nBJ7qLf`Rt3DYcW$P&yqnnF{QHY$yp zm@lpt#lqYPatdbibx~**D{FHB0x%=wo5kDWT#&A8)CznhME@#?C6Vo$O1=m42bvK{ z!UbWYxn8Xo?;%ySB9*I!;p67vG~FW=iVY!GLJ0ztb5STu^zmFU`2$!Q*@VdE6}Z%_ z3zbH(DT$SQ{ci2BGcLmNh>gAz&%;tftlt*v>`<}NEasWOc>F_{b^8awZ566P^KNZe zjYXJitP6FqAmyudQK|@)Dr!O?x?WscFNY#8S)$DuNQ(w&nKDE?!d@ zJ`LwyVbZO@)kAnRIHBOtVKZGCvJ?fqJ&U2$Xy%o%J!YU%(Sp&lTpV_$U$QtFqsaCs z7~U^?42q$hLb;PLOmxB)c9`9xJ#kcly=zr#AldRfcpR%0q!wtWcd4^#wVU`}5OUch?u&NBhb#lvrZuHP-=AH2=Fif5D@$=vu zvIMi!a&Hm*0zDqs``BPw;N2rtFXZ?yexE>=vcBcA(!=I6YIrl;UI{?z9_9%H|p3NPb1zgzQ_J*Uf7(^wwAl)#v+QeMnb$y*TdJtNOR zOsLhwNQTs6x+C00#gYv;;|n&1Clc@snygVo ztWe2|qaYbYc6~H<5<=);FcAw1x8;_Y#8vm&ruX>@0*0 zd0UaFaha|7?1-Tb`rOvt2X!blozh(%>ke0GlCay29GHdHsEMsN$Y;f6KwRFVCiCkk zaXDNb5Z8jG0-f_H!`6R#mr^9}vk^D_z@hKM1q`CRV%q8!&RK26xq{kzuC1Q_^yDW~ zusDh}`2gm3WeuaeBT=x9xz(0gU_>(Iv8ghOTdK@ijatLY&cT6w{Feb(9z%q!eU^@# z(I}Raz<2(uQl+S<`5jr+;?F_Y`vd#HDSD{m34V4s`&ryPbKn0CzdE5cepDh3y*jxLvlK%d z=WPpCc0O$Dm-`S64UD~3zu1S!GDP_ePr~!A^v6gH zjo~YKinJ<)x!}qt0f-J>4k^6zF&r^%c^1wOZ@?~|uTm6*9eNqg4KLT~#j=2lK@x|v z!;3iXDj<>yWquD3@x8Gpp9SFbK%XSzUs(<8b!t#NGdBH(NO&7gzVn6PK!+dw?dzWg z)8rccGT{+N6F0rwSn&;OR(wMm^78;heEpS-f4Sw`=?Xnrb4b4Zg}^%YfRwa_A0ne~ zj2qgzMPpIU_M=QDLY1iYgZYg|V+T}8@v+!~^q$c&CPt8B0 znu7@72sH;cPpGE)7-u6(!!M`Vw+`fBg&qjb74E@FRU`ihz_~-v1sVVH^bjgn#qlL% zR5wiC@@rBcIp(cNH5u6rxNHe zqxFm6@*4XHE0w1oVWoVvJ9Yc|V|R7a`9^EtBQ5+&>q+neC(mXXeKzZ3kj>%-L7Q|K zEP6$`KS?*0ZTbOE`Vs%JpYG3{=>QoQ`VZJ3djE+~IdVw+@`#hRyLwCRrk$xXGIo9; z!-vP17=L#J>jO$S6YBn;8IN#tt%KI?gze>LX&$c&;DwLRhkGq#g| K2(}OV0RI6Qq%uPQ literal 0 HcmV?d00001 diff --git a/Memorystore/owlbot.py b/Memorystore/owlbot.py new file mode 100644 index 000000000000..950ca9be760b --- /dev/null +++ b/Memorystore/owlbot.py @@ -0,0 +1,56 @@ +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""This script is used to synthesize generated parts of this library.""" + +import logging +from pathlib import Path +import subprocess + +import synthtool as s +from synthtool.languages import php +from synthtool import _tracked_paths + +logging.basicConfig(level=logging.DEBUG) + +src = Path(f"../{php.STAGING_DIR}/Memorystore").resolve() +dest = Path().resolve() + +# Added so that we can pass copy_excludes in the owlbot_main() call +_tracked_paths.add(src) + +php.owlbot_main(src=src, dest=dest) + +# remove class_alias code +s.replace( + "src/V*/**/*.php", + r"^// Adding a class alias for backwards compatibility with the previous class name.$" + + "\n" + + r"^class_alias\(.*\);$" + + "\n", + '') + +# format generated clients +subprocess.run([ + 'npm', + 'exec', + '--yes', + '--package=@prettier/plugin-php@^0.16', + '--', + 'prettier', + '**/Client/*', + '--write', + '--parser=php', + '--single-quote', + '--print-width=120']) diff --git a/Memorystore/phpunit.xml.dist b/Memorystore/phpunit.xml.dist new file mode 100644 index 000000000000..6ddf68fcfe36 --- /dev/null +++ b/Memorystore/phpunit.xml.dist @@ -0,0 +1,16 @@ + + + + + src + + + src/V[!a-zA-Z]* + + + + + tests/Unit + + + diff --git a/Memorystore/samples/V1/MemorystoreClient/create_instance.php b/Memorystore/samples/V1/MemorystoreClient/create_instance.php new file mode 100644 index 000000000000..957600091fc7 --- /dev/null +++ b/Memorystore/samples/V1/MemorystoreClient/create_instance.php @@ -0,0 +1,123 @@ +setProjectId($instancePscAutoConnectionsProjectId) + ->setNetwork($formattedInstancePscAutoConnectionsNetwork); + $instancePscAutoConnections = [$pscAutoConnection,]; + $instance = (new Instance()) + ->setPscAutoConnections($instancePscAutoConnections); + $request = (new CreateInstanceRequest()) + ->setParent($formattedParent) + ->setInstanceId($instanceId) + ->setInstance($instance); + + // Call the API and handle any network failures. + try { + /** @var OperationResponse $response */ + $response = $memorystoreClient->createInstance($request); + $response->pollUntilComplete(); + + if ($response->operationSucceeded()) { + /** @var Instance $result */ + $result = $response->getResult(); + printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString()); + } else { + /** @var Status $error */ + $error = $response->getError(); + printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString()); + } + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample has been automatically generated and should be regarded as a code + * template only. It will require modifications to work: + * - It may require correct/in-range values for request initialization. + * - It may require specifying regional endpoints when creating the service client, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $formattedParent = MemorystoreClient::locationName('[PROJECT]', '[LOCATION]'); + $instanceId = '[INSTANCE_ID]'; + $instancePscAutoConnectionsProjectId = '[PROJECT_ID]'; + $formattedInstancePscAutoConnectionsNetwork = MemorystoreClient::networkName( + '[PROJECT]', + '[NETWORK]' + ); + + create_instance_sample( + $formattedParent, + $instanceId, + $instancePscAutoConnectionsProjectId, + $formattedInstancePscAutoConnectionsNetwork + ); +} +// [END memorystore_v1_generated_Memorystore_CreateInstance_sync] diff --git a/Memorystore/samples/V1/MemorystoreClient/delete_instance.php b/Memorystore/samples/V1/MemorystoreClient/delete_instance.php new file mode 100644 index 000000000000..fd4fb18b7ba9 --- /dev/null +++ b/Memorystore/samples/V1/MemorystoreClient/delete_instance.php @@ -0,0 +1,81 @@ +setName($formattedName); + + // Call the API and handle any network failures. + try { + /** @var OperationResponse $response */ + $response = $memorystoreClient->deleteInstance($request); + $response->pollUntilComplete(); + + if ($response->operationSucceeded()) { + printf('Operation completed successfully.' . PHP_EOL); + } else { + /** @var Status $error */ + $error = $response->getError(); + printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString()); + } + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample has been automatically generated and should be regarded as a code + * template only. It will require modifications to work: + * - It may require correct/in-range values for request initialization. + * - It may require specifying regional endpoints when creating the service client, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $formattedName = MemorystoreClient::instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); + + delete_instance_sample($formattedName); +} +// [END memorystore_v1_generated_Memorystore_DeleteInstance_sync] diff --git a/Memorystore/samples/V1/MemorystoreClient/get_certificate_authority.php b/Memorystore/samples/V1/MemorystoreClient/get_certificate_authority.php new file mode 100644 index 000000000000..eb2121794494 --- /dev/null +++ b/Memorystore/samples/V1/MemorystoreClient/get_certificate_authority.php @@ -0,0 +1,73 @@ +setName($formattedName); + + // Call the API and handle any network failures. + try { + /** @var CertificateAuthority $response */ + $response = $memorystoreClient->getCertificateAuthority($request); + printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample has been automatically generated and should be regarded as a code + * template only. It will require modifications to work: + * - It may require correct/in-range values for request initialization. + * - It may require specifying regional endpoints when creating the service client, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $formattedName = MemorystoreClient::instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); + + get_certificate_authority_sample($formattedName); +} +// [END memorystore_v1_generated_Memorystore_GetCertificateAuthority_sync] diff --git a/Memorystore/samples/V1/MemorystoreClient/get_instance.php b/Memorystore/samples/V1/MemorystoreClient/get_instance.php new file mode 100644 index 000000000000..9376db145086 --- /dev/null +++ b/Memorystore/samples/V1/MemorystoreClient/get_instance.php @@ -0,0 +1,72 @@ +setName($formattedName); + + // Call the API and handle any network failures. + try { + /** @var Instance $response */ + $response = $memorystoreClient->getInstance($request); + printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample has been automatically generated and should be regarded as a code + * template only. It will require modifications to work: + * - It may require correct/in-range values for request initialization. + * - It may require specifying regional endpoints when creating the service client, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $formattedName = MemorystoreClient::instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); + + get_instance_sample($formattedName); +} +// [END memorystore_v1_generated_Memorystore_GetInstance_sync] diff --git a/Memorystore/samples/V1/MemorystoreClient/get_location.php b/Memorystore/samples/V1/MemorystoreClient/get_location.php new file mode 100644 index 000000000000..d6d06c0f124b --- /dev/null +++ b/Memorystore/samples/V1/MemorystoreClient/get_location.php @@ -0,0 +1,57 @@ +getLocation($request); + printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} +// [END memorystore_v1_generated_Memorystore_GetLocation_sync] diff --git a/Memorystore/samples/V1/MemorystoreClient/list_instances.php b/Memorystore/samples/V1/MemorystoreClient/list_instances.php new file mode 100644 index 000000000000..bdd720977a71 --- /dev/null +++ b/Memorystore/samples/V1/MemorystoreClient/list_instances.php @@ -0,0 +1,72 @@ +setParent($formattedParent); + + // Call the API and handle any network failures. + try { + /** @var ListInstancesResponse $response */ + $response = $memorystoreClient->listInstances($request); + printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample has been automatically generated and should be regarded as a code + * template only. It will require modifications to work: + * - It may require correct/in-range values for request initialization. + * - It may require specifying regional endpoints when creating the service client, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $formattedParent = MemorystoreClient::locationName('[PROJECT]', '[LOCATION]'); + + list_instances_sample($formattedParent); +} +// [END memorystore_v1_generated_Memorystore_ListInstances_sync] diff --git a/Memorystore/samples/V1/MemorystoreClient/list_locations.php b/Memorystore/samples/V1/MemorystoreClient/list_locations.php new file mode 100644 index 000000000000..6b2a92cce2d2 --- /dev/null +++ b/Memorystore/samples/V1/MemorystoreClient/list_locations.php @@ -0,0 +1,60 @@ +listLocations($request); + + foreach ($response as $element) { + printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString()); + } + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} +// [END memorystore_v1_generated_Memorystore_ListLocations_sync] diff --git a/Memorystore/samples/V1/MemorystoreClient/update_instance.php b/Memorystore/samples/V1/MemorystoreClient/update_instance.php new file mode 100644 index 000000000000..6f538d27d951 --- /dev/null +++ b/Memorystore/samples/V1/MemorystoreClient/update_instance.php @@ -0,0 +1,102 @@ +setProjectId($instancePscAutoConnectionsProjectId) + ->setNetwork($formattedInstancePscAutoConnectionsNetwork); + $instancePscAutoConnections = [$pscAutoConnection,]; + $instance = (new Instance()) + ->setPscAutoConnections($instancePscAutoConnections); + $request = (new UpdateInstanceRequest()) + ->setInstance($instance); + + // Call the API and handle any network failures. + try { + /** @var OperationResponse $response */ + $response = $memorystoreClient->updateInstance($request); + $response->pollUntilComplete(); + + if ($response->operationSucceeded()) { + /** @var Instance $result */ + $result = $response->getResult(); + printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString()); + } else { + /** @var Status $error */ + $error = $response->getError(); + printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString()); + } + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample has been automatically generated and should be regarded as a code + * template only. It will require modifications to work: + * - It may require correct/in-range values for request initialization. + * - It may require specifying regional endpoints when creating the service client, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $instancePscAutoConnectionsProjectId = '[PROJECT_ID]'; + $formattedInstancePscAutoConnectionsNetwork = MemorystoreClient::networkName( + '[PROJECT]', + '[NETWORK]' + ); + + update_instance_sample( + $instancePscAutoConnectionsProjectId, + $formattedInstancePscAutoConnectionsNetwork + ); +} +// [END memorystore_v1_generated_Memorystore_UpdateInstance_sync] diff --git a/Memorystore/src/V1/CertificateAuthority.php b/Memorystore/src/V1/CertificateAuthority.php new file mode 100644 index 000000000000..9792a18178eb --- /dev/null +++ b/Memorystore/src/V1/CertificateAuthority.php @@ -0,0 +1,117 @@ +google.cloud.memorystore.v1.CertificateAuthority + */ +class CertificateAuthority extends \Google\Protobuf\Internal\Message +{ + /** + * Identifier. Unique name of the certificate authority. + * Format: + * projects/{project}/locations/{location}/instances/{instance} + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = IDENTIFIER]; + */ + protected $name = ''; + protected $server_ca; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Memorystore\V1\CertificateAuthority\ManagedCertificateAuthority $managed_server_ca + * A managed server certificate authority. + * @type string $name + * Identifier. Unique name of the certificate authority. + * Format: + * projects/{project}/locations/{location}/instances/{instance} + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Memorystore\V1\Memorystore::initOnce(); + parent::__construct($data); + } + + /** + * A managed server certificate authority. + * + * Generated from protobuf field .google.cloud.memorystore.v1.CertificateAuthority.ManagedCertificateAuthority managed_server_ca = 2; + * @return \Google\Cloud\Memorystore\V1\CertificateAuthority\ManagedCertificateAuthority|null + */ + public function getManagedServerCa() + { + return $this->readOneof(2); + } + + public function hasManagedServerCa() + { + return $this->hasOneof(2); + } + + /** + * A managed server certificate authority. + * + * Generated from protobuf field .google.cloud.memorystore.v1.CertificateAuthority.ManagedCertificateAuthority managed_server_ca = 2; + * @param \Google\Cloud\Memorystore\V1\CertificateAuthority\ManagedCertificateAuthority $var + * @return $this + */ + public function setManagedServerCa($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Memorystore\V1\CertificateAuthority\ManagedCertificateAuthority::class); + $this->writeOneof(2, $var); + + return $this; + } + + /** + * Identifier. Unique name of the certificate authority. + * Format: + * projects/{project}/locations/{location}/instances/{instance} + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = IDENTIFIER]; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Identifier. Unique name of the certificate authority. + * Format: + * projects/{project}/locations/{location}/instances/{instance} + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = IDENTIFIER]; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * @return string + */ + public function getServerCa() + { + return $this->whichOneof("server_ca"); + } + +} + diff --git a/Memorystore/src/V1/CertificateAuthority/ManagedCertificateAuthority.php b/Memorystore/src/V1/CertificateAuthority/ManagedCertificateAuthority.php new file mode 100644 index 000000000000..59a45ad1c186 --- /dev/null +++ b/Memorystore/src/V1/CertificateAuthority/ManagedCertificateAuthority.php @@ -0,0 +1,68 @@ +google.cloud.memorystore.v1.CertificateAuthority.ManagedCertificateAuthority + */ +class ManagedCertificateAuthority extends \Google\Protobuf\Internal\Message +{ + /** + * PEM encoded CA certificate chains for managed server authentication. + * + * Generated from protobuf field repeated .google.cloud.memorystore.v1.CertificateAuthority.ManagedCertificateAuthority.CertChain ca_certs = 1; + */ + private $ca_certs; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\Google\Cloud\Memorystore\V1\CertificateAuthority\ManagedCertificateAuthority\CertChain>|\Google\Protobuf\Internal\RepeatedField $ca_certs + * PEM encoded CA certificate chains for managed server authentication. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Memorystore\V1\Memorystore::initOnce(); + parent::__construct($data); + } + + /** + * PEM encoded CA certificate chains for managed server authentication. + * + * Generated from protobuf field repeated .google.cloud.memorystore.v1.CertificateAuthority.ManagedCertificateAuthority.CertChain ca_certs = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getCaCerts() + { + return $this->ca_certs; + } + + /** + * PEM encoded CA certificate chains for managed server authentication. + * + * Generated from protobuf field repeated .google.cloud.memorystore.v1.CertificateAuthority.ManagedCertificateAuthority.CertChain ca_certs = 1; + * @param array<\Google\Cloud\Memorystore\V1\CertificateAuthority\ManagedCertificateAuthority\CertChain>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setCaCerts($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Memorystore\V1\CertificateAuthority\ManagedCertificateAuthority\CertChain::class); + $this->ca_certs = $arr; + + return $this; + } + +} + + diff --git a/Memorystore/src/V1/CertificateAuthority/ManagedCertificateAuthority/CertChain.php b/Memorystore/src/V1/CertificateAuthority/ManagedCertificateAuthority/CertChain.php new file mode 100644 index 000000000000..2158ed6972f7 --- /dev/null +++ b/Memorystore/src/V1/CertificateAuthority/ManagedCertificateAuthority/CertChain.php @@ -0,0 +1,68 @@ +google.cloud.memorystore.v1.CertificateAuthority.ManagedCertificateAuthority.CertChain + */ +class CertChain extends \Google\Protobuf\Internal\Message +{ + /** + * The certificates that form the CA chain in order of leaf to root. + * + * Generated from protobuf field repeated string certificates = 1; + */ + private $certificates; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array|\Google\Protobuf\Internal\RepeatedField $certificates + * The certificates that form the CA chain in order of leaf to root. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Memorystore\V1\Memorystore::initOnce(); + parent::__construct($data); + } + + /** + * The certificates that form the CA chain in order of leaf to root. + * + * Generated from protobuf field repeated string certificates = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getCertificates() + { + return $this->certificates; + } + + /** + * The certificates that form the CA chain in order of leaf to root. + * + * Generated from protobuf field repeated string certificates = 1; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setCertificates($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->certificates = $arr; + + return $this; + } + +} + + diff --git a/Memorystore/src/V1/Client/MemorystoreClient.php b/Memorystore/src/V1/Client/MemorystoreClient.php new file mode 100644 index 000000000000..2d0db7e5a657 --- /dev/null +++ b/Memorystore/src/V1/Client/MemorystoreClient.php @@ -0,0 +1,584 @@ + createInstanceAsync(CreateInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteInstanceAsync(DeleteInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getCertificateAuthorityAsync(GetCertificateAuthorityRequest $request, array $optionalArgs = []) + * @method PromiseInterface getInstanceAsync(GetInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface listInstancesAsync(ListInstancesRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateInstanceAsync(UpdateInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) + */ +final class MemorystoreClient +{ + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.memorystore.v1.Memorystore'; + + /** + * The default address of the service. + * + * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. + */ + private const SERVICE_ADDRESS = 'memorystore.googleapis.com'; + + /** The address template of the service. */ + private const SERVICE_ADDRESS_TEMPLATE = 'memorystore.UNIVERSE_DOMAIN'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/memorystore_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/memorystore_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/memorystore_rest_client_config.php', + ], + ], + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements ClientOptionsTrait::supportedTransports. */ + private static function supportedTransports() + { + return ['rest']; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) + ? $this->descriptors[$methodName]['longRunning'] + : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Create the default operation client for the service. + * + * @param array $options ClientOptions for the client. + * + * @return OperationsClient + */ + private function createOperationsClient(array $options) + { + // Unset client-specific configuration options + unset($options['serviceName'], $options['clientConfig'], $options['descriptorsConfigPath']); + + if (isset($options['operationsClient'])) { + return $options['operationsClient']; + } + + return new OperationsClient($options); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * forwarding_rule resource. + * + * @param string $project + * @param string $region + * @param string $forwardingRule + * + * @return string The formatted forwarding_rule resource. + */ + public static function forwardingRuleName(string $project, string $region, string $forwardingRule): string + { + return self::getPathTemplate('forwardingRule')->render([ + 'project' => $project, + 'region' => $region, + 'forwarding_rule' => $forwardingRule, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a instance + * resource. + * + * @param string $project + * @param string $location + * @param string $instance + * + * @return string The formatted instance resource. + */ + public static function instanceName(string $project, string $location, string $instance): string + { + return self::getPathTemplate('instance')->render([ + 'project' => $project, + 'location' => $location, + 'instance' => $instance, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a network + * resource. + * + * @param string $project + * @param string $network + * + * @return string The formatted network resource. + */ + public static function networkName(string $project, string $network): string + { + return self::getPathTemplate('network')->render([ + 'project' => $project, + 'network' => $network, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * service_attachment resource. + * + * @param string $project + * @param string $region + * @param string $serviceAttachment + * + * @return string The formatted service_attachment resource. + */ + public static function serviceAttachmentName(string $project, string $region, string $serviceAttachment): string + { + return self::getPathTemplate('serviceAttachment')->render([ + 'project' => $project, + 'region' => $region, + 'service_attachment' => $serviceAttachment, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - forwardingRule: projects/{project}/regions/{region}/forwardingRules/{forwarding_rule} + * - instance: projects/{project}/locations/{location}/instances/{instance} + * - location: projects/{project}/locations/{location} + * - network: projects/{project}/global/networks/{network} + * - serviceAttachment: projects/{project}/regions/{region}/serviceAttachments/{service_attachment} + * + * The optional $template argument can be supplied to specify a particular pattern, + * and must match one of the templates listed above. If no $template argument is + * provided, or if the $template argument does not match one of the templates + * listed, then parseName will check each of the supported templates, and return + * the first match. + * + * @param string $formattedName The formatted name string + * @param ?string $template Optional name of template to match + * + * @return array An associative array from name component IDs to component values. + * + * @throws ValidationException If $formattedName could not be matched. + */ + public static function parseName(string $formattedName, ?string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * Constructor. + * + * @param array $options { + * Optional. Options for configuring the service API wrapper. + * + * @type string $apiEndpoint + * The address of the API remote host. May optionally include the port, formatted + * as ":". Default 'memorystore.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method for the + * supported options. + * @type callable $clientCertSource + * A callable which returns the client cert as a string. This can be used to + * provide a certificate and private key to the transport layer for mTLS. + * @type false|LoggerInterface $logger + * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the + * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * } + * + * @throws ValidationException + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a new Instance in a given project and location. + * + * The async variant is {@see MemorystoreClient::createInstanceAsync()} . + * + * @example samples/V1/MemorystoreClient/create_instance.php + * + * @param CreateInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createInstance(CreateInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateInstance', $request, $callOptions)->wait(); + } + + /** + * Deletes a single Instance. + * + * The async variant is {@see MemorystoreClient::deleteInstanceAsync()} . + * + * @example samples/V1/MemorystoreClient/delete_instance.php + * + * @param DeleteInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteInstance(DeleteInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteInstance', $request, $callOptions)->wait(); + } + + /** + * Gets details about the certificate authority for an Instance. + * + * The async variant is {@see MemorystoreClient::getCertificateAuthorityAsync()} . + * + * @example samples/V1/MemorystoreClient/get_certificate_authority.php + * + * @param GetCertificateAuthorityRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return CertificateAuthority + * + * @throws ApiException Thrown if the API call fails. + */ + public function getCertificateAuthority( + GetCertificateAuthorityRequest $request, + array $callOptions = [] + ): CertificateAuthority { + return $this->startApiCall('GetCertificateAuthority', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single Instance. + * + * The async variant is {@see MemorystoreClient::getInstanceAsync()} . + * + * @example samples/V1/MemorystoreClient/get_instance.php + * + * @param GetInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return Instance + * + * @throws ApiException Thrown if the API call fails. + */ + public function getInstance(GetInstanceRequest $request, array $callOptions = []): Instance + { + return $this->startApiCall('GetInstance', $request, $callOptions)->wait(); + } + + /** + * Lists Instances in a given project and location. + * + * The async variant is {@see MemorystoreClient::listInstancesAsync()} . + * + * @example samples/V1/MemorystoreClient/list_instances.php + * + * @param ListInstancesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return ListInstancesResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listInstances(ListInstancesRequest $request, array $callOptions = []): ListInstancesResponse + { + return $this->startApiCall('ListInstances', $request, $callOptions)->wait(); + } + + /** + * Updates the parameters of a single Instance. + * + * The async variant is {@see MemorystoreClient::updateInstanceAsync()} . + * + * @example samples/V1/MemorystoreClient/update_instance.php + * + * @param UpdateInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateInstance(UpdateInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateInstance', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see MemorystoreClient::getLocationAsync()} . + * + * @example samples/V1/MemorystoreClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see MemorystoreClient::listLocationsAsync()} . + * + * @example samples/V1/MemorystoreClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } +} diff --git a/Memorystore/src/V1/ConnectionType.php b/Memorystore/src/V1/ConnectionType.php new file mode 100644 index 000000000000..64a1b5bfe162 --- /dev/null +++ b/Memorystore/src/V1/ConnectionType.php @@ -0,0 +1,68 @@ +google.cloud.memorystore.v1.ConnectionType + */ +class ConnectionType +{ + /** + * Connection Type is not set + * + * Generated from protobuf enum CONNECTION_TYPE_UNSPECIFIED = 0; + */ + const CONNECTION_TYPE_UNSPECIFIED = 0; + /** + * Connection that will be used for topology discovery. + * + * Generated from protobuf enum CONNECTION_TYPE_DISCOVERY = 1; + */ + const CONNECTION_TYPE_DISCOVERY = 1; + /** + * Connection that will be used as primary endpoint to access primary. + * + * Generated from protobuf enum CONNECTION_TYPE_PRIMARY = 2; + */ + const CONNECTION_TYPE_PRIMARY = 2; + /** + * Connection that will be used as reader endpoint to access replicas. + * + * Generated from protobuf enum CONNECTION_TYPE_READER = 3; + */ + const CONNECTION_TYPE_READER = 3; + + private static $valueToName = [ + self::CONNECTION_TYPE_UNSPECIFIED => 'CONNECTION_TYPE_UNSPECIFIED', + self::CONNECTION_TYPE_DISCOVERY => 'CONNECTION_TYPE_DISCOVERY', + self::CONNECTION_TYPE_PRIMARY => 'CONNECTION_TYPE_PRIMARY', + self::CONNECTION_TYPE_READER => 'CONNECTION_TYPE_READER', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + diff --git a/Memorystore/src/V1/CreateInstanceRequest.php b/Memorystore/src/V1/CreateInstanceRequest.php new file mode 100644 index 000000000000..92db845d67a7 --- /dev/null +++ b/Memorystore/src/V1/CreateInstanceRequest.php @@ -0,0 +1,279 @@ +google.cloud.memorystore.v1.CreateInstanceRequest + */ +class CreateInstanceRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The parent resource where this instance will be created. + * Format: projects/{project}/locations/{location} + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $parent = ''; + /** + * Required. The ID to use for the instance, which will become the final + * component of the instance's resource name. + * This value is subject to the following restrictions: + * * Must be 4-63 characters in length + * * Must begin with a letter or digit + * * Must contain only lowercase letters, digits, and hyphens + * * Must not end with a hyphen + * * Must be unique within a location + * + * Generated from protobuf field string instance_id = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $instance_id = ''; + /** + * Required. The instance to create. + * + * Generated from protobuf field .google.cloud.memorystore.v1.Instance instance = 3 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $instance = null; + /** + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes since the first request. + * For example, consider a situation where you make an initial request and the + * request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * + * Generated from protobuf field string request_id = 4 [(.google.api.field_behavior) = OPTIONAL, (.google.api.field_info) = { + */ + protected $request_id = ''; + + /** + * @param string $parent Required. The parent resource where this instance will be created. + * Format: projects/{project}/locations/{location} + * Please see {@see MemorystoreClient::locationName()} for help formatting this field. + * @param \Google\Cloud\Memorystore\V1\Instance $instance Required. The instance to create. + * @param string $instanceId Required. The ID to use for the instance, which will become the final + * component of the instance's resource name. + * + * This value is subject to the following restrictions: + * + * * Must be 4-63 characters in length + * * Must begin with a letter or digit + * * Must contain only lowercase letters, digits, and hyphens + * * Must not end with a hyphen + * * Must be unique within a location + * + * @return \Google\Cloud\Memorystore\V1\CreateInstanceRequest + * + * @experimental + */ + public static function build(string $parent, \Google\Cloud\Memorystore\V1\Instance $instance, string $instanceId): self + { + return (new self()) + ->setParent($parent) + ->setInstance($instance) + ->setInstanceId($instanceId); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. The parent resource where this instance will be created. + * Format: projects/{project}/locations/{location} + * @type string $instance_id + * Required. The ID to use for the instance, which will become the final + * component of the instance's resource name. + * This value is subject to the following restrictions: + * * Must be 4-63 characters in length + * * Must begin with a letter or digit + * * Must contain only lowercase letters, digits, and hyphens + * * Must not end with a hyphen + * * Must be unique within a location + * @type \Google\Cloud\Memorystore\V1\Instance $instance + * Required. The instance to create. + * @type string $request_id + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes since the first request. + * For example, consider a situation where you make an initial request and the + * request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Memorystore\V1\Memorystore::initOnce(); + parent::__construct($data); + } + + /** + * Required. The parent resource where this instance will be created. + * Format: projects/{project}/locations/{location} + * + * 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 parent resource where this instance will be created. + * Format: projects/{project}/locations/{location} + * + * 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 ID to use for the instance, which will become the final + * component of the instance's resource name. + * This value is subject to the following restrictions: + * * Must be 4-63 characters in length + * * Must begin with a letter or digit + * * Must contain only lowercase letters, digits, and hyphens + * * Must not end with a hyphen + * * Must be unique within a location + * + * Generated from protobuf field string instance_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getInstanceId() + { + return $this->instance_id; + } + + /** + * Required. The ID to use for the instance, which will become the final + * component of the instance's resource name. + * This value is subject to the following restrictions: + * * Must be 4-63 characters in length + * * Must begin with a letter or digit + * * Must contain only lowercase letters, digits, and hyphens + * * Must not end with a hyphen + * * Must be unique within a location + * + * Generated from protobuf field string instance_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setInstanceId($var) + { + GPBUtil::checkString($var, True); + $this->instance_id = $var; + + return $this; + } + + /** + * Required. The instance to create. + * + * Generated from protobuf field .google.cloud.memorystore.v1.Instance instance = 3 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\Memorystore\V1\Instance|null + */ + public function getInstance() + { + return $this->instance; + } + + public function hasInstance() + { + return isset($this->instance); + } + + public function clearInstance() + { + unset($this->instance); + } + + /** + * Required. The instance to create. + * + * Generated from protobuf field .google.cloud.memorystore.v1.Instance instance = 3 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\Memorystore\V1\Instance $var + * @return $this + */ + public function setInstance($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Memorystore\V1\Instance::class); + $this->instance = $var; + + return $this; + } + + /** + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes since the first request. + * For example, consider a situation where you make an initial request and the + * request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * + * Generated from protobuf field string request_id = 4 [(.google.api.field_behavior) = OPTIONAL, (.google.api.field_info) = { + * @return string + */ + public function getRequestId() + { + return $this->request_id; + } + + /** + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes since the first request. + * For example, consider a situation where you make an initial request and the + * request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * + * Generated from protobuf field string request_id = 4 [(.google.api.field_behavior) = OPTIONAL, (.google.api.field_info) = { + * @param string $var + * @return $this + */ + public function setRequestId($var) + { + GPBUtil::checkString($var, True); + $this->request_id = $var; + + return $this; + } + +} + diff --git a/Memorystore/src/V1/DeleteInstanceRequest.php b/Memorystore/src/V1/DeleteInstanceRequest.php new file mode 100644 index 000000000000..c3c9cdd18d60 --- /dev/null +++ b/Memorystore/src/V1/DeleteInstanceRequest.php @@ -0,0 +1,160 @@ +google.cloud.memorystore.v1.DeleteInstanceRequest + */ +class DeleteInstanceRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The name of the instance to delete. + * Format: projects/{project}/locations/{location}/instances/{instance} + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $name = ''; + /** + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes after the first request. + * For example, consider a situation where you make an initial request and the + * request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * + * Generated from protobuf field string request_id = 2 [(.google.api.field_behavior) = OPTIONAL, (.google.api.field_info) = { + */ + protected $request_id = ''; + + /** + * @param string $name Required. The name of the instance to delete. + * Format: projects/{project}/locations/{location}/instances/{instance} + * Please see {@see MemorystoreClient::instanceName()} for help formatting this field. + * + * @return \Google\Cloud\Memorystore\V1\DeleteInstanceRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. The name of the instance to delete. + * Format: projects/{project}/locations/{location}/instances/{instance} + * @type string $request_id + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes after the first request. + * For example, consider a situation where you make an initial request and the + * request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Memorystore\V1\Memorystore::initOnce(); + parent::__construct($data); + } + + /** + * Required. The name of the instance to delete. + * Format: projects/{project}/locations/{location}/instances/{instance} + * + * 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 name of the instance to delete. + * Format: projects/{project}/locations/{location}/instances/{instance} + * + * 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; + } + + /** + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes after the first request. + * For example, consider a situation where you make an initial request and the + * request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * + * Generated from protobuf field string request_id = 2 [(.google.api.field_behavior) = OPTIONAL, (.google.api.field_info) = { + * @return string + */ + public function getRequestId() + { + return $this->request_id; + } + + /** + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes after the first request. + * For example, consider a situation where you make an initial request and the + * request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * + * Generated from protobuf field string request_id = 2 [(.google.api.field_behavior) = OPTIONAL, (.google.api.field_info) = { + * @param string $var + * @return $this + */ + public function setRequestId($var) + { + GPBUtil::checkString($var, True); + $this->request_id = $var; + + return $this; + } + +} + diff --git a/Memorystore/src/V1/DiscoveryEndpoint.php b/Memorystore/src/V1/DiscoveryEndpoint.php new file mode 100644 index 000000000000..8259e4dd9802 --- /dev/null +++ b/Memorystore/src/V1/DiscoveryEndpoint.php @@ -0,0 +1,143 @@ +google.cloud.memorystore.v1.DiscoveryEndpoint + */ +class DiscoveryEndpoint extends \Google\Protobuf\Internal\Message +{ + /** + * Output only. IP address of the exposed endpoint clients connect to. + * + * Generated from protobuf field string address = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $address = ''; + /** + * Output only. The port number of the exposed endpoint. + * + * Generated from protobuf field int32 port = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $port = 0; + /** + * Output only. The network where the IP address of the discovery endpoint + * will be reserved, in the form of + * projects/{network_project}/global/networks/{network_id}. + * + * Generated from protobuf field string network = 4 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { + */ + protected $network = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $address + * Output only. IP address of the exposed endpoint clients connect to. + * @type int $port + * Output only. The port number of the exposed endpoint. + * @type string $network + * Output only. The network where the IP address of the discovery endpoint + * will be reserved, in the form of + * projects/{network_project}/global/networks/{network_id}. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Memorystore\V1\Memorystore::initOnce(); + parent::__construct($data); + } + + /** + * Output only. IP address of the exposed endpoint clients connect to. + * + * Generated from protobuf field string address = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getAddress() + { + return $this->address; + } + + /** + * Output only. IP address of the exposed endpoint clients connect to. + * + * Generated from protobuf field string address = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setAddress($var) + { + GPBUtil::checkString($var, True); + $this->address = $var; + + return $this; + } + + /** + * Output only. The port number of the exposed endpoint. + * + * Generated from protobuf field int32 port = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return int + */ + public function getPort() + { + return $this->port; + } + + /** + * Output only. The port number of the exposed endpoint. + * + * Generated from protobuf field int32 port = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param int $var + * @return $this + */ + public function setPort($var) + { + GPBUtil::checkInt32($var); + $this->port = $var; + + return $this; + } + + /** + * Output only. The network where the IP address of the discovery endpoint + * will be reserved, in the form of + * projects/{network_project}/global/networks/{network_id}. + * + * Generated from protobuf field string network = 4 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { + * @return string + */ + public function getNetwork() + { + return $this->network; + } + + /** + * Output only. The network where the IP address of the discovery endpoint + * will be reserved, in the form of + * projects/{network_project}/global/networks/{network_id}. + * + * Generated from protobuf field string network = 4 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setNetwork($var) + { + GPBUtil::checkString($var, True); + $this->network = $var; + + return $this; + } + +} + diff --git a/Memorystore/src/V1/GetCertificateAuthorityRequest.php b/Memorystore/src/V1/GetCertificateAuthorityRequest.php new file mode 100644 index 000000000000..1835279295b9 --- /dev/null +++ b/Memorystore/src/V1/GetCertificateAuthorityRequest.php @@ -0,0 +1,91 @@ +google.cloud.memorystore.v1.GetCertificateAuthorityRequest + */ +class GetCertificateAuthorityRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The name of the certificate authority. + * Format: + * projects/{project}/locations/{location}/instances/{instance}/certificateAuthority + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $name = ''; + + /** + * @param string $name Required. The name of the certificate authority. + * Format: + * projects/{project}/locations/{location}/instances/{instance}/certificateAuthority + * Please see {@see MemorystoreClient::instanceName()} for help formatting this field. + * + * @return \Google\Cloud\Memorystore\V1\GetCertificateAuthorityRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. The name of the certificate authority. + * Format: + * projects/{project}/locations/{location}/instances/{instance}/certificateAuthority + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Memorystore\V1\Memorystore::initOnce(); + parent::__construct($data); + } + + /** + * Required. The name of the certificate authority. + * Format: + * projects/{project}/locations/{location}/instances/{instance}/certificateAuthority + * + * 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 name of the certificate authority. + * Format: + * projects/{project}/locations/{location}/instances/{instance}/certificateAuthority + * + * 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/Memorystore/src/V1/GetInstanceRequest.php b/Memorystore/src/V1/GetInstanceRequest.php new file mode 100644 index 000000000000..baa7313f2212 --- /dev/null +++ b/Memorystore/src/V1/GetInstanceRequest.php @@ -0,0 +1,86 @@ +google.cloud.memorystore.v1.GetInstanceRequest + */ +class GetInstanceRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The name of the instance to retrieve. + * Format: projects/{project}/locations/{location}/instances/{instance} + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $name = ''; + + /** + * @param string $name Required. The name of the instance to retrieve. + * Format: projects/{project}/locations/{location}/instances/{instance} + * Please see {@see MemorystoreClient::instanceName()} for help formatting this field. + * + * @return \Google\Cloud\Memorystore\V1\GetInstanceRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. The name of the instance to retrieve. + * Format: projects/{project}/locations/{location}/instances/{instance} + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Memorystore\V1\Memorystore::initOnce(); + parent::__construct($data); + } + + /** + * Required. The name of the instance to retrieve. + * Format: projects/{project}/locations/{location}/instances/{instance} + * + * 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 name of the instance to retrieve. + * Format: projects/{project}/locations/{location}/instances/{instance} + * + * 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/Memorystore/src/V1/Instance.php b/Memorystore/src/V1/Instance.php new file mode 100644 index 000000000000..fd1ffc6b9cba --- /dev/null +++ b/Memorystore/src/V1/Instance.php @@ -0,0 +1,881 @@ +google.cloud.memorystore.v1.Instance + */ +class Instance extends \Google\Protobuf\Internal\Message +{ + /** + * Identifier. Unique name of the instance. + * Format: projects/{project}/locations/{location}/instances/{instance} + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = IDENTIFIER]; + */ + protected $name = ''; + /** + * Output only. Creation timestamp of the instance. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $create_time = null; + /** + * Output only. Latest update timestamp of the instance. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $update_time = null; + /** + * Optional. Labels to represent user-provided metadata. + * + * Generated from protobuf field map labels = 4 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $labels; + /** + * Output only. Current state of the instance. + * + * Generated from protobuf field .google.cloud.memorystore.v1.Instance.State state = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $state = 0; + /** + * Output only. Additional information about the state of the instance. + * + * Generated from protobuf field .google.cloud.memorystore.v1.Instance.StateInfo state_info = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $state_info = null; + /** + * Output only. System assigned, unique identifier for the instance. + * + * Generated from protobuf field string uid = 7 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.field_info) = { + */ + protected $uid = ''; + /** + * Optional. Number of replica nodes per shard. If omitted the default is 0 + * replicas. + * + * Generated from protobuf field optional int32 replica_count = 8 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $replica_count = null; + /** + * Optional. Immutable. Authorization mode of the instance. + * + * Generated from protobuf field .google.cloud.memorystore.v1.Instance.AuthorizationMode authorization_mode = 9 [(.google.api.field_behavior) = OPTIONAL, (.google.api.field_behavior) = IMMUTABLE]; + */ + protected $authorization_mode = 0; + /** + * Optional. Immutable. In-transit encryption mode of the instance. + * + * Generated from protobuf field .google.cloud.memorystore.v1.Instance.TransitEncryptionMode transit_encryption_mode = 10 [(.google.api.field_behavior) = OPTIONAL, (.google.api.field_behavior) = IMMUTABLE]; + */ + protected $transit_encryption_mode = 0; + /** + * Optional. Number of shards for the instance. + * + * Generated from protobuf field int32 shard_count = 11 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $shard_count = 0; + /** + * Output only. Endpoints clients can connect to the instance through. + * Currently only one discovery endpoint is supported. + * + * Generated from protobuf field repeated .google.cloud.memorystore.v1.DiscoveryEndpoint discovery_endpoints = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $discovery_endpoints; + /** + * Optional. Immutable. Machine type for individual nodes of the instance. + * + * Generated from protobuf field .google.cloud.memorystore.v1.Instance.NodeType node_type = 13 [(.google.api.field_behavior) = OPTIONAL, (.google.api.field_behavior) = IMMUTABLE]; + */ + protected $node_type = 0; + /** + * Optional. Persistence configuration of the instance. + * + * Generated from protobuf field .google.cloud.memorystore.v1.PersistenceConfig persistence_config = 14 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $persistence_config = null; + /** + * Optional. Immutable. Engine version of the instance. + * + * Generated from protobuf field string engine_version = 15 [(.google.api.field_behavior) = OPTIONAL, (.google.api.field_behavior) = IMMUTABLE]; + */ + protected $engine_version = ''; + /** + * Optional. User-provided engine configurations for the instance. + * + * Generated from protobuf field map engine_configs = 16 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $engine_configs; + /** + * Output only. Configuration of individual nodes of the instance. + * + * Generated from protobuf field .google.cloud.memorystore.v1.NodeConfig node_config = 17 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $node_config = null; + /** + * Optional. Immutable. Zone distribution configuration of the instance for + * node allocation. + * + * Generated from protobuf field .google.cloud.memorystore.v1.ZoneDistributionConfig zone_distribution_config = 18 [(.google.api.field_behavior) = OPTIONAL, (.google.api.field_behavior) = IMMUTABLE]; + */ + protected $zone_distribution_config = null; + /** + * Optional. If set to true deletion of the instance will fail. + * + * Generated from protobuf field optional bool deletion_protection_enabled = 19 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $deletion_protection_enabled = null; + /** + * Required. Immutable. User inputs and resource details of the auto-created + * PSC connections. + * + * Generated from protobuf field repeated .google.cloud.memorystore.v1.PscAutoConnection psc_auto_connections = 20 [(.google.api.field_behavior) = REQUIRED, (.google.api.field_behavior) = IMMUTABLE]; + */ + private $psc_auto_connections; + /** + * Optional. Endpoints for the instance. + * + * Generated from protobuf field repeated .google.cloud.memorystore.v1.Instance.InstanceEndpoint endpoints = 25 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $endpoints; + /** + * Optional. The mode config for the instance. + * + * Generated from protobuf field .google.cloud.memorystore.v1.Instance.Mode mode = 26 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $mode = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Identifier. Unique name of the instance. + * Format: projects/{project}/locations/{location}/instances/{instance} + * @type \Google\Protobuf\Timestamp $create_time + * Output only. Creation timestamp of the instance. + * @type \Google\Protobuf\Timestamp $update_time + * Output only. Latest update timestamp of the instance. + * @type array|\Google\Protobuf\Internal\MapField $labels + * Optional. Labels to represent user-provided metadata. + * @type int $state + * Output only. Current state of the instance. + * @type \Google\Cloud\Memorystore\V1\Instance\StateInfo $state_info + * Output only. Additional information about the state of the instance. + * @type string $uid + * Output only. System assigned, unique identifier for the instance. + * @type int $replica_count + * Optional. Number of replica nodes per shard. If omitted the default is 0 + * replicas. + * @type int $authorization_mode + * Optional. Immutable. Authorization mode of the instance. + * @type int $transit_encryption_mode + * Optional. Immutable. In-transit encryption mode of the instance. + * @type int $shard_count + * Optional. Number of shards for the instance. + * @type array<\Google\Cloud\Memorystore\V1\DiscoveryEndpoint>|\Google\Protobuf\Internal\RepeatedField $discovery_endpoints + * Output only. Endpoints clients can connect to the instance through. + * Currently only one discovery endpoint is supported. + * @type int $node_type + * Optional. Immutable. Machine type for individual nodes of the instance. + * @type \Google\Cloud\Memorystore\V1\PersistenceConfig $persistence_config + * Optional. Persistence configuration of the instance. + * @type string $engine_version + * Optional. Immutable. Engine version of the instance. + * @type array|\Google\Protobuf\Internal\MapField $engine_configs + * Optional. User-provided engine configurations for the instance. + * @type \Google\Cloud\Memorystore\V1\NodeConfig $node_config + * Output only. Configuration of individual nodes of the instance. + * @type \Google\Cloud\Memorystore\V1\ZoneDistributionConfig $zone_distribution_config + * Optional. Immutable. Zone distribution configuration of the instance for + * node allocation. + * @type bool $deletion_protection_enabled + * Optional. If set to true deletion of the instance will fail. + * @type array<\Google\Cloud\Memorystore\V1\PscAutoConnection>|\Google\Protobuf\Internal\RepeatedField $psc_auto_connections + * Required. Immutable. User inputs and resource details of the auto-created + * PSC connections. + * @type array<\Google\Cloud\Memorystore\V1\Instance\InstanceEndpoint>|\Google\Protobuf\Internal\RepeatedField $endpoints + * Optional. Endpoints for the instance. + * @type int $mode + * Optional. The mode config for the instance. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Memorystore\V1\Memorystore::initOnce(); + parent::__construct($data); + } + + /** + * Identifier. Unique name of the instance. + * Format: projects/{project}/locations/{location}/instances/{instance} + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = IDENTIFIER]; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Identifier. Unique name of the instance. + * Format: projects/{project}/locations/{location}/instances/{instance} + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = IDENTIFIER]; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * Output only. Creation timestamp of the instance. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Timestamp|null + */ + public function getCreateTime() + { + return $this->create_time; + } + + public function hasCreateTime() + { + return isset($this->create_time); + } + + public function clearCreateTime() + { + unset($this->create_time); + } + + /** + * Output only. Creation timestamp of the instance. + * + * 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. Latest update timestamp of the instance. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Timestamp|null + */ + public function getUpdateTime() + { + return $this->update_time; + } + + public function hasUpdateTime() + { + return isset($this->update_time); + } + + public function clearUpdateTime() + { + unset($this->update_time); + } + + /** + * Output only. Latest update timestamp of the instance. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setUpdateTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->update_time = $var; + + return $this; + } + + /** + * Optional. Labels to represent user-provided metadata. + * + * Generated from protobuf field map labels = 4 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Protobuf\Internal\MapField + */ + public function getLabels() + { + return $this->labels; + } + + /** + * Optional. Labels to represent user-provided metadata. + * + * Generated from protobuf field map labels = 4 [(.google.api.field_behavior) = OPTIONAL]; + * @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; + } + + /** + * Output only. Current state of the instance. + * + * Generated from protobuf field .google.cloud.memorystore.v1.Instance.State state = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return int + */ + public function getState() + { + return $this->state; + } + + /** + * Output only. Current state of the instance. + * + * Generated from protobuf field .google.cloud.memorystore.v1.Instance.State state = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param int $var + * @return $this + */ + public function setState($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Memorystore\V1\Instance\State::class); + $this->state = $var; + + return $this; + } + + /** + * Output only. Additional information about the state of the instance. + * + * Generated from protobuf field .google.cloud.memorystore.v1.Instance.StateInfo state_info = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Cloud\Memorystore\V1\Instance\StateInfo|null + */ + public function getStateInfo() + { + return $this->state_info; + } + + public function hasStateInfo() + { + return isset($this->state_info); + } + + public function clearStateInfo() + { + unset($this->state_info); + } + + /** + * Output only. Additional information about the state of the instance. + * + * Generated from protobuf field .google.cloud.memorystore.v1.Instance.StateInfo state_info = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Cloud\Memorystore\V1\Instance\StateInfo $var + * @return $this + */ + public function setStateInfo($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Memorystore\V1\Instance\StateInfo::class); + $this->state_info = $var; + + return $this; + } + + /** + * Output only. System assigned, unique identifier for the instance. + * + * Generated from protobuf field string uid = 7 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.field_info) = { + * @return string + */ + public function getUid() + { + return $this->uid; + } + + /** + * Output only. System assigned, unique identifier for the instance. + * + * Generated from protobuf field string uid = 7 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.field_info) = { + * @param string $var + * @return $this + */ + public function setUid($var) + { + GPBUtil::checkString($var, True); + $this->uid = $var; + + return $this; + } + + /** + * Optional. Number of replica nodes per shard. If omitted the default is 0 + * replicas. + * + * Generated from protobuf field optional int32 replica_count = 8 [(.google.api.field_behavior) = OPTIONAL]; + * @return int + */ + public function getReplicaCount() + { + return isset($this->replica_count) ? $this->replica_count : 0; + } + + public function hasReplicaCount() + { + return isset($this->replica_count); + } + + public function clearReplicaCount() + { + unset($this->replica_count); + } + + /** + * Optional. Number of replica nodes per shard. If omitted the default is 0 + * replicas. + * + * Generated from protobuf field optional int32 replica_count = 8 [(.google.api.field_behavior) = OPTIONAL]; + * @param int $var + * @return $this + */ + public function setReplicaCount($var) + { + GPBUtil::checkInt32($var); + $this->replica_count = $var; + + return $this; + } + + /** + * Optional. Immutable. Authorization mode of the instance. + * + * Generated from protobuf field .google.cloud.memorystore.v1.Instance.AuthorizationMode authorization_mode = 9 [(.google.api.field_behavior) = OPTIONAL, (.google.api.field_behavior) = IMMUTABLE]; + * @return int + */ + public function getAuthorizationMode() + { + return $this->authorization_mode; + } + + /** + * Optional. Immutable. Authorization mode of the instance. + * + * Generated from protobuf field .google.cloud.memorystore.v1.Instance.AuthorizationMode authorization_mode = 9 [(.google.api.field_behavior) = OPTIONAL, (.google.api.field_behavior) = IMMUTABLE]; + * @param int $var + * @return $this + */ + public function setAuthorizationMode($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Memorystore\V1\Instance\AuthorizationMode::class); + $this->authorization_mode = $var; + + return $this; + } + + /** + * Optional. Immutable. In-transit encryption mode of the instance. + * + * Generated from protobuf field .google.cloud.memorystore.v1.Instance.TransitEncryptionMode transit_encryption_mode = 10 [(.google.api.field_behavior) = OPTIONAL, (.google.api.field_behavior) = IMMUTABLE]; + * @return int + */ + public function getTransitEncryptionMode() + { + return $this->transit_encryption_mode; + } + + /** + * Optional. Immutable. In-transit encryption mode of the instance. + * + * Generated from protobuf field .google.cloud.memorystore.v1.Instance.TransitEncryptionMode transit_encryption_mode = 10 [(.google.api.field_behavior) = OPTIONAL, (.google.api.field_behavior) = IMMUTABLE]; + * @param int $var + * @return $this + */ + public function setTransitEncryptionMode($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Memorystore\V1\Instance\TransitEncryptionMode::class); + $this->transit_encryption_mode = $var; + + return $this; + } + + /** + * Optional. Number of shards for the instance. + * + * Generated from protobuf field int32 shard_count = 11 [(.google.api.field_behavior) = OPTIONAL]; + * @return int + */ + public function getShardCount() + { + return $this->shard_count; + } + + /** + * Optional. Number of shards for the instance. + * + * Generated from protobuf field int32 shard_count = 11 [(.google.api.field_behavior) = OPTIONAL]; + * @param int $var + * @return $this + */ + public function setShardCount($var) + { + GPBUtil::checkInt32($var); + $this->shard_count = $var; + + return $this; + } + + /** + * Output only. Endpoints clients can connect to the instance through. + * Currently only one discovery endpoint is supported. + * + * Generated from protobuf field repeated .google.cloud.memorystore.v1.DiscoveryEndpoint discovery_endpoints = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getDiscoveryEndpoints() + { + return $this->discovery_endpoints; + } + + /** + * Output only. Endpoints clients can connect to the instance through. + * Currently only one discovery endpoint is supported. + * + * Generated from protobuf field repeated .google.cloud.memorystore.v1.DiscoveryEndpoint discovery_endpoints = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param array<\Google\Cloud\Memorystore\V1\DiscoveryEndpoint>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setDiscoveryEndpoints($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Memorystore\V1\DiscoveryEndpoint::class); + $this->discovery_endpoints = $arr; + + return $this; + } + + /** + * Optional. Immutable. Machine type for individual nodes of the instance. + * + * Generated from protobuf field .google.cloud.memorystore.v1.Instance.NodeType node_type = 13 [(.google.api.field_behavior) = OPTIONAL, (.google.api.field_behavior) = IMMUTABLE]; + * @return int + */ + public function getNodeType() + { + return $this->node_type; + } + + /** + * Optional. Immutable. Machine type for individual nodes of the instance. + * + * Generated from protobuf field .google.cloud.memorystore.v1.Instance.NodeType node_type = 13 [(.google.api.field_behavior) = OPTIONAL, (.google.api.field_behavior) = IMMUTABLE]; + * @param int $var + * @return $this + */ + public function setNodeType($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Memorystore\V1\Instance\NodeType::class); + $this->node_type = $var; + + return $this; + } + + /** + * Optional. Persistence configuration of the instance. + * + * Generated from protobuf field .google.cloud.memorystore.v1.PersistenceConfig persistence_config = 14 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Cloud\Memorystore\V1\PersistenceConfig|null + */ + public function getPersistenceConfig() + { + return $this->persistence_config; + } + + public function hasPersistenceConfig() + { + return isset($this->persistence_config); + } + + public function clearPersistenceConfig() + { + unset($this->persistence_config); + } + + /** + * Optional. Persistence configuration of the instance. + * + * Generated from protobuf field .google.cloud.memorystore.v1.PersistenceConfig persistence_config = 14 [(.google.api.field_behavior) = OPTIONAL]; + * @param \Google\Cloud\Memorystore\V1\PersistenceConfig $var + * @return $this + */ + public function setPersistenceConfig($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Memorystore\V1\PersistenceConfig::class); + $this->persistence_config = $var; + + return $this; + } + + /** + * Optional. Immutable. Engine version of the instance. + * + * Generated from protobuf field string engine_version = 15 [(.google.api.field_behavior) = OPTIONAL, (.google.api.field_behavior) = IMMUTABLE]; + * @return string + */ + public function getEngineVersion() + { + return $this->engine_version; + } + + /** + * Optional. Immutable. Engine version of the instance. + * + * Generated from protobuf field string engine_version = 15 [(.google.api.field_behavior) = OPTIONAL, (.google.api.field_behavior) = IMMUTABLE]; + * @param string $var + * @return $this + */ + public function setEngineVersion($var) + { + GPBUtil::checkString($var, True); + $this->engine_version = $var; + + return $this; + } + + /** + * Optional. User-provided engine configurations for the instance. + * + * Generated from protobuf field map engine_configs = 16 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Protobuf\Internal\MapField + */ + public function getEngineConfigs() + { + return $this->engine_configs; + } + + /** + * Optional. User-provided engine configurations for the instance. + * + * Generated from protobuf field map engine_configs = 16 [(.google.api.field_behavior) = OPTIONAL]; + * @param array|\Google\Protobuf\Internal\MapField $var + * @return $this + */ + public function setEngineConfigs($var) + { + $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::STRING); + $this->engine_configs = $arr; + + return $this; + } + + /** + * Output only. Configuration of individual nodes of the instance. + * + * Generated from protobuf field .google.cloud.memorystore.v1.NodeConfig node_config = 17 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Cloud\Memorystore\V1\NodeConfig|null + */ + public function getNodeConfig() + { + return $this->node_config; + } + + public function hasNodeConfig() + { + return isset($this->node_config); + } + + public function clearNodeConfig() + { + unset($this->node_config); + } + + /** + * Output only. Configuration of individual nodes of the instance. + * + * Generated from protobuf field .google.cloud.memorystore.v1.NodeConfig node_config = 17 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Cloud\Memorystore\V1\NodeConfig $var + * @return $this + */ + public function setNodeConfig($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Memorystore\V1\NodeConfig::class); + $this->node_config = $var; + + return $this; + } + + /** + * Optional. Immutable. Zone distribution configuration of the instance for + * node allocation. + * + * Generated from protobuf field .google.cloud.memorystore.v1.ZoneDistributionConfig zone_distribution_config = 18 [(.google.api.field_behavior) = OPTIONAL, (.google.api.field_behavior) = IMMUTABLE]; + * @return \Google\Cloud\Memorystore\V1\ZoneDistributionConfig|null + */ + public function getZoneDistributionConfig() + { + return $this->zone_distribution_config; + } + + public function hasZoneDistributionConfig() + { + return isset($this->zone_distribution_config); + } + + public function clearZoneDistributionConfig() + { + unset($this->zone_distribution_config); + } + + /** + * Optional. Immutable. Zone distribution configuration of the instance for + * node allocation. + * + * Generated from protobuf field .google.cloud.memorystore.v1.ZoneDistributionConfig zone_distribution_config = 18 [(.google.api.field_behavior) = OPTIONAL, (.google.api.field_behavior) = IMMUTABLE]; + * @param \Google\Cloud\Memorystore\V1\ZoneDistributionConfig $var + * @return $this + */ + public function setZoneDistributionConfig($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Memorystore\V1\ZoneDistributionConfig::class); + $this->zone_distribution_config = $var; + + return $this; + } + + /** + * Optional. If set to true deletion of the instance will fail. + * + * Generated from protobuf field optional bool deletion_protection_enabled = 19 [(.google.api.field_behavior) = OPTIONAL]; + * @return bool + */ + public function getDeletionProtectionEnabled() + { + return isset($this->deletion_protection_enabled) ? $this->deletion_protection_enabled : false; + } + + public function hasDeletionProtectionEnabled() + { + return isset($this->deletion_protection_enabled); + } + + public function clearDeletionProtectionEnabled() + { + unset($this->deletion_protection_enabled); + } + + /** + * Optional. If set to true deletion of the instance will fail. + * + * Generated from protobuf field optional bool deletion_protection_enabled = 19 [(.google.api.field_behavior) = OPTIONAL]; + * @param bool $var + * @return $this + */ + public function setDeletionProtectionEnabled($var) + { + GPBUtil::checkBool($var); + $this->deletion_protection_enabled = $var; + + return $this; + } + + /** + * Required. Immutable. User inputs and resource details of the auto-created + * PSC connections. + * + * Generated from protobuf field repeated .google.cloud.memorystore.v1.PscAutoConnection psc_auto_connections = 20 [(.google.api.field_behavior) = REQUIRED, (.google.api.field_behavior) = IMMUTABLE]; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getPscAutoConnections() + { + return $this->psc_auto_connections; + } + + /** + * Required. Immutable. User inputs and resource details of the auto-created + * PSC connections. + * + * Generated from protobuf field repeated .google.cloud.memorystore.v1.PscAutoConnection psc_auto_connections = 20 [(.google.api.field_behavior) = REQUIRED, (.google.api.field_behavior) = IMMUTABLE]; + * @param array<\Google\Cloud\Memorystore\V1\PscAutoConnection>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setPscAutoConnections($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Memorystore\V1\PscAutoConnection::class); + $this->psc_auto_connections = $arr; + + return $this; + } + + /** + * Optional. Endpoints for the instance. + * + * Generated from protobuf field repeated .google.cloud.memorystore.v1.Instance.InstanceEndpoint endpoints = 25 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getEndpoints() + { + return $this->endpoints; + } + + /** + * Optional. Endpoints for the instance. + * + * Generated from protobuf field repeated .google.cloud.memorystore.v1.Instance.InstanceEndpoint endpoints = 25 [(.google.api.field_behavior) = OPTIONAL]; + * @param array<\Google\Cloud\Memorystore\V1\Instance\InstanceEndpoint>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setEndpoints($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Memorystore\V1\Instance\InstanceEndpoint::class); + $this->endpoints = $arr; + + return $this; + } + + /** + * Optional. The mode config for the instance. + * + * Generated from protobuf field .google.cloud.memorystore.v1.Instance.Mode mode = 26 [(.google.api.field_behavior) = OPTIONAL]; + * @return int + */ + public function getMode() + { + return $this->mode; + } + + /** + * Optional. The mode config for the instance. + * + * Generated from protobuf field .google.cloud.memorystore.v1.Instance.Mode mode = 26 [(.google.api.field_behavior) = OPTIONAL]; + * @param int $var + * @return $this + */ + public function setMode($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Memorystore\V1\Instance\Mode::class); + $this->mode = $var; + + return $this; + } + +} + diff --git a/Memorystore/src/V1/Instance/AuthorizationMode.php b/Memorystore/src/V1/Instance/AuthorizationMode.php new file mode 100644 index 000000000000..8ab01f5f85a3 --- /dev/null +++ b/Memorystore/src/V1/Instance/AuthorizationMode.php @@ -0,0 +1,62 @@ +google.cloud.memorystore.v1.Instance.AuthorizationMode + */ +class AuthorizationMode +{ + /** + * Not set. + * + * Generated from protobuf enum AUTHORIZATION_MODE_UNSPECIFIED = 0; + */ + const AUTHORIZATION_MODE_UNSPECIFIED = 0; + /** + * Authorization disabled. + * + * Generated from protobuf enum AUTH_DISABLED = 1; + */ + const AUTH_DISABLED = 1; + /** + * IAM basic authorization. + * + * Generated from protobuf enum IAM_AUTH = 2; + */ + const IAM_AUTH = 2; + + private static $valueToName = [ + self::AUTHORIZATION_MODE_UNSPECIFIED => 'AUTHORIZATION_MODE_UNSPECIFIED', + self::AUTH_DISABLED => 'AUTH_DISABLED', + self::IAM_AUTH => 'IAM_AUTH', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + + diff --git a/Memorystore/src/V1/Instance/ConnectionDetail.php b/Memorystore/src/V1/Instance/ConnectionDetail.php new file mode 100644 index 000000000000..f7bd6c2db9a9 --- /dev/null +++ b/Memorystore/src/V1/Instance/ConnectionDetail.php @@ -0,0 +1,112 @@ +google.cloud.memorystore.v1.Instance.ConnectionDetail + */ +class ConnectionDetail extends \Google\Protobuf\Internal\Message +{ + protected $connection; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Memorystore\V1\PscAutoConnection $psc_auto_connection + * Detailed information of a PSC connection that is created through + * service connectivity automation. + * @type \Google\Cloud\Memorystore\V1\PscConnection $psc_connection + * Detailed information of a PSC connection that is created by the user. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Memorystore\V1\Memorystore::initOnce(); + parent::__construct($data); + } + + /** + * Detailed information of a PSC connection that is created through + * service connectivity automation. + * + * Generated from protobuf field .google.cloud.memorystore.v1.PscAutoConnection psc_auto_connection = 1; + * @return \Google\Cloud\Memorystore\V1\PscAutoConnection|null + */ + public function getPscAutoConnection() + { + return $this->readOneof(1); + } + + public function hasPscAutoConnection() + { + return $this->hasOneof(1); + } + + /** + * Detailed information of a PSC connection that is created through + * service connectivity automation. + * + * Generated from protobuf field .google.cloud.memorystore.v1.PscAutoConnection psc_auto_connection = 1; + * @param \Google\Cloud\Memorystore\V1\PscAutoConnection $var + * @return $this + */ + public function setPscAutoConnection($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Memorystore\V1\PscAutoConnection::class); + $this->writeOneof(1, $var); + + return $this; + } + + /** + * Detailed information of a PSC connection that is created by the user. + * + * Generated from protobuf field .google.cloud.memorystore.v1.PscConnection psc_connection = 2; + * @return \Google\Cloud\Memorystore\V1\PscConnection|null + */ + public function getPscConnection() + { + return $this->readOneof(2); + } + + public function hasPscConnection() + { + return $this->hasOneof(2); + } + + /** + * Detailed information of a PSC connection that is created by the user. + * + * Generated from protobuf field .google.cloud.memorystore.v1.PscConnection psc_connection = 2; + * @param \Google\Cloud\Memorystore\V1\PscConnection $var + * @return $this + */ + public function setPscConnection($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Memorystore\V1\PscConnection::class); + $this->writeOneof(2, $var); + + return $this; + } + + /** + * @return string + */ + public function getConnection() + { + return $this->whichOneof("connection"); + } + +} + + diff --git a/Memorystore/src/V1/Instance/InstanceEndpoint.php b/Memorystore/src/V1/Instance/InstanceEndpoint.php new file mode 100644 index 000000000000..8851ae720111 --- /dev/null +++ b/Memorystore/src/V1/Instance/InstanceEndpoint.php @@ -0,0 +1,74 @@ +google.cloud.memorystore.v1.Instance.InstanceEndpoint + */ +class InstanceEndpoint extends \Google\Protobuf\Internal\Message +{ + /** + * Optional. A group of PSC connections. They are created in the same VPC + * network, one for each service attachment in the cluster. + * + * Generated from protobuf field repeated .google.cloud.memorystore.v1.Instance.ConnectionDetail connections = 1 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $connections; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\Google\Cloud\Memorystore\V1\Instance\ConnectionDetail>|\Google\Protobuf\Internal\RepeatedField $connections + * Optional. A group of PSC connections. They are created in the same VPC + * network, one for each service attachment in the cluster. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Memorystore\V1\Memorystore::initOnce(); + parent::__construct($data); + } + + /** + * Optional. A group of PSC connections. They are created in the same VPC + * network, one for each service attachment in the cluster. + * + * Generated from protobuf field repeated .google.cloud.memorystore.v1.Instance.ConnectionDetail connections = 1 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getConnections() + { + return $this->connections; + } + + /** + * Optional. A group of PSC connections. They are created in the same VPC + * network, one for each service attachment in the cluster. + * + * Generated from protobuf field repeated .google.cloud.memorystore.v1.Instance.ConnectionDetail connections = 1 [(.google.api.field_behavior) = OPTIONAL]; + * @param array<\Google\Cloud\Memorystore\V1\Instance\ConnectionDetail>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setConnections($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Memorystore\V1\Instance\ConnectionDetail::class); + $this->connections = $arr; + + return $this; + } + +} + + diff --git a/Memorystore/src/V1/Instance/Mode.php b/Memorystore/src/V1/Instance/Mode.php new file mode 100644 index 000000000000..f75c78e7b9bc --- /dev/null +++ b/Memorystore/src/V1/Instance/Mode.php @@ -0,0 +1,62 @@ +google.cloud.memorystore.v1.Instance.Mode + */ +class Mode +{ + /** + * Mode is not specified. + * + * Generated from protobuf enum MODE_UNSPECIFIED = 0; + */ + const MODE_UNSPECIFIED = 0; + /** + * Instance is in standalone mode. + * + * Generated from protobuf enum STANDALONE = 1; + */ + const STANDALONE = 1; + /** + * Instance is in cluster mode. + * + * Generated from protobuf enum CLUSTER = 2; + */ + const CLUSTER = 2; + + private static $valueToName = [ + self::MODE_UNSPECIFIED => 'MODE_UNSPECIFIED', + self::STANDALONE => 'STANDALONE', + self::CLUSTER => 'CLUSTER', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + + diff --git a/Memorystore/src/V1/Instance/NodeType.php b/Memorystore/src/V1/Instance/NodeType.php new file mode 100644 index 000000000000..ca6a5fb08257 --- /dev/null +++ b/Memorystore/src/V1/Instance/NodeType.php @@ -0,0 +1,78 @@ +google.cloud.memorystore.v1.Instance.NodeType + */ +class NodeType +{ + /** + * Not set. + * + * Generated from protobuf enum NODE_TYPE_UNSPECIFIED = 0; + */ + const NODE_TYPE_UNSPECIFIED = 0; + /** + * Shared core nano. + * + * Generated from protobuf enum SHARED_CORE_NANO = 1; + */ + const SHARED_CORE_NANO = 1; + /** + * High memory medium. + * + * Generated from protobuf enum HIGHMEM_MEDIUM = 2; + */ + const HIGHMEM_MEDIUM = 2; + /** + * High memory extra large. + * + * Generated from protobuf enum HIGHMEM_XLARGE = 3; + */ + const HIGHMEM_XLARGE = 3; + /** + * Standard small. + * + * Generated from protobuf enum STANDARD_SMALL = 4; + */ + const STANDARD_SMALL = 4; + + private static $valueToName = [ + self::NODE_TYPE_UNSPECIFIED => 'NODE_TYPE_UNSPECIFIED', + self::SHARED_CORE_NANO => 'SHARED_CORE_NANO', + self::HIGHMEM_MEDIUM => 'HIGHMEM_MEDIUM', + self::HIGHMEM_XLARGE => 'HIGHMEM_XLARGE', + self::STANDARD_SMALL => 'STANDARD_SMALL', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + + diff --git a/Memorystore/src/V1/Instance/State.php b/Memorystore/src/V1/Instance/State.php new file mode 100644 index 000000000000..979a68289a28 --- /dev/null +++ b/Memorystore/src/V1/Instance/State.php @@ -0,0 +1,76 @@ +google.cloud.memorystore.v1.Instance.State + */ +class State +{ + /** + * Not set. + * + * Generated from protobuf enum STATE_UNSPECIFIED = 0; + */ + const STATE_UNSPECIFIED = 0; + /** + * Instance is being created. + * + * Generated from protobuf enum CREATING = 1; + */ + const CREATING = 1; + /** + * Instance has been created and is usable. + * + * Generated from protobuf enum ACTIVE = 2; + */ + const ACTIVE = 2; + /** + * Instance is being updated. + * + * Generated from protobuf enum UPDATING = 3; + */ + const UPDATING = 3; + /** + * Instance is being deleted. + * + * Generated from protobuf enum DELETING = 4; + */ + const DELETING = 4; + + private static $valueToName = [ + self::STATE_UNSPECIFIED => 'STATE_UNSPECIFIED', + self::CREATING => 'CREATING', + self::ACTIVE => 'ACTIVE', + self::UPDATING => 'UPDATING', + self::DELETING => 'DELETING', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + + diff --git a/Memorystore/src/V1/Instance/StateInfo.php b/Memorystore/src/V1/Instance/StateInfo.php new file mode 100644 index 000000000000..f5409c84bed8 --- /dev/null +++ b/Memorystore/src/V1/Instance/StateInfo.php @@ -0,0 +1,76 @@ +google.cloud.memorystore.v1.Instance.StateInfo + */ +class StateInfo extends \Google\Protobuf\Internal\Message +{ + protected $info; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Memorystore\V1\Instance\StateInfo\UpdateInfo $update_info + * Output only. Describes ongoing update when instance state is UPDATING. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Memorystore\V1\Memorystore::initOnce(); + parent::__construct($data); + } + + /** + * Output only. Describes ongoing update when instance state is UPDATING. + * + * Generated from protobuf field .google.cloud.memorystore.v1.Instance.StateInfo.UpdateInfo update_info = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Cloud\Memorystore\V1\Instance\StateInfo\UpdateInfo|null + */ + public function getUpdateInfo() + { + return $this->readOneof(1); + } + + public function hasUpdateInfo() + { + return $this->hasOneof(1); + } + + /** + * Output only. Describes ongoing update when instance state is UPDATING. + * + * Generated from protobuf field .google.cloud.memorystore.v1.Instance.StateInfo.UpdateInfo update_info = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Cloud\Memorystore\V1\Instance\StateInfo\UpdateInfo $var + * @return $this + */ + public function setUpdateInfo($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Memorystore\V1\Instance\StateInfo\UpdateInfo::class); + $this->writeOneof(1, $var); + + return $this; + } + + /** + * @return string + */ + public function getInfo() + { + return $this->whichOneof("info"); + } + +} + + diff --git a/Memorystore/src/V1/Instance/StateInfo/UpdateInfo.php b/Memorystore/src/V1/Instance/StateInfo/UpdateInfo.php new file mode 100644 index 000000000000..5303e143ef9b --- /dev/null +++ b/Memorystore/src/V1/Instance/StateInfo/UpdateInfo.php @@ -0,0 +1,122 @@ +google.cloud.memorystore.v1.Instance.StateInfo.UpdateInfo + */ +class UpdateInfo extends \Google\Protobuf\Internal\Message +{ + /** + * Output only. Target number of shards for the instance. + * + * Generated from protobuf field optional int32 target_shard_count = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $target_shard_count = null; + /** + * Output only. Target number of replica nodes per shard for the instance. + * + * Generated from protobuf field optional int32 target_replica_count = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $target_replica_count = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int $target_shard_count + * Output only. Target number of shards for the instance. + * @type int $target_replica_count + * Output only. Target number of replica nodes per shard for the instance. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Memorystore\V1\Memorystore::initOnce(); + parent::__construct($data); + } + + /** + * Output only. Target number of shards for the instance. + * + * Generated from protobuf field optional int32 target_shard_count = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return int + */ + public function getTargetShardCount() + { + return isset($this->target_shard_count) ? $this->target_shard_count : 0; + } + + public function hasTargetShardCount() + { + return isset($this->target_shard_count); + } + + public function clearTargetShardCount() + { + unset($this->target_shard_count); + } + + /** + * Output only. Target number of shards for the instance. + * + * Generated from protobuf field optional int32 target_shard_count = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param int $var + * @return $this + */ + public function setTargetShardCount($var) + { + GPBUtil::checkInt32($var); + $this->target_shard_count = $var; + + return $this; + } + + /** + * Output only. Target number of replica nodes per shard for the instance. + * + * Generated from protobuf field optional int32 target_replica_count = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return int + */ + public function getTargetReplicaCount() + { + return isset($this->target_replica_count) ? $this->target_replica_count : 0; + } + + public function hasTargetReplicaCount() + { + return isset($this->target_replica_count); + } + + public function clearTargetReplicaCount() + { + unset($this->target_replica_count); + } + + /** + * Output only. Target number of replica nodes per shard for the instance. + * + * Generated from protobuf field optional int32 target_replica_count = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param int $var + * @return $this + */ + public function setTargetReplicaCount($var) + { + GPBUtil::checkInt32($var); + $this->target_replica_count = $var; + + return $this; + } + +} + + diff --git a/Memorystore/src/V1/Instance/TransitEncryptionMode.php b/Memorystore/src/V1/Instance/TransitEncryptionMode.php new file mode 100644 index 000000000000..508c82374ca8 --- /dev/null +++ b/Memorystore/src/V1/Instance/TransitEncryptionMode.php @@ -0,0 +1,62 @@ +google.cloud.memorystore.v1.Instance.TransitEncryptionMode + */ +class TransitEncryptionMode +{ + /** + * Not set. + * + * Generated from protobuf enum TRANSIT_ENCRYPTION_MODE_UNSPECIFIED = 0; + */ + const TRANSIT_ENCRYPTION_MODE_UNSPECIFIED = 0; + /** + * In-transit encryption is disabled. + * + * Generated from protobuf enum TRANSIT_ENCRYPTION_DISABLED = 1; + */ + const TRANSIT_ENCRYPTION_DISABLED = 1; + /** + * Server-managed encryption is used for in-transit encryption. + * + * Generated from protobuf enum SERVER_AUTHENTICATION = 2; + */ + const SERVER_AUTHENTICATION = 2; + + private static $valueToName = [ + self::TRANSIT_ENCRYPTION_MODE_UNSPECIFIED => 'TRANSIT_ENCRYPTION_MODE_UNSPECIFIED', + self::TRANSIT_ENCRYPTION_DISABLED => 'TRANSIT_ENCRYPTION_DISABLED', + self::SERVER_AUTHENTICATION => 'SERVER_AUTHENTICATION', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + + diff --git a/Memorystore/src/V1/ListInstancesRequest.php b/Memorystore/src/V1/ListInstancesRequest.php new file mode 100644 index 000000000000..5c3dd73219ea --- /dev/null +++ b/Memorystore/src/V1/ListInstancesRequest.php @@ -0,0 +1,230 @@ +google.cloud.memorystore.v1.ListInstancesRequest + */ +class ListInstancesRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The parent to list instances from. + * Format: projects/{project}/locations/{location} + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $parent = ''; + /** + * Optional. Requested page size. Server may return fewer items than + * requested. If unspecified, server will pick an appropriate default. + * + * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $page_size = 0; + /** + * Optional. A token identifying a page of results the server should return. + * + * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $page_token = ''; + /** + * Optional. Expression for filtering results. + * + * Generated from protobuf field string filter = 4 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $filter = ''; + /** + * Optional. Sort results by a defined order. Supported values: "name", + * "create_time". + * + * Generated from protobuf field string order_by = 5 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $order_by = ''; + + /** + * @param string $parent Required. The parent to list instances from. + * Format: projects/{project}/locations/{location} + * Please see {@see MemorystoreClient::locationName()} for help formatting this field. + * + * @return \Google\Cloud\Memorystore\V1\ListInstancesRequest + * + * @experimental + */ + public static function build(string $parent): self + { + return (new self()) + ->setParent($parent); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. The parent to list instances from. + * Format: projects/{project}/locations/{location} + * @type int $page_size + * Optional. Requested page size. Server may return fewer items than + * requested. If unspecified, server will pick an appropriate default. + * @type string $page_token + * Optional. A token identifying a page of results the server should return. + * @type string $filter + * Optional. Expression for filtering results. + * @type string $order_by + * Optional. Sort results by a defined order. Supported values: "name", + * "create_time". + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Memorystore\V1\Memorystore::initOnce(); + parent::__construct($data); + } + + /** + * Required. The parent to list instances from. + * Format: projects/{project}/locations/{location} + * + * 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 parent to list instances from. + * Format: projects/{project}/locations/{location} + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setParent($var) + { + GPBUtil::checkString($var, True); + $this->parent = $var; + + return $this; + } + + /** + * Optional. Requested page size. Server may return fewer items than + * requested. If unspecified, server will pick an appropriate default. + * + * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @return int + */ + public function getPageSize() + { + return $this->page_size; + } + + /** + * Optional. Requested page size. Server may return fewer items than + * requested. If unspecified, server will pick an appropriate default. + * + * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @param int $var + * @return $this + */ + public function setPageSize($var) + { + GPBUtil::checkInt32($var); + $this->page_size = $var; + + return $this; + } + + /** + * Optional. A token identifying a page of results the server should return. + * + * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @return string + */ + public function getPageToken() + { + return $this->page_token; + } + + /** + * Optional. A token identifying a page of results the server should return. + * + * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @param string $var + * @return $this + */ + public function setPageToken($var) + { + GPBUtil::checkString($var, True); + $this->page_token = $var; + + return $this; + } + + /** + * Optional. Expression for filtering results. + * + * Generated from protobuf field string filter = 4 [(.google.api.field_behavior) = OPTIONAL]; + * @return string + */ + public function getFilter() + { + return $this->filter; + } + + /** + * Optional. Expression for filtering results. + * + * Generated from protobuf field string filter = 4 [(.google.api.field_behavior) = OPTIONAL]; + * @param string $var + * @return $this + */ + public function setFilter($var) + { + GPBUtil::checkString($var, True); + $this->filter = $var; + + return $this; + } + + /** + * Optional. Sort results by a defined order. Supported values: "name", + * "create_time". + * + * Generated from protobuf field string order_by = 5 [(.google.api.field_behavior) = OPTIONAL]; + * @return string + */ + public function getOrderBy() + { + return $this->order_by; + } + + /** + * Optional. Sort results by a defined order. Supported values: "name", + * "create_time". + * + * Generated from protobuf field string order_by = 5 [(.google.api.field_behavior) = OPTIONAL]; + * @param string $var + * @return $this + */ + public function setOrderBy($var) + { + GPBUtil::checkString($var, True); + $this->order_by = $var; + + return $this; + } + +} + diff --git a/Memorystore/src/V1/ListInstancesResponse.php b/Memorystore/src/V1/ListInstancesResponse.php new file mode 100644 index 000000000000..985dd1d21477 --- /dev/null +++ b/Memorystore/src/V1/ListInstancesResponse.php @@ -0,0 +1,147 @@ +google.cloud.memorystore.v1.ListInstancesResponse + */ +class ListInstancesResponse extends \Google\Protobuf\Internal\Message +{ + /** + * If the {location} requested was "-" the response contains a list of + * instances from all locations. Instances in unreachable locations will be + * omitted. + * + * Generated from protobuf field repeated .google.cloud.memorystore.v1.Instance instances = 1; + */ + private $instances; + /** + * A token, which can be sent as `page_token` to retrieve the next page. + * If this field is omitted, there are no subsequent pages. + * + * Generated from protobuf field string next_page_token = 2; + */ + protected $next_page_token = ''; + /** + * Locations that could not be reached. + * + * Generated from protobuf field repeated string unreachable = 3; + */ + private $unreachable; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\Google\Cloud\Memorystore\V1\Instance>|\Google\Protobuf\Internal\RepeatedField $instances + * If the {location} requested was "-" the response contains a list of + * instances from all locations. Instances in unreachable locations will be + * omitted. + * @type string $next_page_token + * A token, which can be sent as `page_token` to retrieve the next page. + * If this field is omitted, there are no subsequent pages. + * @type array|\Google\Protobuf\Internal\RepeatedField $unreachable + * Locations that could not be reached. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Memorystore\V1\Memorystore::initOnce(); + parent::__construct($data); + } + + /** + * If the {location} requested was "-" the response contains a list of + * instances from all locations. Instances in unreachable locations will be + * omitted. + * + * Generated from protobuf field repeated .google.cloud.memorystore.v1.Instance instances = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getInstances() + { + return $this->instances; + } + + /** + * If the {location} requested was "-" the response contains a list of + * instances from all locations. Instances in unreachable locations will be + * omitted. + * + * Generated from protobuf field repeated .google.cloud.memorystore.v1.Instance instances = 1; + * @param array<\Google\Cloud\Memorystore\V1\Instance>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setInstances($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Memorystore\V1\Instance::class); + $this->instances = $arr; + + return $this; + } + + /** + * A token, which can be sent as `page_token` to retrieve the next page. + * If this field is omitted, there are no subsequent pages. + * + * Generated from protobuf field string next_page_token = 2; + * @return string + */ + public function getNextPageToken() + { + return $this->next_page_token; + } + + /** + * A token, which can be sent as `page_token` to retrieve the next page. + * If this field is omitted, there are no subsequent pages. + * + * Generated from protobuf field string next_page_token = 2; + * @param string $var + * @return $this + */ + public function setNextPageToken($var) + { + GPBUtil::checkString($var, True); + $this->next_page_token = $var; + + return $this; + } + + /** + * Locations that could not be reached. + * + * Generated from protobuf field repeated string unreachable = 3; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getUnreachable() + { + return $this->unreachable; + } + + /** + * Locations that could not be reached. + * + * Generated from protobuf field repeated string unreachable = 3; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setUnreachable($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->unreachable = $arr; + + return $this; + } + +} + diff --git a/Memorystore/src/V1/NodeConfig.php b/Memorystore/src/V1/NodeConfig.php new file mode 100644 index 000000000000..bef3c9fc991e --- /dev/null +++ b/Memorystore/src/V1/NodeConfig.php @@ -0,0 +1,67 @@ +google.cloud.memorystore.v1.NodeConfig + */ +class NodeConfig extends \Google\Protobuf\Internal\Message +{ + /** + * Output only. Memory size in GB of the node. + * + * Generated from protobuf field double size_gb = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $size_gb = 0.0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type float $size_gb + * Output only. Memory size in GB of the node. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Memorystore\V1\Memorystore::initOnce(); + parent::__construct($data); + } + + /** + * Output only. Memory size in GB of the node. + * + * Generated from protobuf field double size_gb = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return float + */ + public function getSizeGb() + { + return $this->size_gb; + } + + /** + * Output only. Memory size in GB of the node. + * + * Generated from protobuf field double size_gb = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param float $var + * @return $this + */ + public function setSizeGb($var) + { + GPBUtil::checkDouble($var); + $this->size_gb = $var; + + return $this; + } + +} + diff --git a/Memorystore/src/V1/OperationMetadata.php b/Memorystore/src/V1/OperationMetadata.php new file mode 100644 index 000000000000..77d59a7dcc01 --- /dev/null +++ b/Memorystore/src/V1/OperationMetadata.php @@ -0,0 +1,307 @@ +google.cloud.memorystore.v1.OperationMetadata + */ +class OperationMetadata extends \Google\Protobuf\Internal\Message +{ + /** + * Output only. The time the operation was created. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $create_time = null; + /** + * Output only. The time the operation finished running. + * + * Generated from protobuf field .google.protobuf.Timestamp end_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $end_time = null; + /** + * Output only. Server-defined resource path for the target of the operation. + * + * Generated from protobuf field string target = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $target = ''; + /** + * Output only. Name of the verb executed by the operation. + * + * Generated from protobuf field string verb = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $verb = ''; + /** + * Output only. Human-readable status of the operation, if any. + * + * Generated from protobuf field string status_message = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $status_message = ''; + /** + * Output only. Identifies whether the user has requested cancellation + * of the operation. Operations that have been cancelled successfully + * have [Operation.error][] value with a + * [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to + * `Code.CANCELLED`. + * + * Generated from protobuf field bool requested_cancellation = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $requested_cancellation = false; + /** + * Output only. API version used to start the operation. + * + * Generated from protobuf field string api_version = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $api_version = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Protobuf\Timestamp $create_time + * Output only. The time the operation was created. + * @type \Google\Protobuf\Timestamp $end_time + * Output only. The time the operation finished running. + * @type string $target + * Output only. Server-defined resource path for the target of the operation. + * @type string $verb + * Output only. Name of the verb executed by the operation. + * @type string $status_message + * Output only. Human-readable status of the operation, if any. + * @type bool $requested_cancellation + * Output only. Identifies whether the user has requested cancellation + * of the operation. Operations that have been cancelled successfully + * have [Operation.error][] value with a + * [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to + * `Code.CANCELLED`. + * @type string $api_version + * Output only. API version used to start the operation. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Memorystore\V1\Memorystore::initOnce(); + parent::__construct($data); + } + + /** + * Output only. The time the operation was created. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Timestamp|null + */ + public function getCreateTime() + { + return $this->create_time; + } + + public function hasCreateTime() + { + return isset($this->create_time); + } + + public function clearCreateTime() + { + unset($this->create_time); + } + + /** + * Output only. The time the operation was created. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 1 [(.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 the operation finished running. + * + * Generated from protobuf field .google.protobuf.Timestamp end_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Timestamp|null + */ + public function getEndTime() + { + return $this->end_time; + } + + public function hasEndTime() + { + return isset($this->end_time); + } + + public function clearEndTime() + { + unset($this->end_time); + } + + /** + * Output only. The time the operation finished running. + * + * Generated from protobuf field .google.protobuf.Timestamp end_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setEndTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->end_time = $var; + + return $this; + } + + /** + * Output only. Server-defined resource path for the target of the operation. + * + * Generated from protobuf field string target = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getTarget() + { + return $this->target; + } + + /** + * Output only. Server-defined resource path for the target of the operation. + * + * Generated from protobuf field string target = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setTarget($var) + { + GPBUtil::checkString($var, True); + $this->target = $var; + + return $this; + } + + /** + * Output only. Name of the verb executed by the operation. + * + * Generated from protobuf field string verb = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getVerb() + { + return $this->verb; + } + + /** + * Output only. Name of the verb executed by the operation. + * + * Generated from protobuf field string verb = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setVerb($var) + { + GPBUtil::checkString($var, True); + $this->verb = $var; + + return $this; + } + + /** + * Output only. Human-readable status of the operation, if any. + * + * Generated from protobuf field string status_message = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getStatusMessage() + { + return $this->status_message; + } + + /** + * Output only. Human-readable status of the operation, if any. + * + * Generated from protobuf field string status_message = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setStatusMessage($var) + { + GPBUtil::checkString($var, True); + $this->status_message = $var; + + return $this; + } + + /** + * Output only. Identifies whether the user has requested cancellation + * of the operation. Operations that have been cancelled successfully + * have [Operation.error][] value with a + * [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to + * `Code.CANCELLED`. + * + * Generated from protobuf field bool requested_cancellation = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return bool + */ + public function getRequestedCancellation() + { + return $this->requested_cancellation; + } + + /** + * Output only. Identifies whether the user has requested cancellation + * of the operation. Operations that have been cancelled successfully + * have [Operation.error][] value with a + * [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to + * `Code.CANCELLED`. + * + * Generated from protobuf field bool requested_cancellation = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param bool $var + * @return $this + */ + public function setRequestedCancellation($var) + { + GPBUtil::checkBool($var); + $this->requested_cancellation = $var; + + return $this; + } + + /** + * Output only. API version used to start the operation. + * + * Generated from protobuf field string api_version = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getApiVersion() + { + return $this->api_version; + } + + /** + * Output only. API version used to start the operation. + * + * Generated from protobuf field string api_version = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setApiVersion($var) + { + GPBUtil::checkString($var, True); + $this->api_version = $var; + + return $this; + } + +} + diff --git a/Memorystore/src/V1/PersistenceConfig.php b/Memorystore/src/V1/PersistenceConfig.php new file mode 100644 index 000000000000..9c0b07a03200 --- /dev/null +++ b/Memorystore/src/V1/PersistenceConfig.php @@ -0,0 +1,155 @@ +google.cloud.memorystore.v1.PersistenceConfig + */ +class PersistenceConfig extends \Google\Protobuf\Internal\Message +{ + /** + * Optional. Current persistence mode. + * + * Generated from protobuf field .google.cloud.memorystore.v1.PersistenceConfig.PersistenceMode mode = 1 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $mode = 0; + /** + * Optional. RDB configuration. This field will be ignored if mode is not RDB. + * + * Generated from protobuf field .google.cloud.memorystore.v1.PersistenceConfig.RDBConfig rdb_config = 2 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $rdb_config = null; + /** + * Optional. AOF configuration. This field will be ignored if mode is not AOF. + * + * Generated from protobuf field .google.cloud.memorystore.v1.PersistenceConfig.AOFConfig aof_config = 3 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $aof_config = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int $mode + * Optional. Current persistence mode. + * @type \Google\Cloud\Memorystore\V1\PersistenceConfig\RDBConfig $rdb_config + * Optional. RDB configuration. This field will be ignored if mode is not RDB. + * @type \Google\Cloud\Memorystore\V1\PersistenceConfig\AOFConfig $aof_config + * Optional. AOF configuration. This field will be ignored if mode is not AOF. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Memorystore\V1\Memorystore::initOnce(); + parent::__construct($data); + } + + /** + * Optional. Current persistence mode. + * + * Generated from protobuf field .google.cloud.memorystore.v1.PersistenceConfig.PersistenceMode mode = 1 [(.google.api.field_behavior) = OPTIONAL]; + * @return int + */ + public function getMode() + { + return $this->mode; + } + + /** + * Optional. Current persistence mode. + * + * Generated from protobuf field .google.cloud.memorystore.v1.PersistenceConfig.PersistenceMode mode = 1 [(.google.api.field_behavior) = OPTIONAL]; + * @param int $var + * @return $this + */ + public function setMode($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Memorystore\V1\PersistenceConfig\PersistenceMode::class); + $this->mode = $var; + + return $this; + } + + /** + * Optional. RDB configuration. This field will be ignored if mode is not RDB. + * + * Generated from protobuf field .google.cloud.memorystore.v1.PersistenceConfig.RDBConfig rdb_config = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Cloud\Memorystore\V1\PersistenceConfig\RDBConfig|null + */ + public function getRdbConfig() + { + return $this->rdb_config; + } + + public function hasRdbConfig() + { + return isset($this->rdb_config); + } + + public function clearRdbConfig() + { + unset($this->rdb_config); + } + + /** + * Optional. RDB configuration. This field will be ignored if mode is not RDB. + * + * Generated from protobuf field .google.cloud.memorystore.v1.PersistenceConfig.RDBConfig rdb_config = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @param \Google\Cloud\Memorystore\V1\PersistenceConfig\RDBConfig $var + * @return $this + */ + public function setRdbConfig($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Memorystore\V1\PersistenceConfig\RDBConfig::class); + $this->rdb_config = $var; + + return $this; + } + + /** + * Optional. AOF configuration. This field will be ignored if mode is not AOF. + * + * Generated from protobuf field .google.cloud.memorystore.v1.PersistenceConfig.AOFConfig aof_config = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Cloud\Memorystore\V1\PersistenceConfig\AOFConfig|null + */ + public function getAofConfig() + { + return $this->aof_config; + } + + public function hasAofConfig() + { + return isset($this->aof_config); + } + + public function clearAofConfig() + { + unset($this->aof_config); + } + + /** + * Optional. AOF configuration. This field will be ignored if mode is not AOF. + * + * Generated from protobuf field .google.cloud.memorystore.v1.PersistenceConfig.AOFConfig aof_config = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @param \Google\Cloud\Memorystore\V1\PersistenceConfig\AOFConfig $var + * @return $this + */ + public function setAofConfig($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Memorystore\V1\PersistenceConfig\AOFConfig::class); + $this->aof_config = $var; + + return $this; + } + +} + diff --git a/Memorystore/src/V1/PersistenceConfig/AOFConfig.php b/Memorystore/src/V1/PersistenceConfig/AOFConfig.php new file mode 100644 index 000000000000..835a98364960 --- /dev/null +++ b/Memorystore/src/V1/PersistenceConfig/AOFConfig.php @@ -0,0 +1,68 @@ +google.cloud.memorystore.v1.PersistenceConfig.AOFConfig + */ +class AOFConfig extends \Google\Protobuf\Internal\Message +{ + /** + * Optional. The fsync mode. + * + * Generated from protobuf field .google.cloud.memorystore.v1.PersistenceConfig.AOFConfig.AppendFsync append_fsync = 1 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $append_fsync = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int $append_fsync + * Optional. The fsync mode. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Memorystore\V1\Memorystore::initOnce(); + parent::__construct($data); + } + + /** + * Optional. The fsync mode. + * + * Generated from protobuf field .google.cloud.memorystore.v1.PersistenceConfig.AOFConfig.AppendFsync append_fsync = 1 [(.google.api.field_behavior) = OPTIONAL]; + * @return int + */ + public function getAppendFsync() + { + return $this->append_fsync; + } + + /** + * Optional. The fsync mode. + * + * Generated from protobuf field .google.cloud.memorystore.v1.PersistenceConfig.AOFConfig.AppendFsync append_fsync = 1 [(.google.api.field_behavior) = OPTIONAL]; + * @param int $var + * @return $this + */ + public function setAppendFsync($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Memorystore\V1\PersistenceConfig\AOFConfig\AppendFsync::class); + $this->append_fsync = $var; + + return $this; + } + +} + + diff --git a/Memorystore/src/V1/PersistenceConfig/AOFConfig/AppendFsync.php b/Memorystore/src/V1/PersistenceConfig/AOFConfig/AppendFsync.php new file mode 100644 index 000000000000..a6333126e3eb --- /dev/null +++ b/Memorystore/src/V1/PersistenceConfig/AOFConfig/AppendFsync.php @@ -0,0 +1,72 @@ +google.cloud.memorystore.v1.PersistenceConfig.AOFConfig.AppendFsync + */ +class AppendFsync +{ + /** + * Not set. Default: EVERY_SEC + * + * Generated from protobuf enum APPEND_FSYNC_UNSPECIFIED = 0; + */ + const APPEND_FSYNC_UNSPECIFIED = 0; + /** + * Never fsync. Normally Linux will flush data every 30 seconds with this + * configuration, but it's up to the kernel's exact tuning. + * + * Generated from protobuf enum NEVER = 1; + */ + const NEVER = 1; + /** + * Fsync every second. You may lose 1 second of data if there is a + * disaster. + * + * Generated from protobuf enum EVERY_SEC = 2; + */ + const EVERY_SEC = 2; + /** + * Fsync every time new write commands are appended to the AOF. The best + * data loss protection at the cost of performance. + * + * Generated from protobuf enum ALWAYS = 3; + */ + const ALWAYS = 3; + + private static $valueToName = [ + self::APPEND_FSYNC_UNSPECIFIED => 'APPEND_FSYNC_UNSPECIFIED', + self::NEVER => 'NEVER', + self::EVERY_SEC => 'EVERY_SEC', + self::ALWAYS => 'ALWAYS', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + + diff --git a/Memorystore/src/V1/PersistenceConfig/PersistenceMode.php b/Memorystore/src/V1/PersistenceConfig/PersistenceMode.php new file mode 100644 index 000000000000..908dbe054a3b --- /dev/null +++ b/Memorystore/src/V1/PersistenceConfig/PersistenceMode.php @@ -0,0 +1,69 @@ +google.cloud.memorystore.v1.PersistenceConfig.PersistenceMode + */ +class PersistenceMode +{ + /** + * Not set. + * + * Generated from protobuf enum PERSISTENCE_MODE_UNSPECIFIED = 0; + */ + const PERSISTENCE_MODE_UNSPECIFIED = 0; + /** + * Persistence is disabled, and any snapshot data is deleted. + * + * Generated from protobuf enum DISABLED = 1; + */ + const DISABLED = 1; + /** + * RDB based persistence is enabled. + * + * Generated from protobuf enum RDB = 2; + */ + const RDB = 2; + /** + * AOF based persistence is enabled. + * + * Generated from protobuf enum AOF = 3; + */ + const AOF = 3; + + private static $valueToName = [ + self::PERSISTENCE_MODE_UNSPECIFIED => 'PERSISTENCE_MODE_UNSPECIFIED', + self::DISABLED => 'DISABLED', + self::RDB => 'RDB', + self::AOF => 'AOF', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + + diff --git a/Memorystore/src/V1/PersistenceConfig/RDBConfig.php b/Memorystore/src/V1/PersistenceConfig/RDBConfig.php new file mode 100644 index 000000000000..f9e94740efe4 --- /dev/null +++ b/Memorystore/src/V1/PersistenceConfig/RDBConfig.php @@ -0,0 +1,120 @@ +google.cloud.memorystore.v1.PersistenceConfig.RDBConfig + */ +class RDBConfig extends \Google\Protobuf\Internal\Message +{ + /** + * Optional. Period between RDB snapshots. + * + * Generated from protobuf field .google.cloud.memorystore.v1.PersistenceConfig.RDBConfig.SnapshotPeriod rdb_snapshot_period = 1 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $rdb_snapshot_period = 0; + /** + * Optional. Time that the first snapshot was/will be attempted, and to + * which future snapshots will be aligned. If not provided, the current time + * will be used. + * + * Generated from protobuf field .google.protobuf.Timestamp rdb_snapshot_start_time = 2 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $rdb_snapshot_start_time = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int $rdb_snapshot_period + * Optional. Period between RDB snapshots. + * @type \Google\Protobuf\Timestamp $rdb_snapshot_start_time + * Optional. Time that the first snapshot was/will be attempted, and to + * which future snapshots will be aligned. If not provided, the current time + * will be used. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Memorystore\V1\Memorystore::initOnce(); + parent::__construct($data); + } + + /** + * Optional. Period between RDB snapshots. + * + * Generated from protobuf field .google.cloud.memorystore.v1.PersistenceConfig.RDBConfig.SnapshotPeriod rdb_snapshot_period = 1 [(.google.api.field_behavior) = OPTIONAL]; + * @return int + */ + public function getRdbSnapshotPeriod() + { + return $this->rdb_snapshot_period; + } + + /** + * Optional. Period between RDB snapshots. + * + * Generated from protobuf field .google.cloud.memorystore.v1.PersistenceConfig.RDBConfig.SnapshotPeriod rdb_snapshot_period = 1 [(.google.api.field_behavior) = OPTIONAL]; + * @param int $var + * @return $this + */ + public function setRdbSnapshotPeriod($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Memorystore\V1\PersistenceConfig\RDBConfig\SnapshotPeriod::class); + $this->rdb_snapshot_period = $var; + + return $this; + } + + /** + * Optional. Time that the first snapshot was/will be attempted, and to + * which future snapshots will be aligned. If not provided, the current time + * will be used. + * + * Generated from protobuf field .google.protobuf.Timestamp rdb_snapshot_start_time = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Protobuf\Timestamp|null + */ + public function getRdbSnapshotStartTime() + { + return $this->rdb_snapshot_start_time; + } + + public function hasRdbSnapshotStartTime() + { + return isset($this->rdb_snapshot_start_time); + } + + public function clearRdbSnapshotStartTime() + { + unset($this->rdb_snapshot_start_time); + } + + /** + * Optional. Time that the first snapshot was/will be attempted, and to + * which future snapshots will be aligned. If not provided, the current time + * will be used. + * + * Generated from protobuf field .google.protobuf.Timestamp rdb_snapshot_start_time = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setRdbSnapshotStartTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->rdb_snapshot_start_time = $var; + + return $this; + } + +} + + diff --git a/Memorystore/src/V1/PersistenceConfig/RDBConfig/SnapshotPeriod.php b/Memorystore/src/V1/PersistenceConfig/RDBConfig/SnapshotPeriod.php new file mode 100644 index 000000000000..3378d53e41d1 --- /dev/null +++ b/Memorystore/src/V1/PersistenceConfig/RDBConfig/SnapshotPeriod.php @@ -0,0 +1,76 @@ +google.cloud.memorystore.v1.PersistenceConfig.RDBConfig.SnapshotPeriod + */ +class SnapshotPeriod +{ + /** + * Not set. + * + * Generated from protobuf enum SNAPSHOT_PERIOD_UNSPECIFIED = 0; + */ + const SNAPSHOT_PERIOD_UNSPECIFIED = 0; + /** + * One hour. + * + * Generated from protobuf enum ONE_HOUR = 1; + */ + const ONE_HOUR = 1; + /** + * Six hours. + * + * Generated from protobuf enum SIX_HOURS = 2; + */ + const SIX_HOURS = 2; + /** + * Twelve hours. + * + * Generated from protobuf enum TWELVE_HOURS = 3; + */ + const TWELVE_HOURS = 3; + /** + * Twenty four hours. + * + * Generated from protobuf enum TWENTY_FOUR_HOURS = 4; + */ + const TWENTY_FOUR_HOURS = 4; + + private static $valueToName = [ + self::SNAPSHOT_PERIOD_UNSPECIFIED => 'SNAPSHOT_PERIOD_UNSPECIFIED', + self::ONE_HOUR => 'ONE_HOUR', + self::SIX_HOURS => 'SIX_HOURS', + self::TWELVE_HOURS => 'TWELVE_HOURS', + self::TWENTY_FOUR_HOURS => 'TWENTY_FOUR_HOURS', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + + diff --git a/Memorystore/src/V1/PscAutoConnection.php b/Memorystore/src/V1/PscAutoConnection.php new file mode 100644 index 000000000000..11ec637315fb --- /dev/null +++ b/Memorystore/src/V1/PscAutoConnection.php @@ -0,0 +1,394 @@ +google.cloud.memorystore.v1.PscAutoConnection + */ +class PscAutoConnection extends \Google\Protobuf\Internal\Message +{ + /** + * Output only. The PSC connection id of the forwarding rule connected to the + * service attachment. + * + * Generated from protobuf field string psc_connection_id = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $psc_connection_id = ''; + /** + * Output only. The IP allocated on the consumer network for the PSC + * forwarding rule. + * + * Generated from protobuf field string ip_address = 2 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.field_info) = { + */ + protected $ip_address = ''; + /** + * Output only. The URI of the consumer side forwarding rule. + * Format: + * projects/{project}/regions/{region}/forwardingRules/{forwarding_rule} + * + * Generated from protobuf field string forwarding_rule = 3 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { + */ + protected $forwarding_rule = ''; + /** + * Required. The consumer project_id where PSC connections are established. + * This should be the same project_id that the instance is being created in. + * + * Generated from protobuf field string project_id = 4 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $project_id = ''; + /** + * Required. The network where the PSC endpoints are created, in the form of + * projects/{project_id}/global/networks/{network_id}. + * + * Generated from protobuf field string network = 5 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $network = ''; + /** + * Output only. The service attachment which is the target of the PSC + * connection, in the form of + * projects/{project-id}/regions/{region}/serviceAttachments/{service-attachment-id}. + * + * Generated from protobuf field string service_attachment = 6 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { + */ + protected $service_attachment = ''; + /** + * Output only. The status of the PSC connection: whether a connection exists + * and ACTIVE or it no longer exists. Please note that this value is updated + * periodically. Please use Private Service Connect APIs for the latest + * status. + * + * Generated from protobuf field .google.cloud.memorystore.v1.PscConnectionStatus psc_connection_status = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $psc_connection_status = 0; + /** + * Output only. Type of the PSC connection. + * + * Generated from protobuf field .google.cloud.memorystore.v1.ConnectionType connection_type = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $connection_type = 0; + protected $ports; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int $port + * Optional. Output only. port will only be set for Primary/Reader or + * Discovery endpoint. + * @type string $psc_connection_id + * Output only. The PSC connection id of the forwarding rule connected to the + * service attachment. + * @type string $ip_address + * Output only. The IP allocated on the consumer network for the PSC + * forwarding rule. + * @type string $forwarding_rule + * Output only. The URI of the consumer side forwarding rule. + * Format: + * projects/{project}/regions/{region}/forwardingRules/{forwarding_rule} + * @type string $project_id + * Required. The consumer project_id where PSC connections are established. + * This should be the same project_id that the instance is being created in. + * @type string $network + * Required. The network where the PSC endpoints are created, in the form of + * projects/{project_id}/global/networks/{network_id}. + * @type string $service_attachment + * Output only. The service attachment which is the target of the PSC + * connection, in the form of + * projects/{project-id}/regions/{region}/serviceAttachments/{service-attachment-id}. + * @type int $psc_connection_status + * Output only. The status of the PSC connection: whether a connection exists + * and ACTIVE or it no longer exists. Please note that this value is updated + * periodically. Please use Private Service Connect APIs for the latest + * status. + * @type int $connection_type + * Output only. Type of the PSC connection. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Memorystore\V1\Memorystore::initOnce(); + parent::__construct($data); + } + + /** + * Optional. Output only. port will only be set for Primary/Reader or + * Discovery endpoint. + * + * Generated from protobuf field int32 port = 9 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.field_behavior) = OPTIONAL]; + * @return int + */ + public function getPort() + { + return $this->readOneof(9); + } + + public function hasPort() + { + return $this->hasOneof(9); + } + + /** + * Optional. Output only. port will only be set for Primary/Reader or + * Discovery endpoint. + * + * Generated from protobuf field int32 port = 9 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.field_behavior) = OPTIONAL]; + * @param int $var + * @return $this + */ + public function setPort($var) + { + GPBUtil::checkInt32($var); + $this->writeOneof(9, $var); + + return $this; + } + + /** + * Output only. The PSC connection id of the forwarding rule connected to the + * service attachment. + * + * Generated from protobuf field string psc_connection_id = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getPscConnectionId() + { + return $this->psc_connection_id; + } + + /** + * Output only. The PSC connection id of the forwarding rule connected to the + * service attachment. + * + * Generated from protobuf field string psc_connection_id = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setPscConnectionId($var) + { + GPBUtil::checkString($var, True); + $this->psc_connection_id = $var; + + return $this; + } + + /** + * Output only. The IP allocated on the consumer network for the PSC + * forwarding rule. + * + * Generated from protobuf field string ip_address = 2 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.field_info) = { + * @return string + */ + public function getIpAddress() + { + return $this->ip_address; + } + + /** + * Output only. The IP allocated on the consumer network for the PSC + * forwarding rule. + * + * Generated from protobuf field string ip_address = 2 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.field_info) = { + * @param string $var + * @return $this + */ + public function setIpAddress($var) + { + GPBUtil::checkString($var, True); + $this->ip_address = $var; + + return $this; + } + + /** + * Output only. The URI of the consumer side forwarding rule. + * Format: + * projects/{project}/regions/{region}/forwardingRules/{forwarding_rule} + * + * Generated from protobuf field string forwarding_rule = 3 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { + * @return string + */ + public function getForwardingRule() + { + return $this->forwarding_rule; + } + + /** + * Output only. The URI of the consumer side forwarding rule. + * Format: + * projects/{project}/regions/{region}/forwardingRules/{forwarding_rule} + * + * Generated from protobuf field string forwarding_rule = 3 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setForwardingRule($var) + { + GPBUtil::checkString($var, True); + $this->forwarding_rule = $var; + + return $this; + } + + /** + * Required. The consumer project_id where PSC connections are established. + * This should be the same project_id that the instance is being created in. + * + * Generated from protobuf field string project_id = 4 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getProjectId() + { + return $this->project_id; + } + + /** + * Required. The consumer project_id where PSC connections are established. + * This should be the same project_id that the instance is being created in. + * + * Generated from protobuf field string project_id = 4 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setProjectId($var) + { + GPBUtil::checkString($var, True); + $this->project_id = $var; + + return $this; + } + + /** + * Required. The network where the PSC endpoints are created, in the form of + * projects/{project_id}/global/networks/{network_id}. + * + * Generated from protobuf field string network = 5 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getNetwork() + { + return $this->network; + } + + /** + * Required. The network where the PSC endpoints are created, in the form of + * projects/{project_id}/global/networks/{network_id}. + * + * Generated from protobuf field string network = 5 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setNetwork($var) + { + GPBUtil::checkString($var, True); + $this->network = $var; + + return $this; + } + + /** + * Output only. The service attachment which is the target of the PSC + * connection, in the form of + * projects/{project-id}/regions/{region}/serviceAttachments/{service-attachment-id}. + * + * Generated from protobuf field string service_attachment = 6 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { + * @return string + */ + public function getServiceAttachment() + { + return $this->service_attachment; + } + + /** + * Output only. The service attachment which is the target of the PSC + * connection, in the form of + * projects/{project-id}/regions/{region}/serviceAttachments/{service-attachment-id}. + * + * Generated from protobuf field string service_attachment = 6 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setServiceAttachment($var) + { + GPBUtil::checkString($var, True); + $this->service_attachment = $var; + + return $this; + } + + /** + * Output only. The status of the PSC connection: whether a connection exists + * and ACTIVE or it no longer exists. Please note that this value is updated + * periodically. Please use Private Service Connect APIs for the latest + * status. + * + * Generated from protobuf field .google.cloud.memorystore.v1.PscConnectionStatus psc_connection_status = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return int + */ + public function getPscConnectionStatus() + { + return $this->psc_connection_status; + } + + /** + * Output only. The status of the PSC connection: whether a connection exists + * and ACTIVE or it no longer exists. Please note that this value is updated + * periodically. Please use Private Service Connect APIs for the latest + * status. + * + * Generated from protobuf field .google.cloud.memorystore.v1.PscConnectionStatus psc_connection_status = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param int $var + * @return $this + */ + public function setPscConnectionStatus($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Memorystore\V1\PscConnectionStatus::class); + $this->psc_connection_status = $var; + + return $this; + } + + /** + * Output only. Type of the PSC connection. + * + * Generated from protobuf field .google.cloud.memorystore.v1.ConnectionType connection_type = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return int + */ + public function getConnectionType() + { + return $this->connection_type; + } + + /** + * Output only. Type of the PSC connection. + * + * Generated from protobuf field .google.cloud.memorystore.v1.ConnectionType connection_type = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param int $var + * @return $this + */ + public function setConnectionType($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Memorystore\V1\ConnectionType::class); + $this->connection_type = $var; + + return $this; + } + + /** + * @return string + */ + public function getPorts() + { + return $this->whichOneof("ports"); + } + +} + diff --git a/Memorystore/src/V1/PscConnection.php b/Memorystore/src/V1/PscConnection.php new file mode 100644 index 000000000000..4c60a46789c4 --- /dev/null +++ b/Memorystore/src/V1/PscConnection.php @@ -0,0 +1,349 @@ +google.cloud.memorystore.v1.PscConnection + */ +class PscConnection extends \Google\Protobuf\Internal\Message +{ + /** + * Output only. The PSC connection id of the forwarding rule connected to the + * service attachment. + * + * Generated from protobuf field string psc_connection_id = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $psc_connection_id = ''; + /** + * Required. The IP allocated on the consumer network for the PSC forwarding + * rule. + * + * Generated from protobuf field string ip_address = 2 [(.google.api.field_behavior) = REQUIRED, (.google.api.field_info) = { + */ + protected $ip_address = ''; + /** + * Required. The URI of the consumer side forwarding rule. + * Format: + * projects/{project}/regions/{region}/forwardingRules/{forwarding_rule} + * + * Generated from protobuf field string forwarding_rule = 3 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $forwarding_rule = ''; + /** + * Output only. The consumer project_id where the forwarding rule is created + * from. + * + * Generated from protobuf field string project_id = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $project_id = ''; + /** + * Required. The consumer network where the IP address resides, in the form of + * projects/{project_id}/global/networks/{network_id}. + * + * Generated from protobuf field string network = 5 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $network = ''; + /** + * Required. The service attachment which is the target of the PSC connection, + * in the form of + * projects/{project-id}/regions/{region}/serviceAttachments/{service-attachment-id}. + * + * Generated from protobuf field string service_attachment = 6 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $service_attachment = ''; + /** + * Output only. The status of the PSC connection: whether a connection exists + * and ACTIVE or it no longer exists. Please note that this value is updated + * periodically. Please use Private Service Connect APIs for the latest + * status. + * + * Generated from protobuf field .google.cloud.memorystore.v1.PscConnectionStatus psc_connection_status = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $psc_connection_status = 0; + /** + * Output only. Type of the PSC connection. + * + * Generated from protobuf field .google.cloud.memorystore.v1.ConnectionType connection_type = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $connection_type = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $psc_connection_id + * Output only. The PSC connection id of the forwarding rule connected to the + * service attachment. + * @type string $ip_address + * Required. The IP allocated on the consumer network for the PSC forwarding + * rule. + * @type string $forwarding_rule + * Required. The URI of the consumer side forwarding rule. + * Format: + * projects/{project}/regions/{region}/forwardingRules/{forwarding_rule} + * @type string $project_id + * Output only. The consumer project_id where the forwarding rule is created + * from. + * @type string $network + * Required. The consumer network where the IP address resides, in the form of + * projects/{project_id}/global/networks/{network_id}. + * @type string $service_attachment + * Required. The service attachment which is the target of the PSC connection, + * in the form of + * projects/{project-id}/regions/{region}/serviceAttachments/{service-attachment-id}. + * @type int $psc_connection_status + * Output only. The status of the PSC connection: whether a connection exists + * and ACTIVE or it no longer exists. Please note that this value is updated + * periodically. Please use Private Service Connect APIs for the latest + * status. + * @type int $connection_type + * Output only. Type of the PSC connection. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Memorystore\V1\Memorystore::initOnce(); + parent::__construct($data); + } + + /** + * Output only. The PSC connection id of the forwarding rule connected to the + * service attachment. + * + * Generated from protobuf field string psc_connection_id = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getPscConnectionId() + { + return $this->psc_connection_id; + } + + /** + * Output only. The PSC connection id of the forwarding rule connected to the + * service attachment. + * + * Generated from protobuf field string psc_connection_id = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setPscConnectionId($var) + { + GPBUtil::checkString($var, True); + $this->psc_connection_id = $var; + + return $this; + } + + /** + * Required. The IP allocated on the consumer network for the PSC forwarding + * rule. + * + * Generated from protobuf field string ip_address = 2 [(.google.api.field_behavior) = REQUIRED, (.google.api.field_info) = { + * @return string + */ + public function getIpAddress() + { + return $this->ip_address; + } + + /** + * Required. The IP allocated on the consumer network for the PSC forwarding + * rule. + * + * Generated from protobuf field string ip_address = 2 [(.google.api.field_behavior) = REQUIRED, (.google.api.field_info) = { + * @param string $var + * @return $this + */ + public function setIpAddress($var) + { + GPBUtil::checkString($var, True); + $this->ip_address = $var; + + return $this; + } + + /** + * Required. The URI of the consumer side forwarding rule. + * Format: + * projects/{project}/regions/{region}/forwardingRules/{forwarding_rule} + * + * Generated from protobuf field string forwarding_rule = 3 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getForwardingRule() + { + return $this->forwarding_rule; + } + + /** + * Required. The URI of the consumer side forwarding rule. + * Format: + * projects/{project}/regions/{region}/forwardingRules/{forwarding_rule} + * + * Generated from protobuf field string forwarding_rule = 3 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setForwardingRule($var) + { + GPBUtil::checkString($var, True); + $this->forwarding_rule = $var; + + return $this; + } + + /** + * Output only. The consumer project_id where the forwarding rule is created + * from. + * + * Generated from protobuf field string project_id = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getProjectId() + { + return $this->project_id; + } + + /** + * Output only. The consumer project_id where the forwarding rule is created + * from. + * + * Generated from protobuf field string project_id = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setProjectId($var) + { + GPBUtil::checkString($var, True); + $this->project_id = $var; + + return $this; + } + + /** + * Required. The consumer network where the IP address resides, in the form of + * projects/{project_id}/global/networks/{network_id}. + * + * Generated from protobuf field string network = 5 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getNetwork() + { + return $this->network; + } + + /** + * Required. The consumer network where the IP address resides, in the form of + * projects/{project_id}/global/networks/{network_id}. + * + * Generated from protobuf field string network = 5 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setNetwork($var) + { + GPBUtil::checkString($var, True); + $this->network = $var; + + return $this; + } + + /** + * Required. The service attachment which is the target of the PSC connection, + * in the form of + * projects/{project-id}/regions/{region}/serviceAttachments/{service-attachment-id}. + * + * Generated from protobuf field string service_attachment = 6 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getServiceAttachment() + { + return $this->service_attachment; + } + + /** + * Required. The service attachment which is the target of the PSC connection, + * in the form of + * projects/{project-id}/regions/{region}/serviceAttachments/{service-attachment-id}. + * + * Generated from protobuf field string service_attachment = 6 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setServiceAttachment($var) + { + GPBUtil::checkString($var, True); + $this->service_attachment = $var; + + return $this; + } + + /** + * Output only. The status of the PSC connection: whether a connection exists + * and ACTIVE or it no longer exists. Please note that this value is updated + * periodically. Please use Private Service Connect APIs for the latest + * status. + * + * Generated from protobuf field .google.cloud.memorystore.v1.PscConnectionStatus psc_connection_status = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return int + */ + public function getPscConnectionStatus() + { + return $this->psc_connection_status; + } + + /** + * Output only. The status of the PSC connection: whether a connection exists + * and ACTIVE or it no longer exists. Please note that this value is updated + * periodically. Please use Private Service Connect APIs for the latest + * status. + * + * Generated from protobuf field .google.cloud.memorystore.v1.PscConnectionStatus psc_connection_status = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param int $var + * @return $this + */ + public function setPscConnectionStatus($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Memorystore\V1\PscConnectionStatus::class); + $this->psc_connection_status = $var; + + return $this; + } + + /** + * Output only. Type of the PSC connection. + * + * Generated from protobuf field .google.cloud.memorystore.v1.ConnectionType connection_type = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return int + */ + public function getConnectionType() + { + return $this->connection_type; + } + + /** + * Output only. Type of the PSC connection. + * + * Generated from protobuf field .google.cloud.memorystore.v1.ConnectionType connection_type = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param int $var + * @return $this + */ + public function setConnectionType($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Memorystore\V1\ConnectionType::class); + $this->connection_type = $var; + + return $this; + } + +} + diff --git a/Memorystore/src/V1/PscConnectionStatus.php b/Memorystore/src/V1/PscConnectionStatus.php new file mode 100644 index 000000000000..f23a484d2065 --- /dev/null +++ b/Memorystore/src/V1/PscConnectionStatus.php @@ -0,0 +1,61 @@ +google.cloud.memorystore.v1.PscConnectionStatus + */ +class PscConnectionStatus +{ + /** + * PSC connection status is not specified. + * + * Generated from protobuf enum PSC_CONNECTION_STATUS_UNSPECIFIED = 0; + */ + const PSC_CONNECTION_STATUS_UNSPECIFIED = 0; + /** + * The connection is active + * + * Generated from protobuf enum ACTIVE = 1; + */ + const ACTIVE = 1; + /** + * Connection not found + * + * Generated from protobuf enum NOT_FOUND = 2; + */ + const NOT_FOUND = 2; + + private static $valueToName = [ + self::PSC_CONNECTION_STATUS_UNSPECIFIED => 'PSC_CONNECTION_STATUS_UNSPECIFIED', + self::ACTIVE => 'ACTIVE', + self::NOT_FOUND => 'NOT_FOUND', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + diff --git a/Memorystore/src/V1/UpdateInstanceRequest.php b/Memorystore/src/V1/UpdateInstanceRequest.php new file mode 100644 index 000000000000..b57891cef7b1 --- /dev/null +++ b/Memorystore/src/V1/UpdateInstanceRequest.php @@ -0,0 +1,215 @@ +google.cloud.memorystore.v1.UpdateInstanceRequest + */ +class UpdateInstanceRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Optional. The list of fields to be updated on the instance. At least one + * field must be specified. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 1 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $update_mask = null; + /** + * Required. The instance to update. + * + * Generated from protobuf field .google.cloud.memorystore.v1.Instance instance = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $instance = null; + /** + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes since the first request. + * For example, consider a situation where you make an initial request and the + * request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * + * Generated from protobuf field string request_id = 3 [(.google.api.field_behavior) = OPTIONAL, (.google.api.field_info) = { + */ + protected $request_id = ''; + + /** + * @param \Google\Cloud\Memorystore\V1\Instance $instance Required. The instance to update. + * @param \Google\Protobuf\FieldMask $updateMask Optional. The list of fields to be updated on the instance. At least one + * field must be specified. + * + * @return \Google\Cloud\Memorystore\V1\UpdateInstanceRequest + * + * @experimental + */ + public static function build(\Google\Cloud\Memorystore\V1\Instance $instance, \Google\Protobuf\FieldMask $updateMask): self + { + return (new self()) + ->setInstance($instance) + ->setUpdateMask($updateMask); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Protobuf\FieldMask $update_mask + * Optional. The list of fields to be updated on the instance. At least one + * field must be specified. + * @type \Google\Cloud\Memorystore\V1\Instance $instance + * Required. The instance to update. + * @type string $request_id + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes since the first request. + * For example, consider a situation where you make an initial request and the + * request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Memorystore\V1\Memorystore::initOnce(); + parent::__construct($data); + } + + /** + * Optional. The list of fields to be updated on the instance. At least one + * field must be specified. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 1 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Protobuf\FieldMask|null + */ + public function getUpdateMask() + { + return $this->update_mask; + } + + public function hasUpdateMask() + { + return isset($this->update_mask); + } + + public function clearUpdateMask() + { + unset($this->update_mask); + } + + /** + * Optional. The list of fields to be updated on the instance. At least one + * field must be specified. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 1 [(.google.api.field_behavior) = OPTIONAL]; + * @param \Google\Protobuf\FieldMask $var + * @return $this + */ + public function setUpdateMask($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\FieldMask::class); + $this->update_mask = $var; + + return $this; + } + + /** + * Required. The instance to update. + * + * Generated from protobuf field .google.cloud.memorystore.v1.Instance instance = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\Memorystore\V1\Instance|null + */ + public function getInstance() + { + return $this->instance; + } + + public function hasInstance() + { + return isset($this->instance); + } + + public function clearInstance() + { + unset($this->instance); + } + + /** + * Required. The instance to update. + * + * Generated from protobuf field .google.cloud.memorystore.v1.Instance instance = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\Memorystore\V1\Instance $var + * @return $this + */ + public function setInstance($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Memorystore\V1\Instance::class); + $this->instance = $var; + + return $this; + } + + /** + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes since the first request. + * For example, consider a situation where you make an initial request and the + * request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * + * Generated from protobuf field string request_id = 3 [(.google.api.field_behavior) = OPTIONAL, (.google.api.field_info) = { + * @return string + */ + public function getRequestId() + { + return $this->request_id; + } + + /** + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes since the first request. + * For example, consider a situation where you make an initial request and the + * request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * + * Generated from protobuf field string request_id = 3 [(.google.api.field_behavior) = OPTIONAL, (.google.api.field_info) = { + * @param string $var + * @return $this + */ + public function setRequestId($var) + { + GPBUtil::checkString($var, True); + $this->request_id = $var; + + return $this; + } + +} + diff --git a/Memorystore/src/V1/ZoneDistributionConfig.php b/Memorystore/src/V1/ZoneDistributionConfig.php new file mode 100644 index 000000000000..2eba29c25088 --- /dev/null +++ b/Memorystore/src/V1/ZoneDistributionConfig.php @@ -0,0 +1,105 @@ +google.cloud.memorystore.v1.ZoneDistributionConfig + */ +class ZoneDistributionConfig extends \Google\Protobuf\Internal\Message +{ + /** + * Optional. Defines zone where all resources will be allocated with + * SINGLE_ZONE mode. Ignored for MULTI_ZONE mode. + * + * Generated from protobuf field string zone = 2 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $zone = ''; + /** + * Optional. Current zone distribution mode. Defaults to MULTI_ZONE. + * + * Generated from protobuf field .google.cloud.memorystore.v1.ZoneDistributionConfig.ZoneDistributionMode mode = 1 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $mode = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $zone + * Optional. Defines zone where all resources will be allocated with + * SINGLE_ZONE mode. Ignored for MULTI_ZONE mode. + * @type int $mode + * Optional. Current zone distribution mode. Defaults to MULTI_ZONE. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Memorystore\V1\Memorystore::initOnce(); + parent::__construct($data); + } + + /** + * Optional. Defines zone where all resources will be allocated with + * SINGLE_ZONE mode. Ignored for MULTI_ZONE mode. + * + * Generated from protobuf field string zone = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @return string + */ + public function getZone() + { + return $this->zone; + } + + /** + * Optional. Defines zone where all resources will be allocated with + * SINGLE_ZONE mode. Ignored for MULTI_ZONE mode. + * + * Generated from protobuf field string zone = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @param string $var + * @return $this + */ + public function setZone($var) + { + GPBUtil::checkString($var, True); + $this->zone = $var; + + return $this; + } + + /** + * Optional. Current zone distribution mode. Defaults to MULTI_ZONE. + * + * Generated from protobuf field .google.cloud.memorystore.v1.ZoneDistributionConfig.ZoneDistributionMode mode = 1 [(.google.api.field_behavior) = OPTIONAL]; + * @return int + */ + public function getMode() + { + return $this->mode; + } + + /** + * Optional. Current zone distribution mode. Defaults to MULTI_ZONE. + * + * Generated from protobuf field .google.cloud.memorystore.v1.ZoneDistributionConfig.ZoneDistributionMode mode = 1 [(.google.api.field_behavior) = OPTIONAL]; + * @param int $var + * @return $this + */ + public function setMode($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Memorystore\V1\ZoneDistributionConfig\ZoneDistributionMode::class); + $this->mode = $var; + + return $this; + } + +} + diff --git a/Memorystore/src/V1/ZoneDistributionConfig/ZoneDistributionMode.php b/Memorystore/src/V1/ZoneDistributionConfig/ZoneDistributionMode.php new file mode 100644 index 000000000000..804813b32224 --- /dev/null +++ b/Memorystore/src/V1/ZoneDistributionConfig/ZoneDistributionMode.php @@ -0,0 +1,63 @@ +google.cloud.memorystore.v1.ZoneDistributionConfig.ZoneDistributionMode + */ +class ZoneDistributionMode +{ + /** + * Not Set. Default: MULTI_ZONE + * + * Generated from protobuf enum ZONE_DISTRIBUTION_MODE_UNSPECIFIED = 0; + */ + const ZONE_DISTRIBUTION_MODE_UNSPECIFIED = 0; + /** + * Distribute resources across 3 zones picked at random within the + * region. + * + * Generated from protobuf enum MULTI_ZONE = 1; + */ + const MULTI_ZONE = 1; + /** + * Provision resources in a single zone. Zone field must be specified. + * + * Generated from protobuf enum SINGLE_ZONE = 2; + */ + const SINGLE_ZONE = 2; + + private static $valueToName = [ + self::ZONE_DISTRIBUTION_MODE_UNSPECIFIED => 'ZONE_DISTRIBUTION_MODE_UNSPECIFIED', + self::MULTI_ZONE => 'MULTI_ZONE', + self::SINGLE_ZONE => 'SINGLE_ZONE', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + + diff --git a/Memorystore/src/V1/gapic_metadata.json b/Memorystore/src/V1/gapic_metadata.json new file mode 100644 index 000000000000..52fd44fec044 --- /dev/null +++ b/Memorystore/src/V1/gapic_metadata.json @@ -0,0 +1,58 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services\/RPCs to the corresponding library clients\/methods", + "language": "php", + "protoPackage": "google.cloud.memorystore.v1", + "libraryPackage": "Google\\Cloud\\Memorystore\\V1", + "services": { + "Memorystore": { + "clients": { + "grpc": { + "libraryClient": "MemorystoreGapicClient", + "rpcs": { + "CreateInstance": { + "methods": [ + "createInstance" + ] + }, + "DeleteInstance": { + "methods": [ + "deleteInstance" + ] + }, + "GetCertificateAuthority": { + "methods": [ + "getCertificateAuthority" + ] + }, + "GetInstance": { + "methods": [ + "getInstance" + ] + }, + "ListInstances": { + "methods": [ + "listInstances" + ] + }, + "UpdateInstance": { + "methods": [ + "updateInstance" + ] + }, + "GetLocation": { + "methods": [ + "getLocation" + ] + }, + "ListLocations": { + "methods": [ + "listLocations" + ] + } + } + } + } + } + } +} \ No newline at end of file diff --git a/Memorystore/src/V1/resources/memorystore_client_config.json b/Memorystore/src/V1/resources/memorystore_client_config.json new file mode 100644 index 000000000000..2757a190ad1f --- /dev/null +++ b/Memorystore/src/V1/resources/memorystore_client_config.json @@ -0,0 +1,84 @@ +{ + "interfaces": { + "google.cloud.memorystore.v1.Memorystore": { + "retry_codes": { + "no_retry_codes": [], + "retry_policy_1_codes": [ + "UNAVAILABLE" + ], + "no_retry_1_codes": [] + }, + "retry_params": { + "no_retry_params": { + "initial_retry_delay_millis": 0, + "retry_delay_multiplier": 0.0, + "max_retry_delay_millis": 0, + "initial_rpc_timeout_millis": 0, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 0, + "total_timeout_millis": 0 + }, + "retry_policy_1_params": { + "initial_retry_delay_millis": 1000, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 10000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 60000 + }, + "no_retry_1_params": { + "initial_retry_delay_millis": 0, + "retry_delay_multiplier": 0.0, + "max_retry_delay_millis": 0, + "initial_rpc_timeout_millis": 600000, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 600000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "CreateInstance": { + "timeout_millis": 600000, + "retry_codes_name": "no_retry_1_codes", + "retry_params_name": "no_retry_1_params" + }, + "DeleteInstance": { + "timeout_millis": 600000, + "retry_codes_name": "no_retry_1_codes", + "retry_params_name": "no_retry_1_params" + }, + "GetCertificateAuthority": { + "timeout_millis": 60000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, + "GetInstance": { + "timeout_millis": 60000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, + "ListInstances": { + "timeout_millis": 60000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, + "UpdateInstance": { + "timeout_millis": 600000, + "retry_codes_name": "no_retry_1_codes", + "retry_params_name": "no_retry_1_params" + }, + "GetLocation": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + }, + "ListLocations": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + } + } + } + } +} diff --git a/Memorystore/src/V1/resources/memorystore_descriptor_config.php b/Memorystore/src/V1/resources/memorystore_descriptor_config.php new file mode 100644 index 000000000000..e794e46563a0 --- /dev/null +++ b/Memorystore/src/V1/resources/memorystore_descriptor_config.php @@ -0,0 +1,163 @@ + [ + 'google.cloud.memorystore.v1.Memorystore' => [ + 'CreateInstance' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Cloud\Memorystore\V1\Instance', + 'metadataReturnType' => '\Google\Cloud\Memorystore\V1\OperationMetadata', + 'initialPollDelayMillis' => '500', + 'pollDelayMultiplier' => '1.5', + 'maxPollDelayMillis' => '5000', + 'totalPollTimeoutMillis' => '300000', + ], + 'callType' => \Google\ApiCore\Call::LONGRUNNING_CALL, + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'DeleteInstance' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Protobuf\GPBEmpty', + 'metadataReturnType' => '\Google\Cloud\Memorystore\V1\OperationMetadata', + 'initialPollDelayMillis' => '500', + 'pollDelayMultiplier' => '1.5', + 'maxPollDelayMillis' => '5000', + 'totalPollTimeoutMillis' => '300000', + ], + 'callType' => \Google\ApiCore\Call::LONGRUNNING_CALL, + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], + 'UpdateInstance' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Cloud\Memorystore\V1\Instance', + 'metadataReturnType' => '\Google\Cloud\Memorystore\V1\OperationMetadata', + 'initialPollDelayMillis' => '500', + 'pollDelayMultiplier' => '1.5', + 'maxPollDelayMillis' => '5000', + 'totalPollTimeoutMillis' => '300000', + ], + 'callType' => \Google\ApiCore\Call::LONGRUNNING_CALL, + 'headerParams' => [ + [ + 'keyName' => 'instance.name', + 'fieldAccessors' => [ + 'getInstance', + 'getName', + ], + ], + ], + ], + 'GetCertificateAuthority' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Memorystore\V1\CertificateAuthority', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], + 'GetInstance' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Memorystore\V1\Instance', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], + 'ListInstances' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Memorystore\V1\ListInstancesResponse', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'GetLocation' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Location\Location', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + 'interfaceOverride' => 'google.cloud.location.Locations', + ], + 'ListLocations' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getLocations', + ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Location\ListLocationsResponse', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + 'interfaceOverride' => 'google.cloud.location.Locations', + ], + 'templateMap' => [ + 'forwardingRule' => 'projects/{project}/regions/{region}/forwardingRules/{forwarding_rule}', + 'instance' => 'projects/{project}/locations/{location}/instances/{instance}', + 'location' => 'projects/{project}/locations/{location}', + 'network' => 'projects/{project}/global/networks/{network}', + 'serviceAttachment' => 'projects/{project}/regions/{region}/serviceAttachments/{service_attachment}', + ], + ], + ], +]; diff --git a/Memorystore/src/V1/resources/memorystore_rest_client_config.php b/Memorystore/src/V1/resources/memorystore_rest_client_config.php new file mode 100644 index 000000000000..02b2fe385bdc --- /dev/null +++ b/Memorystore/src/V1/resources/memorystore_rest_client_config.php @@ -0,0 +1,171 @@ + [ + 'google.cloud.location.Locations' => [ + 'GetLocation' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/locations/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'ListLocations' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*}/locations', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + ], + 'google.cloud.memorystore.v1.Memorystore' => [ + 'CreateInstance' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{parent=projects/*/locations/*}/instances', + 'body' => 'instance', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + 'queryParams' => [ + 'instance_id', + ], + ], + 'DeleteInstance' => [ + 'method' => 'delete', + 'uriTemplate' => '/v1/{name=projects/*/locations/*/instances/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'GetCertificateAuthority' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/locations/*/instances/*}/certificateAuthority', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'GetInstance' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/locations/*/instances/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'ListInstances' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{parent=projects/*/locations/*}/instances', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + 'UpdateInstance' => [ + 'method' => 'patch', + 'uriTemplate' => '/v1/{instance.name=projects/*/locations/*/instances/*}', + 'body' => 'instance', + 'placeholders' => [ + 'instance.name' => [ + 'getters' => [ + 'getInstance', + 'getName', + ], + ], + ], + ], + ], + 'google.longrunning.Operations' => [ + 'CancelOperation' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{name=projects/*/locations/*/operations/*}:cancel', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'DeleteOperation' => [ + 'method' => 'delete', + 'uriTemplate' => '/v1/{name=projects/*/locations/*/operations/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'GetOperation' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/locations/*/operations/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'ListOperations' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/locations/*}/operations', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + ], + ], + 'numericEnums' => true, +]; diff --git a/Memorystore/tests/Unit/V1/Client/MemorystoreClientTest.php b/Memorystore/tests/Unit/V1/Client/MemorystoreClientTest.php new file mode 100644 index 000000000000..67ef4ccacd2c --- /dev/null +++ b/Memorystore/tests/Unit/V1/Client/MemorystoreClientTest.php @@ -0,0 +1,911 @@ +getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); + } + + /** @return MemorystoreClient */ + private function createClient(array $options = []) + { + $options += [ + 'credentials' => $this->createCredentials(), + ]; + return new MemorystoreClient($options); + } + + /** @test */ + public function createInstanceTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/createInstanceTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $name = 'name3373707'; + $uid = 'uid115792'; + $replicaCount = 564075208; + $shardCount = 495377042; + $engineVersion = 'engineVersion-618177573'; + $deletionProtectionEnabled = true; + $expectedResponse = new Instance(); + $expectedResponse->setName($name); + $expectedResponse->setUid($uid); + $expectedResponse->setReplicaCount($replicaCount); + $expectedResponse->setShardCount($shardCount); + $expectedResponse->setEngineVersion($engineVersion); + $expectedResponse->setDeletionProtectionEnabled($deletionProtectionEnabled); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/createInstanceTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); + $instanceId = 'instanceId-2101995259'; + $instance = new Instance(); + $instancePscAutoConnections = []; + $instance->setPscAutoConnections($instancePscAutoConnections); + $request = (new CreateInstanceRequest()) + ->setParent($formattedParent) + ->setInstanceId($instanceId) + ->setInstance($instance); + $response = $gapicClient->createInstance($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.memorystore.v1.Memorystore/CreateInstance', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualApiRequestObject->getInstanceId(); + $this->assertProtobufEquals($instanceId, $actualValue); + $actualValue = $actualApiRequestObject->getInstance(); + $this->assertProtobufEquals($instance, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/createInstanceTest'); + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $transport->popReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsTransport->popReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function createInstanceExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/createInstanceTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $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 + ); + $operationsTransport->addResponse(null, $status); + // Mock request + $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); + $instanceId = 'instanceId-2101995259'; + $instance = new Instance(); + $instancePscAutoConnections = []; + $instance->setPscAutoConnections($instancePscAutoConnections); + $request = (new CreateInstanceRequest()) + ->setParent($formattedParent) + ->setInstanceId($instanceId) + ->setInstance($instance); + $response = $gapicClient->createInstance($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/createInstanceTest'); + try { + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + // If the pollUntilComplete() 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 stubs are exhausted + $transport->popReceivedCalls(); + $operationsTransport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function deleteInstanceTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/deleteInstanceTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $expectedResponse = new GPBEmpty(); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/deleteInstanceTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $formattedName = $gapicClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); + $request = (new DeleteInstanceRequest())->setName($formattedName); + $response = $gapicClient->deleteInstance($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.memorystore.v1.Memorystore/DeleteInstance', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/deleteInstanceTest'); + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $transport->popReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsTransport->popReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function deleteInstanceExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/deleteInstanceTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $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 + ); + $operationsTransport->addResponse(null, $status); + // Mock request + $formattedName = $gapicClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); + $request = (new DeleteInstanceRequest())->setName($formattedName); + $response = $gapicClient->deleteInstance($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/deleteInstanceTest'); + try { + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + // If the pollUntilComplete() 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 stubs are exhausted + $transport->popReceivedCalls(); + $operationsTransport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function getCertificateAuthorityTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name2 = 'name2-1052831874'; + $expectedResponse = new CertificateAuthority(); + $expectedResponse->setName($name2); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); + $request = (new GetCertificateAuthorityRequest())->setName($formattedName); + $response = $gapicClient->getCertificateAuthority($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.memorystore.v1.Memorystore/GetCertificateAuthority', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getCertificateAuthorityExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); + $transport->addResponse(null, $status); + // Mock request + $formattedName = $gapicClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); + $request = (new GetCertificateAuthorityRequest())->setName($formattedName); + try { + $gapicClient->getCertificateAuthority($request); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getInstanceTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name2 = 'name2-1052831874'; + $uid = 'uid115792'; + $replicaCount = 564075208; + $shardCount = 495377042; + $engineVersion = 'engineVersion-618177573'; + $deletionProtectionEnabled = true; + $expectedResponse = new Instance(); + $expectedResponse->setName($name2); + $expectedResponse->setUid($uid); + $expectedResponse->setReplicaCount($replicaCount); + $expectedResponse->setShardCount($shardCount); + $expectedResponse->setEngineVersion($engineVersion); + $expectedResponse->setDeletionProtectionEnabled($deletionProtectionEnabled); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); + $request = (new GetInstanceRequest())->setName($formattedName); + $response = $gapicClient->getInstance($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.memorystore.v1.Memorystore/GetInstance', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getInstanceExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); + $transport->addResponse(null, $status); + // Mock request + $formattedName = $gapicClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); + $request = (new GetInstanceRequest())->setName($formattedName); + try { + $gapicClient->getInstance($request); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listInstancesTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = 'nextPageToken-1530815211'; + $expectedResponse = new ListInstancesResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); + $request = (new ListInstancesRequest())->setParent($formattedParent); + $response = $gapicClient->listInstances($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.memorystore.v1.Memorystore/ListInstances', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listInstancesExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); + $transport->addResponse(null, $status); + // Mock request + $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); + $request = (new ListInstancesRequest())->setParent($formattedParent); + try { + $gapicClient->listInstances($request); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function updateInstanceTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/updateInstanceTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $name = 'name3373707'; + $uid = 'uid115792'; + $replicaCount = 564075208; + $shardCount = 495377042; + $engineVersion = 'engineVersion-618177573'; + $deletionProtectionEnabled = true; + $expectedResponse = new Instance(); + $expectedResponse->setName($name); + $expectedResponse->setUid($uid); + $expectedResponse->setReplicaCount($replicaCount); + $expectedResponse->setShardCount($shardCount); + $expectedResponse->setEngineVersion($engineVersion); + $expectedResponse->setDeletionProtectionEnabled($deletionProtectionEnabled); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/updateInstanceTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $instance = new Instance(); + $instancePscAutoConnections = []; + $instance->setPscAutoConnections($instancePscAutoConnections); + $request = (new UpdateInstanceRequest())->setInstance($instance); + $response = $gapicClient->updateInstance($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.memorystore.v1.Memorystore/UpdateInstance', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getInstance(); + $this->assertProtobufEquals($instance, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/updateInstanceTest'); + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $transport->popReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsTransport->popReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function updateInstanceExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/updateInstanceTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $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 + ); + $operationsTransport->addResponse(null, $status); + // Mock request + $instance = new Instance(); + $instancePscAutoConnections = []; + $instance->setPscAutoConnections($instancePscAutoConnections); + $request = (new UpdateInstanceRequest())->setInstance($instance); + $response = $gapicClient->updateInstance($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/updateInstanceTest'); + try { + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + // If the pollUntilComplete() 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 stubs are exhausted + $transport->popReceivedCalls(); + $operationsTransport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function getLocationTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name2 = 'name2-1052831874'; + $locationId = 'locationId552319461'; + $displayName = 'displayName1615086568'; + $expectedResponse = new Location(); + $expectedResponse->setName($name2); + $expectedResponse->setLocationId($locationId); + $expectedResponse->setDisplayName($displayName); + $transport->addResponse($expectedResponse); + $request = new GetLocationRequest(); + $response = $gapicClient->getLocation($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.location.Locations/GetLocation', $actualFuncCall); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getLocationExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); + $transport->addResponse(null, $status); + $request = new GetLocationRequest(); + try { + $gapicClient->getLocation($request); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listLocationsTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $locationsElement = new Location(); + $locations = [$locationsElement]; + $expectedResponse = new ListLocationsResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setLocations($locations); + $transport->addResponse($expectedResponse); + $request = new ListLocationsRequest(); + $response = $gapicClient->listLocations($request); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getLocations()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.location.Locations/ListLocations', $actualFuncCall); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listLocationsExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); + $transport->addResponse(null, $status); + $request = new ListLocationsRequest(); + try { + $gapicClient->listLocations($request); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function createInstanceAsyncTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/createInstanceTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $name = 'name3373707'; + $uid = 'uid115792'; + $replicaCount = 564075208; + $shardCount = 495377042; + $engineVersion = 'engineVersion-618177573'; + $deletionProtectionEnabled = true; + $expectedResponse = new Instance(); + $expectedResponse->setName($name); + $expectedResponse->setUid($uid); + $expectedResponse->setReplicaCount($replicaCount); + $expectedResponse->setShardCount($shardCount); + $expectedResponse->setEngineVersion($engineVersion); + $expectedResponse->setDeletionProtectionEnabled($deletionProtectionEnabled); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/createInstanceTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); + $instanceId = 'instanceId-2101995259'; + $instance = new Instance(); + $instancePscAutoConnections = []; + $instance->setPscAutoConnections($instancePscAutoConnections); + $request = (new CreateInstanceRequest()) + ->setParent($formattedParent) + ->setInstanceId($instanceId) + ->setInstance($instance); + $response = $gapicClient->createInstanceAsync($request)->wait(); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.memorystore.v1.Memorystore/CreateInstance', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualApiRequestObject->getInstanceId(); + $this->assertProtobufEquals($instanceId, $actualValue); + $actualValue = $actualApiRequestObject->getInstance(); + $this->assertProtobufEquals($instance, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/createInstanceTest'); + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $transport->popReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsTransport->popReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } +} diff --git a/composer.json b/composer.json index 9677187cca0e..43207122fc9f 100644 --- a/composer.json +++ b/composer.json @@ -170,6 +170,7 @@ "google/cloud-managedkafka": "0.2.0", "google/cloud-media-translation": "0.4.4", "google/cloud-memcache": "2.0.1", + "google/cloud-memorystore": "0.0.0", "google/cloud-migrationcenter": "1.0.1", "google/cloud-monitoring": "1.12.0", "google/cloud-netapp": "1.2.0", @@ -365,6 +366,7 @@ "GPBMetadata\\Google\\Cloud\\Managedkafka\\": "ManagedKafka/metadata", "GPBMetadata\\Google\\Cloud\\Mediatranslation\\": "MediaTranslation/metadata", "GPBMetadata\\Google\\Cloud\\Memcache\\": "Memcache/metadata", + "GPBMetadata\\Google\\Cloud\\Memorystore\\": "Memorystore/metadata", "GPBMetadata\\Google\\Cloud\\Metastore\\": "DataprocMetastore/metadata", "GPBMetadata\\Google\\Cloud\\Migrationcenter\\": "MigrationCenter/metadata", "GPBMetadata\\Google\\Cloud\\Netapp\\": "NetApp/metadata", @@ -595,6 +597,7 @@ "Google\\Cloud\\ManagedKafka\\": "ManagedKafka/src", "Google\\Cloud\\MediaTranslation\\": "MediaTranslation/src", "Google\\Cloud\\Memcache\\": "Memcache/src", + "Google\\Cloud\\Memorystore\\": "Memorystore/src", "Google\\Cloud\\Metastore\\": "DataprocMetastore/src", "Google\\Cloud\\MigrationCenter\\": "MigrationCenter/src", "Google\\Cloud\\Monitoring\\": "Monitoring/src",