diff --git a/Ids/.OwlBot.yaml b/Ids/.OwlBot.yaml new file mode 100644 index 00000000000..477bad07e91 --- /dev/null +++ b/Ids/.OwlBot.yaml @@ -0,0 +1,4 @@ +deep-copy-regex: + - source: google/cloud/ids/v1/.*-php/(.*) + dest: /owl-bot-staging/Ids/v1/$1 +api-name: ids diff --git a/Ids/.gitattributes b/Ids/.gitattributes new file mode 100644 index 00000000000..d43b60862bc --- /dev/null +++ b/Ids/.gitattributes @@ -0,0 +1,3 @@ +/*.xml.dist export-ignore +/tests export-ignore +/.github export-ignore diff --git a/Ids/.github/pull_request_template.md b/Ids/.github/pull_request_template.md new file mode 100644 index 00000000000..89e9381c989 --- /dev/null +++ b/Ids/.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 `Ids/src`, and tests in `Ids/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/Ids/.repo-metadata.json b/Ids/.repo-metadata.json new file mode 100644 index 00000000000..858bbe53340 --- /dev/null +++ b/Ids/.repo-metadata.json @@ -0,0 +1,5 @@ +{ + "distribution_name": "google/cloud-ids", + "release_level": "beta", + "client_documentation": "http://googleapis.github.io/google-cloud-php/#/docs/cloud-ids/latest" +} diff --git a/Ids/CODE_OF_CONDUCT.md b/Ids/CODE_OF_CONDUCT.md new file mode 100644 index 00000000000..c3727800341 --- /dev/null +++ b/Ids/CODE_OF_CONDUCT.md @@ -0,0 +1,43 @@ +# Contributor Code of Conduct + +As contributors and maintainers of this project, +and in the interest of fostering an open and welcoming community, +we pledge to respect all people who contribute through reporting issues, +posting feature requests, updating documentation, +submitting pull requests or patches, and other activities. + +We are committed to making participation in this project +a harassment-free experience for everyone, +regardless of level of experience, gender, gender identity and expression, +sexual orientation, disability, personal appearance, +body size, race, ethnicity, age, religion, or nationality. + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery +* Personal attacks +* Trolling or insulting/derogatory comments +* Public or private harassment +* Publishing other's private information, +such as physical or electronic +addresses, without explicit permission +* Other unethical or unprofessional conduct. + +Project maintainers have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct. +By adopting this Code of Conduct, +project maintainers commit themselves to fairly and consistently +applying these principles to every aspect of managing this project. +Project maintainers who do not follow or enforce the Code of Conduct +may be permanently removed from the project team. + +This code of conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. + +Instances of abusive, harassing, or otherwise unacceptable behavior +may be reported by opening an issue +or contacting one or more of the project maintainers. + +This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0, +available at [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/) \ No newline at end of file diff --git a/Ids/CONTRIBUTING.md b/Ids/CONTRIBUTING.md new file mode 100644 index 00000000000..76ea811cacd --- /dev/null +++ b/Ids/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/Ids/LICENSE b/Ids/LICENSE new file mode 100644 index 00000000000..8f71f43fee3 --- /dev/null +++ b/Ids/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/Ids/README.md b/Ids/README.md new file mode 100644 index 00000000000..6136b6d42c3 --- /dev/null +++ b/Ids/README.md @@ -0,0 +1,45 @@ +# Google Cloud Ids for PHP + +> Idiomatic PHP client for [Google Cloud Ids](https://cloud.google.com/ids). + +[![Latest Stable Version](https://poser.pugx.org/google/cloud-ids/v/stable)](https://packagist.org/packages/google/cloud-ids) [![Packagist](https://img.shields.io/packagist/dm/google/cloud-ids.svg)](https://packagist.org/packages/google/cloud-ids) + +* [API documentation](http://googleapis.github.io/google-cloud-php/#/docs/cloud-ids/latest/ids/readme) + +**NOTE:** This repository is part of [Google Cloud PHP](https://github.com/googleapis/google-cloud-php). Any +support requests, bug reports, or development contributions should be directed to +that project. + +### Installation + +To begin, install the preferred dependency manager for PHP, [Composer](https://getcomposer.org/). + +Now to install just this component: + +```sh +$ composer require google/cloud-ids +``` + +Or to install the entire suite of components at once: + +```sh +$ composer require google/cloud +``` + +This component supports both REST over HTTP/1.1 and gRPC. In order to take advantage of the benefits offered by gRPC (such as streaming methods) +please see our [gRPC installation guide](https://cloud.google.com/php/grpc). + +### Authentication + +Please see our [Authentication guide](https://github.com/googleapis/google-cloud-php/blob/main/AUTHENTICATION.md) for more information +on authenticating your client. Once authenticated, you'll be ready to start making requests. + +### Version + +This component is considered beta. As such, it should be expected to be mostly +stable and we're working towards a release candidate. We will address issues +and requests with a higher priority. + +### Next Steps + +1. Understand the [official documentation](https://cloud.google.com/ids/docs). diff --git a/Ids/SECURITY.md b/Ids/SECURITY.md new file mode 100644 index 00000000000..8b58ae9c01a --- /dev/null +++ b/Ids/SECURITY.md @@ -0,0 +1,7 @@ +# Security Policy + +To report a security issue, please use [g.co/vulnz](https://g.co/vulnz). + +The Google Security Team will respond within 5 working days of your report on g.co/vulnz. + +We use g.co/vulnz for our intake, and do coordination and disclosure here using GitHub Security Advisory to privately discuss and fix the issue. diff --git a/Ids/VERSION b/Ids/VERSION new file mode 100644 index 00000000000..77d6f4ca237 --- /dev/null +++ b/Ids/VERSION @@ -0,0 +1 @@ +0.0.0 diff --git a/Ids/composer.json b/Ids/composer.json new file mode 100644 index 00000000000..109990188b9 --- /dev/null +++ b/Ids/composer.json @@ -0,0 +1,37 @@ +{ + "name": "google/cloud-ids", + "description": "Google Cloud Ids Client for PHP", + "license": "Apache-2.0", + "minimum-stability": "stable", + "autoload": { + "psr-4": { + "Google\\Cloud\\Ids\\": "src", + "GPBMetadata\\Google\\Cloud\\Ids\\": "metadata" + } + }, + "autoload-dev": { + "psr-4": { + "Google\\Cloud\\Ids\\Tests\\": "tests" + } + }, + "extra": { + "component": { + "id": "cloud-ids", + "path": "Ids", + "entry": null, + "target": "googleapis/google-cloud-php-ids.git" + } + }, + "require": { + "google/gax": "^1.12.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.8|^5.0", + "google/cloud-core": "^1.31", + "phpdocumentor/reflection": "^3.0" + }, + "suggest": { + "ext-grpc": "Enables use of gRPC, a universal high-performance RPC framework created by Google.", + "ext-protobuf": "Provides a significant increase in throughput over the pure PHP protobuf implementation. See https://cloud.google.com/php/grpc for installation instructions." + } +} diff --git a/Ids/metadata/V1/Ids.php b/Ids/metadata/V1/Ids.php new file mode 100644 index 00000000000..7fc8290f2a6 Binary files /dev/null and b/Ids/metadata/V1/Ids.php differ diff --git a/Ids/owlbot.py b/Ids/owlbot.py new file mode 100644 index 00000000000..f9e9241c07d --- /dev/null +++ b/Ids/owlbot.py @@ -0,0 +1,113 @@ +# Copyright 2022 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}/Ids").resolve() +dest = Path().resolve() + +# Added so that we can pass copy_excludes in the owlbot_main() call +_tracked_paths.add(src) + +php.owlbot_main( + src=src, + dest=dest, + copy_excludes=[ + src / "**/[A-Z]*_*.php" + ] +) + + +# document and utilize apiEndpoint instead of serviceAddress +s.replace( + "**/Gapic/*GapicClient.php", + r"'serviceAddress' =>", + r"'apiEndpoint' =>") +s.replace( + "**/Gapic/*GapicClient.php", + r"@type string \$serviceAddress\n\s+\*\s+The address", + r"""@type string $serviceAddress + * **Deprecated**. This option will be removed in a future major release. Please + * utilize the `$apiEndpoint` option instead. + * @type string $apiEndpoint + * The address""") +s.replace( + "**/Gapic/*GapicClient.php", + r"\$transportConfig, and any \$serviceAddress", + r"$transportConfig, and any `$apiEndpoint`") + +# 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", + '') + +### [START] protoc backwards compatibility fixes + +# roll back to private properties. +s.replace( + "src/**/V*/**/*.php", + r"Generated from protobuf field ([^\n]{0,})\n\s{5}\*/\n\s{4}protected \$", + r"""Generated from protobuf field \1 + */ + private $""") + +# prevent proto messages from being marked final +s.replace( + "src/**/V*/**/*.php", + r"final class", + r"class") + +# Replace "Unwrapped" with "Value" for method names. +s.replace( + "src/**/V*/**/*.php", + r"public function ([s|g]\w{3,})Unwrapped", + r"public function \1Value" +) + +### [END] protoc backwards compatibility fixes + +# fix relative cloud.google.com links +s.replace( + "src/**/V*/**/*.php", + r"(.{0,})\]\((/.{0,})\)", + r"\1](https://cloud.google.com\2)" +) + +# format generated clients +subprocess.run([ + 'npm', + 'exec', + '--yes', + '--package=@prettier/plugin-php@^0.16', + '--', + 'prettier', + '**/Gapic/*', + '--write', + '--parser=php', + '--single-quote', + '--print-width=80']) diff --git a/Ids/phpunit-snippets.xml.dist b/Ids/phpunit-snippets.xml.dist new file mode 100644 index 00000000000..b92fd83e3c1 --- /dev/null +++ b/Ids/phpunit-snippets.xml.dist @@ -0,0 +1,19 @@ + + + + + tests/Snippet + + + + + src + + src/V[!a-zA-Z]* + + + + diff --git a/Ids/phpunit-system.xml.dist b/Ids/phpunit-system.xml.dist new file mode 100644 index 00000000000..6ad255f35f5 --- /dev/null +++ b/Ids/phpunit-system.xml.dist @@ -0,0 +1,16 @@ + + + + + tests/System + + + + + src + + src/V[!a-zA-Z]* + + + + diff --git a/Ids/phpunit.xml.dist b/Ids/phpunit.xml.dist new file mode 100644 index 00000000000..1c2b8f6b56d --- /dev/null +++ b/Ids/phpunit.xml.dist @@ -0,0 +1,16 @@ + + + + + tests/Unit + + + + + src + + src/V[!a-zA-Z]* + + + + diff --git a/Ids/src/V1/CreateEndpointRequest.php b/Ids/src/V1/CreateEndpointRequest.php new file mode 100644 index 00000000000..8cd6e3fb285 --- /dev/null +++ b/Ids/src/V1/CreateEndpointRequest.php @@ -0,0 +1,237 @@ +google.cloud.ids.v1.CreateEndpointRequest + */ +class CreateEndpointRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The endpoint's parent. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $parent = ''; + /** + * Required. The endpoint identifier. This will be part of the endpoint's + * resource name. + * This value must start with a lowercase letter followed by up to 62 + * lowercase letters, numbers, or hyphens, and cannot end with a hyphen. + * Values that do not match this pattern will trigger an INVALID_ARGUMENT + * error. + * + * Generated from protobuf field string endpoint_id = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + private $endpoint_id = ''; + /** + * Required. The endpoint to create. + * + * Generated from protobuf field .google.cloud.ids.v1.Endpoint endpoint = 3 [(.google.api.field_behavior) = REQUIRED]; + */ + private $endpoint = null; + /** + * 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 t + * he 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; + */ + private $request_id = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. The endpoint's parent. + * @type string $endpoint_id + * Required. The endpoint identifier. This will be part of the endpoint's + * resource name. + * This value must start with a lowercase letter followed by up to 62 + * lowercase letters, numbers, or hyphens, and cannot end with a hyphen. + * Values that do not match this pattern will trigger an INVALID_ARGUMENT + * error. + * @type \Google\Cloud\Ids\V1\Endpoint $endpoint + * Required. The endpoint to create. + * @type string $request_id + * 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 t + * he 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\Ids\V1\Ids::initOnce(); + parent::__construct($data); + } + + /** + * Required. The endpoint's parent. + * + * 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 endpoint's parent. + * + * 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 endpoint identifier. This will be part of the endpoint's + * resource name. + * This value must start with a lowercase letter followed by up to 62 + * lowercase letters, numbers, or hyphens, and cannot end with a hyphen. + * Values that do not match this pattern will trigger an INVALID_ARGUMENT + * error. + * + * Generated from protobuf field string endpoint_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getEndpointId() + { + return $this->endpoint_id; + } + + /** + * Required. The endpoint identifier. This will be part of the endpoint's + * resource name. + * This value must start with a lowercase letter followed by up to 62 + * lowercase letters, numbers, or hyphens, and cannot end with a hyphen. + * Values that do not match this pattern will trigger an INVALID_ARGUMENT + * error. + * + * Generated from protobuf field string endpoint_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setEndpointId($var) + { + GPBUtil::checkString($var, True); + $this->endpoint_id = $var; + + return $this; + } + + /** + * Required. The endpoint to create. + * + * Generated from protobuf field .google.cloud.ids.v1.Endpoint endpoint = 3 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\Ids\V1\Endpoint|null + */ + public function getEndpoint() + { + return $this->endpoint; + } + + public function hasEndpoint() + { + return isset($this->endpoint); + } + + public function clearEndpoint() + { + unset($this->endpoint); + } + + /** + * Required. The endpoint to create. + * + * Generated from protobuf field .google.cloud.ids.v1.Endpoint endpoint = 3 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\Ids\V1\Endpoint $var + * @return $this + */ + public function setEndpoint($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Ids\V1\Endpoint::class); + $this->endpoint = $var; + + return $this; + } + + /** + * 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 t + * he 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; + * @return string + */ + public function getRequestId() + { + return $this->request_id; + } + + /** + * 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 t + * he 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; + * @param string $var + * @return $this + */ + public function setRequestId($var) + { + GPBUtil::checkString($var, True); + $this->request_id = $var; + + return $this; + } + +} + diff --git a/Ids/src/V1/DeleteEndpointRequest.php b/Ids/src/V1/DeleteEndpointRequest.php new file mode 100644 index 00000000000..df52678fcaa --- /dev/null +++ b/Ids/src/V1/DeleteEndpointRequest.php @@ -0,0 +1,139 @@ +google.cloud.ids.v1.DeleteEndpointRequest + */ +class DeleteEndpointRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The name of the endpoint to delete. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $name = ''; + /** + * 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 t + * he 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; + */ + private $request_id = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. The name of the endpoint to delete. + * @type string $request_id + * 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 t + * he 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\Ids\V1\Ids::initOnce(); + parent::__construct($data); + } + + /** + * Required. The name of the endpoint to delete. + * + * 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 endpoint to delete. + * + * 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; + } + + /** + * 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 t + * he 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; + * @return string + */ + public function getRequestId() + { + return $this->request_id; + } + + /** + * 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 t + * he 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; + * @param string $var + * @return $this + */ + public function setRequestId($var) + { + GPBUtil::checkString($var, True); + $this->request_id = $var; + + return $this; + } + +} + diff --git a/Ids/src/V1/Endpoint.php b/Ids/src/V1/Endpoint.php new file mode 100644 index 00000000000..a59e611439d --- /dev/null +++ b/Ids/src/V1/Endpoint.php @@ -0,0 +1,432 @@ +google.cloud.ids.v1.Endpoint + */ +class Endpoint extends \Google\Protobuf\Internal\Message +{ + /** + * Output only. The name of the endpoint. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $name = ''; + /** + * Output only. The create time timestamp. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $create_time = null; + /** + * Output only. The update time timestamp. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $update_time = null; + /** + * The labels of the endpoint. + * + * Generated from protobuf field map labels = 4; + */ + private $labels; + /** + * Required. The fully qualified URL of the network to which the IDS Endpoint is + * attached. + * + * Generated from protobuf field string network = 5 [(.google.api.field_behavior) = REQUIRED]; + */ + private $network = ''; + /** + * Output only. The fully qualified URL of the endpoint's ILB Forwarding Rule. + * + * Generated from protobuf field string endpoint_forwarding_rule = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $endpoint_forwarding_rule = ''; + /** + * Output only. The IP address of the IDS Endpoint's ILB. + * + * Generated from protobuf field string endpoint_ip = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $endpoint_ip = ''; + /** + * User-provided description of the endpoint + * + * Generated from protobuf field string description = 8; + */ + private $description = ''; + /** + * Required. Lowest threat severity that this endpoint will alert on. + * + * Generated from protobuf field .google.cloud.ids.v1.Endpoint.Severity severity = 9 [(.google.api.field_behavior) = REQUIRED]; + */ + private $severity = 0; + /** + * Output only. Current state of the endpoint. + * + * Generated from protobuf field .google.cloud.ids.v1.Endpoint.State state = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $state = 0; + /** + * Whether the endpoint should report traffic logs in addition to threat logs. + * + * Generated from protobuf field bool traffic_logs = 13; + */ + private $traffic_logs = false; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Output only. The name of the endpoint. + * @type \Google\Protobuf\Timestamp $create_time + * Output only. The create time timestamp. + * @type \Google\Protobuf\Timestamp $update_time + * Output only. The update time timestamp. + * @type array|\Google\Protobuf\Internal\MapField $labels + * The labels of the endpoint. + * @type string $network + * Required. The fully qualified URL of the network to which the IDS Endpoint is + * attached. + * @type string $endpoint_forwarding_rule + * Output only. The fully qualified URL of the endpoint's ILB Forwarding Rule. + * @type string $endpoint_ip + * Output only. The IP address of the IDS Endpoint's ILB. + * @type string $description + * User-provided description of the endpoint + * @type int $severity + * Required. Lowest threat severity that this endpoint will alert on. + * @type int $state + * Output only. Current state of the endpoint. + * @type bool $traffic_logs + * Whether the endpoint should report traffic logs in addition to threat logs. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Ids\V1\Ids::initOnce(); + parent::__construct($data); + } + + /** + * Output only. The name of the endpoint. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Output only. The name of the endpoint. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * Output only. The create time timestamp. + * + * 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. The create time timestamp. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setCreateTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->create_time = $var; + + return $this; + } + + /** + * Output only. The update time timestamp. + * + * 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. The update time timestamp. + * + * 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; + } + + /** + * The labels of the endpoint. + * + * Generated from protobuf field map labels = 4; + * @return \Google\Protobuf\Internal\MapField + */ + public function getLabels() + { + return $this->labels; + } + + /** + * The labels of the endpoint. + * + * Generated from protobuf field map labels = 4; + * @param array|\Google\Protobuf\Internal\MapField $var + * @return $this + */ + public function setLabels($var) + { + $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::STRING); + $this->labels = $arr; + + return $this; + } + + /** + * Required. The fully qualified URL of the network to which the IDS Endpoint is + * attached. + * + * Generated from protobuf field string network = 5 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getNetwork() + { + return $this->network; + } + + /** + * Required. The fully qualified URL of the network to which the IDS Endpoint is + * attached. + * + * Generated from protobuf field string network = 5 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setNetwork($var) + { + GPBUtil::checkString($var, True); + $this->network = $var; + + return $this; + } + + /** + * Output only. The fully qualified URL of the endpoint's ILB Forwarding Rule. + * + * Generated from protobuf field string endpoint_forwarding_rule = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getEndpointForwardingRule() + { + return $this->endpoint_forwarding_rule; + } + + /** + * Output only. The fully qualified URL of the endpoint's ILB Forwarding Rule. + * + * Generated from protobuf field string endpoint_forwarding_rule = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setEndpointForwardingRule($var) + { + GPBUtil::checkString($var, True); + $this->endpoint_forwarding_rule = $var; + + return $this; + } + + /** + * Output only. The IP address of the IDS Endpoint's ILB. + * + * Generated from protobuf field string endpoint_ip = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getEndpointIp() + { + return $this->endpoint_ip; + } + + /** + * Output only. The IP address of the IDS Endpoint's ILB. + * + * Generated from protobuf field string endpoint_ip = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setEndpointIp($var) + { + GPBUtil::checkString($var, True); + $this->endpoint_ip = $var; + + return $this; + } + + /** + * User-provided description of the endpoint + * + * Generated from protobuf field string description = 8; + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * User-provided description of the endpoint + * + * Generated from protobuf field string description = 8; + * @param string $var + * @return $this + */ + public function setDescription($var) + { + GPBUtil::checkString($var, True); + $this->description = $var; + + return $this; + } + + /** + * Required. Lowest threat severity that this endpoint will alert on. + * + * Generated from protobuf field .google.cloud.ids.v1.Endpoint.Severity severity = 9 [(.google.api.field_behavior) = REQUIRED]; + * @return int + */ + public function getSeverity() + { + return $this->severity; + } + + /** + * Required. Lowest threat severity that this endpoint will alert on. + * + * Generated from protobuf field .google.cloud.ids.v1.Endpoint.Severity severity = 9 [(.google.api.field_behavior) = REQUIRED]; + * @param int $var + * @return $this + */ + public function setSeverity($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Ids\V1\Endpoint\Severity::class); + $this->severity = $var; + + return $this; + } + + /** + * Output only. Current state of the endpoint. + * + * Generated from protobuf field .google.cloud.ids.v1.Endpoint.State state = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return int + */ + public function getState() + { + return $this->state; + } + + /** + * Output only. Current state of the endpoint. + * + * Generated from protobuf field .google.cloud.ids.v1.Endpoint.State state = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param int $var + * @return $this + */ + public function setState($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Ids\V1\Endpoint\State::class); + $this->state = $var; + + return $this; + } + + /** + * Whether the endpoint should report traffic logs in addition to threat logs. + * + * Generated from protobuf field bool traffic_logs = 13; + * @return bool + */ + public function getTrafficLogs() + { + return $this->traffic_logs; + } + + /** + * Whether the endpoint should report traffic logs in addition to threat logs. + * + * Generated from protobuf field bool traffic_logs = 13; + * @param bool $var + * @return $this + */ + public function setTrafficLogs($var) + { + GPBUtil::checkBool($var); + $this->traffic_logs = $var; + + return $this; + } + +} + diff --git a/Ids/src/V1/Endpoint/Severity.php b/Ids/src/V1/Endpoint/Severity.php new file mode 100644 index 00000000000..7f439353b81 --- /dev/null +++ b/Ids/src/V1/Endpoint/Severity.php @@ -0,0 +1,83 @@ +google.cloud.ids.v1.Endpoint.Severity + */ +class Severity +{ + /** + * Not set. + * + * Generated from protobuf enum SEVERITY_UNSPECIFIED = 0; + */ + const SEVERITY_UNSPECIFIED = 0; + /** + * Informational alerts. + * + * Generated from protobuf enum INFORMATIONAL = 1; + */ + const INFORMATIONAL = 1; + /** + * Low severity alerts. + * + * Generated from protobuf enum LOW = 2; + */ + const LOW = 2; + /** + * Medium severity alerts. + * + * Generated from protobuf enum MEDIUM = 3; + */ + const MEDIUM = 3; + /** + * High severity alerts. + * + * Generated from protobuf enum HIGH = 4; + */ + const HIGH = 4; + /** + * Critical severity alerts. + * + * Generated from protobuf enum CRITICAL = 5; + */ + const CRITICAL = 5; + + private static $valueToName = [ + self::SEVERITY_UNSPECIFIED => 'SEVERITY_UNSPECIFIED', + self::INFORMATIONAL => 'INFORMATIONAL', + self::LOW => 'LOW', + self::MEDIUM => 'MEDIUM', + self::HIGH => 'HIGH', + self::CRITICAL => 'CRITICAL', + ]; + + 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/Ids/src/V1/Endpoint/State.php b/Ids/src/V1/Endpoint/State.php new file mode 100644 index 00000000000..0b299d1a8f9 --- /dev/null +++ b/Ids/src/V1/Endpoint/State.php @@ -0,0 +1,69 @@ +google.cloud.ids.v1.Endpoint.State + */ +class State +{ + /** + * Not set. + * + * Generated from protobuf enum STATE_UNSPECIFIED = 0; + */ + const STATE_UNSPECIFIED = 0; + /** + * Being created. + * + * Generated from protobuf enum CREATING = 1; + */ + const CREATING = 1; + /** + * Active and ready for traffic. + * + * Generated from protobuf enum READY = 2; + */ + const READY = 2; + /** + * Being deleted. + * + * Generated from protobuf enum DELETING = 3; + */ + const DELETING = 3; + + private static $valueToName = [ + self::STATE_UNSPECIFIED => 'STATE_UNSPECIFIED', + self::CREATING => 'CREATING', + self::READY => 'READY', + 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/Ids/src/V1/Gapic/IDSGapicClient.php b/Ids/src/V1/Gapic/IDSGapicClient.php new file mode 100644 index 00000000000..6cf300416e4 --- /dev/null +++ b/Ids/src/V1/Gapic/IDSGapicClient.php @@ -0,0 +1,711 @@ +locationName('[PROJECT]', '[LOCATION]'); + * $endpointId = 'endpoint_id'; + * $endpoint = new Endpoint(); + * $operationResponse = $iDSClient->createEndpoint($formattedParent, $endpointId, $endpoint); + * $operationResponse->pollUntilComplete(); + * if ($operationResponse->operationSucceeded()) { + * $result = $operationResponse->getResult(); + * // doSomethingWith($result) + * } else { + * $error = $operationResponse->getError(); + * // handleError($error) + * } + * // Alternatively: + * // start the operation, keep the operation name, and resume later + * $operationResponse = $iDSClient->createEndpoint($formattedParent, $endpointId, $endpoint); + * $operationName = $operationResponse->getName(); + * // ... do other work + * $newOperationResponse = $iDSClient->resumeOperation($operationName, 'createEndpoint'); + * while (!$newOperationResponse->isDone()) { + * // ... do other work + * $newOperationResponse->reload(); + * } + * if ($newOperationResponse->operationSucceeded()) { + * $result = $newOperationResponse->getResult(); + * // doSomethingWith($result) + * } else { + * $error = $newOperationResponse->getError(); + * // handleError($error) + * } + * } finally { + * $iDSClient->close(); + * } + * ``` + * + * Many parameters require resource names to be formatted in a particular way. To + * assist with these names, this class includes a format method for each type of + * name, and additionally a parseName method to extract the individual identifiers + * contained within formatted names that are returned by the API. + */ +class IDSGapicClient +{ + use GapicClientTrait; + + /** + * The name of the service. + */ + const SERVICE_NAME = 'google.cloud.ids.v1.IDS'; + + /** + * The default address of the service. + */ + const SERVICE_ADDRESS = 'ids.googleapis.com'; + + /** + * The default port of the service. + */ + const DEFAULT_SERVICE_PORT = 443; + + /** + * The name of the code generator, to be included in the agent header. + */ + const CODEGEN_NAME = 'gapic'; + + /** + * The default scopes required by the service. + */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static $endpointNameTemplate; + + private static $locationNameTemplate; + + private static $pathTemplateMap; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => + self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/ids_client_config.json', + 'descriptorsConfigPath' => + __DIR__ . '/../resources/ids_descriptor_config.php', + 'gcpApiConfigPath' => + __DIR__ . '/../resources/ids_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => + __DIR__ . '/../resources/ids_rest_client_config.php', + ], + ], + ]; + } + + private static function getEndpointNameTemplate() + { + if (self::$endpointNameTemplate == null) { + self::$endpointNameTemplate = new PathTemplate( + 'projects/{project}/locations/{location}/endpoints/{endpoint}' + ); + } + + return self::$endpointNameTemplate; + } + + private static function getLocationNameTemplate() + { + if (self::$locationNameTemplate == null) { + self::$locationNameTemplate = new PathTemplate( + 'projects/{project}/locations/{location}' + ); + } + + return self::$locationNameTemplate; + } + + private static function getPathTemplateMap() + { + if (self::$pathTemplateMap == null) { + self::$pathTemplateMap = [ + 'endpoint' => self::getEndpointNameTemplate(), + 'location' => self::getLocationNameTemplate(), + ]; + } + + return self::$pathTemplateMap; + } + + /** + * Formats a string containing the fully-qualified path to represent a endpoint + * resource. + * + * @param string $project + * @param string $location + * @param string $endpoint + * + * @return string The formatted endpoint resource. + */ + public static function endpointName($project, $location, $endpoint) + { + return self::getEndpointNameTemplate()->render([ + 'project' => $project, + 'location' => $location, + 'endpoint' => $endpoint, + ]); + } + + /** + * 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($project, $location) + { + return self::getLocationNameTemplate()->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - endpoint: projects/{project}/locations/{location}/endpoints/{endpoint} + * - location: projects/{project}/locations/{location} + * + * 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($formattedName, $template = null) + { + $templateMap = self::getPathTemplateMap(); + if ($template) { + if (!isset($templateMap[$template])) { + throw new ValidationException( + "Template name $template does not exist" + ); + } + + return $templateMap[$template]->match($formattedName); + } + + foreach ($templateMap as $templateName => $pathTemplate) { + try { + return $pathTemplate->match($formattedName); + } catch (ValidationException $ex) { + // Swallow the exception to continue trying other path templates + } + } + + throw new ValidationException( + "Input did not match any known format. Input: $formattedName" + ); + } + + /** + * 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; + } + + /** + * Constructor. + * + * @param array $options { + * Optional. Options for configuring the service API wrapper. + * + * @type string $serviceAddress + * **Deprecated**. This option will be removed in a future major release. Please + * utilize the `$apiEndpoint` option instead. + * @type string $apiEndpoint + * The address of the API remote host. May optionally include the port, formatted + * as ":". Default 'ids.googleapis.com:443'. + * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials + * The credentials to be used by the client to authorize API calls. This option + * accepts either a path to a credentials file, or a decoded credentials file as a + * PHP array. + * *Advanced usage*: In addition, this option can also accept a pre-constructed + * {@see \Google\Auth\FetchAuthTokenInterface} object or + * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these + * objects are provided, any settings in $credentialsConfig will be ignored. + * @type array $credentialsConfig + * Options used to configure credentials, including auth token caching, for the + * client. For a full list of supporting configuration options, see + * {@see \Google\ApiCore\CredentialsWrapper::build()} . + * @type bool $disableRetries + * Determines whether or not retries defined by the client configuration should be + * disabled. Defaults to `false`. + * @type string|array $clientConfig + * Client method configuration, including retry settings. This option can be either + * a path to a JSON file, or a PHP array containing the decoded JSON data. By + * default this settings points to the default client config file, which is + * provided in the resources folder. + * @type string|TransportInterface $transport + * The transport used for executing network requests. May be either the string + * `rest` or `grpc`. Defaults to `grpc` if gRPC support is detected on the system. + * *Advanced usage*: Additionally, it is possible to pass in an already + * instantiated {@see \Google\ApiCore\Transport\TransportInterface} object. Note + * that when this object is provided, any settings in $transportConfig, and any + * $serviceAddress setting, will be ignored. + * @type array $transportConfig + * Configuration options that will be used to construct the transport. Options for + * each supported transport type should be passed in a key for that transport. For + * example: + * $transportConfig = [ + * 'grpc' => [...], + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\GrpcTransport::build()} and + * {@see \Google\ApiCore\Transport\RestTransport::build()} methods for the + * supported options. + * @type callable $clientCertSource + * A callable which returns the client cert as a string. This can be used to + * provide a certificate and private key to the transport layer for mTLS. + * } + * + * @throws ValidationException + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** + * Creates a new Endpoint in a given project and location. + * + * Sample code: + * ``` + * $iDSClient = new IDSClient(); + * try { + * $formattedParent = $iDSClient->locationName('[PROJECT]', '[LOCATION]'); + * $endpointId = 'endpoint_id'; + * $endpoint = new Endpoint(); + * $operationResponse = $iDSClient->createEndpoint($formattedParent, $endpointId, $endpoint); + * $operationResponse->pollUntilComplete(); + * if ($operationResponse->operationSucceeded()) { + * $result = $operationResponse->getResult(); + * // doSomethingWith($result) + * } else { + * $error = $operationResponse->getError(); + * // handleError($error) + * } + * // Alternatively: + * // start the operation, keep the operation name, and resume later + * $operationResponse = $iDSClient->createEndpoint($formattedParent, $endpointId, $endpoint); + * $operationName = $operationResponse->getName(); + * // ... do other work + * $newOperationResponse = $iDSClient->resumeOperation($operationName, 'createEndpoint'); + * while (!$newOperationResponse->isDone()) { + * // ... do other work + * $newOperationResponse->reload(); + * } + * if ($newOperationResponse->operationSucceeded()) { + * $result = $newOperationResponse->getResult(); + * // doSomethingWith($result) + * } else { + * $error = $newOperationResponse->getError(); + * // handleError($error) + * } + * } finally { + * $iDSClient->close(); + * } + * ``` + * + * @param string $parent Required. The endpoint's parent. + * @param string $endpointId Required. The endpoint identifier. This will be part of the endpoint's + * resource name. + * This value must start with a lowercase letter followed by up to 62 + * lowercase letters, numbers, or hyphens, and cannot end with a hyphen. + * Values that do not match this pattern will trigger an INVALID_ARGUMENT + * error. + * @param Endpoint $endpoint Required. The endpoint to create. + * @param array $optionalArgs { + * Optional. + * + * @type string $requestId + * 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 t + * he 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). + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\ApiCore\OperationResponse + * + * @throws ApiException if the remote call fails + */ + public function createEndpoint( + $parent, + $endpointId, + $endpoint, + array $optionalArgs = [] + ) { + $request = new CreateEndpointRequest(); + $requestParamHeaders = []; + $request->setParent($parent); + $request->setEndpointId($endpointId); + $request->setEndpoint($endpoint); + $requestParamHeaders['parent'] = $parent; + if (isset($optionalArgs['requestId'])) { + $request->setRequestId($optionalArgs['requestId']); + } + + $requestParams = new RequestParamsHeaderDescriptor( + $requestParamHeaders + ); + $optionalArgs['headers'] = isset($optionalArgs['headers']) + ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) + : $requestParams->getHeader(); + return $this->startOperationsCall( + 'CreateEndpoint', + $optionalArgs, + $request, + $this->getOperationsClient() + )->wait(); + } + + /** + * Deletes a single Endpoint. + * + * Sample code: + * ``` + * $iDSClient = new IDSClient(); + * try { + * $formattedName = $iDSClient->endpointName('[PROJECT]', '[LOCATION]', '[ENDPOINT]'); + * $operationResponse = $iDSClient->deleteEndpoint($formattedName); + * $operationResponse->pollUntilComplete(); + * if ($operationResponse->operationSucceeded()) { + * // operation succeeded and returns no value + * } else { + * $error = $operationResponse->getError(); + * // handleError($error) + * } + * // Alternatively: + * // start the operation, keep the operation name, and resume later + * $operationResponse = $iDSClient->deleteEndpoint($formattedName); + * $operationName = $operationResponse->getName(); + * // ... do other work + * $newOperationResponse = $iDSClient->resumeOperation($operationName, 'deleteEndpoint'); + * while (!$newOperationResponse->isDone()) { + * // ... do other work + * $newOperationResponse->reload(); + * } + * if ($newOperationResponse->operationSucceeded()) { + * // operation succeeded and returns no value + * } else { + * $error = $newOperationResponse->getError(); + * // handleError($error) + * } + * } finally { + * $iDSClient->close(); + * } + * ``` + * + * @param string $name Required. The name of the endpoint to delete. + * @param array $optionalArgs { + * Optional. + * + * @type string $requestId + * 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 t + * he 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). + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\ApiCore\OperationResponse + * + * @throws ApiException if the remote call fails + */ + public function deleteEndpoint($name, array $optionalArgs = []) + { + $request = new DeleteEndpointRequest(); + $requestParamHeaders = []; + $request->setName($name); + $requestParamHeaders['name'] = $name; + if (isset($optionalArgs['requestId'])) { + $request->setRequestId($optionalArgs['requestId']); + } + + $requestParams = new RequestParamsHeaderDescriptor( + $requestParamHeaders + ); + $optionalArgs['headers'] = isset($optionalArgs['headers']) + ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) + : $requestParams->getHeader(); + return $this->startOperationsCall( + 'DeleteEndpoint', + $optionalArgs, + $request, + $this->getOperationsClient() + )->wait(); + } + + /** + * Gets details of a single Endpoint. + * + * Sample code: + * ``` + * $iDSClient = new IDSClient(); + * try { + * $formattedName = $iDSClient->endpointName('[PROJECT]', '[LOCATION]', '[ENDPOINT]'); + * $response = $iDSClient->getEndpoint($formattedName); + * } finally { + * $iDSClient->close(); + * } + * ``` + * + * @param string $name Required. The name of the endpoint to retrieve. + * Format: `projects/{project}/locations/{location}/endpoints/{endpoint}` + * @param array $optionalArgs { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\Ids\V1\Endpoint + * + * @throws ApiException if the remote call fails + */ + public function getEndpoint($name, array $optionalArgs = []) + { + $request = new GetEndpointRequest(); + $requestParamHeaders = []; + $request->setName($name); + $requestParamHeaders['name'] = $name; + $requestParams = new RequestParamsHeaderDescriptor( + $requestParamHeaders + ); + $optionalArgs['headers'] = isset($optionalArgs['headers']) + ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) + : $requestParams->getHeader(); + return $this->startCall( + 'GetEndpoint', + Endpoint::class, + $optionalArgs, + $request + )->wait(); + } + + /** + * Lists Endpoints in a given project and location. + * + * Sample code: + * ``` + * $iDSClient = new IDSClient(); + * try { + * $formattedParent = $iDSClient->locationName('[PROJECT]', '[LOCATION]'); + * // Iterate over pages of elements + * $pagedResponse = $iDSClient->listEndpoints($formattedParent); + * foreach ($pagedResponse->iteratePages() as $page) { + * foreach ($page as $element) { + * // doSomethingWith($element); + * } + * } + * // Alternatively: + * // Iterate through all elements + * $pagedResponse = $iDSClient->listEndpoints($formattedParent); + * foreach ($pagedResponse->iterateAllElements() as $element) { + * // doSomethingWith($element); + * } + * } finally { + * $iDSClient->close(); + * } + * ``` + * + * @param string $parent Required. The parent, which owns this collection of endpoints. + * @param array $optionalArgs { + * Optional. + * + * @type int $pageSize + * The maximum number of resources contained in the underlying API + * response. The API may return fewer values in a page, even if + * there are additional values to be retrieved. + * @type string $pageToken + * A page token is used to specify a page of values to be returned. + * If no page token is specified (the default), the first page + * of values will be returned. Any page token used here must have + * been generated by a previous call to the API. + * @type string $filter + * Optional. The filter expression, following the syntax outlined in + * https://google.aip.dev/160. + * @type string $orderBy + * Optional. One or more fields to compare and use to sort the output. + * See https://google.aip.dev/132#ordering. + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\ApiCore\PagedListResponse + * + * @throws ApiException if the remote call fails + */ + public function listEndpoints($parent, array $optionalArgs = []) + { + $request = new ListEndpointsRequest(); + $requestParamHeaders = []; + $request->setParent($parent); + $requestParamHeaders['parent'] = $parent; + if (isset($optionalArgs['pageSize'])) { + $request->setPageSize($optionalArgs['pageSize']); + } + + if (isset($optionalArgs['pageToken'])) { + $request->setPageToken($optionalArgs['pageToken']); + } + + if (isset($optionalArgs['filter'])) { + $request->setFilter($optionalArgs['filter']); + } + + if (isset($optionalArgs['orderBy'])) { + $request->setOrderBy($optionalArgs['orderBy']); + } + + $requestParams = new RequestParamsHeaderDescriptor( + $requestParamHeaders + ); + $optionalArgs['headers'] = isset($optionalArgs['headers']) + ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) + : $requestParams->getHeader(); + return $this->getPagedListResponse( + 'ListEndpoints', + $optionalArgs, + ListEndpointsResponse::class, + $request + ); + } +} diff --git a/Ids/src/V1/GetEndpointRequest.php b/Ids/src/V1/GetEndpointRequest.php new file mode 100644 index 00000000000..0d10fc2518e --- /dev/null +++ b/Ids/src/V1/GetEndpointRequest.php @@ -0,0 +1,69 @@ +google.cloud.ids.v1.GetEndpointRequest + */ +class GetEndpointRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The name of the endpoint to retrieve. + * Format: `projects/{project}/locations/{location}/endpoints/{endpoint}` + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $name = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. The name of the endpoint to retrieve. + * Format: `projects/{project}/locations/{location}/endpoints/{endpoint}` + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Ids\V1\Ids::initOnce(); + parent::__construct($data); + } + + /** + * Required. The name of the endpoint to retrieve. + * Format: `projects/{project}/locations/{location}/endpoints/{endpoint}` + * + * 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 endpoint to retrieve. + * Format: `projects/{project}/locations/{location}/endpoints/{endpoint}` + * + * 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/Ids/src/V1/IDSClient.php b/Ids/src/V1/IDSClient.php new file mode 100644 index 00000000000..ee498ea47b6 --- /dev/null +++ b/Ids/src/V1/IDSClient.php @@ -0,0 +1,34 @@ +_simpleRequest('/google.cloud.ids.v1.IDS/ListEndpoints', + $argument, + ['\Google\Cloud\Ids\V1\ListEndpointsResponse', 'decode'], + $metadata, $options); + } + + /** + * Gets details of a single Endpoint. + * @param \Google\Cloud\Ids\V1\GetEndpointRequest $argument input argument + * @param array $metadata metadata + * @param array $options call options + * @return \Grpc\UnaryCall + */ + public function GetEndpoint(\Google\Cloud\Ids\V1\GetEndpointRequest $argument, + $metadata = [], $options = []) { + return $this->_simpleRequest('/google.cloud.ids.v1.IDS/GetEndpoint', + $argument, + ['\Google\Cloud\Ids\V1\Endpoint', 'decode'], + $metadata, $options); + } + + /** + * Creates a new Endpoint in a given project and location. + * @param \Google\Cloud\Ids\V1\CreateEndpointRequest $argument input argument + * @param array $metadata metadata + * @param array $options call options + * @return \Grpc\UnaryCall + */ + public function CreateEndpoint(\Google\Cloud\Ids\V1\CreateEndpointRequest $argument, + $metadata = [], $options = []) { + return $this->_simpleRequest('/google.cloud.ids.v1.IDS/CreateEndpoint', + $argument, + ['\Google\LongRunning\Operation', 'decode'], + $metadata, $options); + } + + /** + * Deletes a single Endpoint. + * @param \Google\Cloud\Ids\V1\DeleteEndpointRequest $argument input argument + * @param array $metadata metadata + * @param array $options call options + * @return \Grpc\UnaryCall + */ + public function DeleteEndpoint(\Google\Cloud\Ids\V1\DeleteEndpointRequest $argument, + $metadata = [], $options = []) { + return $this->_simpleRequest('/google.cloud.ids.v1.IDS/DeleteEndpoint', + $argument, + ['\Google\LongRunning\Operation', 'decode'], + $metadata, $options); + } + +} diff --git a/Ids/src/V1/ListEndpointsRequest.php b/Ids/src/V1/ListEndpointsRequest.php new file mode 100644 index 00000000000..22e4bc3c0b2 --- /dev/null +++ b/Ids/src/V1/ListEndpointsRequest.php @@ -0,0 +1,225 @@ +google.cloud.ids.v1.ListEndpointsRequest + */ +class ListEndpointsRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The parent, which owns this collection of endpoints. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $parent = ''; + /** + * Optional. The maximum number of endpoints to return. The service may return fewer + * than this value. + * + * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $page_size = 0; + /** + * Optional. A page token, received from a previous `ListEndpoints` call. + * Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to `ListEndpoints` must + * match the call that provided the page token. + * + * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $page_token = ''; + /** + * Optional. The filter expression, following the syntax outlined in + * https://google.aip.dev/160. + * + * Generated from protobuf field string filter = 4 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $filter = ''; + /** + * Optional. One or more fields to compare and use to sort the output. + * See https://google.aip.dev/132#ordering. + * + * Generated from protobuf field string order_by = 5 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $order_by = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. The parent, which owns this collection of endpoints. + * @type int $page_size + * Optional. The maximum number of endpoints to return. The service may return fewer + * than this value. + * @type string $page_token + * Optional. A page token, received from a previous `ListEndpoints` call. + * Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to `ListEndpoints` must + * match the call that provided the page token. + * @type string $filter + * Optional. The filter expression, following the syntax outlined in + * https://google.aip.dev/160. + * @type string $order_by + * Optional. One or more fields to compare and use to sort the output. + * See https://google.aip.dev/132#ordering. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Ids\V1\Ids::initOnce(); + parent::__construct($data); + } + + /** + * Required. The parent, which owns this collection of endpoints. + * + * 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, which owns this collection of endpoints. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setParent($var) + { + GPBUtil::checkString($var, True); + $this->parent = $var; + + return $this; + } + + /** + * Optional. The maximum number of endpoints to return. The service may return fewer + * than this value. + * + * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @return int + */ + public function getPageSize() + { + return $this->page_size; + } + + /** + * Optional. The maximum number of endpoints to return. The service may return fewer + * than this value. + * + * 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 page token, received from a previous `ListEndpoints` call. + * Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to `ListEndpoints` must + * match the call that provided the page token. + * + * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @return string + */ + public function getPageToken() + { + return $this->page_token; + } + + /** + * Optional. A page token, received from a previous `ListEndpoints` call. + * Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to `ListEndpoints` must + * match the call that provided the page token. + * + * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @param string $var + * @return $this + */ + public function setPageToken($var) + { + GPBUtil::checkString($var, True); + $this->page_token = $var; + + return $this; + } + + /** + * Optional. The filter expression, following the syntax outlined in + * https://google.aip.dev/160. + * + * Generated from protobuf field string filter = 4 [(.google.api.field_behavior) = OPTIONAL]; + * @return string + */ + public function getFilter() + { + return $this->filter; + } + + /** + * Optional. The filter expression, following the syntax outlined in + * https://google.aip.dev/160. + * + * 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. One or more fields to compare and use to sort the output. + * See https://google.aip.dev/132#ordering. + * + * Generated from protobuf field string order_by = 5 [(.google.api.field_behavior) = OPTIONAL]; + * @return string + */ + public function getOrderBy() + { + return $this->order_by; + } + + /** + * Optional. One or more fields to compare and use to sort the output. + * See https://google.aip.dev/132#ordering. + * + * 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/Ids/src/V1/ListEndpointsResponse.php b/Ids/src/V1/ListEndpointsResponse.php new file mode 100644 index 00000000000..3ef1e4c8da9 --- /dev/null +++ b/Ids/src/V1/ListEndpointsResponse.php @@ -0,0 +1,137 @@ +google.cloud.ids.v1.ListEndpointsResponse + */ +class ListEndpointsResponse extends \Google\Protobuf\Internal\Message +{ + /** + * The list of endpoints response. + * + * Generated from protobuf field repeated .google.cloud.ids.v1.Endpoint endpoints = 1; + */ + private $endpoints; + /** + * 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; + */ + private $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 \Google\Cloud\Ids\V1\Endpoint[]|\Google\Protobuf\Internal\RepeatedField $endpoints + * The list of endpoints response. + * @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 string[]|\Google\Protobuf\Internal\RepeatedField $unreachable + * Locations that could not be reached. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Ids\V1\Ids::initOnce(); + parent::__construct($data); + } + + /** + * The list of endpoints response. + * + * Generated from protobuf field repeated .google.cloud.ids.v1.Endpoint endpoints = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getEndpoints() + { + return $this->endpoints; + } + + /** + * The list of endpoints response. + * + * Generated from protobuf field repeated .google.cloud.ids.v1.Endpoint endpoints = 1; + * @param \Google\Cloud\Ids\V1\Endpoint[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setEndpoints($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Ids\V1\Endpoint::class); + $this->endpoints = $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 string[]|\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/Ids/src/V1/OperationMetadata.php b/Ids/src/V1/OperationMetadata.php new file mode 100644 index 00000000000..4ff2fe963e0 --- /dev/null +++ b/Ids/src/V1/OperationMetadata.php @@ -0,0 +1,303 @@ +google.cloud.ids.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]; + */ + private $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]; + */ + private $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]; + */ + private $target = ''; + /** + * Output only. Name of the verb executed by the operation. + * + * Generated from protobuf field string verb = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $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]; + */ + private $status_message = ''; + /** + * Output only. Identifies whether the user has requested cancellation + * of the operation. Operations that have successfully been cancelled + * 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]; + */ + private $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]; + */ + private $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 successfully been cancelled + * 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\Ids\V1\Ids::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 successfully been cancelled + * 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 successfully been cancelled + * 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/Ids/src/V1/gapic_metadata.json b/Ids/src/V1/gapic_metadata.json new file mode 100644 index 00000000000..5ab423eb60d --- /dev/null +++ b/Ids/src/V1/gapic_metadata.json @@ -0,0 +1,38 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services\/RPCs to the corresponding library clients\/methods", + "language": "php", + "protoPackage": "google.cloud.ids.v1", + "libraryPackage": "Google\\Cloud\\Ids\\V1", + "services": { + "IDS": { + "clients": { + "grpc": { + "libraryClient": "IDSGapicClient", + "rpcs": { + "CreateEndpoint": { + "methods": [ + "createEndpoint" + ] + }, + "DeleteEndpoint": { + "methods": [ + "deleteEndpoint" + ] + }, + "GetEndpoint": { + "methods": [ + "getEndpoint" + ] + }, + "ListEndpoints": { + "methods": [ + "listEndpoints" + ] + } + } + } + } + } + } +} \ No newline at end of file diff --git a/Ids/src/V1/resources/ids_client_config.json b/Ids/src/V1/resources/ids_client_config.json new file mode 100644 index 00000000000..4e6ba8e1950 --- /dev/null +++ b/Ids/src/V1/resources/ids_client_config.json @@ -0,0 +1,74 @@ +{ + "interfaces": { + "google.cloud.ids.v1.IDS": { + "retry_codes": { + "no_retry_codes": [], + "retry_policy_1_codes": [ + "UNAVAILABLE" + ], + "no_retry_1_codes": [], + "no_retry_2_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": 250, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 32000, + "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": 3600000, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 3600000, + "total_timeout_millis": 3600000 + }, + "no_retry_2_params": { + "initial_retry_delay_millis": 0, + "retry_delay_multiplier": 0.0, + "max_retry_delay_millis": 0, + "initial_rpc_timeout_millis": 3600000, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 3600000, + "total_timeout_millis": 3600000 + } + }, + "methods": { + "CreateEndpoint": { + "timeout_millis": 3600000, + "retry_codes_name": "no_retry_1_codes", + "retry_params_name": "no_retry_1_params" + }, + "DeleteEndpoint": { + "timeout_millis": 3600000, + "retry_codes_name": "no_retry_2_codes", + "retry_params_name": "no_retry_2_params" + }, + "GetEndpoint": { + "timeout_millis": 60000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, + "ListEndpoints": { + "timeout_millis": 60000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + } + } + } + } +} diff --git a/Ids/src/V1/resources/ids_descriptor_config.php b/Ids/src/V1/resources/ids_descriptor_config.php new file mode 100644 index 00000000000..ba73e09485b --- /dev/null +++ b/Ids/src/V1/resources/ids_descriptor_config.php @@ -0,0 +1,38 @@ + [ + 'google.cloud.ids.v1.IDS' => [ + 'CreateEndpoint' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Cloud\Ids\V1\Endpoint', + 'metadataReturnType' => '\Google\Cloud\Ids\V1\OperationMetadata', + 'initialPollDelayMillis' => '5000', + 'pollDelayMultiplier' => '2.0', + 'maxPollDelayMillis' => '45000', + 'totalPollTimeoutMillis' => '3600000', + ], + ], + 'DeleteEndpoint' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Protobuf\GPBEmpty', + 'metadataReturnType' => '\Google\Cloud\Ids\V1\OperationMetadata', + 'initialPollDelayMillis' => '5000', + 'pollDelayMultiplier' => '2.0', + 'maxPollDelayMillis' => '45000', + 'totalPollTimeoutMillis' => '3600000', + ], + ], + 'ListEndpoints' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getEndpoints', + ], + ], + ], + ], +]; diff --git a/Ids/src/V1/resources/ids_rest_client_config.php b/Ids/src/V1/resources/ids_rest_client_config.php new file mode 100644 index 00000000000..8a7da295275 --- /dev/null +++ b/Ids/src/V1/resources/ids_rest_client_config.php @@ -0,0 +1,164 @@ + [ + 'google.cloud.ids.v1.IDS' => [ + 'CreateEndpoint' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{parent=projects/*/locations/*}/endpoints', + 'body' => 'endpoint', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + 'queryParams' => [ + 'endpoint_id', + ], + ], + 'DeleteEndpoint' => [ + 'method' => 'delete', + 'uriTemplate' => '/v1/{name=projects/*/locations/*/endpoints/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'GetEndpoint' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/locations/*/endpoints/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'ListEndpoints' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{parent=projects/*/locations/*}/endpoints', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + ], + '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.iam.v1.IAMPolicy' => [ + 'GetIamPolicy' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/endpoints/*}:getIamPolicy', + 'placeholders' => [ + 'resource' => [ + 'getters' => [ + 'getResource', + ], + ], + ], + ], + 'SetIamPolicy' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/endpoints/*}:setIamPolicy', + 'body' => '*', + 'placeholders' => [ + 'resource' => [ + 'getters' => [ + 'getResource', + ], + ], + ], + ], + 'TestIamPermissions' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/endpoints/*}:testIamPermissions', + 'body' => '*', + 'placeholders' => [ + 'resource' => [ + 'getters' => [ + 'getResource', + ], + ], + ], + ], + ], + 'google.longrunning.Operations' => [ + 'CancelOperation' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{name=projects/*/locations/*/operations/*}:cancel', + 'body' => '*', + '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', + ], + ], + ], + ], + ], + ], +]; diff --git a/Ids/tests/Unit/V1/IDSClientTest.php b/Ids/tests/Unit/V1/IDSClientTest.php new file mode 100644 index 00000000000..dce3a07416a --- /dev/null +++ b/Ids/tests/Unit/V1/IDSClientTest.php @@ -0,0 +1,493 @@ +getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + } + + /** + * @return IDSClient + */ + private function createClient(array $options = []) + { + $options += [ + 'credentials' => $this->createCredentials(), + ]; + return new IDSClient($options); + } + + /** + * @test + */ + public function createEndpointTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'serviceAddress' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $client = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/createEndpointTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $name = 'name3373707'; + $network = 'network1843485230'; + $endpointForwardingRule = 'endpointForwardingRule-1878786988'; + $endpointIp = 'endpointIp-1135808495'; + $description = 'description-1724546052'; + $trafficLogs = false; + $expectedResponse = new Endpoint(); + $expectedResponse->setName($name); + $expectedResponse->setNetwork($network); + $expectedResponse->setEndpointForwardingRule($endpointForwardingRule); + $expectedResponse->setEndpointIp($endpointIp); + $expectedResponse->setDescription($description); + $expectedResponse->setTrafficLogs($trafficLogs); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/createEndpointTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $formattedParent = $client->locationName('[PROJECT]', '[LOCATION]'); + $endpointId = 'endpointId-1135808507'; + $endpoint = new Endpoint(); + $endpointNetwork = 'endpointNetwork1670861529'; + $endpoint->setNetwork($endpointNetwork); + $endpointSeverity = Severity::SEVERITY_UNSPECIFIED; + $endpoint->setSeverity($endpointSeverity); + $response = $client->createEndpoint($formattedParent, $endpointId, $endpoint); + $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.ids.v1.IDS/CreateEndpoint', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualApiRequestObject->getEndpointId(); + $this->assertProtobufEquals($endpointId, $actualValue); + $actualValue = $actualApiRequestObject->getEndpoint(); + $this->assertProtobufEquals($endpoint, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/createEndpointTest'); + $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 createEndpointExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'serviceAddress' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $client = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/createEndpointTest'); + $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 = $client->locationName('[PROJECT]', '[LOCATION]'); + $endpointId = 'endpointId-1135808507'; + $endpoint = new Endpoint(); + $endpointNetwork = 'endpointNetwork1670861529'; + $endpoint->setNetwork($endpointNetwork); + $endpointSeverity = Severity::SEVERITY_UNSPECIFIED; + $endpoint->setSeverity($endpointSeverity); + $response = $client->createEndpoint($formattedParent, $endpointId, $endpoint); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/createEndpointTest'); + 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 deleteEndpointTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'serviceAddress' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $client = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/deleteEndpointTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $expectedResponse = new GPBEmpty(); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/deleteEndpointTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $formattedName = $client->endpointName('[PROJECT]', '[LOCATION]', '[ENDPOINT]'); + $response = $client->deleteEndpoint($formattedName); + $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.ids.v1.IDS/DeleteEndpoint', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/deleteEndpointTest'); + $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 deleteEndpointExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'serviceAddress' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $client = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/deleteEndpointTest'); + $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 = $client->endpointName('[PROJECT]', '[LOCATION]', '[ENDPOINT]'); + $response = $client->deleteEndpoint($formattedName); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/deleteEndpointTest'); + 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 getEndpointTest() + { + $transport = $this->createTransport(); + $client = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name2 = 'name2-1052831874'; + $network = 'network1843485230'; + $endpointForwardingRule = 'endpointForwardingRule-1878786988'; + $endpointIp = 'endpointIp-1135808495'; + $description = 'description-1724546052'; + $trafficLogs = false; + $expectedResponse = new Endpoint(); + $expectedResponse->setName($name2); + $expectedResponse->setNetwork($network); + $expectedResponse->setEndpointForwardingRule($endpointForwardingRule); + $expectedResponse->setEndpointIp($endpointIp); + $expectedResponse->setDescription($description); + $expectedResponse->setTrafficLogs($trafficLogs); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $client->endpointName('[PROJECT]', '[LOCATION]', '[ENDPOINT]'); + $response = $client->getEndpoint($formattedName); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.ids.v1.IDS/GetEndpoint', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function getEndpointExceptionTest() + { + $transport = $this->createTransport(); + $client = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedName = $client->endpointName('[PROJECT]', '[LOCATION]', '[ENDPOINT]'); + try { + $client->getEndpoint($formattedName); + // If the $client method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function listEndpointsTest() + { + $transport = $this->createTransport(); + $client = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $endpointsElement = new Endpoint(); + $endpoints = [ + $endpointsElement, + ]; + $expectedResponse = new ListEndpointsResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setEndpoints($endpoints); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $client->locationName('[PROJECT]', '[LOCATION]'); + $response = $client->listEndpoints($formattedParent); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getEndpoints()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.ids.v1.IDS/ListEndpoints', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function listEndpointsExceptionTest() + { + $transport = $this->createTransport(); + $client = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedParent = $client->locationName('[PROJECT]', '[LOCATION]'); + try { + $client->listEndpoints($formattedParent); + // If the $client method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } +} diff --git a/docs/contents/cloud-ids.json b/docs/contents/cloud-ids.json new file mode 100644 index 00000000000..f963abb4d1a --- /dev/null +++ b/docs/contents/cloud-ids.json @@ -0,0 +1,15 @@ +{ + "title": "Ids", + "defaultService": "ids\/readme", + "services": [ + { + "title": "Overview", + "type": "ids\/readme" + }, + { + "title": "IDSClient (v1)", + "type": "ids\/v1\/idsclient" + } + ], + "pattern": "ids\/\\w{1,}" +}