diff --git a/DiscoveryEngine/.OwlBot.yaml b/DiscoveryEngine/.OwlBot.yaml new file mode 100644 index 000000000000..e97dc2d71260 --- /dev/null +++ b/DiscoveryEngine/.OwlBot.yaml @@ -0,0 +1,4 @@ +deep-copy-regex: + - source: /google/cloud/discoveryengine/(v1beta)/.*-php/(.*) + dest: /owl-bot-staging/DiscoveryEngine/$1/$2 +api-name: DiscoveryEngine diff --git a/DiscoveryEngine/.gitattributes b/DiscoveryEngine/.gitattributes new file mode 100644 index 000000000000..8119e7fcc1b2 --- /dev/null +++ b/DiscoveryEngine/.gitattributes @@ -0,0 +1,8 @@ +/*.xml.dist export-ignore +/.OwlBot.yaml export-ignore +/.github export-ignore +/.repo-metadata.json export-ignore +/owlbot.py export-ignore +/src/**/gapic_metadata.json export-ignore +/samples export-ignore +/tests export-ignore diff --git a/DiscoveryEngine/.github/pull_request_template.md b/DiscoveryEngine/.github/pull_request_template.md new file mode 100644 index 000000000000..0bd52a4e577d --- /dev/null +++ b/DiscoveryEngine/.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 `DiscoveryEngine/src`, and tests in `DiscoveryEngine/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/DiscoveryEngine/.repo-metadata.json b/DiscoveryEngine/.repo-metadata.json new file mode 100644 index 000000000000..2eae479d97c5 --- /dev/null +++ b/DiscoveryEngine/.repo-metadata.json @@ -0,0 +1,7 @@ +{ + "distribution_name": "google/cloud-discoveryengine", + "release_level": "preview", + "client_documentation": "https://cloud.google.com/php/docs/reference/cloud-discoveryengine/latest", + "library_type": "GAPIC_AUTO", + "api_shortname": "discoveryengine" +} diff --git a/DiscoveryEngine/CONTRIBUTING.md b/DiscoveryEngine/CONTRIBUTING.md new file mode 100644 index 000000000000..76ea811cacdb --- /dev/null +++ b/DiscoveryEngine/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/DiscoveryEngine/LICENSE b/DiscoveryEngine/LICENSE new file mode 100644 index 000000000000..8f71f43fee3f --- /dev/null +++ b/DiscoveryEngine/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/DiscoveryEngine/README.md b/DiscoveryEngine/README.md new file mode 100644 index 000000000000..70a1d045e426 --- /dev/null +++ b/DiscoveryEngine/README.md @@ -0,0 +1,45 @@ +# Google Cloud Discovery Engine for PHP + +> Idiomatic PHP client for [Google Cloud Discovery Engine](https://cloud.google.com/discovery-engine). + +[![Latest Stable Version](https://poser.pugx.org/google/cloud-discoveryengine/v/stable)](https://packagist.org/packages/google/cloud-discoveryengine) [![Packagist](https://img.shields.io/packagist/dm/google/cloud-discoveryengine.svg)](https://packagist.org/packages/google/cloud-discoveryengine) + +* [API documentation](https://cloud.google.com/php/docs/reference/cloud-discoveryengine/latest) + +**NOTE:** This repository is part of [Google Cloud PHP](https://github.com/googleapis/google-cloud-php). Any +support requests, bug reports, or development contributions should be directed to +that project. + +### Installation + +To begin, install the preferred dependency manager for PHP, [Composer](https://getcomposer.org/). + +Now, install this component: + +```sh +$ composer require google/cloud-discoveryengine +``` + +> Browse the complete list of [Google Cloud APIs](https://cloud.google.com/php/docs/reference) +> for PHP + +This component supports both REST over HTTP/1.1 and gRPC. In order to take advantage of the benefits +offered by gRPC (such as streaming methods) please see our +[gRPC installation guide](https://cloud.google.com/php/grpc). + +### Authentication + +Please see our [Authentication guide](https://github.com/googleapis/google-cloud-php/blob/main/AUTHENTICATION.md) for more information +on authenticating your client. Once authenticated, you'll be ready to start making requests. + +### Sample + +See the [samples directory](https://github.com/googleapis/google-cloud-php-discoveryengine/tree/main/samples) for a canonical list of samples. + +### Version + +This component is considered alpha. As such, it is still a work-in-progress and is more likely to get backwards-incompatible updates. + +### Next Steps + +1. Understand the [official documentation](https://cloud.google.com/discovery-engine/docs/apis). diff --git a/DiscoveryEngine/VERSION b/DiscoveryEngine/VERSION new file mode 100644 index 000000000000..77d6f4ca2371 --- /dev/null +++ b/DiscoveryEngine/VERSION @@ -0,0 +1 @@ +0.0.0 diff --git a/DiscoveryEngine/composer.json b/DiscoveryEngine/composer.json new file mode 100644 index 000000000000..1e604522e4cd --- /dev/null +++ b/DiscoveryEngine/composer.json @@ -0,0 +1,30 @@ +{ + "name": "google/cloud-discoveryengine", + "description": "Google Cloud Discovery Engine Client for PHP", + "license": "Apache-2.0", + "minimum-stability": "stable", + "autoload": { + "psr-4": { + "Google\\Cloud\\DiscoveryEngine\\": "src", + "GPBMetadata\\Google\\Cloud\\Discoveryengine\\": "metadata" + } + }, + "extra": { + "component": { + "id": "cloud-discoveryengine", + "path": "DiscoveryEngine", + "target": "googleapis/google-cloud-php-discoveryengine" + } + }, + "require": { + "php": ">=7.4", + "google/gax": "^1.20.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.0" + }, + "suggest": { + "ext-grpc": "Enables use of gRPC, a universal high-performance RPC framework created by Google.", + "ext-protobuf": "Provides a significant increase in throughput over the pure PHP protobuf implementation. See https://cloud.google.com/php/grpc for installation instructions." + } +} diff --git a/DiscoveryEngine/metadata/V1Beta/Common.php b/DiscoveryEngine/metadata/V1Beta/Common.php new file mode 100644 index 000000000000..7c51f9521ad5 Binary files /dev/null and b/DiscoveryEngine/metadata/V1Beta/Common.php differ diff --git a/DiscoveryEngine/metadata/V1Beta/CompletionService.php b/DiscoveryEngine/metadata/V1Beta/CompletionService.php new file mode 100644 index 000000000000..1e9365bc3ba3 --- /dev/null +++ b/DiscoveryEngine/metadata/V1Beta/CompletionService.php @@ -0,0 +1,45 @@ +internalAddGeneratedFile( + ' + +internalAddGeneratedFile( + ' + +:google/cloud/discoveryengine/v1beta/document_service.proto#google.cloud.discoveryengine.v1betagoogle/api/client.protogoogle/api/field_behavior.protogoogle/api/resource.proto2google/cloud/discoveryengine/v1beta/document.proto7google/cloud/discoveryengine/v1beta/import_config.proto6google/cloud/discoveryengine/v1beta/purge_config.proto#google/longrunning/operations.protogoogle/protobuf/empty.proto"S +GetDocumentRequest= +name ( B/AA) +\'discoveryengine.googleapis.com/Document"| +ListDocumentsRequest= +parent ( B-AA\' +%discoveryengine.googleapis.com/Branch + page_size ( + +page_token ( "r +ListDocumentsResponse@ + documents ( 2-.google.cloud.discoveryengine.v1beta.Document +next_page_token ( " +CreateDocumentRequest= +parent ( B-AA\' +%discoveryengine.googleapis.com/BranchD +document ( 2-.google.cloud.discoveryengine.v1beta.DocumentBA + document_id ( BA"t +UpdateDocumentRequestD +document ( 2-.google.cloud.discoveryengine.v1beta.DocumentBA + allow_missing ("V +DeleteDocumentRequest= +name ( B/AA) +\'discoveryengine.googleapis.com/Document2 +DocumentService + GetDocument7.google.cloud.discoveryengine.v1beta.GetDocumentRequest-.google.cloud.discoveryengine.v1beta.Document"I/v1beta/{name=projects/*/locations/*/dataStores/*/branches/*/documents/*}ZYW/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/branches/*/documents/*}Aname + ListDocuments9.google.cloud.discoveryengine.v1beta.ListDocumentsRequest:.google.cloud.discoveryengine.v1beta.ListDocumentsResponse"I/v1beta/{parent=projects/*/locations/*/dataStores/*/branches/*}/documentsZYW/v1beta/{parent=projects/*/locations/*/collections/*/dataStores/*/branches/*}/documentsAparent +CreateDocument:.google.cloud.discoveryengine.v1beta.CreateDocumentRequest-.google.cloud.discoveryengine.v1beta.Document""I/v1beta/{parent=projects/*/locations/*/dataStores/*/branches/*}/documents:documentZc"W/v1beta/{parent=projects/*/locations/*/collections/*/dataStores/*/branches/*}/documents:documentAparent,document,document_id +UpdateDocument:.google.cloud.discoveryengine.v1beta.UpdateDocumentRequest-.google.cloud.discoveryengine.v1beta.Document"2R/v1beta/{document.name=projects/*/locations/*/dataStores/*/branches/*/documents/*}:documentZl2`/v1beta/{document.name=projects/*/locations/*/collections/*/dataStores/*/branches/*/documents/*}:document +DeleteDocument:.google.cloud.discoveryengine.v1beta.DeleteDocumentRequest.google.protobuf.Empty"*I/v1beta/{name=projects/*/locations/*/dataStores/*/branches/*/documents/*}ZY*W/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/branches/*/documents/*}Aname +ImportDocuments;.google.cloud.discoveryengine.v1beta.ImportDocumentsRequest.google.longrunning.Operation""P/v1beta/{parent=projects/*/locations/*/dataStores/*/branches/*}/documents:import:*Zc"^/v1beta/{parent=projects/*/locations/*/collections/*/dataStores/*/branches/*}/documents:import:*Az +;google.cloud.discoveryengine.v1beta.ImportDocumentsResponse;google.cloud.discoveryengine.v1beta.ImportDocumentsMetadata +PurgeDocuments:.google.cloud.discoveryengine.v1beta.PurgeDocumentsRequest.google.longrunning.Operation""O/v1beta/{parent=projects/*/locations/*/dataStores/*/branches/*}/documents:purge:*Zb"]/v1beta/{parent=projects/*/locations/*/collections/*/dataStores/*/branches/*}/documents:purge:*Ax +:google.cloud.discoveryengine.v1beta.PurgeDocumentsResponse:google.cloud.discoveryengine.v1beta.PurgeDocumentsMetadataRAdiscoveryengine.googleapis.comA.https://www.googleapis.com/auth/cloud-platformB +\'com.google.cloud.discoveryengine.v1betaBDocumentServiceProtoPZQcloud.google.com/go/discoveryengine/apiv1beta/discoveryenginepb;discoveryenginepbDISCOVERYENGINE#Google.Cloud.DiscoveryEngine.V1Beta#Google\\Cloud\\DiscoveryEngine\\V1beta&Google::Cloud::DiscoveryEngine::V1betabproto3' + , true); + + static::$is_initialized = true; + } +} + diff --git a/DiscoveryEngine/metadata/V1Beta/ImportConfig.php b/DiscoveryEngine/metadata/V1Beta/ImportConfig.php new file mode 100644 index 000000000000..7d6999582253 Binary files /dev/null and b/DiscoveryEngine/metadata/V1Beta/ImportConfig.php differ diff --git a/DiscoveryEngine/metadata/V1Beta/PurgeConfig.php b/DiscoveryEngine/metadata/V1Beta/PurgeConfig.php new file mode 100644 index 000000000000..623f49eb0a27 --- /dev/null +++ b/DiscoveryEngine/metadata/V1Beta/PurgeConfig.php @@ -0,0 +1,44 @@ +internalAddGeneratedFile( + ' + +6google/cloud/discoveryengine/v1beta/purge_config.proto#google.cloud.discoveryengine.v1betagoogle/api/resource.protogoogle/protobuf/timestamp.proto"z +PurgeDocumentsRequest= +parent ( B-AA\' +%discoveryengine.googleapis.com/Branch +filter ( BA +force ("q +PurgeDocumentsResponse + purge_count (B + purge_sample ( B,A) +\'discoveryengine.googleapis.com/Document" +PurgeDocumentsMetadata/ + create_time ( 2.google.protobuf.Timestamp/ + update_time ( 2.google.protobuf.Timestamp + success_count ( + failure_count (B +\'com.google.cloud.discoveryengine.v1betaBPurgeConfigProtoPZQcloud.google.com/go/discoveryengine/apiv1beta/discoveryenginepb;discoveryenginepbDISCOVERYENGINE#Google.Cloud.DiscoveryEngine.V1Beta#Google\\Cloud\\DiscoveryEngine\\V1beta&Google::Cloud::DiscoveryEngine::V1betabproto3' + , true); + + static::$is_initialized = true; + } +} + diff --git a/DiscoveryEngine/metadata/V1Beta/RecommendationService.php b/DiscoveryEngine/metadata/V1Beta/RecommendationService.php new file mode 100644 index 000000000000..2b734d1177c2 --- /dev/null +++ b/DiscoveryEngine/metadata/V1Beta/RecommendationService.php @@ -0,0 +1,65 @@ +internalAddGeneratedFile( + ' + +@google/cloud/discoveryengine/v1beta/recommendation_service.proto#google.cloud.discoveryengine.v1betagoogle/api/client.protogoogle/api/field_behavior.protogoogle/api/resource.proto2google/cloud/discoveryengine/v1beta/document.proto4google/cloud/discoveryengine/v1beta/user_event.protogoogle/protobuf/struct.proto" +RecommendRequestL +serving_config ( B4AA. +,discoveryengine.googleapis.com/ServingConfigG + +user_event ( 2..google.cloud.discoveryengine.v1beta.UserEventBA + page_size ( +filter (  + validate_only (Q +params ( 2A.google.cloud.discoveryengine.v1beta.RecommendRequest.ParamsEntryZ + user_labels ( 2E.google.cloud.discoveryengine.v1beta.RecommendRequest.UserLabelsEntryE + ParamsEntry +key ( % +value ( 2.google.protobuf.Value:81 +UserLabelsEntry +key (  +value ( :8" +RecommendResponse\\ +results ( 2K.google.cloud.discoveryengine.v1beta.RecommendResponse.RecommendationResult +attribution_token (  + missing_ids (  + validate_only ( +RecommendationResult + +id ( ? +document ( 2-.google.cloud.discoveryengine.v1beta.Documentk +metadata ( 2Y.google.cloud.discoveryengine.v1beta.RecommendResponse.RecommendationResult.MetadataEntryG + MetadataEntry +key ( % +value ( 2.google.protobuf.Value:82 +RecommendationService + Recommend5.google.cloud.discoveryengine.v1beta.RecommendRequest6.google.cloud.discoveryengine.v1beta.RecommendResponse""W/v1beta/{serving_config=projects/*/locations/*/dataStores/*/servingConfigs/*}:recommend:*Zj"e/v1beta/{serving_config=projects/*/locations/*/collections/*/dataStores/*/servingConfigs/*}:recommend:*RAdiscoveryengine.googleapis.comA.https://www.googleapis.com/auth/cloud-platformB +\'com.google.cloud.discoveryengine.v1betaBRecommendationServiceProtoPZQcloud.google.com/go/discoveryengine/apiv1beta/discoveryenginepb;discoveryenginepbDISCOVERYENGINE#Google.Cloud.DiscoveryEngine.V1Beta#Google\\Cloud\\DiscoveryEngine\\V1beta&Google::Cloud::DiscoveryEngine::V1betabproto3' + , true); + + static::$is_initialized = true; + } +} + diff --git a/DiscoveryEngine/metadata/V1Beta/Schema.php b/DiscoveryEngine/metadata/V1Beta/Schema.php new file mode 100644 index 000000000000..8d02f391ef0e Binary files /dev/null and b/DiscoveryEngine/metadata/V1Beta/Schema.php differ diff --git a/DiscoveryEngine/metadata/V1Beta/SchemaService.php b/DiscoveryEngine/metadata/V1Beta/SchemaService.php new file mode 100644 index 000000000000..41246ae56889 --- /dev/null +++ b/DiscoveryEngine/metadata/V1Beta/SchemaService.php @@ -0,0 +1,76 @@ +internalAddGeneratedFile( + ' + +8google/cloud/discoveryengine/v1beta/schema_service.proto#google.cloud.discoveryengine.v1betagoogle/api/client.protogoogle/api/field_behavior.protogoogle/api/resource.proto0google/cloud/discoveryengine/v1beta/schema.proto#google/longrunning/operations.protogoogle/protobuf/empty.protogoogle/protobuf/timestamp.proto"O +GetSchemaRequest; +name ( B-AA\' +%discoveryengine.googleapis.com/Schema"} +ListSchemasRequest@ +parent ( B0AA* +(discoveryengine.googleapis.com/DataStore + page_size ( + +page_token ( "l +ListSchemasResponse< +schemas ( 2+.google.cloud.discoveryengine.v1beta.Schema +next_page_token ( " +CreateSchemaRequest@ +parent ( B0AA* +(discoveryengine.googleapis.com/DataStore@ +schema ( 2+.google.cloud.discoveryengine.v1beta.SchemaBA + schema_id ( BA"n +UpdateSchemaRequest@ +schema ( 2+.google.cloud.discoveryengine.v1beta.SchemaBA + allow_missing ("R +DeleteSchemaRequest; +name ( B-AA\' +%discoveryengine.googleapis.com/Schema"x +CreateSchemaMetadata/ + create_time ( 2.google.protobuf.Timestamp/ + update_time ( 2.google.protobuf.Timestamp"x +UpdateSchemaMetadata/ + create_time ( 2.google.protobuf.Timestamp/ + update_time ( 2.google.protobuf.Timestamp"x +DeleteSchemaMetadata/ + create_time ( 2.google.protobuf.Timestamp/ + update_time ( 2.google.protobuf.Timestamp2 + SchemaService + GetSchema5.google.cloud.discoveryengine.v1beta.GetSchemaRequest+.google.cloud.discoveryengine.v1beta.Schema" + + + + tests/Unit + + + + + src + + src/V[!a-zA-Z]* + + + + diff --git a/DiscoveryEngine/samples/V1beta/CompletionServiceClient/complete_query.php b/DiscoveryEngine/samples/V1beta/CompletionServiceClient/complete_query.php new file mode 100644 index 000000000000..9c189002c471 --- /dev/null +++ b/DiscoveryEngine/samples/V1beta/CompletionServiceClient/complete_query.php @@ -0,0 +1,81 @@ +setDataStore($formattedDataStore) + ->setQuery($query); + + // Call the API and handle any network failures. + try { + /** @var CompleteQueryResponse $response */ + $response = $completionServiceClient->completeQuery($request); + printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample has been automatically generated and should be regarded as a code + * template only. It will require modifications to work: + * - It may require correct/in-range values for request initialization. + * - It may require specifying regional endpoints when creating the service client, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $formattedDataStore = CompletionServiceClient::dataStoreName( + '[PROJECT]', + '[LOCATION]', + '[DATA_STORE]' + ); + $query = '[QUERY]'; + + complete_query_sample($formattedDataStore, $query); +} +// [END discoveryengine_v1beta_generated_CompletionService_CompleteQuery_sync] diff --git a/DiscoveryEngine/samples/V1beta/DocumentServiceClient/create_document.php b/DiscoveryEngine/samples/V1beta/DocumentServiceClient/create_document.php new file mode 100644 index 000000000000..a8e46998d290 --- /dev/null +++ b/DiscoveryEngine/samples/V1beta/DocumentServiceClient/create_document.php @@ -0,0 +1,98 @@ +setParent($formattedParent) + ->setDocument($document) + ->setDocumentId($documentId); + + // Call the API and handle any network failures. + try { + /** @var Document $response */ + $response = $documentServiceClient->createDocument($request); + printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample has been automatically generated and should be regarded as a code + * template only. It will require modifications to work: + * - It may require correct/in-range values for request initialization. + * - It may require specifying regional endpoints when creating the service client, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $formattedParent = DocumentServiceClient::branchName( + '[PROJECT]', + '[LOCATION]', + '[DATA_STORE]', + '[BRANCH]' + ); + $documentId = '[DOCUMENT_ID]'; + + create_document_sample($formattedParent, $documentId); +} +// [END discoveryengine_v1beta_generated_DocumentService_CreateDocument_sync] diff --git a/DiscoveryEngine/samples/V1beta/DocumentServiceClient/delete_document.php b/DiscoveryEngine/samples/V1beta/DocumentServiceClient/delete_document.php new file mode 100644 index 000000000000..7e1f97e9fd13 --- /dev/null +++ b/DiscoveryEngine/samples/V1beta/DocumentServiceClient/delete_document.php @@ -0,0 +1,84 @@ +setName($formattedName); + + // Call the API and handle any network failures. + try { + $documentServiceClient->deleteDocument($request); + printf('Call completed successfully.' . PHP_EOL); + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample has been automatically generated and should be regarded as a code + * template only. It will require modifications to work: + * - It may require correct/in-range values for request initialization. + * - It may require specifying regional endpoints when creating the service client, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $formattedName = DocumentServiceClient::documentName( + '[PROJECT]', + '[LOCATION]', + '[DATA_STORE]', + '[BRANCH]', + '[DOCUMENT]' + ); + + delete_document_sample($formattedName); +} +// [END discoveryengine_v1beta_generated_DocumentService_DeleteDocument_sync] diff --git a/DiscoveryEngine/samples/V1beta/DocumentServiceClient/get_document.php b/DiscoveryEngine/samples/V1beta/DocumentServiceClient/get_document.php new file mode 100644 index 000000000000..f0244698e8d9 --- /dev/null +++ b/DiscoveryEngine/samples/V1beta/DocumentServiceClient/get_document.php @@ -0,0 +1,86 @@ +setName($formattedName); + + // Call the API and handle any network failures. + try { + /** @var Document $response */ + $response = $documentServiceClient->getDocument($request); + printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample has been automatically generated and should be regarded as a code + * template only. It will require modifications to work: + * - It may require correct/in-range values for request initialization. + * - It may require specifying regional endpoints when creating the service client, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $formattedName = DocumentServiceClient::documentName( + '[PROJECT]', + '[LOCATION]', + '[DATA_STORE]', + '[BRANCH]', + '[DOCUMENT]' + ); + + get_document_sample($formattedName); +} +// [END discoveryengine_v1beta_generated_DocumentService_GetDocument_sync] diff --git a/DiscoveryEngine/samples/V1beta/DocumentServiceClient/import_documents.php b/DiscoveryEngine/samples/V1beta/DocumentServiceClient/import_documents.php new file mode 100644 index 000000000000..a7878c9ca678 --- /dev/null +++ b/DiscoveryEngine/samples/V1beta/DocumentServiceClient/import_documents.php @@ -0,0 +1,96 @@ +setParent($formattedParent); + + // Call the API and handle any network failures. + try { + /** @var OperationResponse $response */ + $response = $documentServiceClient->importDocuments($request); + $response->pollUntilComplete(); + + if ($response->operationSucceeded()) { + /** @var ImportDocumentsResponse $result */ + $result = $response->getResult(); + printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString()); + } else { + /** @var Status $error */ + $error = $response->getError(); + printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString()); + } + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample has been automatically generated and should be regarded as a code + * template only. It will require modifications to work: + * - It may require correct/in-range values for request initialization. + * - It may require specifying regional endpoints when creating the service client, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $formattedParent = DocumentServiceClient::branchName( + '[PROJECT]', + '[LOCATION]', + '[DATA_STORE]', + '[BRANCH]' + ); + + import_documents_sample($formattedParent); +} +// [END discoveryengine_v1beta_generated_DocumentService_ImportDocuments_sync] diff --git a/DiscoveryEngine/samples/V1beta/DocumentServiceClient/list_documents.php b/DiscoveryEngine/samples/V1beta/DocumentServiceClient/list_documents.php new file mode 100644 index 000000000000..b2ec2baaa235 --- /dev/null +++ b/DiscoveryEngine/samples/V1beta/DocumentServiceClient/list_documents.php @@ -0,0 +1,88 @@ +setParent($formattedParent); + + // Call the API and handle any network failures. + try { + /** @var PagedListResponse $response */ + $response = $documentServiceClient->listDocuments($request); + + /** @var Document $element */ + foreach ($response as $element) { + printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString()); + } + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample has been automatically generated and should be regarded as a code + * template only. It will require modifications to work: + * - It may require correct/in-range values for request initialization. + * - It may require specifying regional endpoints when creating the service client, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $formattedParent = DocumentServiceClient::branchName( + '[PROJECT]', + '[LOCATION]', + '[DATA_STORE]', + '[BRANCH]' + ); + + list_documents_sample($formattedParent); +} +// [END discoveryengine_v1beta_generated_DocumentService_ListDocuments_sync] diff --git a/DiscoveryEngine/samples/V1beta/DocumentServiceClient/purge_documents.php b/DiscoveryEngine/samples/V1beta/DocumentServiceClient/purge_documents.php new file mode 100644 index 000000000000..106df6d1c0ec --- /dev/null +++ b/DiscoveryEngine/samples/V1beta/DocumentServiceClient/purge_documents.php @@ -0,0 +1,110 @@ +setParent($formattedParent) + ->setFilter($filter); + + // Call the API and handle any network failures. + try { + /** @var OperationResponse $response */ + $response = $documentServiceClient->purgeDocuments($request); + $response->pollUntilComplete(); + + if ($response->operationSucceeded()) { + /** @var PurgeDocumentsResponse $result */ + $result = $response->getResult(); + printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString()); + } else { + /** @var Status $error */ + $error = $response->getError(); + printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString()); + } + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample has been automatically generated and should be regarded as a code + * template only. It will require modifications to work: + * - It may require correct/in-range values for request initialization. + * - It may require specifying regional endpoints when creating the service client, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $formattedParent = DocumentServiceClient::branchName( + '[PROJECT]', + '[LOCATION]', + '[DATA_STORE]', + '[BRANCH]' + ); + $filter = '[FILTER]'; + + purge_documents_sample($formattedParent, $filter); +} +// [END discoveryengine_v1beta_generated_DocumentService_PurgeDocuments_sync] diff --git a/DiscoveryEngine/samples/V1beta/DocumentServiceClient/update_document.php b/DiscoveryEngine/samples/V1beta/DocumentServiceClient/update_document.php new file mode 100644 index 000000000000..9ff84c5aa563 --- /dev/null +++ b/DiscoveryEngine/samples/V1beta/DocumentServiceClient/update_document.php @@ -0,0 +1,59 @@ +setDocument($document); + + // Call the API and handle any network failures. + try { + /** @var Document $response */ + $response = $documentServiceClient->updateDocument($request); + printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} +// [END discoveryengine_v1beta_generated_DocumentService_UpdateDocument_sync] diff --git a/DiscoveryEngine/samples/V1beta/RecommendationServiceClient/recommend.php b/DiscoveryEngine/samples/V1beta/RecommendationServiceClient/recommend.php new file mode 100644 index 000000000000..1d506baf19fd --- /dev/null +++ b/DiscoveryEngine/samples/V1beta/RecommendationServiceClient/recommend.php @@ -0,0 +1,126 @@ + Men > Jeans + * + * Retail-related values: + * + * * `add-to-cart`: Add an item(s) to cart, e.g. in Retail online shopping + * * `purchase`: Purchase an item(s) + * + * Media-related values: + * + * * `media-play`: Start/resume watching a video, playing a song, etc. + * * `media-complete`: Finished or stopped midway through a video, song, etc. + * @param string $userEventUserPseudoId A unique identifier for tracking visitors. + * + * For example, this could be implemented with an HTTP cookie, which should be + * able to uniquely identify a visitor on a single device. This unique + * identifier should not change if the visitor log in/out of the website. + * + * Do not set the field to the same fixed ID for different users. This mixes + * the event history of those users together, which results in degraded model + * quality. + * + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * + * The field should not contain PII or user-data. We recommend to use Google + * Analytics [Client + * ID](https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#clientId) + * for this field. + */ +function recommend_sample( + string $formattedServingConfig, + string $userEventEventType, + string $userEventUserPseudoId +): void { + // Create a client. + $recommendationServiceClient = new RecommendationServiceClient(); + + // Prepare the request message. + $userEvent = (new UserEvent()) + ->setEventType($userEventEventType) + ->setUserPseudoId($userEventUserPseudoId); + $request = (new RecommendRequest()) + ->setServingConfig($formattedServingConfig) + ->setUserEvent($userEvent); + + // Call the API and handle any network failures. + try { + /** @var RecommendResponse $response */ + $response = $recommendationServiceClient->recommend($request); + printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample has been automatically generated and should be regarded as a code + * template only. It will require modifications to work: + * - It may require correct/in-range values for request initialization. + * - It may require specifying regional endpoints when creating the service client, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $formattedServingConfig = RecommendationServiceClient::servingConfigName( + '[PROJECT]', + '[LOCATION]', + '[DATA_STORE]', + '[SERVING_CONFIG]' + ); + $userEventEventType = '[EVENT_TYPE]'; + $userEventUserPseudoId = '[USER_PSEUDO_ID]'; + + recommend_sample($formattedServingConfig, $userEventEventType, $userEventUserPseudoId); +} +// [END discoveryengine_v1beta_generated_RecommendationService_Recommend_sync] diff --git a/DiscoveryEngine/samples/V1beta/SchemaServiceClient/create_schema.php b/DiscoveryEngine/samples/V1beta/SchemaServiceClient/create_schema.php new file mode 100644 index 000000000000..8b59f61f95ab --- /dev/null +++ b/DiscoveryEngine/samples/V1beta/SchemaServiceClient/create_schema.php @@ -0,0 +1,96 @@ +setParent($formattedParent) + ->setSchema($schema) + ->setSchemaId($schemaId); + + // Call the API and handle any network failures. + try { + /** @var OperationResponse $response */ + $response = $schemaServiceClient->createSchema($request); + $response->pollUntilComplete(); + + if ($response->operationSucceeded()) { + /** @var Schema $result */ + $result = $response->getResult(); + printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString()); + } else { + /** @var Status $error */ + $error = $response->getError(); + printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString()); + } + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample has been automatically generated and should be regarded as a code + * template only. It will require modifications to work: + * - It may require correct/in-range values for request initialization. + * - It may require specifying regional endpoints when creating the service client, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $formattedParent = SchemaServiceClient::dataStoreName('[PROJECT]', '[LOCATION]', '[DATA_STORE]'); + $schemaId = '[SCHEMA_ID]'; + + create_schema_sample($formattedParent, $schemaId); +} +// [END discoveryengine_v1beta_generated_SchemaService_CreateSchema_sync] diff --git a/DiscoveryEngine/samples/V1beta/SchemaServiceClient/delete_schema.php b/DiscoveryEngine/samples/V1beta/SchemaServiceClient/delete_schema.php new file mode 100644 index 000000000000..88465c02b0c4 --- /dev/null +++ b/DiscoveryEngine/samples/V1beta/SchemaServiceClient/delete_schema.php @@ -0,0 +1,86 @@ +setName($formattedName); + + // Call the API and handle any network failures. + try { + /** @var OperationResponse $response */ + $response = $schemaServiceClient->deleteSchema($request); + $response->pollUntilComplete(); + + if ($response->operationSucceeded()) { + printf('Operation completed successfully.' . PHP_EOL); + } else { + /** @var Status $error */ + $error = $response->getError(); + printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString()); + } + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample has been automatically generated and should be regarded as a code + * template only. It will require modifications to work: + * - It may require correct/in-range values for request initialization. + * - It may require specifying regional endpoints when creating the service client, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $formattedName = SchemaServiceClient::schemaName( + '[PROJECT]', + '[LOCATION]', + '[DATA_STORE]', + '[SCHEMA]' + ); + + delete_schema_sample($formattedName); +} +// [END discoveryengine_v1beta_generated_SchemaService_DeleteSchema_sync] diff --git a/DiscoveryEngine/samples/V1beta/SchemaServiceClient/get_schema.php b/DiscoveryEngine/samples/V1beta/SchemaServiceClient/get_schema.php new file mode 100644 index 000000000000..fe9bad536488 --- /dev/null +++ b/DiscoveryEngine/samples/V1beta/SchemaServiceClient/get_schema.php @@ -0,0 +1,77 @@ +setName($formattedName); + + // Call the API and handle any network failures. + try { + /** @var Schema $response */ + $response = $schemaServiceClient->getSchema($request); + printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample has been automatically generated and should be regarded as a code + * template only. It will require modifications to work: + * - It may require correct/in-range values for request initialization. + * - It may require specifying regional endpoints when creating the service client, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $formattedName = SchemaServiceClient::schemaName( + '[PROJECT]', + '[LOCATION]', + '[DATA_STORE]', + '[SCHEMA]' + ); + + get_schema_sample($formattedName); +} +// [END discoveryengine_v1beta_generated_SchemaService_GetSchema_sync] diff --git a/DiscoveryEngine/samples/V1beta/SchemaServiceClient/list_schemas.php b/DiscoveryEngine/samples/V1beta/SchemaServiceClient/list_schemas.php new file mode 100644 index 000000000000..6cc72cd99c30 --- /dev/null +++ b/DiscoveryEngine/samples/V1beta/SchemaServiceClient/list_schemas.php @@ -0,0 +1,77 @@ +setParent($formattedParent); + + // Call the API and handle any network failures. + try { + /** @var PagedListResponse $response */ + $response = $schemaServiceClient->listSchemas($request); + + /** @var Schema $element */ + foreach ($response as $element) { + printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString()); + } + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample has been automatically generated and should be regarded as a code + * template only. It will require modifications to work: + * - It may require correct/in-range values for request initialization. + * - It may require specifying regional endpoints when creating the service client, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $formattedParent = SchemaServiceClient::dataStoreName('[PROJECT]', '[LOCATION]', '[DATA_STORE]'); + + list_schemas_sample($formattedParent); +} +// [END discoveryengine_v1beta_generated_SchemaService_ListSchemas_sync] diff --git a/DiscoveryEngine/samples/V1beta/SchemaServiceClient/update_schema.php b/DiscoveryEngine/samples/V1beta/SchemaServiceClient/update_schema.php new file mode 100644 index 000000000000..4634c84a3008 --- /dev/null +++ b/DiscoveryEngine/samples/V1beta/SchemaServiceClient/update_schema.php @@ -0,0 +1,71 @@ +setSchema($schema); + + // Call the API and handle any network failures. + try { + /** @var OperationResponse $response */ + $response = $schemaServiceClient->updateSchema($request); + $response->pollUntilComplete(); + + if ($response->operationSucceeded()) { + /** @var Schema $result */ + $result = $response->getResult(); + printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString()); + } else { + /** @var Status $error */ + $error = $response->getError(); + printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString()); + } + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} +// [END discoveryengine_v1beta_generated_SchemaService_UpdateSchema_sync] diff --git a/DiscoveryEngine/samples/V1beta/SearchServiceClient/search.php b/DiscoveryEngine/samples/V1beta/SearchServiceClient/search.php new file mode 100644 index 000000000000..eccb5311c97c --- /dev/null +++ b/DiscoveryEngine/samples/V1beta/SearchServiceClient/search.php @@ -0,0 +1,84 @@ +setServingConfig($formattedServingConfig); + + // Call the API and handle any network failures. + try { + /** @var PagedListResponse $response */ + $response = $searchServiceClient->search($request); + + /** @var SearchResult $element */ + foreach ($response as $element) { + printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString()); + } + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample has been automatically generated and should be regarded as a code + * template only. It will require modifications to work: + * - It may require correct/in-range values for request initialization. + * - It may require specifying regional endpoints when creating the service client, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $formattedServingConfig = SearchServiceClient::servingConfigName( + '[PROJECT]', + '[LOCATION]', + '[DATA_STORE]', + '[SERVING_CONFIG]' + ); + + search_sample($formattedServingConfig); +} +// [END discoveryengine_v1beta_generated_SearchService_Search_sync] diff --git a/DiscoveryEngine/samples/V1beta/UserEventServiceClient/collect_user_event.php b/DiscoveryEngine/samples/V1beta/UserEventServiceClient/collect_user_event.php new file mode 100644 index 000000000000..a6f2e7f12231 --- /dev/null +++ b/DiscoveryEngine/samples/V1beta/UserEventServiceClient/collect_user_event.php @@ -0,0 +1,80 @@ +setParent($formattedParent) + ->setUserEvent($userEvent); + + // Call the API and handle any network failures. + try { + /** @var HttpBody $response */ + $response = $userEventServiceClient->collectUserEvent($request); + printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample has been automatically generated and should be regarded as a code + * template only. It will require modifications to work: + * - It may require correct/in-range values for request initialization. + * - It may require specifying regional endpoints when creating the service client, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $formattedParent = UserEventServiceClient::dataStoreName('[PROJECT]', '[LOCATION]', '[DATA_STORE]'); + $userEvent = '[USER_EVENT]'; + + collect_user_event_sample($formattedParent, $userEvent); +} +// [END discoveryengine_v1beta_generated_UserEventService_CollectUserEvent_sync] diff --git a/DiscoveryEngine/samples/V1beta/UserEventServiceClient/import_user_events.php b/DiscoveryEngine/samples/V1beta/UserEventServiceClient/import_user_events.php new file mode 100644 index 000000000000..b62f1d95f16e --- /dev/null +++ b/DiscoveryEngine/samples/V1beta/UserEventServiceClient/import_user_events.php @@ -0,0 +1,144 @@ + Men > Jeans + * + * Retail-related values: + * + * * `add-to-cart`: Add an item(s) to cart, e.g. in Retail online shopping + * * `purchase`: Purchase an item(s) + * + * Media-related values: + * + * * `media-play`: Start/resume watching a video, playing a song, etc. + * * `media-complete`: Finished or stopped midway through a video, song, etc. + * @param string $inlineSourceUserEventsUserPseudoId A unique identifier for tracking visitors. + * + * For example, this could be implemented with an HTTP cookie, which should be + * able to uniquely identify a visitor on a single device. This unique + * identifier should not change if the visitor log in/out of the website. + * + * Do not set the field to the same fixed ID for different users. This mixes + * the event history of those users together, which results in degraded model + * quality. + * + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * + * The field should not contain PII or user-data. We recommend to use Google + * Analytics [Client + * ID](https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#clientId) + * for this field. + * @param string $formattedParent Parent DataStore resource name, of the form + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}` + * Please see {@see UserEventServiceClient::dataStoreName()} for help formatting this field. + */ +function import_user_events_sample( + string $inlineSourceUserEventsEventType, + string $inlineSourceUserEventsUserPseudoId, + string $formattedParent +): void { + // Create a client. + $userEventServiceClient = new UserEventServiceClient(); + + // Prepare the request message. + $userEvent = (new UserEvent()) + ->setEventType($inlineSourceUserEventsEventType) + ->setUserPseudoId($inlineSourceUserEventsUserPseudoId); + $inlineSourceUserEvents = [$userEvent,]; + $inlineSource = (new InlineSource()) + ->setUserEvents($inlineSourceUserEvents); + $request = (new ImportUserEventsRequest()) + ->setInlineSource($inlineSource) + ->setParent($formattedParent); + + // Call the API and handle any network failures. + try { + /** @var OperationResponse $response */ + $response = $userEventServiceClient->importUserEvents($request); + $response->pollUntilComplete(); + + if ($response->operationSucceeded()) { + /** @var ImportUserEventsResponse $result */ + $result = $response->getResult(); + printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString()); + } else { + /** @var Status $error */ + $error = $response->getError(); + printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString()); + } + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample has been automatically generated and should be regarded as a code + * template only. It will require modifications to work: + * - It may require correct/in-range values for request initialization. + * - It may require specifying regional endpoints when creating the service client, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $inlineSourceUserEventsEventType = '[EVENT_TYPE]'; + $inlineSourceUserEventsUserPseudoId = '[USER_PSEUDO_ID]'; + $formattedParent = UserEventServiceClient::dataStoreName('[PROJECT]', '[LOCATION]', '[DATA_STORE]'); + + import_user_events_sample( + $inlineSourceUserEventsEventType, + $inlineSourceUserEventsUserPseudoId, + $formattedParent + ); +} +// [END discoveryengine_v1beta_generated_UserEventService_ImportUserEvents_sync] diff --git a/DiscoveryEngine/samples/V1beta/UserEventServiceClient/write_user_event.php b/DiscoveryEngine/samples/V1beta/UserEventServiceClient/write_user_event.php new file mode 100644 index 000000000000..889fb8188328 --- /dev/null +++ b/DiscoveryEngine/samples/V1beta/UserEventServiceClient/write_user_event.php @@ -0,0 +1,117 @@ + Men > Jeans + * + * Retail-related values: + * + * * `add-to-cart`: Add an item(s) to cart, e.g. in Retail online shopping + * * `purchase`: Purchase an item(s) + * + * Media-related values: + * + * * `media-play`: Start/resume watching a video, playing a song, etc. + * * `media-complete`: Finished or stopped midway through a video, song, etc. + * @param string $userEventUserPseudoId A unique identifier for tracking visitors. + * + * For example, this could be implemented with an HTTP cookie, which should be + * able to uniquely identify a visitor on a single device. This unique + * identifier should not change if the visitor log in/out of the website. + * + * Do not set the field to the same fixed ID for different users. This mixes + * the event history of those users together, which results in degraded model + * quality. + * + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * + * The field should not contain PII or user-data. We recommend to use Google + * Analytics [Client + * ID](https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#clientId) + * for this field. + */ +function write_user_event_sample( + string $formattedParent, + string $userEventEventType, + string $userEventUserPseudoId +): void { + // Create a client. + $userEventServiceClient = new UserEventServiceClient(); + + // Prepare the request message. + $userEvent = (new UserEvent()) + ->setEventType($userEventEventType) + ->setUserPseudoId($userEventUserPseudoId); + $request = (new WriteUserEventRequest()) + ->setParent($formattedParent) + ->setUserEvent($userEvent); + + // Call the API and handle any network failures. + try { + /** @var UserEvent $response */ + $response = $userEventServiceClient->writeUserEvent($request); + printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample has been automatically generated and should be regarded as a code + * template only. It will require modifications to work: + * - It may require correct/in-range values for request initialization. + * - It may require specifying regional endpoints when creating the service client, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $formattedParent = UserEventServiceClient::dataStoreName('[PROJECT]', '[LOCATION]', '[DATA_STORE]'); + $userEventEventType = '[EVENT_TYPE]'; + $userEventUserPseudoId = '[USER_PSEUDO_ID]'; + + write_user_event_sample($formattedParent, $userEventEventType, $userEventUserPseudoId); +} +// [END discoveryengine_v1beta_generated_UserEventService_WriteUserEvent_sync] diff --git a/DiscoveryEngine/src/V1beta/BigQuerySource.php b/DiscoveryEngine/src/V1beta/BigQuerySource.php new file mode 100644 index 000000000000..3ed7537a9ca0 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/BigQuerySource.php @@ -0,0 +1,325 @@ +google.cloud.discoveryengine.v1beta.BigQuerySource + */ +class BigQuerySource extends \Google\Protobuf\Internal\Message +{ + /** + * The project ID (can be project # or ID) that the BigQuery source is in with + * a length limit of 128 characters. If not specified, inherits the project + * ID from the parent request. + * + * Generated from protobuf field string project_id = 1; + */ + protected $project_id = ''; + /** + * Required. The BigQuery data set to copy the data from with a length limit + * of 1,024 characters. + * + * Generated from protobuf field string dataset_id = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $dataset_id = ''; + /** + * Required. The BigQuery table to copy the data from with a length limit of + * 1,024 characters. + * + * Generated from protobuf field string table_id = 3 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $table_id = ''; + /** + * Intermediate Cloud Storage directory used for the import with a length + * limit of 2,000 characters. Can be specified if one wants to have the + * BigQuery export to a specific Cloud Storage directory. + * + * Generated from protobuf field string gcs_staging_dir = 4; + */ + protected $gcs_staging_dir = ''; + /** + * The schema to use when parsing the data from the source. + * Supported values for user event imports: + * * `user_event` (default): One + * [UserEvent][google.cloud.discoveryengine.v1beta.UserEvent] per row. + * Supported values for document imports: + * * `document` (default): One + * [Document][google.cloud.discoveryengine.v1beta.Document] format per + * row. Each document must have a valid + * [Document.id][google.cloud.discoveryengine.v1beta.Document.id] and one of + * [Document.json_data][google.cloud.discoveryengine.v1beta.Document.json_data] + * or + * [Document.struct_data][google.cloud.discoveryengine.v1beta.Document.struct_data]. + * * `custom`: One custom data per row in arbitrary format that conforms the + * defined [Schema][google.cloud.discoveryengine.v1beta.Schema] of the data + * store. This can only be used by the GENERIC Data Store vertical. + * + * Generated from protobuf field string data_schema = 6; + */ + protected $data_schema = ''; + protected $partition; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Type\Date $partition_date + * BigQuery time partitioned table's _PARTITIONDATE in YYYY-MM-DD format. + * @type string $project_id + * The project ID (can be project # or ID) that the BigQuery source is in with + * a length limit of 128 characters. If not specified, inherits the project + * ID from the parent request. + * @type string $dataset_id + * Required. The BigQuery data set to copy the data from with a length limit + * of 1,024 characters. + * @type string $table_id + * Required. The BigQuery table to copy the data from with a length limit of + * 1,024 characters. + * @type string $gcs_staging_dir + * Intermediate Cloud Storage directory used for the import with a length + * limit of 2,000 characters. Can be specified if one wants to have the + * BigQuery export to a specific Cloud Storage directory. + * @type string $data_schema + * The schema to use when parsing the data from the source. + * Supported values for user event imports: + * * `user_event` (default): One + * [UserEvent][google.cloud.discoveryengine.v1beta.UserEvent] per row. + * Supported values for document imports: + * * `document` (default): One + * [Document][google.cloud.discoveryengine.v1beta.Document] format per + * row. Each document must have a valid + * [Document.id][google.cloud.discoveryengine.v1beta.Document.id] and one of + * [Document.json_data][google.cloud.discoveryengine.v1beta.Document.json_data] + * or + * [Document.struct_data][google.cloud.discoveryengine.v1beta.Document.struct_data]. + * * `custom`: One custom data per row in arbitrary format that conforms the + * defined [Schema][google.cloud.discoveryengine.v1beta.Schema] of the data + * store. This can only be used by the GENERIC Data Store vertical. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\ImportConfig::initOnce(); + parent::__construct($data); + } + + /** + * BigQuery time partitioned table's _PARTITIONDATE in YYYY-MM-DD format. + * + * Generated from protobuf field .google.type.Date partition_date = 5; + * @return \Google\Type\Date|null + */ + public function getPartitionDate() + { + return $this->readOneof(5); + } + + public function hasPartitionDate() + { + return $this->hasOneof(5); + } + + /** + * BigQuery time partitioned table's _PARTITIONDATE in YYYY-MM-DD format. + * + * Generated from protobuf field .google.type.Date partition_date = 5; + * @param \Google\Type\Date $var + * @return $this + */ + public function setPartitionDate($var) + { + GPBUtil::checkMessage($var, \Google\Type\Date::class); + $this->writeOneof(5, $var); + + return $this; + } + + /** + * The project ID (can be project # or ID) that the BigQuery source is in with + * a length limit of 128 characters. If not specified, inherits the project + * ID from the parent request. + * + * Generated from protobuf field string project_id = 1; + * @return string + */ + public function getProjectId() + { + return $this->project_id; + } + + /** + * The project ID (can be project # or ID) that the BigQuery source is in with + * a length limit of 128 characters. If not specified, inherits the project + * ID from the parent request. + * + * Generated from protobuf field string project_id = 1; + * @param string $var + * @return $this + */ + public function setProjectId($var) + { + GPBUtil::checkString($var, True); + $this->project_id = $var; + + return $this; + } + + /** + * Required. The BigQuery data set to copy the data from with a length limit + * of 1,024 characters. + * + * Generated from protobuf field string dataset_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getDatasetId() + { + return $this->dataset_id; + } + + /** + * Required. The BigQuery data set to copy the data from with a length limit + * of 1,024 characters. + * + * Generated from protobuf field string dataset_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setDatasetId($var) + { + GPBUtil::checkString($var, True); + $this->dataset_id = $var; + + return $this; + } + + /** + * Required. The BigQuery table to copy the data from with a length limit of + * 1,024 characters. + * + * Generated from protobuf field string table_id = 3 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getTableId() + { + return $this->table_id; + } + + /** + * Required. The BigQuery table to copy the data from with a length limit of + * 1,024 characters. + * + * Generated from protobuf field string table_id = 3 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setTableId($var) + { + GPBUtil::checkString($var, True); + $this->table_id = $var; + + return $this; + } + + /** + * Intermediate Cloud Storage directory used for the import with a length + * limit of 2,000 characters. Can be specified if one wants to have the + * BigQuery export to a specific Cloud Storage directory. + * + * Generated from protobuf field string gcs_staging_dir = 4; + * @return string + */ + public function getGcsStagingDir() + { + return $this->gcs_staging_dir; + } + + /** + * Intermediate Cloud Storage directory used for the import with a length + * limit of 2,000 characters. Can be specified if one wants to have the + * BigQuery export to a specific Cloud Storage directory. + * + * Generated from protobuf field string gcs_staging_dir = 4; + * @param string $var + * @return $this + */ + public function setGcsStagingDir($var) + { + GPBUtil::checkString($var, True); + $this->gcs_staging_dir = $var; + + return $this; + } + + /** + * The schema to use when parsing the data from the source. + * Supported values for user event imports: + * * `user_event` (default): One + * [UserEvent][google.cloud.discoveryengine.v1beta.UserEvent] per row. + * Supported values for document imports: + * * `document` (default): One + * [Document][google.cloud.discoveryengine.v1beta.Document] format per + * row. Each document must have a valid + * [Document.id][google.cloud.discoveryengine.v1beta.Document.id] and one of + * [Document.json_data][google.cloud.discoveryengine.v1beta.Document.json_data] + * or + * [Document.struct_data][google.cloud.discoveryengine.v1beta.Document.struct_data]. + * * `custom`: One custom data per row in arbitrary format that conforms the + * defined [Schema][google.cloud.discoveryengine.v1beta.Schema] of the data + * store. This can only be used by the GENERIC Data Store vertical. + * + * Generated from protobuf field string data_schema = 6; + * @return string + */ + public function getDataSchema() + { + return $this->data_schema; + } + + /** + * The schema to use when parsing the data from the source. + * Supported values for user event imports: + * * `user_event` (default): One + * [UserEvent][google.cloud.discoveryengine.v1beta.UserEvent] per row. + * Supported values for document imports: + * * `document` (default): One + * [Document][google.cloud.discoveryengine.v1beta.Document] format per + * row. Each document must have a valid + * [Document.id][google.cloud.discoveryengine.v1beta.Document.id] and one of + * [Document.json_data][google.cloud.discoveryengine.v1beta.Document.json_data] + * or + * [Document.struct_data][google.cloud.discoveryengine.v1beta.Document.struct_data]. + * * `custom`: One custom data per row in arbitrary format that conforms the + * defined [Schema][google.cloud.discoveryengine.v1beta.Schema] of the data + * store. This can only be used by the GENERIC Data Store vertical. + * + * Generated from protobuf field string data_schema = 6; + * @param string $var + * @return $this + */ + public function setDataSchema($var) + { + GPBUtil::checkString($var, True); + $this->data_schema = $var; + + return $this; + } + + /** + * @return string + */ + public function getPartition() + { + return $this->whichOneof("partition"); + } + +} + diff --git a/DiscoveryEngine/src/V1beta/Client/BaseClient/CompletionServiceBaseClient.php b/DiscoveryEngine/src/V1beta/Client/BaseClient/CompletionServiceBaseClient.php new file mode 100644 index 000000000000..668127063557 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/Client/BaseClient/CompletionServiceBaseClient.php @@ -0,0 +1,324 @@ + self::SERVICE_NAME, + 'apiEndpoint' => + self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => + __DIR__ . + '/../../resources/completion_service_client_config.json', + 'descriptorsConfigPath' => + __DIR__ . + '/../../resources/completion_service_descriptor_config.php', + 'gcpApiConfigPath' => + __DIR__ . + '/../../resources/completion_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => + __DIR__ . + '/../../resources/completion_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a data_store + * resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * + * @return string The formatted data_store resource. + * + * @experimental + */ + public static function dataStoreName( + string $project, + string $location, + string $dataStore + ): string { + return self::getPathTemplate('dataStore')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_collection_data_store resource. + * + * @param string $project + * @param string $location + * @param string $collection + * @param string $dataStore + * + * @return string The formatted project_location_collection_data_store resource. + * + * @experimental + */ + public static function projectLocationCollectionDataStoreName( + string $project, + string $location, + string $collection, + string $dataStore + ): string { + return self::getPathTemplate( + 'projectLocationCollectionDataStore' + )->render([ + 'project' => $project, + 'location' => $location, + 'collection' => $collection, + 'data_store' => $dataStore, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_data_store resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * + * @return string The formatted project_location_data_store resource. + * + * @experimental + */ + public static function projectLocationDataStoreName( + string $project, + string $location, + string $dataStore + ): string { + return self::getPathTemplate('projectLocationDataStore')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - dataStore: projects/{project}/locations/{location}/dataStores/{data_store} + * - projectLocationCollectionDataStore: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store} + * - projectLocationDataStore: projects/{project}/locations/{location}/dataStores/{data_store} + * + * The optional $template argument can be supplied to specify a particular pattern, + * and must match one of the templates listed above. If no $template argument is + * provided, or if the $template argument does not match one of the templates + * listed, then parseName will check each of the supported templates, and return + * the first match. + * + * @param string $formattedName The formatted name string + * @param string $template Optional name of template to match + * + * @return array An associative array from name component IDs to component values. + * + * @throws ValidationException If $formattedName could not be matched. + * + * @experimental + */ + public static function parseName( + string $formattedName, + string $template = null + ): array { + return self::parseFormattedName($formattedName, $template); + } + + /** + * Constructor. + * + * @param array $options { + * Optional. Options for configuring the service API wrapper. + * + * @type string $apiEndpoint + * The address of the API remote host. May optionally include the port, formatted + * as ":". Default 'discoveryengine.googleapis.com:443'. + * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials + * The credentials to be used by the client to authorize API calls. This option + * accepts either a path to a credentials file, or a decoded credentials file as a + * PHP array. + * *Advanced usage*: In addition, this option can also accept a pre-constructed + * {@see \Google\Auth\FetchAuthTokenInterface} object or + * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these + * objects are provided, any settings in $credentialsConfig will be ignored. + * @type array $credentialsConfig + * Options used to configure credentials, including auth token caching, for the + * client. For a full list of supporting configuration options, see + * {@see \Google\ApiCore\CredentialsWrapper::build()} . + * @type bool $disableRetries + * Determines whether or not retries defined by the client configuration should be + * disabled. Defaults to `false`. + * @type string|array $clientConfig + * Client method configuration, including retry settings. This option can be either + * a path to a JSON file, or a PHP array containing the decoded JSON data. By + * default this settings points to the default client config file, which is + * provided in the resources folder. + * @type string|TransportInterface $transport + * The transport used for executing network requests. May be either the string + * `rest` or `grpc`. Defaults to `grpc` if gRPC support is detected on the system. + * *Advanced usage*: Additionally, it is possible to pass in an already + * instantiated {@see \Google\ApiCore\Transport\TransportInterface} object. Note + * that when this object is provided, any settings in $transportConfig, and any + * $apiEndpoint setting, will be ignored. + * @type array $transportConfig + * Configuration options that will be used to construct the transport. Options for + * each supported transport type should be passed in a key for that transport. For + * example: + * $transportConfig = [ + * 'grpc' => [...], + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\GrpcTransport::build()} and + * {@see \Google\ApiCore\Transport\RestTransport::build()} methods for the + * supported options. + * @type callable $clientCertSource + * A callable which returns the client cert as a string. This can be used to + * provide a certificate and private key to the transport layer for mTLS. + * } + * + * @throws ValidationException + * + * @experimental + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error( + 'Call to undefined method ' . __CLASS__ . "::$method()", + E_USER_ERROR + ); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Completes the specified user input with keyword suggestions. + * + * The async variant is {@see self::completeQueryAsync()} . + * + * @param CompleteQueryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return CompleteQueryResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function completeQuery( + CompleteQueryRequest $request, + array $callOptions = [] + ): CompleteQueryResponse { + return $this->startApiCall( + 'CompleteQuery', + $request, + $callOptions + )->wait(); + } +} diff --git a/DiscoveryEngine/src/V1beta/Client/BaseClient/DocumentServiceBaseClient.php b/DiscoveryEngine/src/V1beta/Client/BaseClient/DocumentServiceBaseClient.php new file mode 100644 index 000000000000..622e93b7e4a5 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/Client/BaseClient/DocumentServiceBaseClient.php @@ -0,0 +1,696 @@ + self::SERVICE_NAME, + 'apiEndpoint' => + self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => + __DIR__ . + '/../../resources/document_service_client_config.json', + 'descriptorsConfigPath' => + __DIR__ . + '/../../resources/document_service_descriptor_config.php', + 'gcpApiConfigPath' => + __DIR__ . '/../../resources/document_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => + __DIR__ . + '/../../resources/document_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + * + * @experimental + */ + 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 + * + * @experimental + */ + 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; + } + + /** + * Formats a string containing the fully-qualified path to represent a branch + * resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * @param string $branch + * + * @return string The formatted branch resource. + * + * @experimental + */ + public static function branchName( + string $project, + string $location, + string $dataStore, + string $branch + ): string { + return self::getPathTemplate('branch')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + 'branch' => $branch, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a document + * resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * @param string $branch + * @param string $document + * + * @return string The formatted document resource. + * + * @experimental + */ + public static function documentName( + string $project, + string $location, + string $dataStore, + string $branch, + string $document + ): string { + return self::getPathTemplate('document')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + 'branch' => $branch, + 'document' => $document, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_collection_data_store_branch resource. + * + * @param string $project + * @param string $location + * @param string $collection + * @param string $dataStore + * @param string $branch + * + * @return string The formatted project_location_collection_data_store_branch resource. + * + * @experimental + */ + public static function projectLocationCollectionDataStoreBranchName( + string $project, + string $location, + string $collection, + string $dataStore, + string $branch + ): string { + return self::getPathTemplate( + 'projectLocationCollectionDataStoreBranch' + )->render([ + 'project' => $project, + 'location' => $location, + 'collection' => $collection, + 'data_store' => $dataStore, + 'branch' => $branch, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_collection_data_store_branch_document resource. + * + * @param string $project + * @param string $location + * @param string $collection + * @param string $dataStore + * @param string $branch + * @param string $document + * + * @return string The formatted project_location_collection_data_store_branch_document resource. + * + * @experimental + */ + public static function projectLocationCollectionDataStoreBranchDocumentName( + string $project, + string $location, + string $collection, + string $dataStore, + string $branch, + string $document + ): string { + return self::getPathTemplate( + 'projectLocationCollectionDataStoreBranchDocument' + )->render([ + 'project' => $project, + 'location' => $location, + 'collection' => $collection, + 'data_store' => $dataStore, + 'branch' => $branch, + 'document' => $document, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_data_store_branch resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * @param string $branch + * + * @return string The formatted project_location_data_store_branch resource. + * + * @experimental + */ + public static function projectLocationDataStoreBranchName( + string $project, + string $location, + string $dataStore, + string $branch + ): string { + return self::getPathTemplate('projectLocationDataStoreBranch')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + 'branch' => $branch, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_data_store_branch_document resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * @param string $branch + * @param string $document + * + * @return string The formatted project_location_data_store_branch_document resource. + * + * @experimental + */ + public static function projectLocationDataStoreBranchDocumentName( + string $project, + string $location, + string $dataStore, + string $branch, + string $document + ): string { + return self::getPathTemplate( + 'projectLocationDataStoreBranchDocument' + )->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + 'branch' => $branch, + 'document' => $document, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - branch: projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch} + * - document: projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document} + * - projectLocationCollectionDataStoreBranch: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch} + * - projectLocationCollectionDataStoreBranchDocument: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document} + * - projectLocationDataStoreBranch: projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch} + * - projectLocationDataStoreBranchDocument: projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document} + * + * The optional $template argument can be supplied to specify a particular pattern, + * and must match one of the templates listed above. If no $template argument is + * provided, or if the $template argument does not match one of the templates + * listed, then parseName will check each of the supported templates, and return + * the first match. + * + * @param string $formattedName The formatted name string + * @param string $template Optional name of template to match + * + * @return array An associative array from name component IDs to component values. + * + * @throws ValidationException If $formattedName could not be matched. + * + * @experimental + */ + public static function parseName( + string $formattedName, + string $template = null + ): array { + return self::parseFormattedName($formattedName, $template); + } + + /** + * Constructor. + * + * @param array $options { + * Optional. Options for configuring the service API wrapper. + * + * @type string $apiEndpoint + * The address of the API remote host. May optionally include the port, formatted + * as ":". Default 'discoveryengine.googleapis.com:443'. + * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials + * The credentials to be used by the client to authorize API calls. This option + * accepts either a path to a credentials file, or a decoded credentials file as a + * PHP array. + * *Advanced usage*: In addition, this option can also accept a pre-constructed + * {@see \Google\Auth\FetchAuthTokenInterface} object or + * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these + * objects are provided, any settings in $credentialsConfig will be ignored. + * @type array $credentialsConfig + * Options used to configure credentials, including auth token caching, for the + * client. For a full list of supporting configuration options, see + * {@see \Google\ApiCore\CredentialsWrapper::build()} . + * @type bool $disableRetries + * Determines whether or not retries defined by the client configuration should be + * disabled. Defaults to `false`. + * @type string|array $clientConfig + * Client method configuration, including retry settings. This option can be either + * a path to a JSON file, or a PHP array containing the decoded JSON data. By + * default this settings points to the default client config file, which is + * provided in the resources folder. + * @type string|TransportInterface $transport + * The transport used for executing network requests. May be either the string + * `rest` or `grpc`. Defaults to `grpc` if gRPC support is detected on the system. + * *Advanced usage*: Additionally, it is possible to pass in an already + * instantiated {@see \Google\ApiCore\Transport\TransportInterface} object. Note + * that when this object is provided, any settings in $transportConfig, and any + * $apiEndpoint setting, will be ignored. + * @type array $transportConfig + * Configuration options that will be used to construct the transport. Options for + * each supported transport type should be passed in a key for that transport. For + * example: + * $transportConfig = [ + * 'grpc' => [...], + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\GrpcTransport::build()} and + * {@see \Google\ApiCore\Transport\RestTransport::build()} methods for the + * supported options. + * @type callable $clientCertSource + * A callable which returns the client cert as a string. This can be used to + * provide a certificate and private key to the transport layer for mTLS. + * } + * + * @throws ValidationException + * + * @experimental + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error( + 'Call to undefined method ' . __CLASS__ . "::$method()", + E_USER_ERROR + ); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a [Document][google.cloud.discoveryengine.v1beta.Document]. + * + * The async variant is {@see self::createDocumentAsync()} . + * + * @param CreateDocumentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return Document + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function createDocument( + CreateDocumentRequest $request, + array $callOptions = [] + ): Document { + return $this->startApiCall( + 'CreateDocument', + $request, + $callOptions + )->wait(); + } + + /** + * Deletes a [Document][google.cloud.discoveryengine.v1beta.Document]. + * + * The async variant is {@see self::deleteDocumentAsync()} . + * + * @param DeleteDocumentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function deleteDocument( + DeleteDocumentRequest $request, + array $callOptions = [] + ): void { + $this->startApiCall('DeleteDocument', $request, $callOptions)->wait(); + } + + /** + * Gets a [Document][google.cloud.discoveryengine.v1beta.Document]. + * + * The async variant is {@see self::getDocumentAsync()} . + * + * @param GetDocumentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return Document + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function getDocument( + GetDocumentRequest $request, + array $callOptions = [] + ): Document { + return $this->startApiCall( + 'GetDocument', + $request, + $callOptions + )->wait(); + } + + /** + * Bulk import of multiple + * [Document][google.cloud.discoveryengine.v1beta.Document]s. Request + * processing may be synchronous. Non-existing items will be created. + * + * Note: It is possible for a subset of the + * [Document][google.cloud.discoveryengine.v1beta.Document]s to be + * successfully updated. + * + * The async variant is {@see self::importDocumentsAsync()} . + * + * @param ImportDocumentsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return OperationResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function importDocuments( + ImportDocumentsRequest $request, + array $callOptions = [] + ): OperationResponse { + return $this->startApiCall( + 'ImportDocuments', + $request, + $callOptions + )->wait(); + } + + /** + * Gets a list of [Document][google.cloud.discoveryengine.v1beta.Document]s. + * + * The async variant is {@see self::listDocumentsAsync()} . + * + * @param ListDocumentsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function listDocuments( + ListDocumentsRequest $request, + array $callOptions = [] + ): PagedListResponse { + return $this->startApiCall('ListDocuments', $request, $callOptions); + } + + /** + * Permanently deletes all selected + * [Document][google.cloud.discoveryengine.v1beta.Document]s in a branch. + * + * This process is asynchronous. Depending on the number of + * [Document][google.cloud.discoveryengine.v1beta.Document]s to be deleted, + * this operation can take hours to complete. Before the delete operation + * completes, some [Document][google.cloud.discoveryengine.v1beta.Document]s + * might still be returned by + * [DocumentService.GetDocument][google.cloud.discoveryengine.v1beta.DocumentService.GetDocument] + * or + * [DocumentService.ListDocuments][google.cloud.discoveryengine.v1beta.DocumentService.ListDocuments]. + * + * To get a list of the + * [Document][google.cloud.discoveryengine.v1beta.Document]s to be deleted, + * set + * [PurgeDocumentsRequest.force][google.cloud.discoveryengine.v1beta.PurgeDocumentsRequest.force] + * to false. + * + * The async variant is {@see self::purgeDocumentsAsync()} . + * + * @param PurgeDocumentsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return OperationResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function purgeDocuments( + PurgeDocumentsRequest $request, + array $callOptions = [] + ): OperationResponse { + return $this->startApiCall( + 'PurgeDocuments', + $request, + $callOptions + )->wait(); + } + + /** + * Updates a [Document][google.cloud.discoveryengine.v1beta.Document]. + * + * The async variant is {@see self::updateDocumentAsync()} . + * + * @param UpdateDocumentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return Document + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function updateDocument( + UpdateDocumentRequest $request, + array $callOptions = [] + ): Document { + return $this->startApiCall( + 'UpdateDocument', + $request, + $callOptions + )->wait(); + } +} diff --git a/DiscoveryEngine/src/V1beta/Client/BaseClient/RecommendationServiceBaseClient.php b/DiscoveryEngine/src/V1beta/Client/BaseClient/RecommendationServiceBaseClient.php new file mode 100644 index 000000000000..cdf4b10ba9a1 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/Client/BaseClient/RecommendationServiceBaseClient.php @@ -0,0 +1,431 @@ + self::SERVICE_NAME, + 'apiEndpoint' => + self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => + __DIR__ . + '/../../resources/recommendation_service_client_config.json', + 'descriptorsConfigPath' => + __DIR__ . + '/../../resources/recommendation_service_descriptor_config.php', + 'gcpApiConfigPath' => + __DIR__ . + '/../../resources/recommendation_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => + __DIR__ . + '/../../resources/recommendation_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a document + * resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * @param string $branch + * @param string $document + * + * @return string The formatted document resource. + * + * @experimental + */ + public static function documentName( + string $project, + string $location, + string $dataStore, + string $branch, + string $document + ): string { + return self::getPathTemplate('document')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + 'branch' => $branch, + 'document' => $document, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_collection_data_store_branch_document resource. + * + * @param string $project + * @param string $location + * @param string $collection + * @param string $dataStore + * @param string $branch + * @param string $document + * + * @return string The formatted project_location_collection_data_store_branch_document resource. + * + * @experimental + */ + public static function projectLocationCollectionDataStoreBranchDocumentName( + string $project, + string $location, + string $collection, + string $dataStore, + string $branch, + string $document + ): string { + return self::getPathTemplate( + 'projectLocationCollectionDataStoreBranchDocument' + )->render([ + 'project' => $project, + 'location' => $location, + 'collection' => $collection, + 'data_store' => $dataStore, + 'branch' => $branch, + 'document' => $document, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_collection_data_store_serving_config resource. + * + * @param string $project + * @param string $location + * @param string $collection + * @param string $dataStore + * @param string $servingConfig + * + * @return string The formatted project_location_collection_data_store_serving_config resource. + * + * @experimental + */ + public static function projectLocationCollectionDataStoreServingConfigName( + string $project, + string $location, + string $collection, + string $dataStore, + string $servingConfig + ): string { + return self::getPathTemplate( + 'projectLocationCollectionDataStoreServingConfig' + )->render([ + 'project' => $project, + 'location' => $location, + 'collection' => $collection, + 'data_store' => $dataStore, + 'serving_config' => $servingConfig, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_data_store_branch_document resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * @param string $branch + * @param string $document + * + * @return string The formatted project_location_data_store_branch_document resource. + * + * @experimental + */ + public static function projectLocationDataStoreBranchDocumentName( + string $project, + string $location, + string $dataStore, + string $branch, + string $document + ): string { + return self::getPathTemplate( + 'projectLocationDataStoreBranchDocument' + )->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + 'branch' => $branch, + 'document' => $document, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_data_store_serving_config resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * @param string $servingConfig + * + * @return string The formatted project_location_data_store_serving_config resource. + * + * @experimental + */ + public static function projectLocationDataStoreServingConfigName( + string $project, + string $location, + string $dataStore, + string $servingConfig + ): string { + return self::getPathTemplate( + 'projectLocationDataStoreServingConfig' + )->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + 'serving_config' => $servingConfig, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * serving_config resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * @param string $servingConfig + * + * @return string The formatted serving_config resource. + * + * @experimental + */ + public static function servingConfigName( + string $project, + string $location, + string $dataStore, + string $servingConfig + ): string { + return self::getPathTemplate('servingConfig')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + 'serving_config' => $servingConfig, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - document: projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document} + * - projectLocationCollectionDataStoreBranchDocument: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document} + * - projectLocationCollectionDataStoreServingConfig: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/servingConfigs/{serving_config} + * - projectLocationDataStoreBranchDocument: projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document} + * - projectLocationDataStoreServingConfig: projects/{project}/locations/{location}/dataStores/{data_store}/servingConfigs/{serving_config} + * - servingConfig: projects/{project}/locations/{location}/dataStores/{data_store}/servingConfigs/{serving_config} + * + * The optional $template argument can be supplied to specify a particular pattern, + * and must match one of the templates listed above. If no $template argument is + * provided, or if the $template argument does not match one of the templates + * listed, then parseName will check each of the supported templates, and return + * the first match. + * + * @param string $formattedName The formatted name string + * @param string $template Optional name of template to match + * + * @return array An associative array from name component IDs to component values. + * + * @throws ValidationException If $formattedName could not be matched. + * + * @experimental + */ + public static function parseName( + string $formattedName, + string $template = null + ): array { + return self::parseFormattedName($formattedName, $template); + } + + /** + * Constructor. + * + * @param array $options { + * Optional. Options for configuring the service API wrapper. + * + * @type string $apiEndpoint + * The address of the API remote host. May optionally include the port, formatted + * as ":". Default 'discoveryengine.googleapis.com:443'. + * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials + * The credentials to be used by the client to authorize API calls. This option + * accepts either a path to a credentials file, or a decoded credentials file as a + * PHP array. + * *Advanced usage*: In addition, this option can also accept a pre-constructed + * {@see \Google\Auth\FetchAuthTokenInterface} object or + * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these + * objects are provided, any settings in $credentialsConfig will be ignored. + * @type array $credentialsConfig + * Options used to configure credentials, including auth token caching, for the + * client. For a full list of supporting configuration options, see + * {@see \Google\ApiCore\CredentialsWrapper::build()} . + * @type bool $disableRetries + * Determines whether or not retries defined by the client configuration should be + * disabled. Defaults to `false`. + * @type string|array $clientConfig + * Client method configuration, including retry settings. This option can be either + * a path to a JSON file, or a PHP array containing the decoded JSON data. By + * default this settings points to the default client config file, which is + * provided in the resources folder. + * @type string|TransportInterface $transport + * The transport used for executing network requests. May be either the string + * `rest` or `grpc`. Defaults to `grpc` if gRPC support is detected on the system. + * *Advanced usage*: Additionally, it is possible to pass in an already + * instantiated {@see \Google\ApiCore\Transport\TransportInterface} object. Note + * that when this object is provided, any settings in $transportConfig, and any + * $apiEndpoint setting, will be ignored. + * @type array $transportConfig + * Configuration options that will be used to construct the transport. Options for + * each supported transport type should be passed in a key for that transport. For + * example: + * $transportConfig = [ + * 'grpc' => [...], + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\GrpcTransport::build()} and + * {@see \Google\ApiCore\Transport\RestTransport::build()} methods for the + * supported options. + * @type callable $clientCertSource + * A callable which returns the client cert as a string. This can be used to + * provide a certificate and private key to the transport layer for mTLS. + * } + * + * @throws ValidationException + * + * @experimental + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error( + 'Call to undefined method ' . __CLASS__ . "::$method()", + E_USER_ERROR + ); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Makes a recommendation, which requires a contextual user event. + * + * The async variant is {@see self::recommendAsync()} . + * + * @param RecommendRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return RecommendResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function recommend( + RecommendRequest $request, + array $callOptions = [] + ): RecommendResponse { + return $this->startApiCall('Recommend', $request, $callOptions)->wait(); + } +} diff --git a/DiscoveryEngine/src/V1beta/Client/BaseClient/SchemaServiceBaseClient.php b/DiscoveryEngine/src/V1beta/Client/BaseClient/SchemaServiceBaseClient.php new file mode 100644 index 000000000000..aafe7df4ace3 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/Client/BaseClient/SchemaServiceBaseClient.php @@ -0,0 +1,585 @@ + self::SERVICE_NAME, + 'apiEndpoint' => + self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => + __DIR__ . '/../../resources/schema_service_client_config.json', + 'descriptorsConfigPath' => + __DIR__ . + '/../../resources/schema_service_descriptor_config.php', + 'gcpApiConfigPath' => + __DIR__ . '/../../resources/schema_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => + __DIR__ . + '/../../resources/schema_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + * + * @experimental + */ + 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 + * + * @experimental + */ + 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; + } + + /** + * Formats a string containing the fully-qualified path to represent a data_store + * resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * + * @return string The formatted data_store resource. + * + * @experimental + */ + public static function dataStoreName( + string $project, + string $location, + string $dataStore + ): string { + return self::getPathTemplate('dataStore')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_collection_data_store resource. + * + * @param string $project + * @param string $location + * @param string $collection + * @param string $dataStore + * + * @return string The formatted project_location_collection_data_store resource. + * + * @experimental + */ + public static function projectLocationCollectionDataStoreName( + string $project, + string $location, + string $collection, + string $dataStore + ): string { + return self::getPathTemplate( + 'projectLocationCollectionDataStore' + )->render([ + 'project' => $project, + 'location' => $location, + 'collection' => $collection, + 'data_store' => $dataStore, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_collection_data_store_schema resource. + * + * @param string $project + * @param string $location + * @param string $collection + * @param string $dataStore + * @param string $schema + * + * @return string The formatted project_location_collection_data_store_schema resource. + * + * @experimental + */ + public static function projectLocationCollectionDataStoreSchemaName( + string $project, + string $location, + string $collection, + string $dataStore, + string $schema + ): string { + return self::getPathTemplate( + 'projectLocationCollectionDataStoreSchema' + )->render([ + 'project' => $project, + 'location' => $location, + 'collection' => $collection, + 'data_store' => $dataStore, + 'schema' => $schema, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_data_store resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * + * @return string The formatted project_location_data_store resource. + * + * @experimental + */ + public static function projectLocationDataStoreName( + string $project, + string $location, + string $dataStore + ): string { + return self::getPathTemplate('projectLocationDataStore')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_data_store_schema resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * @param string $schema + * + * @return string The formatted project_location_data_store_schema resource. + * + * @experimental + */ + public static function projectLocationDataStoreSchemaName( + string $project, + string $location, + string $dataStore, + string $schema + ): string { + return self::getPathTemplate('projectLocationDataStoreSchema')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + 'schema' => $schema, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a schema + * resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * @param string $schema + * + * @return string The formatted schema resource. + * + * @experimental + */ + public static function schemaName( + string $project, + string $location, + string $dataStore, + string $schema + ): string { + return self::getPathTemplate('schema')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + 'schema' => $schema, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - dataStore: projects/{project}/locations/{location}/dataStores/{data_store} + * - projectLocationCollectionDataStore: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store} + * - projectLocationCollectionDataStoreSchema: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema} + * - projectLocationDataStore: projects/{project}/locations/{location}/dataStores/{data_store} + * - projectLocationDataStoreSchema: projects/{project}/locations/{location}/dataStores/{data_store}/schemas/{schema} + * - schema: projects/{project}/locations/{location}/dataStores/{data_store}/schemas/{schema} + * + * The optional $template argument can be supplied to specify a particular pattern, + * and must match one of the templates listed above. If no $template argument is + * provided, or if the $template argument does not match one of the templates + * listed, then parseName will check each of the supported templates, and return + * the first match. + * + * @param string $formattedName The formatted name string + * @param string $template Optional name of template to match + * + * @return array An associative array from name component IDs to component values. + * + * @throws ValidationException If $formattedName could not be matched. + * + * @experimental + */ + public static function parseName( + string $formattedName, + string $template = null + ): array { + return self::parseFormattedName($formattedName, $template); + } + + /** + * Constructor. + * + * @param array $options { + * Optional. Options for configuring the service API wrapper. + * + * @type string $apiEndpoint + * The address of the API remote host. May optionally include the port, formatted + * as ":". Default 'discoveryengine.googleapis.com:443'. + * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials + * The credentials to be used by the client to authorize API calls. This option + * accepts either a path to a credentials file, or a decoded credentials file as a + * PHP array. + * *Advanced usage*: In addition, this option can also accept a pre-constructed + * {@see \Google\Auth\FetchAuthTokenInterface} object or + * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these + * objects are provided, any settings in $credentialsConfig will be ignored. + * @type array $credentialsConfig + * Options used to configure credentials, including auth token caching, for the + * client. For a full list of supporting configuration options, see + * {@see \Google\ApiCore\CredentialsWrapper::build()} . + * @type bool $disableRetries + * Determines whether or not retries defined by the client configuration should be + * disabled. Defaults to `false`. + * @type string|array $clientConfig + * Client method configuration, including retry settings. This option can be either + * a path to a JSON file, or a PHP array containing the decoded JSON data. By + * default this settings points to the default client config file, which is + * provided in the resources folder. + * @type string|TransportInterface $transport + * The transport used for executing network requests. May be either the string + * `rest` or `grpc`. Defaults to `grpc` if gRPC support is detected on the system. + * *Advanced usage*: Additionally, it is possible to pass in an already + * instantiated {@see \Google\ApiCore\Transport\TransportInterface} object. Note + * that when this object is provided, any settings in $transportConfig, and any + * $apiEndpoint setting, will be ignored. + * @type array $transportConfig + * Configuration options that will be used to construct the transport. Options for + * each supported transport type should be passed in a key for that transport. For + * example: + * $transportConfig = [ + * 'grpc' => [...], + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\GrpcTransport::build()} and + * {@see \Google\ApiCore\Transport\RestTransport::build()} methods for the + * supported options. + * @type callable $clientCertSource + * A callable which returns the client cert as a string. This can be used to + * provide a certificate and private key to the transport layer for mTLS. + * } + * + * @throws ValidationException + * + * @experimental + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error( + 'Call to undefined method ' . __CLASS__ . "::$method()", + E_USER_ERROR + ); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a [Schema][google.cloud.discoveryengine.v1beta.Schema]. + * + * The async variant is {@see self::createSchemaAsync()} . + * + * @param CreateSchemaRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return OperationResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function createSchema( + CreateSchemaRequest $request, + array $callOptions = [] + ): OperationResponse { + return $this->startApiCall( + 'CreateSchema', + $request, + $callOptions + )->wait(); + } + + /** + * Deletes a [Schema][google.cloud.discoveryengine.v1beta.Schema]. + * + * The async variant is {@see self::deleteSchemaAsync()} . + * + * @param DeleteSchemaRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return OperationResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function deleteSchema( + DeleteSchemaRequest $request, + array $callOptions = [] + ): OperationResponse { + return $this->startApiCall( + 'DeleteSchema', + $request, + $callOptions + )->wait(); + } + + /** + * Gets a [Schema][google.cloud.discoveryengine.v1beta.Schema]. + * + * The async variant is {@see self::getSchemaAsync()} . + * + * @param GetSchemaRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return Schema + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function getSchema( + GetSchemaRequest $request, + array $callOptions = [] + ): Schema { + return $this->startApiCall('GetSchema', $request, $callOptions)->wait(); + } + + /** + * Gets a list of [Schema][google.cloud.discoveryengine.v1beta.Schema]s. + * + * The async variant is {@see self::listSchemasAsync()} . + * + * @param ListSchemasRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function listSchemas( + ListSchemasRequest $request, + array $callOptions = [] + ): PagedListResponse { + return $this->startApiCall('ListSchemas', $request, $callOptions); + } + + /** + * Updates a [Schema][google.cloud.discoveryengine.v1beta.Schema]. + * + * The async variant is {@see self::updateSchemaAsync()} . + * + * @param UpdateSchemaRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return OperationResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function updateSchema( + UpdateSchemaRequest $request, + array $callOptions = [] + ): OperationResponse { + return $this->startApiCall( + 'UpdateSchema', + $request, + $callOptions + )->wait(); + } +} diff --git a/DiscoveryEngine/src/V1beta/Client/BaseClient/SearchServiceBaseClient.php b/DiscoveryEngine/src/V1beta/Client/BaseClient/SearchServiceBaseClient.php new file mode 100644 index 000000000000..741f59853899 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/Client/BaseClient/SearchServiceBaseClient.php @@ -0,0 +1,418 @@ + self::SERVICE_NAME, + 'apiEndpoint' => + self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => + __DIR__ . '/../../resources/search_service_client_config.json', + 'descriptorsConfigPath' => + __DIR__ . + '/../../resources/search_service_descriptor_config.php', + 'gcpApiConfigPath' => + __DIR__ . '/../../resources/search_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => + __DIR__ . + '/../../resources/search_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a branch + * resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * @param string $branch + * + * @return string The formatted branch resource. + * + * @experimental + */ + public static function branchName( + string $project, + string $location, + string $dataStore, + string $branch + ): string { + return self::getPathTemplate('branch')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + 'branch' => $branch, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_collection_data_store_branch resource. + * + * @param string $project + * @param string $location + * @param string $collection + * @param string $dataStore + * @param string $branch + * + * @return string The formatted project_location_collection_data_store_branch resource. + * + * @experimental + */ + public static function projectLocationCollectionDataStoreBranchName( + string $project, + string $location, + string $collection, + string $dataStore, + string $branch + ): string { + return self::getPathTemplate( + 'projectLocationCollectionDataStoreBranch' + )->render([ + 'project' => $project, + 'location' => $location, + 'collection' => $collection, + 'data_store' => $dataStore, + 'branch' => $branch, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_collection_data_store_serving_config resource. + * + * @param string $project + * @param string $location + * @param string $collection + * @param string $dataStore + * @param string $servingConfig + * + * @return string The formatted project_location_collection_data_store_serving_config resource. + * + * @experimental + */ + public static function projectLocationCollectionDataStoreServingConfigName( + string $project, + string $location, + string $collection, + string $dataStore, + string $servingConfig + ): string { + return self::getPathTemplate( + 'projectLocationCollectionDataStoreServingConfig' + )->render([ + 'project' => $project, + 'location' => $location, + 'collection' => $collection, + 'data_store' => $dataStore, + 'serving_config' => $servingConfig, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_data_store_branch resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * @param string $branch + * + * @return string The formatted project_location_data_store_branch resource. + * + * @experimental + */ + public static function projectLocationDataStoreBranchName( + string $project, + string $location, + string $dataStore, + string $branch + ): string { + return self::getPathTemplate('projectLocationDataStoreBranch')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + 'branch' => $branch, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_data_store_serving_config resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * @param string $servingConfig + * + * @return string The formatted project_location_data_store_serving_config resource. + * + * @experimental + */ + public static function projectLocationDataStoreServingConfigName( + string $project, + string $location, + string $dataStore, + string $servingConfig + ): string { + return self::getPathTemplate( + 'projectLocationDataStoreServingConfig' + )->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + 'serving_config' => $servingConfig, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * serving_config resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * @param string $servingConfig + * + * @return string The formatted serving_config resource. + * + * @experimental + */ + public static function servingConfigName( + string $project, + string $location, + string $dataStore, + string $servingConfig + ): string { + return self::getPathTemplate('servingConfig')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + 'serving_config' => $servingConfig, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - branch: projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch} + * - projectLocationCollectionDataStoreBranch: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch} + * - projectLocationCollectionDataStoreServingConfig: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/servingConfigs/{serving_config} + * - projectLocationDataStoreBranch: projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch} + * - projectLocationDataStoreServingConfig: projects/{project}/locations/{location}/dataStores/{data_store}/servingConfigs/{serving_config} + * - servingConfig: projects/{project}/locations/{location}/dataStores/{data_store}/servingConfigs/{serving_config} + * + * The optional $template argument can be supplied to specify a particular pattern, + * and must match one of the templates listed above. If no $template argument is + * provided, or if the $template argument does not match one of the templates + * listed, then parseName will check each of the supported templates, and return + * the first match. + * + * @param string $formattedName The formatted name string + * @param string $template Optional name of template to match + * + * @return array An associative array from name component IDs to component values. + * + * @throws ValidationException If $formattedName could not be matched. + * + * @experimental + */ + public static function parseName( + string $formattedName, + string $template = null + ): array { + return self::parseFormattedName($formattedName, $template); + } + + /** + * Constructor. + * + * @param array $options { + * Optional. Options for configuring the service API wrapper. + * + * @type string $apiEndpoint + * The address of the API remote host. May optionally include the port, formatted + * as ":". Default 'discoveryengine.googleapis.com:443'. + * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials + * The credentials to be used by the client to authorize API calls. This option + * accepts either a path to a credentials file, or a decoded credentials file as a + * PHP array. + * *Advanced usage*: In addition, this option can also accept a pre-constructed + * {@see \Google\Auth\FetchAuthTokenInterface} object or + * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these + * objects are provided, any settings in $credentialsConfig will be ignored. + * @type array $credentialsConfig + * Options used to configure credentials, including auth token caching, for the + * client. For a full list of supporting configuration options, see + * {@see \Google\ApiCore\CredentialsWrapper::build()} . + * @type bool $disableRetries + * Determines whether or not retries defined by the client configuration should be + * disabled. Defaults to `false`. + * @type string|array $clientConfig + * Client method configuration, including retry settings. This option can be either + * a path to a JSON file, or a PHP array containing the decoded JSON data. By + * default this settings points to the default client config file, which is + * provided in the resources folder. + * @type string|TransportInterface $transport + * The transport used for executing network requests. May be either the string + * `rest` or `grpc`. Defaults to `grpc` if gRPC support is detected on the system. + * *Advanced usage*: Additionally, it is possible to pass in an already + * instantiated {@see \Google\ApiCore\Transport\TransportInterface} object. Note + * that when this object is provided, any settings in $transportConfig, and any + * $apiEndpoint setting, will be ignored. + * @type array $transportConfig + * Configuration options that will be used to construct the transport. Options for + * each supported transport type should be passed in a key for that transport. For + * example: + * $transportConfig = [ + * 'grpc' => [...], + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\GrpcTransport::build()} and + * {@see \Google\ApiCore\Transport\RestTransport::build()} methods for the + * supported options. + * @type callable $clientCertSource + * A callable which returns the client cert as a string. This can be used to + * provide a certificate and private key to the transport layer for mTLS. + * } + * + * @throws ValidationException + * + * @experimental + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error( + 'Call to undefined method ' . __CLASS__ . "::$method()", + E_USER_ERROR + ); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Performs a search. + * + * The async variant is {@see self::searchAsync()} . + * + * @param SearchRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function search( + SearchRequest $request, + array $callOptions = [] + ): PagedListResponse { + return $this->startApiCall('Search', $request, $callOptions); + } +} diff --git a/DiscoveryEngine/src/V1beta/Client/BaseClient/UserEventServiceBaseClient.php b/DiscoveryEngine/src/V1beta/Client/BaseClient/UserEventServiceBaseClient.php new file mode 100644 index 000000000000..7faede0e7d69 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/Client/BaseClient/UserEventServiceBaseClient.php @@ -0,0 +1,548 @@ + self::SERVICE_NAME, + 'apiEndpoint' => + self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => + __DIR__ . + '/../../resources/user_event_service_client_config.json', + 'descriptorsConfigPath' => + __DIR__ . + '/../../resources/user_event_service_descriptor_config.php', + 'gcpApiConfigPath' => + __DIR__ . + '/../../resources/user_event_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => + __DIR__ . + '/../../resources/user_event_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + * + * @experimental + */ + 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 + * + * @experimental + */ + 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; + } + + /** + * Formats a string containing the fully-qualified path to represent a data_store + * resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * + * @return string The formatted data_store resource. + * + * @experimental + */ + public static function dataStoreName( + string $project, + string $location, + string $dataStore + ): string { + return self::getPathTemplate('dataStore')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a document + * resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * @param string $branch + * @param string $document + * + * @return string The formatted document resource. + * + * @experimental + */ + public static function documentName( + string $project, + string $location, + string $dataStore, + string $branch, + string $document + ): string { + return self::getPathTemplate('document')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + 'branch' => $branch, + 'document' => $document, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_collection_data_store resource. + * + * @param string $project + * @param string $location + * @param string $collection + * @param string $dataStore + * + * @return string The formatted project_location_collection_data_store resource. + * + * @experimental + */ + public static function projectLocationCollectionDataStoreName( + string $project, + string $location, + string $collection, + string $dataStore + ): string { + return self::getPathTemplate( + 'projectLocationCollectionDataStore' + )->render([ + 'project' => $project, + 'location' => $location, + 'collection' => $collection, + 'data_store' => $dataStore, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_collection_data_store_branch_document resource. + * + * @param string $project + * @param string $location + * @param string $collection + * @param string $dataStore + * @param string $branch + * @param string $document + * + * @return string The formatted project_location_collection_data_store_branch_document resource. + * + * @experimental + */ + public static function projectLocationCollectionDataStoreBranchDocumentName( + string $project, + string $location, + string $collection, + string $dataStore, + string $branch, + string $document + ): string { + return self::getPathTemplate( + 'projectLocationCollectionDataStoreBranchDocument' + )->render([ + 'project' => $project, + 'location' => $location, + 'collection' => $collection, + 'data_store' => $dataStore, + 'branch' => $branch, + 'document' => $document, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_data_store resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * + * @return string The formatted project_location_data_store resource. + * + * @experimental + */ + public static function projectLocationDataStoreName( + string $project, + string $location, + string $dataStore + ): string { + return self::getPathTemplate('projectLocationDataStore')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_data_store_branch_document resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * @param string $branch + * @param string $document + * + * @return string The formatted project_location_data_store_branch_document resource. + * + * @experimental + */ + public static function projectLocationDataStoreBranchDocumentName( + string $project, + string $location, + string $dataStore, + string $branch, + string $document + ): string { + return self::getPathTemplate( + 'projectLocationDataStoreBranchDocument' + )->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + 'branch' => $branch, + 'document' => $document, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - dataStore: projects/{project}/locations/{location}/dataStores/{data_store} + * - document: projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document} + * - projectLocationCollectionDataStore: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store} + * - projectLocationCollectionDataStoreBranchDocument: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document} + * - projectLocationDataStore: projects/{project}/locations/{location}/dataStores/{data_store} + * - projectLocationDataStoreBranchDocument: projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document} + * + * The optional $template argument can be supplied to specify a particular pattern, + * and must match one of the templates listed above. If no $template argument is + * provided, or if the $template argument does not match one of the templates + * listed, then parseName will check each of the supported templates, and return + * the first match. + * + * @param string $formattedName The formatted name string + * @param string $template Optional name of template to match + * + * @return array An associative array from name component IDs to component values. + * + * @throws ValidationException If $formattedName could not be matched. + * + * @experimental + */ + public static function parseName( + string $formattedName, + string $template = null + ): array { + return self::parseFormattedName($formattedName, $template); + } + + /** + * Constructor. + * + * @param array $options { + * Optional. Options for configuring the service API wrapper. + * + * @type string $apiEndpoint + * The address of the API remote host. May optionally include the port, formatted + * as ":". Default 'discoveryengine.googleapis.com:443'. + * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials + * The credentials to be used by the client to authorize API calls. This option + * accepts either a path to a credentials file, or a decoded credentials file as a + * PHP array. + * *Advanced usage*: In addition, this option can also accept a pre-constructed + * {@see \Google\Auth\FetchAuthTokenInterface} object or + * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these + * objects are provided, any settings in $credentialsConfig will be ignored. + * @type array $credentialsConfig + * Options used to configure credentials, including auth token caching, for the + * client. For a full list of supporting configuration options, see + * {@see \Google\ApiCore\CredentialsWrapper::build()} . + * @type bool $disableRetries + * Determines whether or not retries defined by the client configuration should be + * disabled. Defaults to `false`. + * @type string|array $clientConfig + * Client method configuration, including retry settings. This option can be either + * a path to a JSON file, or a PHP array containing the decoded JSON data. By + * default this settings points to the default client config file, which is + * provided in the resources folder. + * @type string|TransportInterface $transport + * The transport used for executing network requests. May be either the string + * `rest` or `grpc`. Defaults to `grpc` if gRPC support is detected on the system. + * *Advanced usage*: Additionally, it is possible to pass in an already + * instantiated {@see \Google\ApiCore\Transport\TransportInterface} object. Note + * that when this object is provided, any settings in $transportConfig, and any + * $apiEndpoint setting, will be ignored. + * @type array $transportConfig + * Configuration options that will be used to construct the transport. Options for + * each supported transport type should be passed in a key for that transport. For + * example: + * $transportConfig = [ + * 'grpc' => [...], + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\GrpcTransport::build()} and + * {@see \Google\ApiCore\Transport\RestTransport::build()} methods for the + * supported options. + * @type callable $clientCertSource + * A callable which returns the client cert as a string. This can be used to + * provide a certificate and private key to the transport layer for mTLS. + * } + * + * @throws ValidationException + * + * @experimental + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error( + 'Call to undefined method ' . __CLASS__ . "::$method()", + E_USER_ERROR + ); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Writes a single user event from the browser. This uses a GET request to + * due to browser restriction of POST-ing to a 3rd party domain. + * + * This method is used only by the Discovery Engine API JavaScript pixel and + * Google Tag Manager. Users should not call this method directly. + * + * The async variant is {@see self::collectUserEventAsync()} . + * + * @param CollectUserEventRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return HttpBody + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function collectUserEvent( + CollectUserEventRequest $request, + array $callOptions = [] + ): HttpBody { + return $this->startApiCall( + 'CollectUserEvent', + $request, + $callOptions + )->wait(); + } + + /** + * Bulk import of User events. Request processing might be + * synchronous. Events that already exist are skipped. + * Use this method for backfilling historical user events. + * + * Operation.response is of type ImportResponse. Note that it is + * possible for a subset of the items to be successfully inserted. + * Operation.metadata is of type ImportMetadata. + * + * The async variant is {@see self::importUserEventsAsync()} . + * + * @param ImportUserEventsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return OperationResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function importUserEvents( + ImportUserEventsRequest $request, + array $callOptions = [] + ): OperationResponse { + return $this->startApiCall( + 'ImportUserEvents', + $request, + $callOptions + )->wait(); + } + + /** + * Writes a single user event. + * + * The async variant is {@see self::writeUserEventAsync()} . + * + * @param WriteUserEventRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return UserEvent + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function writeUserEvent( + WriteUserEventRequest $request, + array $callOptions = [] + ): UserEvent { + return $this->startApiCall( + 'WriteUserEvent', + $request, + $callOptions + )->wait(); + } +} diff --git a/DiscoveryEngine/src/V1beta/Client/CompletionServiceClient.php b/DiscoveryEngine/src/V1beta/Client/CompletionServiceClient.php new file mode 100644 index 000000000000..6855fab218e3 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/Client/CompletionServiceClient.php @@ -0,0 +1,42 @@ +google.cloud.discoveryengine.v1beta.CollectUserEventRequest + */ +class CollectUserEventRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The parent DataStore resource name, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $parent = ''; + /** + * Required. URL encoded UserEvent proto with a length limit of 2,000,000 + * characters. + * + * Generated from protobuf field string user_event = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $user_event = ''; + /** + * The URL including cgi-parameters but excluding the hash fragment with a + * length limit of 5,000 characters. This is often more useful than the + * referer URL, because many browsers only send the domain for 3rd party + * requests. + * + * Generated from protobuf field optional string uri = 3; + */ + protected $uri = null; + /** + * The event timestamp in milliseconds. This prevents browser caching of + * otherwise identical get requests. The name is abbreviated to reduce the + * payload bytes. + * + * Generated from protobuf field optional int64 ets = 4; + */ + protected $ets = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. The parent DataStore resource name, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. + * @type string $user_event + * Required. URL encoded UserEvent proto with a length limit of 2,000,000 + * characters. + * @type string $uri + * The URL including cgi-parameters but excluding the hash fragment with a + * length limit of 5,000 characters. This is often more useful than the + * referer URL, because many browsers only send the domain for 3rd party + * requests. + * @type int|string $ets + * The event timestamp in milliseconds. This prevents browser caching of + * otherwise identical get requests. The name is abbreviated to reduce the + * payload bytes. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\UserEventService::initOnce(); + parent::__construct($data); + } + + /** + * Required. The parent DataStore resource name, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. + * + * 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 DataStore resource name, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. + * + * 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. URL encoded UserEvent proto with a length limit of 2,000,000 + * characters. + * + * Generated from protobuf field string user_event = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getUserEvent() + { + return $this->user_event; + } + + /** + * Required. URL encoded UserEvent proto with a length limit of 2,000,000 + * characters. + * + * Generated from protobuf field string user_event = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setUserEvent($var) + { + GPBUtil::checkString($var, True); + $this->user_event = $var; + + return $this; + } + + /** + * The URL including cgi-parameters but excluding the hash fragment with a + * length limit of 5,000 characters. This is often more useful than the + * referer URL, because many browsers only send the domain for 3rd party + * requests. + * + * Generated from protobuf field optional string uri = 3; + * @return string + */ + public function getUri() + { + return isset($this->uri) ? $this->uri : ''; + } + + public function hasUri() + { + return isset($this->uri); + } + + public function clearUri() + { + unset($this->uri); + } + + /** + * The URL including cgi-parameters but excluding the hash fragment with a + * length limit of 5,000 characters. This is often more useful than the + * referer URL, because many browsers only send the domain for 3rd party + * requests. + * + * Generated from protobuf field optional string uri = 3; + * @param string $var + * @return $this + */ + public function setUri($var) + { + GPBUtil::checkString($var, True); + $this->uri = $var; + + return $this; + } + + /** + * The event timestamp in milliseconds. This prevents browser caching of + * otherwise identical get requests. The name is abbreviated to reduce the + * payload bytes. + * + * Generated from protobuf field optional int64 ets = 4; + * @return int|string + */ + public function getEts() + { + return isset($this->ets) ? $this->ets : 0; + } + + public function hasEts() + { + return isset($this->ets); + } + + public function clearEts() + { + unset($this->ets); + } + + /** + * The event timestamp in milliseconds. This prevents browser caching of + * otherwise identical get requests. The name is abbreviated to reduce the + * payload bytes. + * + * Generated from protobuf field optional int64 ets = 4; + * @param int|string $var + * @return $this + */ + public function setEts($var) + { + GPBUtil::checkInt64($var); + $this->ets = $var; + + return $this; + } + +} + diff --git a/DiscoveryEngine/src/V1beta/CompleteQueryRequest.php b/DiscoveryEngine/src/V1beta/CompleteQueryRequest.php new file mode 100644 index 000000000000..16a54166ff36 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/CompleteQueryRequest.php @@ -0,0 +1,271 @@ +google.cloud.discoveryengine.v1beta.CompleteQueryRequest + */ +class CompleteQueryRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The parent data store resource name for which the completion is + * performed, such as + * `projects/*/locations/global/collections/default_collection/dataStores/default_data_store`. + * + * Generated from protobuf field string data_store = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $data_store = ''; + /** + * Required. The typeahead input used to fetch suggestions. Maximum length is + * 128 characters. + * + * Generated from protobuf field string query = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $query = ''; + /** + * Selects data model of query suggestions for serving. Currently supported + * values: + * * `document` - Using suggestions generated from user-imported documents. + * * `search-history` - Using suggestions generated from the past history of + * [SearchService.Search][google.cloud.discoveryengine.v1beta.SearchService.Search] + * API calls. Do not use it when there is no traffic for Search API. + * * `user-event` - Using suggestions generated from user-imported search + * events. + * Default values: + * * `document` is the default model for regular dataStores. + * * `search-history` is the default model for + * [IndustryVertical.SITE_SEARCH][google.cloud.discoveryengine.v1beta.IndustryVertical.SITE_SEARCH] + * dataStores. + * + * Generated from protobuf field string query_model = 3; + */ + protected $query_model = ''; + /** + * A unique identifier for tracking visitors. For example, this could be + * implemented with an HTTP cookie, which should be able to uniquely identify + * a visitor on a single device. This unique identifier should not change if + * the visitor logs in or out of the website. + * This field should NOT have a fixed value such as `unknown_visitor`. + * This should be the same identifier as + * [UserEvent.user_pseudo_id][google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id] + * and + * [SearchRequest.user_pseudo_id][google.cloud.discoveryengine.v1beta.SearchRequest.user_pseudo_id]. + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an `INVALID_ARGUMENT` error is returned. + * + * Generated from protobuf field string user_pseudo_id = 4; + */ + protected $user_pseudo_id = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $data_store + * Required. The parent data store resource name for which the completion is + * performed, such as + * `projects/*/locations/global/collections/default_collection/dataStores/default_data_store`. + * @type string $query + * Required. The typeahead input used to fetch suggestions. Maximum length is + * 128 characters. + * @type string $query_model + * Selects data model of query suggestions for serving. Currently supported + * values: + * * `document` - Using suggestions generated from user-imported documents. + * * `search-history` - Using suggestions generated from the past history of + * [SearchService.Search][google.cloud.discoveryengine.v1beta.SearchService.Search] + * API calls. Do not use it when there is no traffic for Search API. + * * `user-event` - Using suggestions generated from user-imported search + * events. + * Default values: + * * `document` is the default model for regular dataStores. + * * `search-history` is the default model for + * [IndustryVertical.SITE_SEARCH][google.cloud.discoveryengine.v1beta.IndustryVertical.SITE_SEARCH] + * dataStores. + * @type string $user_pseudo_id + * A unique identifier for tracking visitors. For example, this could be + * implemented with an HTTP cookie, which should be able to uniquely identify + * a visitor on a single device. This unique identifier should not change if + * the visitor logs in or out of the website. + * This field should NOT have a fixed value such as `unknown_visitor`. + * This should be the same identifier as + * [UserEvent.user_pseudo_id][google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id] + * and + * [SearchRequest.user_pseudo_id][google.cloud.discoveryengine.v1beta.SearchRequest.user_pseudo_id]. + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an `INVALID_ARGUMENT` error is returned. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\CompletionService::initOnce(); + parent::__construct($data); + } + + /** + * Required. The parent data store resource name for which the completion is + * performed, such as + * `projects/*/locations/global/collections/default_collection/dataStores/default_data_store`. + * + * Generated from protobuf field string data_store = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getDataStore() + { + return $this->data_store; + } + + /** + * Required. The parent data store resource name for which the completion is + * performed, such as + * `projects/*/locations/global/collections/default_collection/dataStores/default_data_store`. + * + * Generated from protobuf field string data_store = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setDataStore($var) + { + GPBUtil::checkString($var, True); + $this->data_store = $var; + + return $this; + } + + /** + * Required. The typeahead input used to fetch suggestions. Maximum length is + * 128 characters. + * + * Generated from protobuf field string query = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getQuery() + { + return $this->query; + } + + /** + * Required. The typeahead input used to fetch suggestions. Maximum length is + * 128 characters. + * + * Generated from protobuf field string query = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setQuery($var) + { + GPBUtil::checkString($var, True); + $this->query = $var; + + return $this; + } + + /** + * Selects data model of query suggestions for serving. Currently supported + * values: + * * `document` - Using suggestions generated from user-imported documents. + * * `search-history` - Using suggestions generated from the past history of + * [SearchService.Search][google.cloud.discoveryengine.v1beta.SearchService.Search] + * API calls. Do not use it when there is no traffic for Search API. + * * `user-event` - Using suggestions generated from user-imported search + * events. + * Default values: + * * `document` is the default model for regular dataStores. + * * `search-history` is the default model for + * [IndustryVertical.SITE_SEARCH][google.cloud.discoveryengine.v1beta.IndustryVertical.SITE_SEARCH] + * dataStores. + * + * Generated from protobuf field string query_model = 3; + * @return string + */ + public function getQueryModel() + { + return $this->query_model; + } + + /** + * Selects data model of query suggestions for serving. Currently supported + * values: + * * `document` - Using suggestions generated from user-imported documents. + * * `search-history` - Using suggestions generated from the past history of + * [SearchService.Search][google.cloud.discoveryengine.v1beta.SearchService.Search] + * API calls. Do not use it when there is no traffic for Search API. + * * `user-event` - Using suggestions generated from user-imported search + * events. + * Default values: + * * `document` is the default model for regular dataStores. + * * `search-history` is the default model for + * [IndustryVertical.SITE_SEARCH][google.cloud.discoveryengine.v1beta.IndustryVertical.SITE_SEARCH] + * dataStores. + * + * Generated from protobuf field string query_model = 3; + * @param string $var + * @return $this + */ + public function setQueryModel($var) + { + GPBUtil::checkString($var, True); + $this->query_model = $var; + + return $this; + } + + /** + * A unique identifier for tracking visitors. For example, this could be + * implemented with an HTTP cookie, which should be able to uniquely identify + * a visitor on a single device. This unique identifier should not change if + * the visitor logs in or out of the website. + * This field should NOT have a fixed value such as `unknown_visitor`. + * This should be the same identifier as + * [UserEvent.user_pseudo_id][google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id] + * and + * [SearchRequest.user_pseudo_id][google.cloud.discoveryengine.v1beta.SearchRequest.user_pseudo_id]. + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an `INVALID_ARGUMENT` error is returned. + * + * Generated from protobuf field string user_pseudo_id = 4; + * @return string + */ + public function getUserPseudoId() + { + return $this->user_pseudo_id; + } + + /** + * A unique identifier for tracking visitors. For example, this could be + * implemented with an HTTP cookie, which should be able to uniquely identify + * a visitor on a single device. This unique identifier should not change if + * the visitor logs in or out of the website. + * This field should NOT have a fixed value such as `unknown_visitor`. + * This should be the same identifier as + * [UserEvent.user_pseudo_id][google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id] + * and + * [SearchRequest.user_pseudo_id][google.cloud.discoveryengine.v1beta.SearchRequest.user_pseudo_id]. + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an `INVALID_ARGUMENT` error is returned. + * + * Generated from protobuf field string user_pseudo_id = 4; + * @param string $var + * @return $this + */ + public function setUserPseudoId($var) + { + GPBUtil::checkString($var, True); + $this->user_pseudo_id = $var; + + return $this; + } + +} + diff --git a/DiscoveryEngine/src/V1beta/CompleteQueryResponse.php b/DiscoveryEngine/src/V1beta/CompleteQueryResponse.php new file mode 100644 index 000000000000..2eea62ecb7dd --- /dev/null +++ b/DiscoveryEngine/src/V1beta/CompleteQueryResponse.php @@ -0,0 +1,73 @@ +google.cloud.discoveryengine.v1beta.CompleteQueryResponse + */ +class CompleteQueryResponse extends \Google\Protobuf\Internal\Message +{ + /** + * Results of the matched query suggestions. The result list is ordered and + * the first result is a top suggestion. + * + * Generated from protobuf field repeated .google.cloud.discoveryengine.v1beta.CompleteQueryResponse.QuerySuggestion query_suggestions = 1; + */ + private $query_suggestions; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\Google\Cloud\DiscoveryEngine\V1beta\CompleteQueryResponse\QuerySuggestion>|\Google\Protobuf\Internal\RepeatedField $query_suggestions + * Results of the matched query suggestions. The result list is ordered and + * the first result is a top suggestion. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\CompletionService::initOnce(); + parent::__construct($data); + } + + /** + * Results of the matched query suggestions. The result list is ordered and + * the first result is a top suggestion. + * + * Generated from protobuf field repeated .google.cloud.discoveryengine.v1beta.CompleteQueryResponse.QuerySuggestion query_suggestions = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getQuerySuggestions() + { + return $this->query_suggestions; + } + + /** + * Results of the matched query suggestions. The result list is ordered and + * the first result is a top suggestion. + * + * Generated from protobuf field repeated .google.cloud.discoveryengine.v1beta.CompleteQueryResponse.QuerySuggestion query_suggestions = 1; + * @param array<\Google\Cloud\DiscoveryEngine\V1beta\CompleteQueryResponse\QuerySuggestion>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setQuerySuggestions($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\DiscoveryEngine\V1beta\CompleteQueryResponse\QuerySuggestion::class); + $this->query_suggestions = $arr; + + return $this; + } + +} + diff --git a/DiscoveryEngine/src/V1beta/CompleteQueryResponse/QuerySuggestion.php b/DiscoveryEngine/src/V1beta/CompleteQueryResponse/QuerySuggestion.php new file mode 100644 index 000000000000..1cad729c371c --- /dev/null +++ b/DiscoveryEngine/src/V1beta/CompleteQueryResponse/QuerySuggestion.php @@ -0,0 +1,68 @@ +google.cloud.discoveryengine.v1beta.CompleteQueryResponse.QuerySuggestion + */ +class QuerySuggestion extends \Google\Protobuf\Internal\Message +{ + /** + * The suggestion for the query. + * + * Generated from protobuf field string suggestion = 1; + */ + protected $suggestion = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $suggestion + * The suggestion for the query. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\CompletionService::initOnce(); + parent::__construct($data); + } + + /** + * The suggestion for the query. + * + * Generated from protobuf field string suggestion = 1; + * @return string + */ + public function getSuggestion() + { + return $this->suggestion; + } + + /** + * The suggestion for the query. + * + * Generated from protobuf field string suggestion = 1; + * @param string $var + * @return $this + */ + public function setSuggestion($var) + { + GPBUtil::checkString($var, True); + $this->suggestion = $var; + + return $this; + } + +} + + diff --git a/DiscoveryEngine/src/V1beta/CompletionInfo.php b/DiscoveryEngine/src/V1beta/CompletionInfo.php new file mode 100644 index 000000000000..aa1a16ce98fb --- /dev/null +++ b/DiscoveryEngine/src/V1beta/CompletionInfo.php @@ -0,0 +1,106 @@ +google.cloud.discoveryengine.v1beta.CompletionInfo + */ +class CompletionInfo extends \Google\Protobuf\Internal\Message +{ + /** + * End user selected [CompleteQueryResponse.CompletionResult.suggestion][]. + * + * Generated from protobuf field string selected_suggestion = 1; + */ + protected $selected_suggestion = ''; + /** + * End user selected [CompleteQueryResponse.CompletionResult.suggestion][] + * position, starting from 0. + * + * Generated from protobuf field int32 selected_position = 2; + */ + protected $selected_position = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $selected_suggestion + * End user selected [CompleteQueryResponse.CompletionResult.suggestion][]. + * @type int $selected_position + * End user selected [CompleteQueryResponse.CompletionResult.suggestion][] + * position, starting from 0. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\UserEvent::initOnce(); + parent::__construct($data); + } + + /** + * End user selected [CompleteQueryResponse.CompletionResult.suggestion][]. + * + * Generated from protobuf field string selected_suggestion = 1; + * @return string + */ + public function getSelectedSuggestion() + { + return $this->selected_suggestion; + } + + /** + * End user selected [CompleteQueryResponse.CompletionResult.suggestion][]. + * + * Generated from protobuf field string selected_suggestion = 1; + * @param string $var + * @return $this + */ + public function setSelectedSuggestion($var) + { + GPBUtil::checkString($var, True); + $this->selected_suggestion = $var; + + return $this; + } + + /** + * End user selected [CompleteQueryResponse.CompletionResult.suggestion][] + * position, starting from 0. + * + * Generated from protobuf field int32 selected_position = 2; + * @return int + */ + public function getSelectedPosition() + { + return $this->selected_position; + } + + /** + * End user selected [CompleteQueryResponse.CompletionResult.suggestion][] + * position, starting from 0. + * + * Generated from protobuf field int32 selected_position = 2; + * @param int $var + * @return $this + */ + public function setSelectedPosition($var) + { + GPBUtil::checkInt32($var); + $this->selected_position = $var; + + return $this; + } + +} + diff --git a/DiscoveryEngine/src/V1beta/CreateDocumentRequest.php b/DiscoveryEngine/src/V1beta/CreateDocumentRequest.php new file mode 100644 index 000000000000..c3ff577a2b3d --- /dev/null +++ b/DiscoveryEngine/src/V1beta/CreateDocumentRequest.php @@ -0,0 +1,243 @@ +google.cloud.discoveryengine.v1beta.CreateDocumentRequest + */ +class CreateDocumentRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The parent resource name, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $parent = ''; + /** + * Required. The [Document][google.cloud.discoveryengine.v1beta.Document] to + * create. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.Document document = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $document = null; + /** + * Required. The ID to use for the + * [Document][google.cloud.discoveryengine.v1beta.Document], which will become + * the final component of the + * [Document.name][google.cloud.discoveryengine.v1beta.Document.name]. + * If the caller does not have permission to create the + * [Document][google.cloud.discoveryengine.v1beta.Document], regardless of + * whether or not it exists, a `PERMISSION_DENIED` error is returned. + * This field must be unique among all + * [Document][google.cloud.discoveryengine.v1beta.Document]s with the same + * [parent][google.cloud.discoveryengine.v1beta.CreateDocumentRequest.parent]. + * Otherwise, an `ALREADY_EXISTS` error is returned. + * This field must conform to [RFC-1034](https://tools.ietf.org/html/rfc1034) + * standard with a length limit of 63 characters. Otherwise, an + * `INVALID_ARGUMENT` error is returned. + * + * Generated from protobuf field string document_id = 3 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $document_id = ''; + + /** + * @param string $parent Required. The parent resource name, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. Please see + * {@see DocumentServiceClient::branchName()} for help formatting this field. + * @param \Google\Cloud\DiscoveryEngine\V1beta\Document $document Required. The [Document][google.cloud.discoveryengine.v1beta.Document] to + * create. + * @param string $documentId Required. The ID to use for the + * [Document][google.cloud.discoveryengine.v1beta.Document], which will become + * the final component of the + * [Document.name][google.cloud.discoveryengine.v1beta.Document.name]. + * + * If the caller does not have permission to create the + * [Document][google.cloud.discoveryengine.v1beta.Document], regardless of + * whether or not it exists, a `PERMISSION_DENIED` error is returned. + * + * This field must be unique among all + * [Document][google.cloud.discoveryengine.v1beta.Document]s with the same + * [parent][google.cloud.discoveryengine.v1beta.CreateDocumentRequest.parent]. + * Otherwise, an `ALREADY_EXISTS` error is returned. + * + * This field must conform to [RFC-1034](https://tools.ietf.org/html/rfc1034) + * standard with a length limit of 63 characters. Otherwise, an + * `INVALID_ARGUMENT` error is returned. + * + * @return \Google\Cloud\DiscoveryEngine\V1beta\CreateDocumentRequest + * + * @experimental + */ + public static function build(string $parent, \Google\Cloud\DiscoveryEngine\V1beta\Document $document, string $documentId): self + { + return (new self()) + ->setParent($parent) + ->setDocument($document) + ->setDocumentId($documentId); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. The parent resource name, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. + * @type \Google\Cloud\DiscoveryEngine\V1beta\Document $document + * Required. The [Document][google.cloud.discoveryengine.v1beta.Document] to + * create. + * @type string $document_id + * Required. The ID to use for the + * [Document][google.cloud.discoveryengine.v1beta.Document], which will become + * the final component of the + * [Document.name][google.cloud.discoveryengine.v1beta.Document.name]. + * If the caller does not have permission to create the + * [Document][google.cloud.discoveryengine.v1beta.Document], regardless of + * whether or not it exists, a `PERMISSION_DENIED` error is returned. + * This field must be unique among all + * [Document][google.cloud.discoveryengine.v1beta.Document]s with the same + * [parent][google.cloud.discoveryengine.v1beta.CreateDocumentRequest.parent]. + * Otherwise, an `ALREADY_EXISTS` error is returned. + * This field must conform to [RFC-1034](https://tools.ietf.org/html/rfc1034) + * standard with a length limit of 63 characters. Otherwise, an + * `INVALID_ARGUMENT` error is returned. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\DocumentService::initOnce(); + parent::__construct($data); + } + + /** + * Required. The parent resource name, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * Required. The parent resource name, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. + * + * 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 [Document][google.cloud.discoveryengine.v1beta.Document] to + * create. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.Document document = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\DiscoveryEngine\V1beta\Document|null + */ + public function getDocument() + { + return $this->document; + } + + public function hasDocument() + { + return isset($this->document); + } + + public function clearDocument() + { + unset($this->document); + } + + /** + * Required. The [Document][google.cloud.discoveryengine.v1beta.Document] to + * create. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.Document document = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\DiscoveryEngine\V1beta\Document $var + * @return $this + */ + public function setDocument($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\DiscoveryEngine\V1beta\Document::class); + $this->document = $var; + + return $this; + } + + /** + * Required. The ID to use for the + * [Document][google.cloud.discoveryengine.v1beta.Document], which will become + * the final component of the + * [Document.name][google.cloud.discoveryengine.v1beta.Document.name]. + * If the caller does not have permission to create the + * [Document][google.cloud.discoveryengine.v1beta.Document], regardless of + * whether or not it exists, a `PERMISSION_DENIED` error is returned. + * This field must be unique among all + * [Document][google.cloud.discoveryengine.v1beta.Document]s with the same + * [parent][google.cloud.discoveryengine.v1beta.CreateDocumentRequest.parent]. + * Otherwise, an `ALREADY_EXISTS` error is returned. + * This field must conform to [RFC-1034](https://tools.ietf.org/html/rfc1034) + * standard with a length limit of 63 characters. Otherwise, an + * `INVALID_ARGUMENT` error is returned. + * + * Generated from protobuf field string document_id = 3 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getDocumentId() + { + return $this->document_id; + } + + /** + * Required. The ID to use for the + * [Document][google.cloud.discoveryengine.v1beta.Document], which will become + * the final component of the + * [Document.name][google.cloud.discoveryengine.v1beta.Document.name]. + * If the caller does not have permission to create the + * [Document][google.cloud.discoveryengine.v1beta.Document], regardless of + * whether or not it exists, a `PERMISSION_DENIED` error is returned. + * This field must be unique among all + * [Document][google.cloud.discoveryengine.v1beta.Document]s with the same + * [parent][google.cloud.discoveryengine.v1beta.CreateDocumentRequest.parent]. + * Otherwise, an `ALREADY_EXISTS` error is returned. + * This field must conform to [RFC-1034](https://tools.ietf.org/html/rfc1034) + * standard with a length limit of 63 characters. Otherwise, an + * `INVALID_ARGUMENT` error is returned. + * + * Generated from protobuf field string document_id = 3 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setDocumentId($var) + { + GPBUtil::checkString($var, True); + $this->document_id = $var; + + return $this; + } + +} + diff --git a/DiscoveryEngine/src/V1beta/CreateSchemaMetadata.php b/DiscoveryEngine/src/V1beta/CreateSchemaMetadata.php new file mode 100644 index 000000000000..5142fd3817cb --- /dev/null +++ b/DiscoveryEngine/src/V1beta/CreateSchemaMetadata.php @@ -0,0 +1,125 @@ +google.cloud.discoveryengine.v1beta.CreateSchemaMetadata + */ +class CreateSchemaMetadata extends \Google\Protobuf\Internal\Message +{ + /** + * Operation create time. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 1; + */ + protected $create_time = null; + /** + * Operation last update time. If the operation is done, this is also the + * finish time. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 2; + */ + protected $update_time = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Protobuf\Timestamp $create_time + * Operation create time. + * @type \Google\Protobuf\Timestamp $update_time + * Operation last update time. If the operation is done, this is also the + * finish time. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\SchemaService::initOnce(); + parent::__construct($data); + } + + /** + * Operation create time. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 1; + * @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); + } + + /** + * Operation create time. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 1; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setCreateTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->create_time = $var; + + return $this; + } + + /** + * Operation last update time. If the operation is done, this is also the + * finish time. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 2; + * @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); + } + + /** + * Operation last update time. If the operation is done, this is also the + * finish time. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 2; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setUpdateTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->update_time = $var; + + return $this; + } + +} + diff --git a/DiscoveryEngine/src/V1beta/CreateSchemaRequest.php b/DiscoveryEngine/src/V1beta/CreateSchemaRequest.php new file mode 100644 index 000000000000..2433a108c8b0 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/CreateSchemaRequest.php @@ -0,0 +1,206 @@ +google.cloud.discoveryengine.v1beta.CreateSchemaRequest + */ +class CreateSchemaRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The parent data store resource name, in the format of + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $parent = ''; + /** + * Required. The [Schema][google.cloud.discoveryengine.v1beta.Schema] to + * create. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.Schema schema = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $schema = null; + /** + * Required. The ID to use for the + * [Schema][google.cloud.discoveryengine.v1beta.Schema], which will become the + * final component of the + * [Schema.name][google.cloud.discoveryengine.v1beta.Schema.name]. + * This field should conform to + * [RFC-1034](https://tools.ietf.org/html/rfc1034) standard with a length + * limit of 63 characters. + * + * Generated from protobuf field string schema_id = 3 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $schema_id = ''; + + /** + * @param string $parent Required. The parent data store resource name, in the format of + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. Please see + * {@see SchemaServiceClient::dataStoreName()} for help formatting this field. + * @param \Google\Cloud\DiscoveryEngine\V1beta\Schema $schema Required. The [Schema][google.cloud.discoveryengine.v1beta.Schema] to + * create. + * @param string $schemaId Required. The ID to use for the + * [Schema][google.cloud.discoveryengine.v1beta.Schema], which will become the + * final component of the + * [Schema.name][google.cloud.discoveryengine.v1beta.Schema.name]. + * + * This field should conform to + * [RFC-1034](https://tools.ietf.org/html/rfc1034) standard with a length + * limit of 63 characters. + * + * @return \Google\Cloud\DiscoveryEngine\V1beta\CreateSchemaRequest + * + * @experimental + */ + public static function build(string $parent, \Google\Cloud\DiscoveryEngine\V1beta\Schema $schema, string $schemaId): self + { + return (new self()) + ->setParent($parent) + ->setSchema($schema) + ->setSchemaId($schemaId); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. The parent data store resource name, in the format of + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. + * @type \Google\Cloud\DiscoveryEngine\V1beta\Schema $schema + * Required. The [Schema][google.cloud.discoveryengine.v1beta.Schema] to + * create. + * @type string $schema_id + * Required. The ID to use for the + * [Schema][google.cloud.discoveryengine.v1beta.Schema], which will become the + * final component of the + * [Schema.name][google.cloud.discoveryengine.v1beta.Schema.name]. + * This field should conform to + * [RFC-1034](https://tools.ietf.org/html/rfc1034) standard with a length + * limit of 63 characters. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\SchemaService::initOnce(); + parent::__construct($data); + } + + /** + * Required. The parent data store resource name, in the format of + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. + * + * 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 data store resource name, in the format of + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. + * + * 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 [Schema][google.cloud.discoveryengine.v1beta.Schema] to + * create. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.Schema schema = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\DiscoveryEngine\V1beta\Schema|null + */ + public function getSchema() + { + return $this->schema; + } + + public function hasSchema() + { + return isset($this->schema); + } + + public function clearSchema() + { + unset($this->schema); + } + + /** + * Required. The [Schema][google.cloud.discoveryengine.v1beta.Schema] to + * create. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.Schema schema = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\DiscoveryEngine\V1beta\Schema $var + * @return $this + */ + public function setSchema($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\DiscoveryEngine\V1beta\Schema::class); + $this->schema = $var; + + return $this; + } + + /** + * Required. The ID to use for the + * [Schema][google.cloud.discoveryengine.v1beta.Schema], which will become the + * final component of the + * [Schema.name][google.cloud.discoveryengine.v1beta.Schema.name]. + * This field should conform to + * [RFC-1034](https://tools.ietf.org/html/rfc1034) standard with a length + * limit of 63 characters. + * + * Generated from protobuf field string schema_id = 3 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getSchemaId() + { + return $this->schema_id; + } + + /** + * Required. The ID to use for the + * [Schema][google.cloud.discoveryengine.v1beta.Schema], which will become the + * final component of the + * [Schema.name][google.cloud.discoveryengine.v1beta.Schema.name]. + * This field should conform to + * [RFC-1034](https://tools.ietf.org/html/rfc1034) standard with a length + * limit of 63 characters. + * + * Generated from protobuf field string schema_id = 3 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setSchemaId($var) + { + GPBUtil::checkString($var, True); + $this->schema_id = $var; + + return $this; + } + +} + diff --git a/DiscoveryEngine/src/V1beta/CustomAttribute.php b/DiscoveryEngine/src/V1beta/CustomAttribute.php new file mode 100644 index 000000000000..bcb2514c5d68 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/CustomAttribute.php @@ -0,0 +1,158 @@ +google.cloud.discoveryengine.v1beta.CustomAttribute + */ +class CustomAttribute extends \Google\Protobuf\Internal\Message +{ + /** + * The textual values of this custom attribute. For example, `["yellow", + * "green"]` when the key is "color". + * Empty string is not allowed. Otherwise, an `INVALID_ARGUMENT` error is + * returned. + * Exactly one of + * [CustomAttribute.text][google.cloud.discoveryengine.v1beta.CustomAttribute.text] + * or + * [CustomAttribute.numbers][google.cloud.discoveryengine.v1beta.CustomAttribute.numbers] + * should be set. Otherwise, an `INVALID_ARGUMENT` error is returned. + * + * Generated from protobuf field repeated string text = 1; + */ + private $text; + /** + * The numerical values of this custom attribute. For example, `[2.3, 15.4]` + * when the key is "lengths_cm". + * Exactly one of + * [CustomAttribute.text][google.cloud.discoveryengine.v1beta.CustomAttribute.text] + * or + * [CustomAttribute.numbers][google.cloud.discoveryengine.v1beta.CustomAttribute.numbers] + * should be set. Otherwise, an `INVALID_ARGUMENT` error is returned. + * + * Generated from protobuf field repeated double numbers = 2; + */ + private $numbers; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array|\Google\Protobuf\Internal\RepeatedField $text + * The textual values of this custom attribute. For example, `["yellow", + * "green"]` when the key is "color". + * Empty string is not allowed. Otherwise, an `INVALID_ARGUMENT` error is + * returned. + * Exactly one of + * [CustomAttribute.text][google.cloud.discoveryengine.v1beta.CustomAttribute.text] + * or + * [CustomAttribute.numbers][google.cloud.discoveryengine.v1beta.CustomAttribute.numbers] + * should be set. Otherwise, an `INVALID_ARGUMENT` error is returned. + * @type array|\Google\Protobuf\Internal\RepeatedField $numbers + * The numerical values of this custom attribute. For example, `[2.3, 15.4]` + * when the key is "lengths_cm". + * Exactly one of + * [CustomAttribute.text][google.cloud.discoveryengine.v1beta.CustomAttribute.text] + * or + * [CustomAttribute.numbers][google.cloud.discoveryengine.v1beta.CustomAttribute.numbers] + * should be set. Otherwise, an `INVALID_ARGUMENT` error is returned. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\Common::initOnce(); + parent::__construct($data); + } + + /** + * The textual values of this custom attribute. For example, `["yellow", + * "green"]` when the key is "color". + * Empty string is not allowed. Otherwise, an `INVALID_ARGUMENT` error is + * returned. + * Exactly one of + * [CustomAttribute.text][google.cloud.discoveryengine.v1beta.CustomAttribute.text] + * or + * [CustomAttribute.numbers][google.cloud.discoveryengine.v1beta.CustomAttribute.numbers] + * should be set. Otherwise, an `INVALID_ARGUMENT` error is returned. + * + * Generated from protobuf field repeated string text = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getText() + { + return $this->text; + } + + /** + * The textual values of this custom attribute. For example, `["yellow", + * "green"]` when the key is "color". + * Empty string is not allowed. Otherwise, an `INVALID_ARGUMENT` error is + * returned. + * Exactly one of + * [CustomAttribute.text][google.cloud.discoveryengine.v1beta.CustomAttribute.text] + * or + * [CustomAttribute.numbers][google.cloud.discoveryengine.v1beta.CustomAttribute.numbers] + * should be set. Otherwise, an `INVALID_ARGUMENT` error is returned. + * + * Generated from protobuf field repeated string text = 1; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setText($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->text = $arr; + + return $this; + } + + /** + * The numerical values of this custom attribute. For example, `[2.3, 15.4]` + * when the key is "lengths_cm". + * Exactly one of + * [CustomAttribute.text][google.cloud.discoveryengine.v1beta.CustomAttribute.text] + * or + * [CustomAttribute.numbers][google.cloud.discoveryengine.v1beta.CustomAttribute.numbers] + * should be set. Otherwise, an `INVALID_ARGUMENT` error is returned. + * + * Generated from protobuf field repeated double numbers = 2; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getNumbers() + { + return $this->numbers; + } + + /** + * The numerical values of this custom attribute. For example, `[2.3, 15.4]` + * when the key is "lengths_cm". + * Exactly one of + * [CustomAttribute.text][google.cloud.discoveryengine.v1beta.CustomAttribute.text] + * or + * [CustomAttribute.numbers][google.cloud.discoveryengine.v1beta.CustomAttribute.numbers] + * should be set. Otherwise, an `INVALID_ARGUMENT` error is returned. + * + * Generated from protobuf field repeated double numbers = 2; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setNumbers($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::DOUBLE); + $this->numbers = $arr; + + return $this; + } + +} + diff --git a/DiscoveryEngine/src/V1beta/DeleteDocumentRequest.php b/DiscoveryEngine/src/V1beta/DeleteDocumentRequest.php new file mode 100644 index 000000000000..fd4914bd7778 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/DeleteDocumentRequest.php @@ -0,0 +1,120 @@ +google.cloud.discoveryengine.v1beta.DeleteDocumentRequest + */ +class DeleteDocumentRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. Full resource name of + * [Document][google.cloud.discoveryengine.v1beta.Document], such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}`. + * If the caller does not have permission to delete the + * [Document][google.cloud.discoveryengine.v1beta.Document], regardless of + * whether or not it exists, a `PERMISSION_DENIED` error is returned. + * If the [Document][google.cloud.discoveryengine.v1beta.Document] to delete + * does not exist, a `NOT_FOUND` error is returned. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $name = ''; + + /** + * @param string $name Required. Full resource name of + * [Document][google.cloud.discoveryengine.v1beta.Document], such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}`. + * + * If the caller does not have permission to delete the + * [Document][google.cloud.discoveryengine.v1beta.Document], regardless of + * whether or not it exists, a `PERMISSION_DENIED` error is returned. + * + * If the [Document][google.cloud.discoveryengine.v1beta.Document] to delete + * does not exist, a `NOT_FOUND` error is returned. Please see + * {@see DocumentServiceClient::documentName()} for help formatting this field. + * + * @return \Google\Cloud\DiscoveryEngine\V1beta\DeleteDocumentRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. Full resource name of + * [Document][google.cloud.discoveryengine.v1beta.Document], such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}`. + * If the caller does not have permission to delete the + * [Document][google.cloud.discoveryengine.v1beta.Document], regardless of + * whether or not it exists, a `PERMISSION_DENIED` error is returned. + * If the [Document][google.cloud.discoveryengine.v1beta.Document] to delete + * does not exist, a `NOT_FOUND` error is returned. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\DocumentService::initOnce(); + parent::__construct($data); + } + + /** + * Required. Full resource name of + * [Document][google.cloud.discoveryengine.v1beta.Document], such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}`. + * If the caller does not have permission to delete the + * [Document][google.cloud.discoveryengine.v1beta.Document], regardless of + * whether or not it exists, a `PERMISSION_DENIED` error is returned. + * If the [Document][google.cloud.discoveryengine.v1beta.Document] to delete + * does not exist, a `NOT_FOUND` error is returned. + * + * 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. Full resource name of + * [Document][google.cloud.discoveryengine.v1beta.Document], such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}`. + * If the caller does not have permission to delete the + * [Document][google.cloud.discoveryengine.v1beta.Document], regardless of + * whether or not it exists, a `PERMISSION_DENIED` error is returned. + * If the [Document][google.cloud.discoveryengine.v1beta.Document] to delete + * does not exist, a `NOT_FOUND` error is returned. + * + * 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/DiscoveryEngine/src/V1beta/DeleteSchemaMetadata.php b/DiscoveryEngine/src/V1beta/DeleteSchemaMetadata.php new file mode 100644 index 000000000000..abb7de3169fa --- /dev/null +++ b/DiscoveryEngine/src/V1beta/DeleteSchemaMetadata.php @@ -0,0 +1,125 @@ +google.cloud.discoveryengine.v1beta.DeleteSchemaMetadata + */ +class DeleteSchemaMetadata extends \Google\Protobuf\Internal\Message +{ + /** + * Operation create time. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 1; + */ + protected $create_time = null; + /** + * Operation last update time. If the operation is done, this is also the + * finish time. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 2; + */ + protected $update_time = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Protobuf\Timestamp $create_time + * Operation create time. + * @type \Google\Protobuf\Timestamp $update_time + * Operation last update time. If the operation is done, this is also the + * finish time. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\SchemaService::initOnce(); + parent::__construct($data); + } + + /** + * Operation create time. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 1; + * @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); + } + + /** + * Operation create time. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 1; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setCreateTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->create_time = $var; + + return $this; + } + + /** + * Operation last update time. If the operation is done, this is also the + * finish time. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 2; + * @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); + } + + /** + * Operation last update time. If the operation is done, this is also the + * finish time. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 2; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setUpdateTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->update_time = $var; + + return $this; + } + +} + diff --git a/DiscoveryEngine/src/V1beta/DeleteSchemaRequest.php b/DiscoveryEngine/src/V1beta/DeleteSchemaRequest.php new file mode 100644 index 000000000000..51e741330edf --- /dev/null +++ b/DiscoveryEngine/src/V1beta/DeleteSchemaRequest.php @@ -0,0 +1,88 @@ +google.cloud.discoveryengine.v1beta.DeleteSchemaRequest + */ +class DeleteSchemaRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The full resource name of the schema, in the format of + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $name = ''; + + /** + * @param string $name Required. The full resource name of the schema, in the format of + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}`. Please see + * {@see SchemaServiceClient::schemaName()} for help formatting this field. + * + * @return \Google\Cloud\DiscoveryEngine\V1beta\DeleteSchemaRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. The full resource name of the schema, in the format of + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\SchemaService::initOnce(); + parent::__construct($data); + } + + /** + * Required. The full resource name of the schema, in the format of + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}`. + * + * 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 full resource name of the schema, in the format of + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}`. + * + * 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/DiscoveryEngine/src/V1beta/Document.php b/DiscoveryEngine/src/V1beta/Document.php new file mode 100644 index 000000000000..faeb67f629d5 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/Document.php @@ -0,0 +1,399 @@ +google.cloud.discoveryengine.v1beta.Document + */ +class Document extends \Google\Protobuf\Internal\Message +{ + /** + * Immutable. The full resource name of the document. + * Format: + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document_id}`. + * This field must be a UTF-8 encoded string with a length limit of 1024 + * characters. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = IMMUTABLE]; + */ + protected $name = ''; + /** + * Immutable. The identifier of the document. + * Id should conform to [RFC-1034](https://tools.ietf.org/html/rfc1034) + * standard with a length limit of 63 characters. + * + * Generated from protobuf field string id = 2 [(.google.api.field_behavior) = IMMUTABLE]; + */ + protected $id = ''; + /** + * The identifier of the schema located in the same data store. + * + * Generated from protobuf field string schema_id = 3; + */ + protected $schema_id = ''; + /** + * The unstructured data linked to this document. Content must be set if this + * document is under a + * `CONTENT_REQUIRED` data store. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.Document.Content content = 10; + */ + protected $content = null; + /** + * The identifier of the parent document. Currently supports at most two level + * document hierarchy. + * Id should conform to [RFC-1034](https://tools.ietf.org/html/rfc1034) + * standard with a length limit of 63 characters. + * + * Generated from protobuf field string parent_document_id = 7; + */ + protected $parent_document_id = ''; + /** + * Output only. This field is OUTPUT_ONLY. + * It contains derived data that are not in the original input document. + * + * Generated from protobuf field .google.protobuf.Struct derived_struct_data = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $derived_struct_data = null; + protected $data; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Protobuf\Struct $struct_data + * The structured JSON data for the document. It should conform to the + * registered + * [Schema.schema][google.cloud.discoveryengine.v1beta.Schema.schema] or an + * `INVALID_ARGUMENT` error is thrown. + * @type string $json_data + * The JSON string representation of the document. It should conform to the + * registered + * [Schema.schema][google.cloud.discoveryengine.v1beta.Schema.schema] or an + * `INVALID_ARGUMENT` error is thrown. + * @type string $name + * Immutable. The full resource name of the document. + * Format: + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document_id}`. + * This field must be a UTF-8 encoded string with a length limit of 1024 + * characters. + * @type string $id + * Immutable. The identifier of the document. + * Id should conform to [RFC-1034](https://tools.ietf.org/html/rfc1034) + * standard with a length limit of 63 characters. + * @type string $schema_id + * The identifier of the schema located in the same data store. + * @type \Google\Cloud\DiscoveryEngine\V1beta\Document\Content $content + * The unstructured data linked to this document. Content must be set if this + * document is under a + * `CONTENT_REQUIRED` data store. + * @type string $parent_document_id + * The identifier of the parent document. Currently supports at most two level + * document hierarchy. + * Id should conform to [RFC-1034](https://tools.ietf.org/html/rfc1034) + * standard with a length limit of 63 characters. + * @type \Google\Protobuf\Struct $derived_struct_data + * Output only. This field is OUTPUT_ONLY. + * It contains derived data that are not in the original input document. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\Document::initOnce(); + parent::__construct($data); + } + + /** + * The structured JSON data for the document. It should conform to the + * registered + * [Schema.schema][google.cloud.discoveryengine.v1beta.Schema.schema] or an + * `INVALID_ARGUMENT` error is thrown. + * + * Generated from protobuf field .google.protobuf.Struct struct_data = 4; + * @return \Google\Protobuf\Struct|null + */ + public function getStructData() + { + return $this->readOneof(4); + } + + public function hasStructData() + { + return $this->hasOneof(4); + } + + /** + * The structured JSON data for the document. It should conform to the + * registered + * [Schema.schema][google.cloud.discoveryengine.v1beta.Schema.schema] or an + * `INVALID_ARGUMENT` error is thrown. + * + * Generated from protobuf field .google.protobuf.Struct struct_data = 4; + * @param \Google\Protobuf\Struct $var + * @return $this + */ + public function setStructData($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Struct::class); + $this->writeOneof(4, $var); + + return $this; + } + + /** + * The JSON string representation of the document. It should conform to the + * registered + * [Schema.schema][google.cloud.discoveryengine.v1beta.Schema.schema] or an + * `INVALID_ARGUMENT` error is thrown. + * + * Generated from protobuf field string json_data = 5; + * @return string + */ + public function getJsonData() + { + return $this->readOneof(5); + } + + public function hasJsonData() + { + return $this->hasOneof(5); + } + + /** + * The JSON string representation of the document. It should conform to the + * registered + * [Schema.schema][google.cloud.discoveryengine.v1beta.Schema.schema] or an + * `INVALID_ARGUMENT` error is thrown. + * + * Generated from protobuf field string json_data = 5; + * @param string $var + * @return $this + */ + public function setJsonData($var) + { + GPBUtil::checkString($var, True); + $this->writeOneof(5, $var); + + return $this; + } + + /** + * Immutable. The full resource name of the document. + * Format: + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document_id}`. + * This field must be a UTF-8 encoded string with a length limit of 1024 + * characters. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = IMMUTABLE]; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Immutable. The full resource name of the document. + * Format: + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document_id}`. + * This field must be a UTF-8 encoded string with a length limit of 1024 + * characters. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = IMMUTABLE]; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * Immutable. The identifier of the document. + * Id should conform to [RFC-1034](https://tools.ietf.org/html/rfc1034) + * standard with a length limit of 63 characters. + * + * Generated from protobuf field string id = 2 [(.google.api.field_behavior) = IMMUTABLE]; + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * Immutable. The identifier of the document. + * Id should conform to [RFC-1034](https://tools.ietf.org/html/rfc1034) + * standard with a length limit of 63 characters. + * + * Generated from protobuf field string id = 2 [(.google.api.field_behavior) = IMMUTABLE]; + * @param string $var + * @return $this + */ + public function setId($var) + { + GPBUtil::checkString($var, True); + $this->id = $var; + + return $this; + } + + /** + * The identifier of the schema located in the same data store. + * + * Generated from protobuf field string schema_id = 3; + * @return string + */ + public function getSchemaId() + { + return $this->schema_id; + } + + /** + * The identifier of the schema located in the same data store. + * + * Generated from protobuf field string schema_id = 3; + * @param string $var + * @return $this + */ + public function setSchemaId($var) + { + GPBUtil::checkString($var, True); + $this->schema_id = $var; + + return $this; + } + + /** + * The unstructured data linked to this document. Content must be set if this + * document is under a + * `CONTENT_REQUIRED` data store. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.Document.Content content = 10; + * @return \Google\Cloud\DiscoveryEngine\V1beta\Document\Content|null + */ + public function getContent() + { + return $this->content; + } + + public function hasContent() + { + return isset($this->content); + } + + public function clearContent() + { + unset($this->content); + } + + /** + * The unstructured data linked to this document. Content must be set if this + * document is under a + * `CONTENT_REQUIRED` data store. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.Document.Content content = 10; + * @param \Google\Cloud\DiscoveryEngine\V1beta\Document\Content $var + * @return $this + */ + public function setContent($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\DiscoveryEngine\V1beta\Document\Content::class); + $this->content = $var; + + return $this; + } + + /** + * The identifier of the parent document. Currently supports at most two level + * document hierarchy. + * Id should conform to [RFC-1034](https://tools.ietf.org/html/rfc1034) + * standard with a length limit of 63 characters. + * + * Generated from protobuf field string parent_document_id = 7; + * @return string + */ + public function getParentDocumentId() + { + return $this->parent_document_id; + } + + /** + * The identifier of the parent document. Currently supports at most two level + * document hierarchy. + * Id should conform to [RFC-1034](https://tools.ietf.org/html/rfc1034) + * standard with a length limit of 63 characters. + * + * Generated from protobuf field string parent_document_id = 7; + * @param string $var + * @return $this + */ + public function setParentDocumentId($var) + { + GPBUtil::checkString($var, True); + $this->parent_document_id = $var; + + return $this; + } + + /** + * Output only. This field is OUTPUT_ONLY. + * It contains derived data that are not in the original input document. + * + * Generated from protobuf field .google.protobuf.Struct derived_struct_data = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Struct|null + */ + public function getDerivedStructData() + { + return $this->derived_struct_data; + } + + public function hasDerivedStructData() + { + return isset($this->derived_struct_data); + } + + public function clearDerivedStructData() + { + unset($this->derived_struct_data); + } + + /** + * Output only. This field is OUTPUT_ONLY. + * It contains derived data that are not in the original input document. + * + * Generated from protobuf field .google.protobuf.Struct derived_struct_data = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Protobuf\Struct $var + * @return $this + */ + public function setDerivedStructData($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Struct::class); + $this->derived_struct_data = $var; + + return $this; + } + + /** + * @return string + */ + public function getData() + { + return $this->whichOneof("data"); + } + +} + diff --git a/DiscoveryEngine/src/V1beta/Document/Content.php b/DiscoveryEngine/src/V1beta/Document/Content.php new file mode 100644 index 000000000000..f8519c25533e --- /dev/null +++ b/DiscoveryEngine/src/V1beta/Document/Content.php @@ -0,0 +1,179 @@ +google.cloud.discoveryengine.v1beta.Document.Content + */ +class Content extends \Google\Protobuf\Internal\Message +{ + /** + * The MIME type of the content. Supported types: + * * `application/pdf` (PDF) + * * `text/html` (HTML) + * See https://www.iana.org/assignments/media-types/media-types.xhtml. + * + * Generated from protobuf field string mime_type = 1; + */ + protected $mime_type = ''; + protected $content; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $raw_bytes + * The content represented as a stream of bytes. The maximum length is + * 1,000,000 bytes (1 MB / ~0.95 MiB). + * Note: As with all `bytes` fields, this field is represented as pure + * binary in Protocol Buffers and base64-encoded string in JSON. For + * example, `abc123!?$*&()'-=@~` should be represented as + * `YWJjMTIzIT8kKiYoKSctPUB+` in JSON. See + * https://developers.google.com/protocol-buffers/docs/proto3#json. + * @type string $uri + * The URI of the content. Only Cloud Storage URIs (e.g. + * `gs://bucket-name/path/to/file`) are supported. The maximum file size + * is 100 MB. + * @type string $mime_type + * The MIME type of the content. Supported types: + * * `application/pdf` (PDF) + * * `text/html` (HTML) + * See https://www.iana.org/assignments/media-types/media-types.xhtml. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\Document::initOnce(); + parent::__construct($data); + } + + /** + * The content represented as a stream of bytes. The maximum length is + * 1,000,000 bytes (1 MB / ~0.95 MiB). + * Note: As with all `bytes` fields, this field is represented as pure + * binary in Protocol Buffers and base64-encoded string in JSON. For + * example, `abc123!?$*&()'-=@~` should be represented as + * `YWJjMTIzIT8kKiYoKSctPUB+` in JSON. See + * https://developers.google.com/protocol-buffers/docs/proto3#json. + * + * Generated from protobuf field bytes raw_bytes = 2; + * @return string + */ + public function getRawBytes() + { + return $this->readOneof(2); + } + + public function hasRawBytes() + { + return $this->hasOneof(2); + } + + /** + * The content represented as a stream of bytes. The maximum length is + * 1,000,000 bytes (1 MB / ~0.95 MiB). + * Note: As with all `bytes` fields, this field is represented as pure + * binary in Protocol Buffers and base64-encoded string in JSON. For + * example, `abc123!?$*&()'-=@~` should be represented as + * `YWJjMTIzIT8kKiYoKSctPUB+` in JSON. See + * https://developers.google.com/protocol-buffers/docs/proto3#json. + * + * Generated from protobuf field bytes raw_bytes = 2; + * @param string $var + * @return $this + */ + public function setRawBytes($var) + { + GPBUtil::checkString($var, False); + $this->writeOneof(2, $var); + + return $this; + } + + /** + * The URI of the content. Only Cloud Storage URIs (e.g. + * `gs://bucket-name/path/to/file`) are supported. The maximum file size + * is 100 MB. + * + * Generated from protobuf field string uri = 3; + * @return string + */ + public function getUri() + { + return $this->readOneof(3); + } + + public function hasUri() + { + return $this->hasOneof(3); + } + + /** + * The URI of the content. Only Cloud Storage URIs (e.g. + * `gs://bucket-name/path/to/file`) are supported. The maximum file size + * is 100 MB. + * + * Generated from protobuf field string uri = 3; + * @param string $var + * @return $this + */ + public function setUri($var) + { + GPBUtil::checkString($var, True); + $this->writeOneof(3, $var); + + return $this; + } + + /** + * The MIME type of the content. Supported types: + * * `application/pdf` (PDF) + * * `text/html` (HTML) + * See https://www.iana.org/assignments/media-types/media-types.xhtml. + * + * Generated from protobuf field string mime_type = 1; + * @return string + */ + public function getMimeType() + { + return $this->mime_type; + } + + /** + * The MIME type of the content. Supported types: + * * `application/pdf` (PDF) + * * `text/html` (HTML) + * See https://www.iana.org/assignments/media-types/media-types.xhtml. + * + * Generated from protobuf field string mime_type = 1; + * @param string $var + * @return $this + */ + public function setMimeType($var) + { + GPBUtil::checkString($var, True); + $this->mime_type = $var; + + return $this; + } + + /** + * @return string + */ + public function getContent() + { + return $this->whichOneof("content"); + } + +} + + diff --git a/DiscoveryEngine/src/V1beta/DocumentInfo.php b/DiscoveryEngine/src/V1beta/DocumentInfo.php new file mode 100644 index 000000000000..f2f1a88132a0 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/DocumentInfo.php @@ -0,0 +1,213 @@ +google.cloud.discoveryengine.v1beta.DocumentInfo + */ +class DocumentInfo extends \Google\Protobuf\Internal\Message +{ + /** + * Quantity of the Document associated with the user event. Defaults to 1. + * For example, this field will be 2 if two quantities of the same Document + * are involved in a `add-to-cart` event. + * Required for events of the following event types: + * * `add-to-cart` + * * `purchase` + * + * Generated from protobuf field optional int32 quantity = 3; + */ + protected $quantity = null; + /** + * The promotion IDs associated with this Document. + * Currently, this field is restricted to at most one ID. + * + * Generated from protobuf field repeated string promotion_ids = 4; + */ + private $promotion_ids; + protected $document_descriptor; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $id + * Required. The Document resource ID. + * @type string $name + * Required. The Document resource full name, of the form: + * `projects/{project_id}/locations/{location}/collections/{collection_id}/dataStores/{data_store_id}/branches/{branch_id}/documents/{document_id}` + * @type int $quantity + * Quantity of the Document associated with the user event. Defaults to 1. + * For example, this field will be 2 if two quantities of the same Document + * are involved in a `add-to-cart` event. + * Required for events of the following event types: + * * `add-to-cart` + * * `purchase` + * @type array|\Google\Protobuf\Internal\RepeatedField $promotion_ids + * The promotion IDs associated with this Document. + * Currently, this field is restricted to at most one ID. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\UserEvent::initOnce(); + parent::__construct($data); + } + + /** + * Required. The Document resource ID. + * + * Generated from protobuf field string id = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getId() + { + return $this->readOneof(1); + } + + public function hasId() + { + return $this->hasOneof(1); + } + + /** + * Required. The Document resource ID. + * + * Generated from protobuf field string id = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setId($var) + { + GPBUtil::checkString($var, True); + $this->writeOneof(1, $var); + + return $this; + } + + /** + * Required. The Document resource full name, of the form: + * `projects/{project_id}/locations/{location}/collections/{collection_id}/dataStores/{data_store_id}/branches/{branch_id}/documents/{document_id}` + * + * Generated from protobuf field string name = 2 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getName() + { + return $this->readOneof(2); + } + + public function hasName() + { + return $this->hasOneof(2); + } + + /** + * Required. The Document resource full name, of the form: + * `projects/{project_id}/locations/{location}/collections/{collection_id}/dataStores/{data_store_id}/branches/{branch_id}/documents/{document_id}` + * + * Generated from protobuf field string name = 2 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->writeOneof(2, $var); + + return $this; + } + + /** + * Quantity of the Document associated with the user event. Defaults to 1. + * For example, this field will be 2 if two quantities of the same Document + * are involved in a `add-to-cart` event. + * Required for events of the following event types: + * * `add-to-cart` + * * `purchase` + * + * Generated from protobuf field optional int32 quantity = 3; + * @return int + */ + public function getQuantity() + { + return isset($this->quantity) ? $this->quantity : 0; + } + + public function hasQuantity() + { + return isset($this->quantity); + } + + public function clearQuantity() + { + unset($this->quantity); + } + + /** + * Quantity of the Document associated with the user event. Defaults to 1. + * For example, this field will be 2 if two quantities of the same Document + * are involved in a `add-to-cart` event. + * Required for events of the following event types: + * * `add-to-cart` + * * `purchase` + * + * Generated from protobuf field optional int32 quantity = 3; + * @param int $var + * @return $this + */ + public function setQuantity($var) + { + GPBUtil::checkInt32($var); + $this->quantity = $var; + + return $this; + } + + /** + * The promotion IDs associated with this Document. + * Currently, this field is restricted to at most one ID. + * + * Generated from protobuf field repeated string promotion_ids = 4; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getPromotionIds() + { + return $this->promotion_ids; + } + + /** + * The promotion IDs associated with this Document. + * Currently, this field is restricted to at most one ID. + * + * Generated from protobuf field repeated string promotion_ids = 4; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setPromotionIds($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->promotion_ids = $arr; + + return $this; + } + + /** + * @return string + */ + public function getDocumentDescriptor() + { + return $this->whichOneof("document_descriptor"); + } + +} + diff --git a/DiscoveryEngine/src/V1beta/GcsSource.php b/DiscoveryEngine/src/V1beta/GcsSource.php new file mode 100644 index 000000000000..cb3471dd119e --- /dev/null +++ b/DiscoveryEngine/src/V1beta/GcsSource.php @@ -0,0 +1,185 @@ +google.cloud.discoveryengine.v1beta.GcsSource + */ +class GcsSource extends \Google\Protobuf\Internal\Message +{ + /** + * Required. Cloud Storage URIs to input files. URI can be up to + * 2000 characters long. URIs can match the full object path (for example, + * `gs://bucket/directory/object.json`) or a pattern matching one or more + * files, such as `gs://bucket/directory/*.json`. + * A request can contain at most 100 files (or 100,000 files if `data_schema` + * is `content`). Each file can be up to 2 GB (or 100 MB if `data_schema` is + * `content`). + * + * Generated from protobuf field repeated string input_uris = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + private $input_uris; + /** + * The schema to use when parsing the data from the source. + * Supported values for document imports: + * * `document` (default): One JSON + * [Document][google.cloud.discoveryengine.v1beta.Document] per line. Each + * document must + * have a valid + * [Document.id][google.cloud.discoveryengine.v1beta.Document.id]. + * * `content`: Unstructured data (e.g. PDF, HTML). Each file matched by + * `input_uris` will become a document, with the ID set to the first 128 + * bits of SHA256(URI) encoded as a hex string. + * * `custom`: One custom data JSON per row in arbitrary format that conforms + * the defined [Schema][google.cloud.discoveryengine.v1beta.Schema] of the + * data store. This can only be used by the GENERIC Data Store vertical. + * Supported values for user even imports: + * * `user_event` (default): One JSON + * [UserEvent][google.cloud.discoveryengine.v1beta.UserEvent] per line. + * + * Generated from protobuf field string data_schema = 2; + */ + protected $data_schema = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array|\Google\Protobuf\Internal\RepeatedField $input_uris + * Required. Cloud Storage URIs to input files. URI can be up to + * 2000 characters long. URIs can match the full object path (for example, + * `gs://bucket/directory/object.json`) or a pattern matching one or more + * files, such as `gs://bucket/directory/*.json`. + * A request can contain at most 100 files (or 100,000 files if `data_schema` + * is `content`). Each file can be up to 2 GB (or 100 MB if `data_schema` is + * `content`). + * @type string $data_schema + * The schema to use when parsing the data from the source. + * Supported values for document imports: + * * `document` (default): One JSON + * [Document][google.cloud.discoveryengine.v1beta.Document] per line. Each + * document must + * have a valid + * [Document.id][google.cloud.discoveryengine.v1beta.Document.id]. + * * `content`: Unstructured data (e.g. PDF, HTML). Each file matched by + * `input_uris` will become a document, with the ID set to the first 128 + * bits of SHA256(URI) encoded as a hex string. + * * `custom`: One custom data JSON per row in arbitrary format that conforms + * the defined [Schema][google.cloud.discoveryengine.v1beta.Schema] of the + * data store. This can only be used by the GENERIC Data Store vertical. + * Supported values for user even imports: + * * `user_event` (default): One JSON + * [UserEvent][google.cloud.discoveryengine.v1beta.UserEvent] per line. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\ImportConfig::initOnce(); + parent::__construct($data); + } + + /** + * Required. Cloud Storage URIs to input files. URI can be up to + * 2000 characters long. URIs can match the full object path (for example, + * `gs://bucket/directory/object.json`) or a pattern matching one or more + * files, such as `gs://bucket/directory/*.json`. + * A request can contain at most 100 files (or 100,000 files if `data_schema` + * is `content`). Each file can be up to 2 GB (or 100 MB if `data_schema` is + * `content`). + * + * Generated from protobuf field repeated string input_uris = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getInputUris() + { + return $this->input_uris; + } + + /** + * Required. Cloud Storage URIs to input files. URI can be up to + * 2000 characters long. URIs can match the full object path (for example, + * `gs://bucket/directory/object.json`) or a pattern matching one or more + * files, such as `gs://bucket/directory/*.json`. + * A request can contain at most 100 files (or 100,000 files if `data_schema` + * is `content`). Each file can be up to 2 GB (or 100 MB if `data_schema` is + * `content`). + * + * Generated from protobuf field repeated string input_uris = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setInputUris($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->input_uris = $arr; + + return $this; + } + + /** + * The schema to use when parsing the data from the source. + * Supported values for document imports: + * * `document` (default): One JSON + * [Document][google.cloud.discoveryengine.v1beta.Document] per line. Each + * document must + * have a valid + * [Document.id][google.cloud.discoveryengine.v1beta.Document.id]. + * * `content`: Unstructured data (e.g. PDF, HTML). Each file matched by + * `input_uris` will become a document, with the ID set to the first 128 + * bits of SHA256(URI) encoded as a hex string. + * * `custom`: One custom data JSON per row in arbitrary format that conforms + * the defined [Schema][google.cloud.discoveryengine.v1beta.Schema] of the + * data store. This can only be used by the GENERIC Data Store vertical. + * Supported values for user even imports: + * * `user_event` (default): One JSON + * [UserEvent][google.cloud.discoveryengine.v1beta.UserEvent] per line. + * + * Generated from protobuf field string data_schema = 2; + * @return string + */ + public function getDataSchema() + { + return $this->data_schema; + } + + /** + * The schema to use when parsing the data from the source. + * Supported values for document imports: + * * `document` (default): One JSON + * [Document][google.cloud.discoveryengine.v1beta.Document] per line. Each + * document must + * have a valid + * [Document.id][google.cloud.discoveryengine.v1beta.Document.id]. + * * `content`: Unstructured data (e.g. PDF, HTML). Each file matched by + * `input_uris` will become a document, with the ID set to the first 128 + * bits of SHA256(URI) encoded as a hex string. + * * `custom`: One custom data JSON per row in arbitrary format that conforms + * the defined [Schema][google.cloud.discoveryengine.v1beta.Schema] of the + * data store. This can only be used by the GENERIC Data Store vertical. + * Supported values for user even imports: + * * `user_event` (default): One JSON + * [UserEvent][google.cloud.discoveryengine.v1beta.UserEvent] per line. + * + * Generated from protobuf field string data_schema = 2; + * @param string $var + * @return $this + */ + public function setDataSchema($var) + { + GPBUtil::checkString($var, True); + $this->data_schema = $var; + + return $this; + } + +} + diff --git a/DiscoveryEngine/src/V1beta/GetDocumentRequest.php b/DiscoveryEngine/src/V1beta/GetDocumentRequest.php new file mode 100644 index 000000000000..3a69b7e806d6 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/GetDocumentRequest.php @@ -0,0 +1,120 @@ +google.cloud.discoveryengine.v1beta.GetDocumentRequest + */ +class GetDocumentRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. Full resource name of + * [Document][google.cloud.discoveryengine.v1beta.Document], such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}`. + * If the caller does not have permission to access the + * [Document][google.cloud.discoveryengine.v1beta.Document], regardless of + * whether or not it exists, a `PERMISSION_DENIED` error is returned. + * If the requested [Document][google.cloud.discoveryengine.v1beta.Document] + * does not exist, a `NOT_FOUND` error is returned. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $name = ''; + + /** + * @param string $name Required. Full resource name of + * [Document][google.cloud.discoveryengine.v1beta.Document], such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}`. + * + * If the caller does not have permission to access the + * [Document][google.cloud.discoveryengine.v1beta.Document], regardless of + * whether or not it exists, a `PERMISSION_DENIED` error is returned. + * + * If the requested [Document][google.cloud.discoveryengine.v1beta.Document] + * does not exist, a `NOT_FOUND` error is returned. Please see + * {@see DocumentServiceClient::documentName()} for help formatting this field. + * + * @return \Google\Cloud\DiscoveryEngine\V1beta\GetDocumentRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. Full resource name of + * [Document][google.cloud.discoveryengine.v1beta.Document], such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}`. + * If the caller does not have permission to access the + * [Document][google.cloud.discoveryengine.v1beta.Document], regardless of + * whether or not it exists, a `PERMISSION_DENIED` error is returned. + * If the requested [Document][google.cloud.discoveryengine.v1beta.Document] + * does not exist, a `NOT_FOUND` error is returned. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\DocumentService::initOnce(); + parent::__construct($data); + } + + /** + * Required. Full resource name of + * [Document][google.cloud.discoveryengine.v1beta.Document], such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}`. + * If the caller does not have permission to access the + * [Document][google.cloud.discoveryengine.v1beta.Document], regardless of + * whether or not it exists, a `PERMISSION_DENIED` error is returned. + * If the requested [Document][google.cloud.discoveryengine.v1beta.Document] + * does not exist, a `NOT_FOUND` error is returned. + * + * 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. Full resource name of + * [Document][google.cloud.discoveryengine.v1beta.Document], such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}`. + * If the caller does not have permission to access the + * [Document][google.cloud.discoveryengine.v1beta.Document], regardless of + * whether or not it exists, a `PERMISSION_DENIED` error is returned. + * If the requested [Document][google.cloud.discoveryengine.v1beta.Document] + * does not exist, a `NOT_FOUND` error is returned. + * + * 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/DiscoveryEngine/src/V1beta/GetSchemaRequest.php b/DiscoveryEngine/src/V1beta/GetSchemaRequest.php new file mode 100644 index 000000000000..4e19a0e38020 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/GetSchemaRequest.php @@ -0,0 +1,88 @@ +google.cloud.discoveryengine.v1beta.GetSchemaRequest + */ +class GetSchemaRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The full resource name of the schema, in the format of + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $name = ''; + + /** + * @param string $name Required. The full resource name of the schema, in the format of + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}`. Please see + * {@see SchemaServiceClient::schemaName()} for help formatting this field. + * + * @return \Google\Cloud\DiscoveryEngine\V1beta\GetSchemaRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. The full resource name of the schema, in the format of + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\SchemaService::initOnce(); + parent::__construct($data); + } + + /** + * Required. The full resource name of the schema, in the format of + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}`. + * + * 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 full resource name of the schema, in the format of + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}`. + * + * 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/DiscoveryEngine/src/V1beta/ImportDocumentsMetadata.php b/DiscoveryEngine/src/V1beta/ImportDocumentsMetadata.php new file mode 100644 index 000000000000..16d7a70135e5 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/ImportDocumentsMetadata.php @@ -0,0 +1,194 @@ +google.cloud.discoveryengine.v1beta.ImportDocumentsMetadata + */ +class ImportDocumentsMetadata extends \Google\Protobuf\Internal\Message +{ + /** + * Operation create time. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 1; + */ + protected $create_time = null; + /** + * Operation last update time. If the operation is done, this is also the + * finish time. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 2; + */ + protected $update_time = null; + /** + * Count of entries that were processed successfully. + * + * Generated from protobuf field int64 success_count = 3; + */ + protected $success_count = 0; + /** + * Count of entries that encountered errors while processing. + * + * Generated from protobuf field int64 failure_count = 4; + */ + protected $failure_count = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Protobuf\Timestamp $create_time + * Operation create time. + * @type \Google\Protobuf\Timestamp $update_time + * Operation last update time. If the operation is done, this is also the + * finish time. + * @type int|string $success_count + * Count of entries that were processed successfully. + * @type int|string $failure_count + * Count of entries that encountered errors while processing. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\ImportConfig::initOnce(); + parent::__construct($data); + } + + /** + * Operation create time. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 1; + * @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); + } + + /** + * Operation create time. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 1; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setCreateTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->create_time = $var; + + return $this; + } + + /** + * Operation last update time. If the operation is done, this is also the + * finish time. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 2; + * @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); + } + + /** + * Operation last update time. If the operation is done, this is also the + * finish time. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 2; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setUpdateTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->update_time = $var; + + return $this; + } + + /** + * Count of entries that were processed successfully. + * + * Generated from protobuf field int64 success_count = 3; + * @return int|string + */ + public function getSuccessCount() + { + return $this->success_count; + } + + /** + * Count of entries that were processed successfully. + * + * Generated from protobuf field int64 success_count = 3; + * @param int|string $var + * @return $this + */ + public function setSuccessCount($var) + { + GPBUtil::checkInt64($var); + $this->success_count = $var; + + return $this; + } + + /** + * Count of entries that encountered errors while processing. + * + * Generated from protobuf field int64 failure_count = 4; + * @return int|string + */ + public function getFailureCount() + { + return $this->failure_count; + } + + /** + * Count of entries that encountered errors while processing. + * + * Generated from protobuf field int64 failure_count = 4; + * @param int|string $var + * @return $this + */ + public function setFailureCount($var) + { + GPBUtil::checkInt64($var); + $this->failure_count = $var; + + return $this; + } + +} + diff --git a/DiscoveryEngine/src/V1beta/ImportDocumentsRequest.php b/DiscoveryEngine/src/V1beta/ImportDocumentsRequest.php new file mode 100644 index 000000000000..5ccc6a06fd77 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/ImportDocumentsRequest.php @@ -0,0 +1,269 @@ +google.cloud.discoveryengine.v1beta.ImportDocumentsRequest + */ +class ImportDocumentsRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The parent branch resource name, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. + * Requires create/update permission. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $parent = ''; + /** + * The desired location of errors incurred during the Import. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.ImportErrorConfig error_config = 5; + */ + protected $error_config = null; + /** + * The mode of reconciliation between existing documents and the documents to + * be imported. Defaults to + * [ReconciliationMode.INCREMENTAL][google.cloud.discoveryengine.v1beta.ImportDocumentsRequest.ReconciliationMode.INCREMENTAL]. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.ImportDocumentsRequest.ReconciliationMode reconciliation_mode = 6; + */ + protected $reconciliation_mode = 0; + protected $source; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\DiscoveryEngine\V1beta\ImportDocumentsRequest\InlineSource $inline_source + * The Inline source for the input content for documents. + * @type \Google\Cloud\DiscoveryEngine\V1beta\GcsSource $gcs_source + * Cloud Storage location for the input content. + * @type \Google\Cloud\DiscoveryEngine\V1beta\BigQuerySource $bigquery_source + * BigQuery input source. + * @type string $parent + * Required. The parent branch resource name, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. + * Requires create/update permission. + * @type \Google\Cloud\DiscoveryEngine\V1beta\ImportErrorConfig $error_config + * The desired location of errors incurred during the Import. + * @type int $reconciliation_mode + * The mode of reconciliation between existing documents and the documents to + * be imported. Defaults to + * [ReconciliationMode.INCREMENTAL][google.cloud.discoveryengine.v1beta.ImportDocumentsRequest.ReconciliationMode.INCREMENTAL]. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\ImportConfig::initOnce(); + parent::__construct($data); + } + + /** + * The Inline source for the input content for documents. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.ImportDocumentsRequest.InlineSource inline_source = 2; + * @return \Google\Cloud\DiscoveryEngine\V1beta\ImportDocumentsRequest\InlineSource|null + */ + public function getInlineSource() + { + return $this->readOneof(2); + } + + public function hasInlineSource() + { + return $this->hasOneof(2); + } + + /** + * The Inline source for the input content for documents. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.ImportDocumentsRequest.InlineSource inline_source = 2; + * @param \Google\Cloud\DiscoveryEngine\V1beta\ImportDocumentsRequest\InlineSource $var + * @return $this + */ + public function setInlineSource($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\DiscoveryEngine\V1beta\ImportDocumentsRequest\InlineSource::class); + $this->writeOneof(2, $var); + + return $this; + } + + /** + * Cloud Storage location for the input content. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.GcsSource gcs_source = 3; + * @return \Google\Cloud\DiscoveryEngine\V1beta\GcsSource|null + */ + public function getGcsSource() + { + return $this->readOneof(3); + } + + public function hasGcsSource() + { + return $this->hasOneof(3); + } + + /** + * Cloud Storage location for the input content. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.GcsSource gcs_source = 3; + * @param \Google\Cloud\DiscoveryEngine\V1beta\GcsSource $var + * @return $this + */ + public function setGcsSource($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\DiscoveryEngine\V1beta\GcsSource::class); + $this->writeOneof(3, $var); + + return $this; + } + + /** + * BigQuery input source. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.BigQuerySource bigquery_source = 4; + * @return \Google\Cloud\DiscoveryEngine\V1beta\BigQuerySource|null + */ + public function getBigquerySource() + { + return $this->readOneof(4); + } + + public function hasBigquerySource() + { + return $this->hasOneof(4); + } + + /** + * BigQuery input source. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.BigQuerySource bigquery_source = 4; + * @param \Google\Cloud\DiscoveryEngine\V1beta\BigQuerySource $var + * @return $this + */ + public function setBigquerySource($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\DiscoveryEngine\V1beta\BigQuerySource::class); + $this->writeOneof(4, $var); + + return $this; + } + + /** + * Required. The parent branch resource name, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. + * Requires create/update permission. + * + * 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 branch resource name, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. + * Requires create/update permission. + * + * 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; + } + + /** + * The desired location of errors incurred during the Import. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.ImportErrorConfig error_config = 5; + * @return \Google\Cloud\DiscoveryEngine\V1beta\ImportErrorConfig|null + */ + public function getErrorConfig() + { + return $this->error_config; + } + + public function hasErrorConfig() + { + return isset($this->error_config); + } + + public function clearErrorConfig() + { + unset($this->error_config); + } + + /** + * The desired location of errors incurred during the Import. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.ImportErrorConfig error_config = 5; + * @param \Google\Cloud\DiscoveryEngine\V1beta\ImportErrorConfig $var + * @return $this + */ + public function setErrorConfig($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\DiscoveryEngine\V1beta\ImportErrorConfig::class); + $this->error_config = $var; + + return $this; + } + + /** + * The mode of reconciliation between existing documents and the documents to + * be imported. Defaults to + * [ReconciliationMode.INCREMENTAL][google.cloud.discoveryengine.v1beta.ImportDocumentsRequest.ReconciliationMode.INCREMENTAL]. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.ImportDocumentsRequest.ReconciliationMode reconciliation_mode = 6; + * @return int + */ + public function getReconciliationMode() + { + return $this->reconciliation_mode; + } + + /** + * The mode of reconciliation between existing documents and the documents to + * be imported. Defaults to + * [ReconciliationMode.INCREMENTAL][google.cloud.discoveryengine.v1beta.ImportDocumentsRequest.ReconciliationMode.INCREMENTAL]. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.ImportDocumentsRequest.ReconciliationMode reconciliation_mode = 6; + * @param int $var + * @return $this + */ + public function setReconciliationMode($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\DiscoveryEngine\V1beta\ImportDocumentsRequest\ReconciliationMode::class); + $this->reconciliation_mode = $var; + + return $this; + } + + /** + * @return string + */ + public function getSource() + { + return $this->whichOneof("source"); + } + +} + diff --git a/DiscoveryEngine/src/V1beta/ImportDocumentsRequest/InlineSource.php b/DiscoveryEngine/src/V1beta/ImportDocumentsRequest/InlineSource.php new file mode 100644 index 000000000000..e4f13d871bfb --- /dev/null +++ b/DiscoveryEngine/src/V1beta/ImportDocumentsRequest/InlineSource.php @@ -0,0 +1,76 @@ +google.cloud.discoveryengine.v1beta.ImportDocumentsRequest.InlineSource + */ +class InlineSource extends \Google\Protobuf\Internal\Message +{ + /** + * Required. A list of documents to update/create. Each document must have a + * valid [Document.id][google.cloud.discoveryengine.v1beta.Document.id]. + * Recommended max of 100 items. + * + * Generated from protobuf field repeated .google.cloud.discoveryengine.v1beta.Document documents = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + private $documents; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\Google\Cloud\DiscoveryEngine\V1beta\Document>|\Google\Protobuf\Internal\RepeatedField $documents + * Required. A list of documents to update/create. Each document must have a + * valid [Document.id][google.cloud.discoveryengine.v1beta.Document.id]. + * Recommended max of 100 items. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\ImportConfig::initOnce(); + parent::__construct($data); + } + + /** + * Required. A list of documents to update/create. Each document must have a + * valid [Document.id][google.cloud.discoveryengine.v1beta.Document.id]. + * Recommended max of 100 items. + * + * Generated from protobuf field repeated .google.cloud.discoveryengine.v1beta.Document documents = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getDocuments() + { + return $this->documents; + } + + /** + * Required. A list of documents to update/create. Each document must have a + * valid [Document.id][google.cloud.discoveryengine.v1beta.Document.id]. + * Recommended max of 100 items. + * + * Generated from protobuf field repeated .google.cloud.discoveryengine.v1beta.Document documents = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param array<\Google\Cloud\DiscoveryEngine\V1beta\Document>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setDocuments($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\DiscoveryEngine\V1beta\Document::class); + $this->documents = $arr; + + return $this; + } + +} + + diff --git a/DiscoveryEngine/src/V1beta/ImportDocumentsRequest/ReconciliationMode.php b/DiscoveryEngine/src/V1beta/ImportDocumentsRequest/ReconciliationMode.php new file mode 100644 index 000000000000..e1199eb0efde --- /dev/null +++ b/DiscoveryEngine/src/V1beta/ImportDocumentsRequest/ReconciliationMode.php @@ -0,0 +1,64 @@ +google.cloud.discoveryengine.v1beta.ImportDocumentsRequest.ReconciliationMode + */ +class ReconciliationMode +{ + /** + * Defaults to INCREMENTAL. + * + * Generated from protobuf enum RECONCILIATION_MODE_UNSPECIFIED = 0; + */ + const RECONCILIATION_MODE_UNSPECIFIED = 0; + /** + * Inserts new documents or updates existing documents. + * + * Generated from protobuf enum INCREMENTAL = 1; + */ + const INCREMENTAL = 1; + /** + * Calculates diff and replaces the entire document dataset. Existing + * documents may be deleted if they are not present in the source location. + * + * Generated from protobuf enum FULL = 2; + */ + const FULL = 2; + + private static $valueToName = [ + self::RECONCILIATION_MODE_UNSPECIFIED => 'RECONCILIATION_MODE_UNSPECIFIED', + self::INCREMENTAL => 'INCREMENTAL', + self::FULL => 'FULL', + ]; + + 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/DiscoveryEngine/src/V1beta/ImportDocumentsResponse.php b/DiscoveryEngine/src/V1beta/ImportDocumentsResponse.php new file mode 100644 index 000000000000..e7b7a892fb75 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/ImportDocumentsResponse.php @@ -0,0 +1,114 @@ +google.cloud.discoveryengine.v1beta.ImportDocumentsResponse + */ +class ImportDocumentsResponse extends \Google\Protobuf\Internal\Message +{ + /** + * A sample of errors encountered while processing the request. + * + * Generated from protobuf field repeated .google.rpc.Status error_samples = 1; + */ + private $error_samples; + /** + * Echoes the destination for the complete errors in the request if set. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.ImportErrorConfig error_config = 2; + */ + protected $error_config = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\Google\Rpc\Status>|\Google\Protobuf\Internal\RepeatedField $error_samples + * A sample of errors encountered while processing the request. + * @type \Google\Cloud\DiscoveryEngine\V1beta\ImportErrorConfig $error_config + * Echoes the destination for the complete errors in the request if set. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\ImportConfig::initOnce(); + parent::__construct($data); + } + + /** + * A sample of errors encountered while processing the request. + * + * Generated from protobuf field repeated .google.rpc.Status error_samples = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getErrorSamples() + { + return $this->error_samples; + } + + /** + * A sample of errors encountered while processing the request. + * + * Generated from protobuf field repeated .google.rpc.Status error_samples = 1; + * @param array<\Google\Rpc\Status>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setErrorSamples($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Rpc\Status::class); + $this->error_samples = $arr; + + return $this; + } + + /** + * Echoes the destination for the complete errors in the request if set. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.ImportErrorConfig error_config = 2; + * @return \Google\Cloud\DiscoveryEngine\V1beta\ImportErrorConfig|null + */ + public function getErrorConfig() + { + return $this->error_config; + } + + public function hasErrorConfig() + { + return isset($this->error_config); + } + + public function clearErrorConfig() + { + unset($this->error_config); + } + + /** + * Echoes the destination for the complete errors in the request if set. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.ImportErrorConfig error_config = 2; + * @param \Google\Cloud\DiscoveryEngine\V1beta\ImportErrorConfig $var + * @return $this + */ + public function setErrorConfig($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\DiscoveryEngine\V1beta\ImportErrorConfig::class); + $this->error_config = $var; + + return $this; + } + +} + diff --git a/DiscoveryEngine/src/V1beta/ImportErrorConfig.php b/DiscoveryEngine/src/V1beta/ImportErrorConfig.php new file mode 100644 index 000000000000..13587c527081 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/ImportErrorConfig.php @@ -0,0 +1,84 @@ +google.cloud.discoveryengine.v1beta.ImportErrorConfig + */ +class ImportErrorConfig extends \Google\Protobuf\Internal\Message +{ + protected $destination; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $gcs_prefix + * Cloud Storage prefix for import errors. This must be an empty, + * existing Cloud Storage directory. Import errors will be written to + * sharded files in this directory, one per line, as a JSON-encoded + * `google.rpc.Status` message. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\ImportConfig::initOnce(); + parent::__construct($data); + } + + /** + * Cloud Storage prefix for import errors. This must be an empty, + * existing Cloud Storage directory. Import errors will be written to + * sharded files in this directory, one per line, as a JSON-encoded + * `google.rpc.Status` message. + * + * Generated from protobuf field string gcs_prefix = 1; + * @return string + */ + public function getGcsPrefix() + { + return $this->readOneof(1); + } + + public function hasGcsPrefix() + { + return $this->hasOneof(1); + } + + /** + * Cloud Storage prefix for import errors. This must be an empty, + * existing Cloud Storage directory. Import errors will be written to + * sharded files in this directory, one per line, as a JSON-encoded + * `google.rpc.Status` message. + * + * Generated from protobuf field string gcs_prefix = 1; + * @param string $var + * @return $this + */ + public function setGcsPrefix($var) + { + GPBUtil::checkString($var, True); + $this->writeOneof(1, $var); + + return $this; + } + + /** + * @return string + */ + public function getDestination() + { + return $this->whichOneof("destination"); + } + +} + diff --git a/DiscoveryEngine/src/V1beta/ImportUserEventsMetadata.php b/DiscoveryEngine/src/V1beta/ImportUserEventsMetadata.php new file mode 100644 index 000000000000..7ec7afad623d --- /dev/null +++ b/DiscoveryEngine/src/V1beta/ImportUserEventsMetadata.php @@ -0,0 +1,194 @@ +google.cloud.discoveryengine.v1beta.ImportUserEventsMetadata + */ +class ImportUserEventsMetadata extends \Google\Protobuf\Internal\Message +{ + /** + * Operation create time. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 1; + */ + protected $create_time = null; + /** + * Operation last update time. If the operation is done, this is also the + * finish time. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 2; + */ + protected $update_time = null; + /** + * Count of entries that were processed successfully. + * + * Generated from protobuf field int64 success_count = 3; + */ + protected $success_count = 0; + /** + * Count of entries that encountered errors while processing. + * + * Generated from protobuf field int64 failure_count = 4; + */ + protected $failure_count = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Protobuf\Timestamp $create_time + * Operation create time. + * @type \Google\Protobuf\Timestamp $update_time + * Operation last update time. If the operation is done, this is also the + * finish time. + * @type int|string $success_count + * Count of entries that were processed successfully. + * @type int|string $failure_count + * Count of entries that encountered errors while processing. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\ImportConfig::initOnce(); + parent::__construct($data); + } + + /** + * Operation create time. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 1; + * @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); + } + + /** + * Operation create time. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 1; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setCreateTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->create_time = $var; + + return $this; + } + + /** + * Operation last update time. If the operation is done, this is also the + * finish time. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 2; + * @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); + } + + /** + * Operation last update time. If the operation is done, this is also the + * finish time. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 2; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setUpdateTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->update_time = $var; + + return $this; + } + + /** + * Count of entries that were processed successfully. + * + * Generated from protobuf field int64 success_count = 3; + * @return int|string + */ + public function getSuccessCount() + { + return $this->success_count; + } + + /** + * Count of entries that were processed successfully. + * + * Generated from protobuf field int64 success_count = 3; + * @param int|string $var + * @return $this + */ + public function setSuccessCount($var) + { + GPBUtil::checkInt64($var); + $this->success_count = $var; + + return $this; + } + + /** + * Count of entries that encountered errors while processing. + * + * Generated from protobuf field int64 failure_count = 4; + * @return int|string + */ + public function getFailureCount() + { + return $this->failure_count; + } + + /** + * Count of entries that encountered errors while processing. + * + * Generated from protobuf field int64 failure_count = 4; + * @param int|string $var + * @return $this + */ + public function setFailureCount($var) + { + GPBUtil::checkInt64($var); + $this->failure_count = $var; + + return $this; + } + +} + diff --git a/DiscoveryEngine/src/V1beta/ImportUserEventsRequest.php b/DiscoveryEngine/src/V1beta/ImportUserEventsRequest.php new file mode 100644 index 000000000000..efac6cfedb93 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/ImportUserEventsRequest.php @@ -0,0 +1,227 @@ +google.cloud.discoveryengine.v1beta.ImportUserEventsRequest + */ +class ImportUserEventsRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. Parent DataStore resource name, of the form + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}` + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $parent = ''; + /** + * The desired location of errors incurred during the Import. Cannot be set + * for inline user event imports. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.ImportErrorConfig error_config = 5; + */ + protected $error_config = null; + protected $source; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\DiscoveryEngine\V1beta\ImportUserEventsRequest\InlineSource $inline_source + * Required. The Inline source for the input content for UserEvents. + * @type \Google\Cloud\DiscoveryEngine\V1beta\GcsSource $gcs_source + * Required. Cloud Storage location for the input content. + * @type \Google\Cloud\DiscoveryEngine\V1beta\BigQuerySource $bigquery_source + * Required. BigQuery input source. + * @type string $parent + * Required. Parent DataStore resource name, of the form + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}` + * @type \Google\Cloud\DiscoveryEngine\V1beta\ImportErrorConfig $error_config + * The desired location of errors incurred during the Import. Cannot be set + * for inline user event imports. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\ImportConfig::initOnce(); + parent::__construct($data); + } + + /** + * Required. The Inline source for the input content for UserEvents. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.ImportUserEventsRequest.InlineSource inline_source = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\DiscoveryEngine\V1beta\ImportUserEventsRequest\InlineSource|null + */ + public function getInlineSource() + { + return $this->readOneof(2); + } + + public function hasInlineSource() + { + return $this->hasOneof(2); + } + + /** + * Required. The Inline source for the input content for UserEvents. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.ImportUserEventsRequest.InlineSource inline_source = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\DiscoveryEngine\V1beta\ImportUserEventsRequest\InlineSource $var + * @return $this + */ + public function setInlineSource($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\DiscoveryEngine\V1beta\ImportUserEventsRequest\InlineSource::class); + $this->writeOneof(2, $var); + + return $this; + } + + /** + * Required. Cloud Storage location for the input content. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.GcsSource gcs_source = 3 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\DiscoveryEngine\V1beta\GcsSource|null + */ + public function getGcsSource() + { + return $this->readOneof(3); + } + + public function hasGcsSource() + { + return $this->hasOneof(3); + } + + /** + * Required. Cloud Storage location for the input content. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.GcsSource gcs_source = 3 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\DiscoveryEngine\V1beta\GcsSource $var + * @return $this + */ + public function setGcsSource($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\DiscoveryEngine\V1beta\GcsSource::class); + $this->writeOneof(3, $var); + + return $this; + } + + /** + * Required. BigQuery input source. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.BigQuerySource bigquery_source = 4 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\DiscoveryEngine\V1beta\BigQuerySource|null + */ + public function getBigquerySource() + { + return $this->readOneof(4); + } + + public function hasBigquerySource() + { + return $this->hasOneof(4); + } + + /** + * Required. BigQuery input source. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.BigQuerySource bigquery_source = 4 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\DiscoveryEngine\V1beta\BigQuerySource $var + * @return $this + */ + public function setBigquerySource($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\DiscoveryEngine\V1beta\BigQuerySource::class); + $this->writeOneof(4, $var); + + return $this; + } + + /** + * Required. Parent DataStore resource name, of the form + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}` + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * Required. Parent DataStore resource name, of the form + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}` + * + * 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; + } + + /** + * The desired location of errors incurred during the Import. Cannot be set + * for inline user event imports. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.ImportErrorConfig error_config = 5; + * @return \Google\Cloud\DiscoveryEngine\V1beta\ImportErrorConfig|null + */ + public function getErrorConfig() + { + return $this->error_config; + } + + public function hasErrorConfig() + { + return isset($this->error_config); + } + + public function clearErrorConfig() + { + unset($this->error_config); + } + + /** + * The desired location of errors incurred during the Import. Cannot be set + * for inline user event imports. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.ImportErrorConfig error_config = 5; + * @param \Google\Cloud\DiscoveryEngine\V1beta\ImportErrorConfig $var + * @return $this + */ + public function setErrorConfig($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\DiscoveryEngine\V1beta\ImportErrorConfig::class); + $this->error_config = $var; + + return $this; + } + + /** + * @return string + */ + public function getSource() + { + return $this->whichOneof("source"); + } + +} + diff --git a/DiscoveryEngine/src/V1beta/ImportUserEventsRequest/InlineSource.php b/DiscoveryEngine/src/V1beta/ImportUserEventsRequest/InlineSource.php new file mode 100644 index 000000000000..eab1428f4bca --- /dev/null +++ b/DiscoveryEngine/src/V1beta/ImportUserEventsRequest/InlineSource.php @@ -0,0 +1,68 @@ +google.cloud.discoveryengine.v1beta.ImportUserEventsRequest.InlineSource + */ +class InlineSource extends \Google\Protobuf\Internal\Message +{ + /** + * Required. A list of user events to import. Recommended max of 10k items. + * + * Generated from protobuf field repeated .google.cloud.discoveryengine.v1beta.UserEvent user_events = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + private $user_events; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\Google\Cloud\DiscoveryEngine\V1beta\UserEvent>|\Google\Protobuf\Internal\RepeatedField $user_events + * Required. A list of user events to import. Recommended max of 10k items. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\ImportConfig::initOnce(); + parent::__construct($data); + } + + /** + * Required. A list of user events to import. Recommended max of 10k items. + * + * Generated from protobuf field repeated .google.cloud.discoveryengine.v1beta.UserEvent user_events = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getUserEvents() + { + return $this->user_events; + } + + /** + * Required. A list of user events to import. Recommended max of 10k items. + * + * Generated from protobuf field repeated .google.cloud.discoveryengine.v1beta.UserEvent user_events = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param array<\Google\Cloud\DiscoveryEngine\V1beta\UserEvent>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setUserEvents($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\DiscoveryEngine\V1beta\UserEvent::class); + $this->user_events = $arr; + + return $this; + } + +} + + diff --git a/DiscoveryEngine/src/V1beta/ImportUserEventsResponse.php b/DiscoveryEngine/src/V1beta/ImportUserEventsResponse.php new file mode 100644 index 000000000000..e7fcdc3bd028 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/ImportUserEventsResponse.php @@ -0,0 +1,189 @@ +google.cloud.discoveryengine.v1beta.ImportUserEventsResponse + */ +class ImportUserEventsResponse extends \Google\Protobuf\Internal\Message +{ + /** + * A sample of errors encountered while processing the request. + * + * Generated from protobuf field repeated .google.rpc.Status error_samples = 1; + */ + private $error_samples; + /** + * Echoes the destination for the complete errors if this field was set in + * the request. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.ImportErrorConfig error_config = 2; + */ + protected $error_config = null; + /** + * Count of user events imported with complete existing Documents. + * + * Generated from protobuf field int64 joined_events_count = 3; + */ + protected $joined_events_count = 0; + /** + * Count of user events imported, but with Document information not found + * in the existing Branch. + * + * Generated from protobuf field int64 unjoined_events_count = 4; + */ + protected $unjoined_events_count = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\Google\Rpc\Status>|\Google\Protobuf\Internal\RepeatedField $error_samples + * A sample of errors encountered while processing the request. + * @type \Google\Cloud\DiscoveryEngine\V1beta\ImportErrorConfig $error_config + * Echoes the destination for the complete errors if this field was set in + * the request. + * @type int|string $joined_events_count + * Count of user events imported with complete existing Documents. + * @type int|string $unjoined_events_count + * Count of user events imported, but with Document information not found + * in the existing Branch. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\ImportConfig::initOnce(); + parent::__construct($data); + } + + /** + * A sample of errors encountered while processing the request. + * + * Generated from protobuf field repeated .google.rpc.Status error_samples = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getErrorSamples() + { + return $this->error_samples; + } + + /** + * A sample of errors encountered while processing the request. + * + * Generated from protobuf field repeated .google.rpc.Status error_samples = 1; + * @param array<\Google\Rpc\Status>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setErrorSamples($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Rpc\Status::class); + $this->error_samples = $arr; + + return $this; + } + + /** + * Echoes the destination for the complete errors if this field was set in + * the request. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.ImportErrorConfig error_config = 2; + * @return \Google\Cloud\DiscoveryEngine\V1beta\ImportErrorConfig|null + */ + public function getErrorConfig() + { + return $this->error_config; + } + + public function hasErrorConfig() + { + return isset($this->error_config); + } + + public function clearErrorConfig() + { + unset($this->error_config); + } + + /** + * Echoes the destination for the complete errors if this field was set in + * the request. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.ImportErrorConfig error_config = 2; + * @param \Google\Cloud\DiscoveryEngine\V1beta\ImportErrorConfig $var + * @return $this + */ + public function setErrorConfig($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\DiscoveryEngine\V1beta\ImportErrorConfig::class); + $this->error_config = $var; + + return $this; + } + + /** + * Count of user events imported with complete existing Documents. + * + * Generated from protobuf field int64 joined_events_count = 3; + * @return int|string + */ + public function getJoinedEventsCount() + { + return $this->joined_events_count; + } + + /** + * Count of user events imported with complete existing Documents. + * + * Generated from protobuf field int64 joined_events_count = 3; + * @param int|string $var + * @return $this + */ + public function setJoinedEventsCount($var) + { + GPBUtil::checkInt64($var); + $this->joined_events_count = $var; + + return $this; + } + + /** + * Count of user events imported, but with Document information not found + * in the existing Branch. + * + * Generated from protobuf field int64 unjoined_events_count = 4; + * @return int|string + */ + public function getUnjoinedEventsCount() + { + return $this->unjoined_events_count; + } + + /** + * Count of user events imported, but with Document information not found + * in the existing Branch. + * + * Generated from protobuf field int64 unjoined_events_count = 4; + * @param int|string $var + * @return $this + */ + public function setUnjoinedEventsCount($var) + { + GPBUtil::checkInt64($var); + $this->unjoined_events_count = $var; + + return $this; + } + +} + diff --git a/DiscoveryEngine/src/V1beta/Interval.php b/DiscoveryEngine/src/V1beta/Interval.php new file mode 100644 index 000000000000..0b49a3c8d689 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/Interval.php @@ -0,0 +1,183 @@ +google.cloud.discoveryengine.v1beta.Interval + */ +class Interval extends \Google\Protobuf\Internal\Message +{ + protected $min; + protected $max; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type float $minimum + * Inclusive lower bound. + * @type float $exclusive_minimum + * Exclusive lower bound. + * @type float $maximum + * Inclusive upper bound. + * @type float $exclusive_maximum + * Exclusive upper bound. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\Common::initOnce(); + parent::__construct($data); + } + + /** + * Inclusive lower bound. + * + * Generated from protobuf field double minimum = 1; + * @return float + */ + public function getMinimum() + { + return $this->readOneof(1); + } + + public function hasMinimum() + { + return $this->hasOneof(1); + } + + /** + * Inclusive lower bound. + * + * Generated from protobuf field double minimum = 1; + * @param float $var + * @return $this + */ + public function setMinimum($var) + { + GPBUtil::checkDouble($var); + $this->writeOneof(1, $var); + + return $this; + } + + /** + * Exclusive lower bound. + * + * Generated from protobuf field double exclusive_minimum = 2; + * @return float + */ + public function getExclusiveMinimum() + { + return $this->readOneof(2); + } + + public function hasExclusiveMinimum() + { + return $this->hasOneof(2); + } + + /** + * Exclusive lower bound. + * + * Generated from protobuf field double exclusive_minimum = 2; + * @param float $var + * @return $this + */ + public function setExclusiveMinimum($var) + { + GPBUtil::checkDouble($var); + $this->writeOneof(2, $var); + + return $this; + } + + /** + * Inclusive upper bound. + * + * Generated from protobuf field double maximum = 3; + * @return float + */ + public function getMaximum() + { + return $this->readOneof(3); + } + + public function hasMaximum() + { + return $this->hasOneof(3); + } + + /** + * Inclusive upper bound. + * + * Generated from protobuf field double maximum = 3; + * @param float $var + * @return $this + */ + public function setMaximum($var) + { + GPBUtil::checkDouble($var); + $this->writeOneof(3, $var); + + return $this; + } + + /** + * Exclusive upper bound. + * + * Generated from protobuf field double exclusive_maximum = 4; + * @return float + */ + public function getExclusiveMaximum() + { + return $this->readOneof(4); + } + + public function hasExclusiveMaximum() + { + return $this->hasOneof(4); + } + + /** + * Exclusive upper bound. + * + * Generated from protobuf field double exclusive_maximum = 4; + * @param float $var + * @return $this + */ + public function setExclusiveMaximum($var) + { + GPBUtil::checkDouble($var); + $this->writeOneof(4, $var); + + return $this; + } + + /** + * @return string + */ + public function getMin() + { + return $this->whichOneof("min"); + } + + /** + * @return string + */ + public function getMax() + { + return $this->whichOneof("max"); + } + +} + diff --git a/DiscoveryEngine/src/V1beta/ListDocumentsRequest.php b/DiscoveryEngine/src/V1beta/ListDocumentsRequest.php new file mode 100644 index 000000000000..2f2126fce3cc --- /dev/null +++ b/DiscoveryEngine/src/V1beta/ListDocumentsRequest.php @@ -0,0 +1,226 @@ +google.cloud.discoveryengine.v1beta.ListDocumentsRequest + */ +class ListDocumentsRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The parent branch resource name, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. + * Use `default_branch` as the branch ID, to list documents under the default + * branch. + * If the caller does not have permission to list [Documents][]s under this + * branch, regardless of whether or not this branch exists, a + * `PERMISSION_DENIED` error is returned. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $parent = ''; + /** + * Maximum number of [Document][google.cloud.discoveryengine.v1beta.Document]s + * to return. If unspecified, defaults to 100. The maximum allowed value is + * 1000. Values above 1000 will be coerced to 1000. + * If this field is negative, an `INVALID_ARGUMENT` error is returned. + * + * Generated from protobuf field int32 page_size = 2; + */ + protected $page_size = 0; + /** + * A page token + * [ListDocumentsResponse.next_page_token][google.cloud.discoveryengine.v1beta.ListDocumentsResponse.next_page_token], + * received from a previous + * [DocumentService.ListDocuments][google.cloud.discoveryengine.v1beta.DocumentService.ListDocuments] + * call. Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to + * [DocumentService.ListDocuments][google.cloud.discoveryengine.v1beta.DocumentService.ListDocuments] + * must match the call that provided the page token. Otherwise, an + * `INVALID_ARGUMENT` error is returned. + * + * Generated from protobuf field string page_token = 3; + */ + protected $page_token = ''; + + /** + * @param string $parent Required. The parent branch resource name, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. + * Use `default_branch` as the branch ID, to list documents under the default + * branch. + * + * If the caller does not have permission to list [Documents][]s under this + * branch, regardless of whether or not this branch exists, a + * `PERMISSION_DENIED` error is returned. Please see + * {@see DocumentServiceClient::branchName()} for help formatting this field. + * + * @return \Google\Cloud\DiscoveryEngine\V1beta\ListDocumentsRequest + * + * @experimental + */ + public static function build(string $parent): self + { + return (new self()) + ->setParent($parent); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. The parent branch resource name, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. + * Use `default_branch` as the branch ID, to list documents under the default + * branch. + * If the caller does not have permission to list [Documents][]s under this + * branch, regardless of whether or not this branch exists, a + * `PERMISSION_DENIED` error is returned. + * @type int $page_size + * Maximum number of [Document][google.cloud.discoveryengine.v1beta.Document]s + * to return. If unspecified, defaults to 100. The maximum allowed value is + * 1000. Values above 1000 will be coerced to 1000. + * If this field is negative, an `INVALID_ARGUMENT` error is returned. + * @type string $page_token + * A page token + * [ListDocumentsResponse.next_page_token][google.cloud.discoveryengine.v1beta.ListDocumentsResponse.next_page_token], + * received from a previous + * [DocumentService.ListDocuments][google.cloud.discoveryengine.v1beta.DocumentService.ListDocuments] + * call. Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to + * [DocumentService.ListDocuments][google.cloud.discoveryengine.v1beta.DocumentService.ListDocuments] + * must match the call that provided the page token. Otherwise, an + * `INVALID_ARGUMENT` error is returned. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\DocumentService::initOnce(); + parent::__construct($data); + } + + /** + * Required. The parent branch resource name, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. + * Use `default_branch` as the branch ID, to list documents under the default + * branch. + * If the caller does not have permission to list [Documents][]s under this + * branch, regardless of whether or not this branch exists, a + * `PERMISSION_DENIED` error is returned. + * + * 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 branch resource name, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. + * Use `default_branch` as the branch ID, to list documents under the default + * branch. + * If the caller does not have permission to list [Documents][]s under this + * branch, regardless of whether or not this branch exists, a + * `PERMISSION_DENIED` error is returned. + * + * 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; + } + + /** + * Maximum number of [Document][google.cloud.discoveryengine.v1beta.Document]s + * to return. If unspecified, defaults to 100. The maximum allowed value is + * 1000. Values above 1000 will be coerced to 1000. + * If this field is negative, an `INVALID_ARGUMENT` error is returned. + * + * Generated from protobuf field int32 page_size = 2; + * @return int + */ + public function getPageSize() + { + return $this->page_size; + } + + /** + * Maximum number of [Document][google.cloud.discoveryengine.v1beta.Document]s + * to return. If unspecified, defaults to 100. The maximum allowed value is + * 1000. Values above 1000 will be coerced to 1000. + * If this field is negative, an `INVALID_ARGUMENT` error is returned. + * + * Generated from protobuf field int32 page_size = 2; + * @param int $var + * @return $this + */ + public function setPageSize($var) + { + GPBUtil::checkInt32($var); + $this->page_size = $var; + + return $this; + } + + /** + * A page token + * [ListDocumentsResponse.next_page_token][google.cloud.discoveryengine.v1beta.ListDocumentsResponse.next_page_token], + * received from a previous + * [DocumentService.ListDocuments][google.cloud.discoveryengine.v1beta.DocumentService.ListDocuments] + * call. Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to + * [DocumentService.ListDocuments][google.cloud.discoveryengine.v1beta.DocumentService.ListDocuments] + * must match the call that provided the page token. Otherwise, an + * `INVALID_ARGUMENT` error is returned. + * + * Generated from protobuf field string page_token = 3; + * @return string + */ + public function getPageToken() + { + return $this->page_token; + } + + /** + * A page token + * [ListDocumentsResponse.next_page_token][google.cloud.discoveryengine.v1beta.ListDocumentsResponse.next_page_token], + * received from a previous + * [DocumentService.ListDocuments][google.cloud.discoveryengine.v1beta.DocumentService.ListDocuments] + * call. Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to + * [DocumentService.ListDocuments][google.cloud.discoveryengine.v1beta.DocumentService.ListDocuments] + * must match the call that provided the page token. Otherwise, an + * `INVALID_ARGUMENT` error is returned. + * + * Generated from protobuf field string page_token = 3; + * @param string $var + * @return $this + */ + public function setPageToken($var) + { + GPBUtil::checkString($var, True); + $this->page_token = $var; + + return $this; + } + +} + diff --git a/DiscoveryEngine/src/V1beta/ListDocumentsResponse.php b/DiscoveryEngine/src/V1beta/ListDocumentsResponse.php new file mode 100644 index 000000000000..1d2842848b1d --- /dev/null +++ b/DiscoveryEngine/src/V1beta/ListDocumentsResponse.php @@ -0,0 +1,115 @@ +google.cloud.discoveryengine.v1beta.ListDocumentsResponse + */ +class ListDocumentsResponse extends \Google\Protobuf\Internal\Message +{ + /** + * The [Document][google.cloud.discoveryengine.v1beta.Document]s. + * + * Generated from protobuf field repeated .google.cloud.discoveryengine.v1beta.Document documents = 1; + */ + private $documents; + /** + * A token that can be sent as + * [ListDocumentsRequest.page_token][google.cloud.discoveryengine.v1beta.ListDocumentsRequest.page_token] + * to retrieve the next page. If this field is omitted, there are no + * subsequent pages. + * + * Generated from protobuf field string next_page_token = 2; + */ + protected $next_page_token = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\Google\Cloud\DiscoveryEngine\V1beta\Document>|\Google\Protobuf\Internal\RepeatedField $documents + * The [Document][google.cloud.discoveryengine.v1beta.Document]s. + * @type string $next_page_token + * A token that can be sent as + * [ListDocumentsRequest.page_token][google.cloud.discoveryengine.v1beta.ListDocumentsRequest.page_token] + * to retrieve the next page. If this field is omitted, there are no + * subsequent pages. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\DocumentService::initOnce(); + parent::__construct($data); + } + + /** + * The [Document][google.cloud.discoveryengine.v1beta.Document]s. + * + * Generated from protobuf field repeated .google.cloud.discoveryengine.v1beta.Document documents = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getDocuments() + { + return $this->documents; + } + + /** + * The [Document][google.cloud.discoveryengine.v1beta.Document]s. + * + * Generated from protobuf field repeated .google.cloud.discoveryengine.v1beta.Document documents = 1; + * @param array<\Google\Cloud\DiscoveryEngine\V1beta\Document>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setDocuments($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\DiscoveryEngine\V1beta\Document::class); + $this->documents = $arr; + + return $this; + } + + /** + * A token that can be sent as + * [ListDocumentsRequest.page_token][google.cloud.discoveryengine.v1beta.ListDocumentsRequest.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 that can be sent as + * [ListDocumentsRequest.page_token][google.cloud.discoveryengine.v1beta.ListDocumentsRequest.page_token] + * to retrieve the next page. If this field is omitted, there are no + * subsequent pages. + * + * Generated from protobuf field string next_page_token = 2; + * @param string $var + * @return $this + */ + public function setNextPageToken($var) + { + GPBUtil::checkString($var, True); + $this->next_page_token = $var; + + return $this; + } + +} + diff --git a/DiscoveryEngine/src/V1beta/ListSchemasRequest.php b/DiscoveryEngine/src/V1beta/ListSchemasRequest.php new file mode 100644 index 000000000000..d1de3973ccbd --- /dev/null +++ b/DiscoveryEngine/src/V1beta/ListSchemasRequest.php @@ -0,0 +1,192 @@ +google.cloud.discoveryengine.v1beta.ListSchemasRequest + */ +class ListSchemasRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The parent data store resource name, in the format of + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $parent = ''; + /** + * The maximum number of [Schema][google.cloud.discoveryengine.v1beta.Schema]s + * to return. The service may return fewer than this value. + * If unspecified, at most 100 + * [Schema][google.cloud.discoveryengine.v1beta.Schema]s will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * + * Generated from protobuf field int32 page_size = 2; + */ + protected $page_size = 0; + /** + * A page token, received from a previous + * [SchemaService.ListSchemas][google.cloud.discoveryengine.v1beta.SchemaService.ListSchemas] + * call. Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to + * [SchemaService.ListSchemas][google.cloud.discoveryengine.v1beta.SchemaService.ListSchemas] + * must match the call that provided the page token. + * + * Generated from protobuf field string page_token = 3; + */ + protected $page_token = ''; + + /** + * @param string $parent Required. The parent data store resource name, in the format of + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. Please see + * {@see SchemaServiceClient::dataStoreName()} for help formatting this field. + * + * @return \Google\Cloud\DiscoveryEngine\V1beta\ListSchemasRequest + * + * @experimental + */ + public static function build(string $parent): self + { + return (new self()) + ->setParent($parent); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. The parent data store resource name, in the format of + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. + * @type int $page_size + * The maximum number of [Schema][google.cloud.discoveryengine.v1beta.Schema]s + * to return. The service may return fewer than this value. + * If unspecified, at most 100 + * [Schema][google.cloud.discoveryengine.v1beta.Schema]s will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @type string $page_token + * A page token, received from a previous + * [SchemaService.ListSchemas][google.cloud.discoveryengine.v1beta.SchemaService.ListSchemas] + * call. Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to + * [SchemaService.ListSchemas][google.cloud.discoveryengine.v1beta.SchemaService.ListSchemas] + * must match the call that provided the page token. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\SchemaService::initOnce(); + parent::__construct($data); + } + + /** + * Required. The parent data store resource name, in the format of + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. + * + * 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 data store resource name, in the format of + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. + * + * 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; + } + + /** + * The maximum number of [Schema][google.cloud.discoveryengine.v1beta.Schema]s + * to return. The service may return fewer than this value. + * If unspecified, at most 100 + * [Schema][google.cloud.discoveryengine.v1beta.Schema]s will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * + * Generated from protobuf field int32 page_size = 2; + * @return int + */ + public function getPageSize() + { + return $this->page_size; + } + + /** + * The maximum number of [Schema][google.cloud.discoveryengine.v1beta.Schema]s + * to return. The service may return fewer than this value. + * If unspecified, at most 100 + * [Schema][google.cloud.discoveryengine.v1beta.Schema]s will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * + * Generated from protobuf field int32 page_size = 2; + * @param int $var + * @return $this + */ + public function setPageSize($var) + { + GPBUtil::checkInt32($var); + $this->page_size = $var; + + return $this; + } + + /** + * A page token, received from a previous + * [SchemaService.ListSchemas][google.cloud.discoveryengine.v1beta.SchemaService.ListSchemas] + * call. Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to + * [SchemaService.ListSchemas][google.cloud.discoveryengine.v1beta.SchemaService.ListSchemas] + * must match the call that provided the page token. + * + * Generated from protobuf field string page_token = 3; + * @return string + */ + public function getPageToken() + { + return $this->page_token; + } + + /** + * A page token, received from a previous + * [SchemaService.ListSchemas][google.cloud.discoveryengine.v1beta.SchemaService.ListSchemas] + * call. Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to + * [SchemaService.ListSchemas][google.cloud.discoveryengine.v1beta.SchemaService.ListSchemas] + * must match the call that provided the page token. + * + * Generated from protobuf field string page_token = 3; + * @param string $var + * @return $this + */ + public function setPageToken($var) + { + GPBUtil::checkString($var, True); + $this->page_token = $var; + + return $this; + } + +} + diff --git a/DiscoveryEngine/src/V1beta/ListSchemasResponse.php b/DiscoveryEngine/src/V1beta/ListSchemasResponse.php new file mode 100644 index 000000000000..f99765b34761 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/ListSchemasResponse.php @@ -0,0 +1,115 @@ +google.cloud.discoveryengine.v1beta.ListSchemasResponse + */ +class ListSchemasResponse extends \Google\Protobuf\Internal\Message +{ + /** + * The [Schema][google.cloud.discoveryengine.v1beta.Schema]s. + * + * Generated from protobuf field repeated .google.cloud.discoveryengine.v1beta.Schema schemas = 1; + */ + private $schemas; + /** + * A token that can be sent as + * [ListSchemasRequest.page_token][google.cloud.discoveryengine.v1beta.ListSchemasRequest.page_token] + * to retrieve the next page. If this field is omitted, there are no + * subsequent pages. + * + * Generated from protobuf field string next_page_token = 2; + */ + protected $next_page_token = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\Google\Cloud\DiscoveryEngine\V1beta\Schema>|\Google\Protobuf\Internal\RepeatedField $schemas + * The [Schema][google.cloud.discoveryengine.v1beta.Schema]s. + * @type string $next_page_token + * A token that can be sent as + * [ListSchemasRequest.page_token][google.cloud.discoveryengine.v1beta.ListSchemasRequest.page_token] + * to retrieve the next page. If this field is omitted, there are no + * subsequent pages. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\SchemaService::initOnce(); + parent::__construct($data); + } + + /** + * The [Schema][google.cloud.discoveryengine.v1beta.Schema]s. + * + * Generated from protobuf field repeated .google.cloud.discoveryengine.v1beta.Schema schemas = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getSchemas() + { + return $this->schemas; + } + + /** + * The [Schema][google.cloud.discoveryengine.v1beta.Schema]s. + * + * Generated from protobuf field repeated .google.cloud.discoveryengine.v1beta.Schema schemas = 1; + * @param array<\Google\Cloud\DiscoveryEngine\V1beta\Schema>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setSchemas($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\DiscoveryEngine\V1beta\Schema::class); + $this->schemas = $arr; + + return $this; + } + + /** + * A token that can be sent as + * [ListSchemasRequest.page_token][google.cloud.discoveryengine.v1beta.ListSchemasRequest.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 that can be sent as + * [ListSchemasRequest.page_token][google.cloud.discoveryengine.v1beta.ListSchemasRequest.page_token] + * to retrieve the next page. If this field is omitted, there are no + * subsequent pages. + * + * Generated from protobuf field string next_page_token = 2; + * @param string $var + * @return $this + */ + public function setNextPageToken($var) + { + GPBUtil::checkString($var, True); + $this->next_page_token = $var; + + return $this; + } + +} + diff --git a/DiscoveryEngine/src/V1beta/MediaInfo.php b/DiscoveryEngine/src/V1beta/MediaInfo.php new file mode 100644 index 000000000000..44834c68deda --- /dev/null +++ b/DiscoveryEngine/src/V1beta/MediaInfo.php @@ -0,0 +1,149 @@ +google.cloud.discoveryengine.v1beta.MediaInfo + */ +class MediaInfo extends \Google\Protobuf\Internal\Message +{ + /** + * The media progress time in seconds, if applicable. + * For example, if the end user has finished 90 seconds of a playback video, + * then [MediaInfo.media_progress_duration.seconds][Duration.seconds] should + * be set to 90. + * + * Generated from protobuf field .google.protobuf.Duration media_progress_duration = 1; + */ + protected $media_progress_duration = null; + /** + * Media progress should be computed using only the media_progress_duration + * relative to the media total length. + * This value must be between `[0, 1.0]` inclusive. + * If this is not a playback or the progress cannot be computed (e.g. ongoing + * livestream), this field should be unset. + * + * Generated from protobuf field optional float media_progress_percentage = 2; + */ + protected $media_progress_percentage = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Protobuf\Duration $media_progress_duration + * The media progress time in seconds, if applicable. + * For example, if the end user has finished 90 seconds of a playback video, + * then [MediaInfo.media_progress_duration.seconds][Duration.seconds] should + * be set to 90. + * @type float $media_progress_percentage + * Media progress should be computed using only the media_progress_duration + * relative to the media total length. + * This value must be between `[0, 1.0]` inclusive. + * If this is not a playback or the progress cannot be computed (e.g. ongoing + * livestream), this field should be unset. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\UserEvent::initOnce(); + parent::__construct($data); + } + + /** + * The media progress time in seconds, if applicable. + * For example, if the end user has finished 90 seconds of a playback video, + * then [MediaInfo.media_progress_duration.seconds][Duration.seconds] should + * be set to 90. + * + * Generated from protobuf field .google.protobuf.Duration media_progress_duration = 1; + * @return \Google\Protobuf\Duration|null + */ + public function getMediaProgressDuration() + { + return $this->media_progress_duration; + } + + public function hasMediaProgressDuration() + { + return isset($this->media_progress_duration); + } + + public function clearMediaProgressDuration() + { + unset($this->media_progress_duration); + } + + /** + * The media progress time in seconds, if applicable. + * For example, if the end user has finished 90 seconds of a playback video, + * then [MediaInfo.media_progress_duration.seconds][Duration.seconds] should + * be set to 90. + * + * Generated from protobuf field .google.protobuf.Duration media_progress_duration = 1; + * @param \Google\Protobuf\Duration $var + * @return $this + */ + public function setMediaProgressDuration($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Duration::class); + $this->media_progress_duration = $var; + + return $this; + } + + /** + * Media progress should be computed using only the media_progress_duration + * relative to the media total length. + * This value must be between `[0, 1.0]` inclusive. + * If this is not a playback or the progress cannot be computed (e.g. ongoing + * livestream), this field should be unset. + * + * Generated from protobuf field optional float media_progress_percentage = 2; + * @return float + */ + public function getMediaProgressPercentage() + { + return isset($this->media_progress_percentage) ? $this->media_progress_percentage : 0.0; + } + + public function hasMediaProgressPercentage() + { + return isset($this->media_progress_percentage); + } + + public function clearMediaProgressPercentage() + { + unset($this->media_progress_percentage); + } + + /** + * Media progress should be computed using only the media_progress_duration + * relative to the media total length. + * This value must be between `[0, 1.0]` inclusive. + * If this is not a playback or the progress cannot be computed (e.g. ongoing + * livestream), this field should be unset. + * + * Generated from protobuf field optional float media_progress_percentage = 2; + * @param float $var + * @return $this + */ + public function setMediaProgressPercentage($var) + { + GPBUtil::checkFloat($var); + $this->media_progress_percentage = $var; + + return $this; + } + +} + diff --git a/DiscoveryEngine/src/V1beta/PageInfo.php b/DiscoveryEngine/src/V1beta/PageInfo.php new file mode 100644 index 000000000000..c23014301f01 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/PageInfo.php @@ -0,0 +1,253 @@ +google.cloud.discoveryengine.v1beta.PageInfo + */ +class PageInfo extends \Google\Protobuf\Internal\Message +{ + /** + * A unique ID of a web page view. + * This should be kept the same for all user events triggered from the same + * pageview. For example, an item detail page view could trigger multiple + * events as the user is browsing the page. The `pageViewId` property should + * be kept the same for all these events so that they can be grouped together + * properly. + * When using the client side event reporting with JavaScript pixel and Google + * Tag Manager, this value is filled in automatically. + * + * Generated from protobuf field string pageview_id = 1; + */ + protected $pageview_id = ''; + /** + * The most specific category associated with a category page. + * To represent full path of category, use '>' sign to separate different + * hierarchies. If '>' is part of the category name, please replace it with + * other character(s). + * Category pages include special pages such as sales or promotions. For + * instance, a special sale page may have the category hierarchy: + * "pageCategory" : "Sales > 2017 Black Friday Deals". + * Required for `view-category-page` events. Other event types should not set + * this field. Otherwise, an INVALID_ARGUMENT error is returned. + * + * Generated from protobuf field string page_category = 2; + */ + protected $page_category = ''; + /** + * Complete URL (window.location.href) of the user's current page. + * When using the client side event reporting with JavaScript pixel and Google + * Tag Manager, this value is filled in automatically. Maximum length 5,000 + * characters. + * + * Generated from protobuf field string uri = 3; + */ + protected $uri = ''; + /** + * The referrer URL of the current page. + * When using the client side event reporting with JavaScript pixel and Google + * Tag Manager, this value is filled in automatically. However, some browser + * privacy restrictions may cause this field to be empty. + * + * Generated from protobuf field string referrer_uri = 4; + */ + protected $referrer_uri = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $pageview_id + * A unique ID of a web page view. + * This should be kept the same for all user events triggered from the same + * pageview. For example, an item detail page view could trigger multiple + * events as the user is browsing the page. The `pageViewId` property should + * be kept the same for all these events so that they can be grouped together + * properly. + * When using the client side event reporting with JavaScript pixel and Google + * Tag Manager, this value is filled in automatically. + * @type string $page_category + * The most specific category associated with a category page. + * To represent full path of category, use '>' sign to separate different + * hierarchies. If '>' is part of the category name, please replace it with + * other character(s). + * Category pages include special pages such as sales or promotions. For + * instance, a special sale page may have the category hierarchy: + * "pageCategory" : "Sales > 2017 Black Friday Deals". + * Required for `view-category-page` events. Other event types should not set + * this field. Otherwise, an INVALID_ARGUMENT error is returned. + * @type string $uri + * Complete URL (window.location.href) of the user's current page. + * When using the client side event reporting with JavaScript pixel and Google + * Tag Manager, this value is filled in automatically. Maximum length 5,000 + * characters. + * @type string $referrer_uri + * The referrer URL of the current page. + * When using the client side event reporting with JavaScript pixel and Google + * Tag Manager, this value is filled in automatically. However, some browser + * privacy restrictions may cause this field to be empty. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\UserEvent::initOnce(); + parent::__construct($data); + } + + /** + * A unique ID of a web page view. + * This should be kept the same for all user events triggered from the same + * pageview. For example, an item detail page view could trigger multiple + * events as the user is browsing the page. The `pageViewId` property should + * be kept the same for all these events so that they can be grouped together + * properly. + * When using the client side event reporting with JavaScript pixel and Google + * Tag Manager, this value is filled in automatically. + * + * Generated from protobuf field string pageview_id = 1; + * @return string + */ + public function getPageviewId() + { + return $this->pageview_id; + } + + /** + * A unique ID of a web page view. + * This should be kept the same for all user events triggered from the same + * pageview. For example, an item detail page view could trigger multiple + * events as the user is browsing the page. The `pageViewId` property should + * be kept the same for all these events so that they can be grouped together + * properly. + * When using the client side event reporting with JavaScript pixel and Google + * Tag Manager, this value is filled in automatically. + * + * Generated from protobuf field string pageview_id = 1; + * @param string $var + * @return $this + */ + public function setPageviewId($var) + { + GPBUtil::checkString($var, True); + $this->pageview_id = $var; + + return $this; + } + + /** + * The most specific category associated with a category page. + * To represent full path of category, use '>' sign to separate different + * hierarchies. If '>' is part of the category name, please replace it with + * other character(s). + * Category pages include special pages such as sales or promotions. For + * instance, a special sale page may have the category hierarchy: + * "pageCategory" : "Sales > 2017 Black Friday Deals". + * Required for `view-category-page` events. Other event types should not set + * this field. Otherwise, an INVALID_ARGUMENT error is returned. + * + * Generated from protobuf field string page_category = 2; + * @return string + */ + public function getPageCategory() + { + return $this->page_category; + } + + /** + * The most specific category associated with a category page. + * To represent full path of category, use '>' sign to separate different + * hierarchies. If '>' is part of the category name, please replace it with + * other character(s). + * Category pages include special pages such as sales or promotions. For + * instance, a special sale page may have the category hierarchy: + * "pageCategory" : "Sales > 2017 Black Friday Deals". + * Required for `view-category-page` events. Other event types should not set + * this field. Otherwise, an INVALID_ARGUMENT error is returned. + * + * Generated from protobuf field string page_category = 2; + * @param string $var + * @return $this + */ + public function setPageCategory($var) + { + GPBUtil::checkString($var, True); + $this->page_category = $var; + + return $this; + } + + /** + * Complete URL (window.location.href) of the user's current page. + * When using the client side event reporting with JavaScript pixel and Google + * Tag Manager, this value is filled in automatically. Maximum length 5,000 + * characters. + * + * Generated from protobuf field string uri = 3; + * @return string + */ + public function getUri() + { + return $this->uri; + } + + /** + * Complete URL (window.location.href) of the user's current page. + * When using the client side event reporting with JavaScript pixel and Google + * Tag Manager, this value is filled in automatically. Maximum length 5,000 + * characters. + * + * Generated from protobuf field string uri = 3; + * @param string $var + * @return $this + */ + public function setUri($var) + { + GPBUtil::checkString($var, True); + $this->uri = $var; + + return $this; + } + + /** + * The referrer URL of the current page. + * When using the client side event reporting with JavaScript pixel and Google + * Tag Manager, this value is filled in automatically. However, some browser + * privacy restrictions may cause this field to be empty. + * + * Generated from protobuf field string referrer_uri = 4; + * @return string + */ + public function getReferrerUri() + { + return $this->referrer_uri; + } + + /** + * The referrer URL of the current page. + * When using the client side event reporting with JavaScript pixel and Google + * Tag Manager, this value is filled in automatically. However, some browser + * privacy restrictions may cause this field to be empty. + * + * Generated from protobuf field string referrer_uri = 4; + * @param string $var + * @return $this + */ + public function setReferrerUri($var) + { + GPBUtil::checkString($var, True); + $this->referrer_uri = $var; + + return $this; + } + +} + diff --git a/DiscoveryEngine/src/V1beta/PanelInfo.php b/DiscoveryEngine/src/V1beta/PanelInfo.php new file mode 100644 index 000000000000..4e6f18a8604f --- /dev/null +++ b/DiscoveryEngine/src/V1beta/PanelInfo.php @@ -0,0 +1,213 @@ +google.cloud.discoveryengine.v1beta.PanelInfo + */ +class PanelInfo extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The panel ID. + * + * Generated from protobuf field string panel_id = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $panel_id = ''; + /** + * The display name of the panel. + * + * Generated from protobuf field string display_name = 3; + */ + protected $display_name = ''; + /** + * The ordered position of the panel, if shown to the user with other panels. + * If set, then + * [total_panels][google.cloud.discoveryengine.v1beta.PanelInfo.total_panels] + * must also be set. + * + * Generated from protobuf field optional int32 panel_position = 4; + */ + protected $panel_position = null; + /** + * The total number of panels, including this one, shown to the user. + * Must be set if + * [panel_position][google.cloud.discoveryengine.v1beta.PanelInfo.panel_position] + * is set. + * + * Generated from protobuf field optional int32 total_panels = 5; + */ + protected $total_panels = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $panel_id + * Required. The panel ID. + * @type string $display_name + * The display name of the panel. + * @type int $panel_position + * The ordered position of the panel, if shown to the user with other panels. + * If set, then + * [total_panels][google.cloud.discoveryengine.v1beta.PanelInfo.total_panels] + * must also be set. + * @type int $total_panels + * The total number of panels, including this one, shown to the user. + * Must be set if + * [panel_position][google.cloud.discoveryengine.v1beta.PanelInfo.panel_position] + * is set. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\UserEvent::initOnce(); + parent::__construct($data); + } + + /** + * Required. The panel ID. + * + * Generated from protobuf field string panel_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getPanelId() + { + return $this->panel_id; + } + + /** + * Required. The panel ID. + * + * Generated from protobuf field string panel_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setPanelId($var) + { + GPBUtil::checkString($var, True); + $this->panel_id = $var; + + return $this; + } + + /** + * The display name of the panel. + * + * Generated from protobuf field string display_name = 3; + * @return string + */ + public function getDisplayName() + { + return $this->display_name; + } + + /** + * The display name of the panel. + * + * Generated from protobuf field string display_name = 3; + * @param string $var + * @return $this + */ + public function setDisplayName($var) + { + GPBUtil::checkString($var, True); + $this->display_name = $var; + + return $this; + } + + /** + * The ordered position of the panel, if shown to the user with other panels. + * If set, then + * [total_panels][google.cloud.discoveryengine.v1beta.PanelInfo.total_panels] + * must also be set. + * + * Generated from protobuf field optional int32 panel_position = 4; + * @return int + */ + public function getPanelPosition() + { + return isset($this->panel_position) ? $this->panel_position : 0; + } + + public function hasPanelPosition() + { + return isset($this->panel_position); + } + + public function clearPanelPosition() + { + unset($this->panel_position); + } + + /** + * The ordered position of the panel, if shown to the user with other panels. + * If set, then + * [total_panels][google.cloud.discoveryengine.v1beta.PanelInfo.total_panels] + * must also be set. + * + * Generated from protobuf field optional int32 panel_position = 4; + * @param int $var + * @return $this + */ + public function setPanelPosition($var) + { + GPBUtil::checkInt32($var); + $this->panel_position = $var; + + return $this; + } + + /** + * The total number of panels, including this one, shown to the user. + * Must be set if + * [panel_position][google.cloud.discoveryengine.v1beta.PanelInfo.panel_position] + * is set. + * + * Generated from protobuf field optional int32 total_panels = 5; + * @return int + */ + public function getTotalPanels() + { + return isset($this->total_panels) ? $this->total_panels : 0; + } + + public function hasTotalPanels() + { + return isset($this->total_panels); + } + + public function clearTotalPanels() + { + unset($this->total_panels); + } + + /** + * The total number of panels, including this one, shown to the user. + * Must be set if + * [panel_position][google.cloud.discoveryengine.v1beta.PanelInfo.panel_position] + * is set. + * + * Generated from protobuf field optional int32 total_panels = 5; + * @param int $var + * @return $this + */ + public function setTotalPanels($var) + { + GPBUtil::checkInt32($var); + $this->total_panels = $var; + + return $this; + } + +} + diff --git a/DiscoveryEngine/src/V1beta/PurgeDocumentsMetadata.php b/DiscoveryEngine/src/V1beta/PurgeDocumentsMetadata.php new file mode 100644 index 000000000000..3207bdbf6122 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/PurgeDocumentsMetadata.php @@ -0,0 +1,194 @@ +google.cloud.discoveryengine.v1beta.PurgeDocumentsMetadata + */ +class PurgeDocumentsMetadata extends \Google\Protobuf\Internal\Message +{ + /** + * Operation create time. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 1; + */ + protected $create_time = null; + /** + * Operation last update time. If the operation is done, this is also the + * finish time. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 2; + */ + protected $update_time = null; + /** + * Count of entries that were deleted successfully. + * + * Generated from protobuf field int64 success_count = 3; + */ + protected $success_count = 0; + /** + * Count of entries that encountered errors while processing. + * + * Generated from protobuf field int64 failure_count = 4; + */ + protected $failure_count = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Protobuf\Timestamp $create_time + * Operation create time. + * @type \Google\Protobuf\Timestamp $update_time + * Operation last update time. If the operation is done, this is also the + * finish time. + * @type int|string $success_count + * Count of entries that were deleted successfully. + * @type int|string $failure_count + * Count of entries that encountered errors while processing. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\PurgeConfig::initOnce(); + parent::__construct($data); + } + + /** + * Operation create time. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 1; + * @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); + } + + /** + * Operation create time. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 1; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setCreateTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->create_time = $var; + + return $this; + } + + /** + * Operation last update time. If the operation is done, this is also the + * finish time. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 2; + * @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); + } + + /** + * Operation last update time. If the operation is done, this is also the + * finish time. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 2; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setUpdateTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->update_time = $var; + + return $this; + } + + /** + * Count of entries that were deleted successfully. + * + * Generated from protobuf field int64 success_count = 3; + * @return int|string + */ + public function getSuccessCount() + { + return $this->success_count; + } + + /** + * Count of entries that were deleted successfully. + * + * Generated from protobuf field int64 success_count = 3; + * @param int|string $var + * @return $this + */ + public function setSuccessCount($var) + { + GPBUtil::checkInt64($var); + $this->success_count = $var; + + return $this; + } + + /** + * Count of entries that encountered errors while processing. + * + * Generated from protobuf field int64 failure_count = 4; + * @return int|string + */ + public function getFailureCount() + { + return $this->failure_count; + } + + /** + * Count of entries that encountered errors while processing. + * + * Generated from protobuf field int64 failure_count = 4; + * @param int|string $var + * @return $this + */ + public function setFailureCount($var) + { + GPBUtil::checkInt64($var); + $this->failure_count = $var; + + return $this; + } + +} + diff --git a/DiscoveryEngine/src/V1beta/PurgeDocumentsRequest.php b/DiscoveryEngine/src/V1beta/PurgeDocumentsRequest.php new file mode 100644 index 000000000000..99adaad192e5 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/PurgeDocumentsRequest.php @@ -0,0 +1,153 @@ +google.cloud.discoveryengine.v1beta.PurgeDocumentsRequest + */ +class PurgeDocumentsRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The parent resource name, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $parent = ''; + /** + * Required. Filter matching documents to purge. Only currently supported + * value is + * `*` (all items). + * + * Generated from protobuf field string filter = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $filter = ''; + /** + * Actually performs the purge. If `force` is set to false, return the + * expected purge count without deleting any documents. + * + * Generated from protobuf field bool force = 3; + */ + protected $force = false; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. The parent resource name, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. + * @type string $filter + * Required. Filter matching documents to purge. Only currently supported + * value is + * `*` (all items). + * @type bool $force + * Actually performs the purge. If `force` is set to false, return the + * expected purge count without deleting any documents. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\PurgeConfig::initOnce(); + parent::__construct($data); + } + + /** + * Required. The parent resource name, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * Required. The parent resource name, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. + * + * 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. Filter matching documents to purge. Only currently supported + * value is + * `*` (all items). + * + * Generated from protobuf field string filter = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getFilter() + { + return $this->filter; + } + + /** + * Required. Filter matching documents to purge. Only currently supported + * value is + * `*` (all items). + * + * Generated from protobuf field string filter = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setFilter($var) + { + GPBUtil::checkString($var, True); + $this->filter = $var; + + return $this; + } + + /** + * Actually performs the purge. If `force` is set to false, return the + * expected purge count without deleting any documents. + * + * Generated from protobuf field bool force = 3; + * @return bool + */ + public function getForce() + { + return $this->force; + } + + /** + * Actually performs the purge. If `force` is set to false, return the + * expected purge count without deleting any documents. + * + * Generated from protobuf field bool force = 3; + * @param bool $var + * @return $this + */ + public function setForce($var) + { + GPBUtil::checkBool($var); + $this->force = $var; + + return $this; + } + +} + diff --git a/DiscoveryEngine/src/V1beta/PurgeDocumentsResponse.php b/DiscoveryEngine/src/V1beta/PurgeDocumentsResponse.php new file mode 100644 index 000000000000..fd207e22e4f6 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/PurgeDocumentsResponse.php @@ -0,0 +1,112 @@ +google.cloud.discoveryengine.v1beta.PurgeDocumentsResponse + */ +class PurgeDocumentsResponse extends \Google\Protobuf\Internal\Message +{ + /** + * The total count of documents purged as a result of the operation. + * + * Generated from protobuf field int64 purge_count = 1; + */ + protected $purge_count = 0; + /** + * A sample of document names that will be deleted. Only populated if `force` + * is set to false. A max of 100 names will be returned and the names are + * chosen at random. + * + * Generated from protobuf field repeated string purge_sample = 2 [(.google.api.resource_reference) = { + */ + private $purge_sample; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int|string $purge_count + * The total count of documents purged as a result of the operation. + * @type array|\Google\Protobuf\Internal\RepeatedField $purge_sample + * A sample of document names that will be deleted. Only populated if `force` + * is set to false. A max of 100 names will be returned and the names are + * chosen at random. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\PurgeConfig::initOnce(); + parent::__construct($data); + } + + /** + * The total count of documents purged as a result of the operation. + * + * Generated from protobuf field int64 purge_count = 1; + * @return int|string + */ + public function getPurgeCount() + { + return $this->purge_count; + } + + /** + * The total count of documents purged as a result of the operation. + * + * Generated from protobuf field int64 purge_count = 1; + * @param int|string $var + * @return $this + */ + public function setPurgeCount($var) + { + GPBUtil::checkInt64($var); + $this->purge_count = $var; + + return $this; + } + + /** + * A sample of document names that will be deleted. Only populated if `force` + * is set to false. A max of 100 names will be returned and the names are + * chosen at random. + * + * Generated from protobuf field repeated string purge_sample = 2 [(.google.api.resource_reference) = { + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getPurgeSample() + { + return $this->purge_sample; + } + + /** + * A sample of document names that will be deleted. Only populated if `force` + * is set to false. A max of 100 names will be returned and the names are + * chosen at random. + * + * Generated from protobuf field repeated string purge_sample = 2 [(.google.api.resource_reference) = { + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setPurgeSample($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->purge_sample = $arr; + + return $this; + } + +} + diff --git a/DiscoveryEngine/src/V1beta/RecommendRequest.php b/DiscoveryEngine/src/V1beta/RecommendRequest.php new file mode 100644 index 000000000000..e433ed62c9ae --- /dev/null +++ b/DiscoveryEngine/src/V1beta/RecommendRequest.php @@ -0,0 +1,565 @@ +google.cloud.discoveryengine.v1beta.RecommendRequest + */ +class RecommendRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. Full resource name of the format: + * `projects/*/locations/global/collections/*/dataStores/*/servingConfigs/*` + * Before you can request recommendations from your model, you must create at + * least one serving config for it. + * + * Generated from protobuf field string serving_config = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $serving_config = ''; + /** + * Required. Context about the user, what they are looking at and what action + * they took to trigger the Recommend request. Note that this user event + * detail won't be ingested to userEvent logs. Thus, a separate userEvent + * write request is required for event logging. + * Don't set + * [UserEvent.user_pseudo_id][google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id] + * or + * [UserEvent.user_info.user_id][google.cloud.discoveryengine.v1beta.UserInfo.user_id] + * to the same fixed ID for different users. If you are trying to receive + * non-personalized recommendations (not recommended; this can negatively + * impact model performance), instead set + * [UserEvent.user_pseudo_id][google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id] + * to a random unique ID and leave + * [UserEvent.user_info.user_id][google.cloud.discoveryengine.v1beta.UserInfo.user_id] + * unset. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.UserEvent user_event = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $user_event = null; + /** + * Maximum number of results to return. Set this property + * to the number of recommendation results needed. If zero, the service will + * choose a reasonable default. The maximum allowed value is 100. Values + * above 100 will be coerced to 100. + * + * Generated from protobuf field int32 page_size = 3; + */ + protected $page_size = 0; + /** + * Filter for restricting recommendation results with a length limit of 5,000 + * characters. Currently, only filter expressions on the `filter_tags` + * attribute is supported. + * Examples: + * * `(filter_tags: ANY("Red", "Blue") OR filter_tags: ANY("Hot", "Cold"))` + * * `(filter_tags: ANY("Red", "Blue")) AND NOT (filter_tags: ANY("Green"))` + * If your filter blocks all results, the API will return generic + * (unfiltered) popular Documents. If you only want results strictly matching + * the filters, set `strictFiltering` to True in + * [RecommendRequest.params][google.cloud.discoveryengine.v1beta.RecommendRequest.params] + * to receive empty results instead. + * Note that the API will never return + * [Document][google.cloud.discoveryengine.v1beta.Document]s with + * `storageStatus` of `EXPIRED` or `DELETED` regardless of filter choices. + * + * Generated from protobuf field string filter = 4; + */ + protected $filter = ''; + /** + * Use validate only mode for this recommendation query. If set to true, a + * fake model will be used that returns arbitrary Document IDs. + * Note that the validate only mode should only be used for testing the API, + * or if the model is not ready. + * + * Generated from protobuf field bool validate_only = 5; + */ + protected $validate_only = false; + /** + * Additional domain specific parameters for the recommendations. + * Allowed values: + * * `returnDocument`: Boolean. If set to true, the associated Document + * object will be returned in + * [RecommendResponse.RecommendationResult.document][google.cloud.discoveryengine.v1beta.RecommendResponse.RecommendationResult.document]. + * * `returnScore`: Boolean. If set to true, the recommendation 'score' + * corresponding to each returned Document will be set in + * [RecommendResponse.RecommendationResult.metadata][google.cloud.discoveryengine.v1beta.RecommendResponse.RecommendationResult.metadata]. + * The given 'score' indicates the probability of a Document conversion + * given the user's context and history. + * * `strictFiltering`: Boolean. True by default. If set to false, the service + * will return generic (unfiltered) popular Documents instead of empty if + * your filter blocks all recommendation results. + * * `diversityLevel`: String. Default empty. If set to be non-empty, then + * it needs to be one of: + * * `no-diversity` + * * `low-diversity` + * * `medium-diversity` + * * `high-diversity` + * * `auto-diversity` + * This gives request-level control and adjusts recommendation results + * based on Document category. + * + * Generated from protobuf field map params = 6; + */ + private $params; + /** + * The user labels applied to a resource must meet the following requirements: + * * Each resource can have multiple labels, up to a maximum of 64. + * * Each label must be a key-value pair. + * * Keys have a minimum length of 1 character and a maximum length of 63 + * characters and cannot be empty. Values can be empty and have a maximum + * length of 63 characters. + * * Keys and values can contain only lowercase letters, numeric characters, + * underscores, and dashes. All characters must use UTF-8 encoding, and + * international characters are allowed. + * * The key portion of a label must be unique. However, you can use the same + * key with multiple resources. + * * Keys must start with a lowercase letter or international character. + * See [Requirements for + * labels](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + * for more details. + * + * Generated from protobuf field map user_labels = 8; + */ + private $user_labels; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $serving_config + * Required. Full resource name of the format: + * `projects/*/locations/global/collections/*/dataStores/*/servingConfigs/*` + * Before you can request recommendations from your model, you must create at + * least one serving config for it. + * @type \Google\Cloud\DiscoveryEngine\V1beta\UserEvent $user_event + * Required. Context about the user, what they are looking at and what action + * they took to trigger the Recommend request. Note that this user event + * detail won't be ingested to userEvent logs. Thus, a separate userEvent + * write request is required for event logging. + * Don't set + * [UserEvent.user_pseudo_id][google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id] + * or + * [UserEvent.user_info.user_id][google.cloud.discoveryengine.v1beta.UserInfo.user_id] + * to the same fixed ID for different users. If you are trying to receive + * non-personalized recommendations (not recommended; this can negatively + * impact model performance), instead set + * [UserEvent.user_pseudo_id][google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id] + * to a random unique ID and leave + * [UserEvent.user_info.user_id][google.cloud.discoveryengine.v1beta.UserInfo.user_id] + * unset. + * @type int $page_size + * Maximum number of results to return. Set this property + * to the number of recommendation results needed. If zero, the service will + * choose a reasonable default. The maximum allowed value is 100. Values + * above 100 will be coerced to 100. + * @type string $filter + * Filter for restricting recommendation results with a length limit of 5,000 + * characters. Currently, only filter expressions on the `filter_tags` + * attribute is supported. + * Examples: + * * `(filter_tags: ANY("Red", "Blue") OR filter_tags: ANY("Hot", "Cold"))` + * * `(filter_tags: ANY("Red", "Blue")) AND NOT (filter_tags: ANY("Green"))` + * If your filter blocks all results, the API will return generic + * (unfiltered) popular Documents. If you only want results strictly matching + * the filters, set `strictFiltering` to True in + * [RecommendRequest.params][google.cloud.discoveryengine.v1beta.RecommendRequest.params] + * to receive empty results instead. + * Note that the API will never return + * [Document][google.cloud.discoveryengine.v1beta.Document]s with + * `storageStatus` of `EXPIRED` or `DELETED` regardless of filter choices. + * @type bool $validate_only + * Use validate only mode for this recommendation query. If set to true, a + * fake model will be used that returns arbitrary Document IDs. + * Note that the validate only mode should only be used for testing the API, + * or if the model is not ready. + * @type array|\Google\Protobuf\Internal\MapField $params + * Additional domain specific parameters for the recommendations. + * Allowed values: + * * `returnDocument`: Boolean. If set to true, the associated Document + * object will be returned in + * [RecommendResponse.RecommendationResult.document][google.cloud.discoveryengine.v1beta.RecommendResponse.RecommendationResult.document]. + * * `returnScore`: Boolean. If set to true, the recommendation 'score' + * corresponding to each returned Document will be set in + * [RecommendResponse.RecommendationResult.metadata][google.cloud.discoveryengine.v1beta.RecommendResponse.RecommendationResult.metadata]. + * The given 'score' indicates the probability of a Document conversion + * given the user's context and history. + * * `strictFiltering`: Boolean. True by default. If set to false, the service + * will return generic (unfiltered) popular Documents instead of empty if + * your filter blocks all recommendation results. + * * `diversityLevel`: String. Default empty. If set to be non-empty, then + * it needs to be one of: + * * `no-diversity` + * * `low-diversity` + * * `medium-diversity` + * * `high-diversity` + * * `auto-diversity` + * This gives request-level control and adjusts recommendation results + * based on Document category. + * @type array|\Google\Protobuf\Internal\MapField $user_labels + * The user labels applied to a resource must meet the following requirements: + * * Each resource can have multiple labels, up to a maximum of 64. + * * Each label must be a key-value pair. + * * Keys have a minimum length of 1 character and a maximum length of 63 + * characters and cannot be empty. Values can be empty and have a maximum + * length of 63 characters. + * * Keys and values can contain only lowercase letters, numeric characters, + * underscores, and dashes. All characters must use UTF-8 encoding, and + * international characters are allowed. + * * The key portion of a label must be unique. However, you can use the same + * key with multiple resources. + * * Keys must start with a lowercase letter or international character. + * See [Requirements for + * labels](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + * for more details. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\RecommendationService::initOnce(); + parent::__construct($data); + } + + /** + * Required. Full resource name of the format: + * `projects/*/locations/global/collections/*/dataStores/*/servingConfigs/*` + * Before you can request recommendations from your model, you must create at + * least one serving config for it. + * + * Generated from protobuf field string serving_config = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getServingConfig() + { + return $this->serving_config; + } + + /** + * Required. Full resource name of the format: + * `projects/*/locations/global/collections/*/dataStores/*/servingConfigs/*` + * Before you can request recommendations from your model, you must create at + * least one serving config for it. + * + * Generated from protobuf field string serving_config = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setServingConfig($var) + { + GPBUtil::checkString($var, True); + $this->serving_config = $var; + + return $this; + } + + /** + * Required. Context about the user, what they are looking at and what action + * they took to trigger the Recommend request. Note that this user event + * detail won't be ingested to userEvent logs. Thus, a separate userEvent + * write request is required for event logging. + * Don't set + * [UserEvent.user_pseudo_id][google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id] + * or + * [UserEvent.user_info.user_id][google.cloud.discoveryengine.v1beta.UserInfo.user_id] + * to the same fixed ID for different users. If you are trying to receive + * non-personalized recommendations (not recommended; this can negatively + * impact model performance), instead set + * [UserEvent.user_pseudo_id][google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id] + * to a random unique ID and leave + * [UserEvent.user_info.user_id][google.cloud.discoveryengine.v1beta.UserInfo.user_id] + * unset. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.UserEvent user_event = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\DiscoveryEngine\V1beta\UserEvent|null + */ + public function getUserEvent() + { + return $this->user_event; + } + + public function hasUserEvent() + { + return isset($this->user_event); + } + + public function clearUserEvent() + { + unset($this->user_event); + } + + /** + * Required. Context about the user, what they are looking at and what action + * they took to trigger the Recommend request. Note that this user event + * detail won't be ingested to userEvent logs. Thus, a separate userEvent + * write request is required for event logging. + * Don't set + * [UserEvent.user_pseudo_id][google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id] + * or + * [UserEvent.user_info.user_id][google.cloud.discoveryengine.v1beta.UserInfo.user_id] + * to the same fixed ID for different users. If you are trying to receive + * non-personalized recommendations (not recommended; this can negatively + * impact model performance), instead set + * [UserEvent.user_pseudo_id][google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id] + * to a random unique ID and leave + * [UserEvent.user_info.user_id][google.cloud.discoveryengine.v1beta.UserInfo.user_id] + * unset. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.UserEvent user_event = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\DiscoveryEngine\V1beta\UserEvent $var + * @return $this + */ + public function setUserEvent($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\DiscoveryEngine\V1beta\UserEvent::class); + $this->user_event = $var; + + return $this; + } + + /** + * Maximum number of results to return. Set this property + * to the number of recommendation results needed. If zero, the service will + * choose a reasonable default. The maximum allowed value is 100. Values + * above 100 will be coerced to 100. + * + * Generated from protobuf field int32 page_size = 3; + * @return int + */ + public function getPageSize() + { + return $this->page_size; + } + + /** + * Maximum number of results to return. Set this property + * to the number of recommendation results needed. If zero, the service will + * choose a reasonable default. The maximum allowed value is 100. Values + * above 100 will be coerced to 100. + * + * Generated from protobuf field int32 page_size = 3; + * @param int $var + * @return $this + */ + public function setPageSize($var) + { + GPBUtil::checkInt32($var); + $this->page_size = $var; + + return $this; + } + + /** + * Filter for restricting recommendation results with a length limit of 5,000 + * characters. Currently, only filter expressions on the `filter_tags` + * attribute is supported. + * Examples: + * * `(filter_tags: ANY("Red", "Blue") OR filter_tags: ANY("Hot", "Cold"))` + * * `(filter_tags: ANY("Red", "Blue")) AND NOT (filter_tags: ANY("Green"))` + * If your filter blocks all results, the API will return generic + * (unfiltered) popular Documents. If you only want results strictly matching + * the filters, set `strictFiltering` to True in + * [RecommendRequest.params][google.cloud.discoveryengine.v1beta.RecommendRequest.params] + * to receive empty results instead. + * Note that the API will never return + * [Document][google.cloud.discoveryengine.v1beta.Document]s with + * `storageStatus` of `EXPIRED` or `DELETED` regardless of filter choices. + * + * Generated from protobuf field string filter = 4; + * @return string + */ + public function getFilter() + { + return $this->filter; + } + + /** + * Filter for restricting recommendation results with a length limit of 5,000 + * characters. Currently, only filter expressions on the `filter_tags` + * attribute is supported. + * Examples: + * * `(filter_tags: ANY("Red", "Blue") OR filter_tags: ANY("Hot", "Cold"))` + * * `(filter_tags: ANY("Red", "Blue")) AND NOT (filter_tags: ANY("Green"))` + * If your filter blocks all results, the API will return generic + * (unfiltered) popular Documents. If you only want results strictly matching + * the filters, set `strictFiltering` to True in + * [RecommendRequest.params][google.cloud.discoveryengine.v1beta.RecommendRequest.params] + * to receive empty results instead. + * Note that the API will never return + * [Document][google.cloud.discoveryengine.v1beta.Document]s with + * `storageStatus` of `EXPIRED` or `DELETED` regardless of filter choices. + * + * Generated from protobuf field string filter = 4; + * @param string $var + * @return $this + */ + public function setFilter($var) + { + GPBUtil::checkString($var, True); + $this->filter = $var; + + return $this; + } + + /** + * Use validate only mode for this recommendation query. If set to true, a + * fake model will be used that returns arbitrary Document IDs. + * Note that the validate only mode should only be used for testing the API, + * or if the model is not ready. + * + * Generated from protobuf field bool validate_only = 5; + * @return bool + */ + public function getValidateOnly() + { + return $this->validate_only; + } + + /** + * Use validate only mode for this recommendation query. If set to true, a + * fake model will be used that returns arbitrary Document IDs. + * Note that the validate only mode should only be used for testing the API, + * or if the model is not ready. + * + * Generated from protobuf field bool validate_only = 5; + * @param bool $var + * @return $this + */ + public function setValidateOnly($var) + { + GPBUtil::checkBool($var); + $this->validate_only = $var; + + return $this; + } + + /** + * Additional domain specific parameters for the recommendations. + * Allowed values: + * * `returnDocument`: Boolean. If set to true, the associated Document + * object will be returned in + * [RecommendResponse.RecommendationResult.document][google.cloud.discoveryengine.v1beta.RecommendResponse.RecommendationResult.document]. + * * `returnScore`: Boolean. If set to true, the recommendation 'score' + * corresponding to each returned Document will be set in + * [RecommendResponse.RecommendationResult.metadata][google.cloud.discoveryengine.v1beta.RecommendResponse.RecommendationResult.metadata]. + * The given 'score' indicates the probability of a Document conversion + * given the user's context and history. + * * `strictFiltering`: Boolean. True by default. If set to false, the service + * will return generic (unfiltered) popular Documents instead of empty if + * your filter blocks all recommendation results. + * * `diversityLevel`: String. Default empty. If set to be non-empty, then + * it needs to be one of: + * * `no-diversity` + * * `low-diversity` + * * `medium-diversity` + * * `high-diversity` + * * `auto-diversity` + * This gives request-level control and adjusts recommendation results + * based on Document category. + * + * Generated from protobuf field map params = 6; + * @return \Google\Protobuf\Internal\MapField + */ + public function getParams() + { + return $this->params; + } + + /** + * Additional domain specific parameters for the recommendations. + * Allowed values: + * * `returnDocument`: Boolean. If set to true, the associated Document + * object will be returned in + * [RecommendResponse.RecommendationResult.document][google.cloud.discoveryengine.v1beta.RecommendResponse.RecommendationResult.document]. + * * `returnScore`: Boolean. If set to true, the recommendation 'score' + * corresponding to each returned Document will be set in + * [RecommendResponse.RecommendationResult.metadata][google.cloud.discoveryengine.v1beta.RecommendResponse.RecommendationResult.metadata]. + * The given 'score' indicates the probability of a Document conversion + * given the user's context and history. + * * `strictFiltering`: Boolean. True by default. If set to false, the service + * will return generic (unfiltered) popular Documents instead of empty if + * your filter blocks all recommendation results. + * * `diversityLevel`: String. Default empty. If set to be non-empty, then + * it needs to be one of: + * * `no-diversity` + * * `low-diversity` + * * `medium-diversity` + * * `high-diversity` + * * `auto-diversity` + * This gives request-level control and adjusts recommendation results + * based on Document category. + * + * Generated from protobuf field map params = 6; + * @param array|\Google\Protobuf\Internal\MapField $var + * @return $this + */ + public function setParams($var) + { + $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Value::class); + $this->params = $arr; + + return $this; + } + + /** + * The user labels applied to a resource must meet the following requirements: + * * Each resource can have multiple labels, up to a maximum of 64. + * * Each label must be a key-value pair. + * * Keys have a minimum length of 1 character and a maximum length of 63 + * characters and cannot be empty. Values can be empty and have a maximum + * length of 63 characters. + * * Keys and values can contain only lowercase letters, numeric characters, + * underscores, and dashes. All characters must use UTF-8 encoding, and + * international characters are allowed. + * * The key portion of a label must be unique. However, you can use the same + * key with multiple resources. + * * Keys must start with a lowercase letter or international character. + * See [Requirements for + * labels](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + * for more details. + * + * Generated from protobuf field map user_labels = 8; + * @return \Google\Protobuf\Internal\MapField + */ + public function getUserLabels() + { + return $this->user_labels; + } + + /** + * The user labels applied to a resource must meet the following requirements: + * * Each resource can have multiple labels, up to a maximum of 64. + * * Each label must be a key-value pair. + * * Keys have a minimum length of 1 character and a maximum length of 63 + * characters and cannot be empty. Values can be empty and have a maximum + * length of 63 characters. + * * Keys and values can contain only lowercase letters, numeric characters, + * underscores, and dashes. All characters must use UTF-8 encoding, and + * international characters are allowed. + * * The key portion of a label must be unique. However, you can use the same + * key with multiple resources. + * * Keys must start with a lowercase letter or international character. + * See [Requirements for + * labels](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + * for more details. + * + * Generated from protobuf field map user_labels = 8; + * @param array|\Google\Protobuf\Internal\MapField $var + * @return $this + */ + public function setUserLabels($var) + { + $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::STRING); + $this->user_labels = $arr; + + return $this; + } + +} + diff --git a/DiscoveryEngine/src/V1beta/RecommendResponse.php b/DiscoveryEngine/src/V1beta/RecommendResponse.php new file mode 100644 index 000000000000..8e44adf0d4f0 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/RecommendResponse.php @@ -0,0 +1,197 @@ +google.cloud.discoveryengine.v1beta.RecommendResponse + */ +class RecommendResponse extends \Google\Protobuf\Internal\Message +{ + /** + * A list of recommended Documents. The order represents the ranking (from the + * most relevant Document to the least). + * + * Generated from protobuf field repeated .google.cloud.discoveryengine.v1beta.RecommendResponse.RecommendationResult results = 1; + */ + private $results; + /** + * A unique attribution token. This should be included in the + * [UserEvent][google.cloud.discoveryengine.v1beta.UserEvent] logs resulting + * from this recommendation, which enables accurate attribution of + * recommendation model performance. + * + * Generated from protobuf field string attribution_token = 2; + */ + protected $attribution_token = ''; + /** + * IDs of documents in the request that were missing from the default Branch + * associated with the requested ServingConfig. + * + * Generated from protobuf field repeated string missing_ids = 3; + */ + private $missing_ids; + /** + * True if + * [RecommendRequest.validate_only][google.cloud.discoveryengine.v1beta.RecommendRequest.validate_only] + * was set. + * + * Generated from protobuf field bool validate_only = 4; + */ + protected $validate_only = false; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\Google\Cloud\DiscoveryEngine\V1beta\RecommendResponse\RecommendationResult>|\Google\Protobuf\Internal\RepeatedField $results + * A list of recommended Documents. The order represents the ranking (from the + * most relevant Document to the least). + * @type string $attribution_token + * A unique attribution token. This should be included in the + * [UserEvent][google.cloud.discoveryengine.v1beta.UserEvent] logs resulting + * from this recommendation, which enables accurate attribution of + * recommendation model performance. + * @type array|\Google\Protobuf\Internal\RepeatedField $missing_ids + * IDs of documents in the request that were missing from the default Branch + * associated with the requested ServingConfig. + * @type bool $validate_only + * True if + * [RecommendRequest.validate_only][google.cloud.discoveryengine.v1beta.RecommendRequest.validate_only] + * was set. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\RecommendationService::initOnce(); + parent::__construct($data); + } + + /** + * A list of recommended Documents. The order represents the ranking (from the + * most relevant Document to the least). + * + * Generated from protobuf field repeated .google.cloud.discoveryengine.v1beta.RecommendResponse.RecommendationResult results = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getResults() + { + return $this->results; + } + + /** + * A list of recommended Documents. The order represents the ranking (from the + * most relevant Document to the least). + * + * Generated from protobuf field repeated .google.cloud.discoveryengine.v1beta.RecommendResponse.RecommendationResult results = 1; + * @param array<\Google\Cloud\DiscoveryEngine\V1beta\RecommendResponse\RecommendationResult>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setResults($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\DiscoveryEngine\V1beta\RecommendResponse\RecommendationResult::class); + $this->results = $arr; + + return $this; + } + + /** + * A unique attribution token. This should be included in the + * [UserEvent][google.cloud.discoveryengine.v1beta.UserEvent] logs resulting + * from this recommendation, which enables accurate attribution of + * recommendation model performance. + * + * Generated from protobuf field string attribution_token = 2; + * @return string + */ + public function getAttributionToken() + { + return $this->attribution_token; + } + + /** + * A unique attribution token. This should be included in the + * [UserEvent][google.cloud.discoveryengine.v1beta.UserEvent] logs resulting + * from this recommendation, which enables accurate attribution of + * recommendation model performance. + * + * Generated from protobuf field string attribution_token = 2; + * @param string $var + * @return $this + */ + public function setAttributionToken($var) + { + GPBUtil::checkString($var, True); + $this->attribution_token = $var; + + return $this; + } + + /** + * IDs of documents in the request that were missing from the default Branch + * associated with the requested ServingConfig. + * + * Generated from protobuf field repeated string missing_ids = 3; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getMissingIds() + { + return $this->missing_ids; + } + + /** + * IDs of documents in the request that were missing from the default Branch + * associated with the requested ServingConfig. + * + * Generated from protobuf field repeated string missing_ids = 3; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setMissingIds($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->missing_ids = $arr; + + return $this; + } + + /** + * True if + * [RecommendRequest.validate_only][google.cloud.discoveryengine.v1beta.RecommendRequest.validate_only] + * was set. + * + * Generated from protobuf field bool validate_only = 4; + * @return bool + */ + public function getValidateOnly() + { + return $this->validate_only; + } + + /** + * True if + * [RecommendRequest.validate_only][google.cloud.discoveryengine.v1beta.RecommendRequest.validate_only] + * was set. + * + * Generated from protobuf field bool validate_only = 4; + * @param bool $var + * @return $this + */ + public function setValidateOnly($var) + { + GPBUtil::checkBool($var); + $this->validate_only = $var; + + return $this; + } + +} + diff --git a/DiscoveryEngine/src/V1beta/RecommendResponse/RecommendationResult.php b/DiscoveryEngine/src/V1beta/RecommendResponse/RecommendationResult.php new file mode 100644 index 000000000000..1f9f2f67608b --- /dev/null +++ b/DiscoveryEngine/src/V1beta/RecommendResponse/RecommendationResult.php @@ -0,0 +1,167 @@ +google.cloud.discoveryengine.v1beta.RecommendResponse.RecommendationResult + */ +class RecommendationResult extends \Google\Protobuf\Internal\Message +{ + /** + * Resource ID of the recommended Document. + * + * Generated from protobuf field string id = 1; + */ + protected $id = ''; + /** + * Set if `returnDocument` is set to true in + * [RecommendRequest.params][google.cloud.discoveryengine.v1beta.RecommendRequest.params]. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.Document document = 2; + */ + protected $document = null; + /** + * Additional Document metadata / annotations. + * Possible values: + * * `score`: Recommendation score in double value. Is set if + * `returnScore` is set to true in + * [RecommendRequest.params][google.cloud.discoveryengine.v1beta.RecommendRequest.params]. + * + * Generated from protobuf field map metadata = 3; + */ + private $metadata; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $id + * Resource ID of the recommended Document. + * @type \Google\Cloud\DiscoveryEngine\V1beta\Document $document + * Set if `returnDocument` is set to true in + * [RecommendRequest.params][google.cloud.discoveryengine.v1beta.RecommendRequest.params]. + * @type array|\Google\Protobuf\Internal\MapField $metadata + * Additional Document metadata / annotations. + * Possible values: + * * `score`: Recommendation score in double value. Is set if + * `returnScore` is set to true in + * [RecommendRequest.params][google.cloud.discoveryengine.v1beta.RecommendRequest.params]. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\RecommendationService::initOnce(); + parent::__construct($data); + } + + /** + * Resource ID of the recommended Document. + * + * Generated from protobuf field string id = 1; + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * Resource ID of the recommended Document. + * + * Generated from protobuf field string id = 1; + * @param string $var + * @return $this + */ + public function setId($var) + { + GPBUtil::checkString($var, True); + $this->id = $var; + + return $this; + } + + /** + * Set if `returnDocument` is set to true in + * [RecommendRequest.params][google.cloud.discoveryengine.v1beta.RecommendRequest.params]. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.Document document = 2; + * @return \Google\Cloud\DiscoveryEngine\V1beta\Document|null + */ + public function getDocument() + { + return $this->document; + } + + public function hasDocument() + { + return isset($this->document); + } + + public function clearDocument() + { + unset($this->document); + } + + /** + * Set if `returnDocument` is set to true in + * [RecommendRequest.params][google.cloud.discoveryengine.v1beta.RecommendRequest.params]. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.Document document = 2; + * @param \Google\Cloud\DiscoveryEngine\V1beta\Document $var + * @return $this + */ + public function setDocument($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\DiscoveryEngine\V1beta\Document::class); + $this->document = $var; + + return $this; + } + + /** + * Additional Document metadata / annotations. + * Possible values: + * * `score`: Recommendation score in double value. Is set if + * `returnScore` is set to true in + * [RecommendRequest.params][google.cloud.discoveryengine.v1beta.RecommendRequest.params]. + * + * Generated from protobuf field map metadata = 3; + * @return \Google\Protobuf\Internal\MapField + */ + public function getMetadata() + { + return $this->metadata; + } + + /** + * Additional Document metadata / annotations. + * Possible values: + * * `score`: Recommendation score in double value. Is set if + * `returnScore` is set to true in + * [RecommendRequest.params][google.cloud.discoveryengine.v1beta.RecommendRequest.params]. + * + * Generated from protobuf field map metadata = 3; + * @param array|\Google\Protobuf\Internal\MapField $var + * @return $this + */ + public function setMetadata($var) + { + $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Value::class); + $this->metadata = $arr; + + return $this; + } + +} + + diff --git a/DiscoveryEngine/src/V1beta/Schema.php b/DiscoveryEngine/src/V1beta/Schema.php new file mode 100644 index 000000000000..707f22be7389 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/Schema.php @@ -0,0 +1,154 @@ +google.cloud.discoveryengine.v1beta.Schema + */ +class Schema extends \Google\Protobuf\Internal\Message +{ + /** + * Immutable. The full resource name of the schema, in the format of + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}`. + * This field must be a UTF-8 encoded string with a length limit of 1024 + * characters. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = IMMUTABLE]; + */ + protected $name = ''; + protected $schema; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Protobuf\Struct $struct_schema + * The structured representation of the schema. + * @type string $json_schema + * The JSON representation of the schema. + * @type string $name + * Immutable. The full resource name of the schema, in the format of + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}`. + * This field must be a UTF-8 encoded string with a length limit of 1024 + * characters. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\Schema::initOnce(); + parent::__construct($data); + } + + /** + * The structured representation of the schema. + * + * Generated from protobuf field .google.protobuf.Struct struct_schema = 2; + * @return \Google\Protobuf\Struct|null + */ + public function getStructSchema() + { + return $this->readOneof(2); + } + + public function hasStructSchema() + { + return $this->hasOneof(2); + } + + /** + * The structured representation of the schema. + * + * Generated from protobuf field .google.protobuf.Struct struct_schema = 2; + * @param \Google\Protobuf\Struct $var + * @return $this + */ + public function setStructSchema($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Struct::class); + $this->writeOneof(2, $var); + + return $this; + } + + /** + * The JSON representation of the schema. + * + * Generated from protobuf field string json_schema = 3; + * @return string + */ + public function getJsonSchema() + { + return $this->readOneof(3); + } + + public function hasJsonSchema() + { + return $this->hasOneof(3); + } + + /** + * The JSON representation of the schema. + * + * Generated from protobuf field string json_schema = 3; + * @param string $var + * @return $this + */ + public function setJsonSchema($var) + { + GPBUtil::checkString($var, True); + $this->writeOneof(3, $var); + + return $this; + } + + /** + * Immutable. The full resource name of the schema, in the format of + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}`. + * This field must be a UTF-8 encoded string with a length limit of 1024 + * characters. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = IMMUTABLE]; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Immutable. The full resource name of the schema, in the format of + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}`. + * This field must be a UTF-8 encoded string with a length limit of 1024 + * characters. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = IMMUTABLE]; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * @return string + */ + public function getSchema() + { + return $this->whichOneof("schema"); + } + +} + diff --git a/DiscoveryEngine/src/V1beta/SearchInfo.php b/DiscoveryEngine/src/V1beta/SearchInfo.php new file mode 100644 index 000000000000..e53353b2a2c2 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/SearchInfo.php @@ -0,0 +1,245 @@ +google.cloud.discoveryengine.v1beta.SearchInfo + */ +class SearchInfo extends \Google\Protobuf\Internal\Message +{ + /** + * The user's search query. + * See + * [SearchRequest.query][google.cloud.discoveryengine.v1beta.SearchRequest.query] + * for definition. + * The value must be a UTF-8 encoded string with a length limit of 5,000 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * At least one of + * [search_query][google.cloud.discoveryengine.v1beta.SearchInfo.search_query] + * or + * [PageInfo.page_category][google.cloud.discoveryengine.v1beta.PageInfo.page_category] + * is required for `search` events. Other event types should not set this + * field. Otherwise, an INVALID_ARGUMENT error is returned. + * + * Generated from protobuf field string search_query = 1; + */ + protected $search_query = ''; + /** + * The order in which products are returned, if applicable. + * See + * [SearchRequest.order_by][google.cloud.discoveryengine.v1beta.SearchRequest.order_by] + * for definition and syntax. + * The value must be a UTF-8 encoded string with a length limit of 1,000 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * This can only be set for `search` events. Other event types should not set + * this field. Otherwise, an INVALID_ARGUMENT error is returned. + * + * Generated from protobuf field string order_by = 2; + */ + protected $order_by = ''; + /** + * An integer that specifies the current offset for pagination (the 0-indexed + * starting location, amongst the products deemed by the API as relevant). + * See + * [SearchRequest.offset][google.cloud.discoveryengine.v1beta.SearchRequest.offset] + * for definition. + * If this field is negative, an INVALID_ARGUMENT is returned. + * This can only be set for `search` events. Other event types should not set + * this field. Otherwise, an INVALID_ARGUMENT error is returned. + * + * Generated from protobuf field optional int32 offset = 3; + */ + protected $offset = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $search_query + * The user's search query. + * See + * [SearchRequest.query][google.cloud.discoveryengine.v1beta.SearchRequest.query] + * for definition. + * The value must be a UTF-8 encoded string with a length limit of 5,000 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * At least one of + * [search_query][google.cloud.discoveryengine.v1beta.SearchInfo.search_query] + * or + * [PageInfo.page_category][google.cloud.discoveryengine.v1beta.PageInfo.page_category] + * is required for `search` events. Other event types should not set this + * field. Otherwise, an INVALID_ARGUMENT error is returned. + * @type string $order_by + * The order in which products are returned, if applicable. + * See + * [SearchRequest.order_by][google.cloud.discoveryengine.v1beta.SearchRequest.order_by] + * for definition and syntax. + * The value must be a UTF-8 encoded string with a length limit of 1,000 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * This can only be set for `search` events. Other event types should not set + * this field. Otherwise, an INVALID_ARGUMENT error is returned. + * @type int $offset + * An integer that specifies the current offset for pagination (the 0-indexed + * starting location, amongst the products deemed by the API as relevant). + * See + * [SearchRequest.offset][google.cloud.discoveryengine.v1beta.SearchRequest.offset] + * for definition. + * If this field is negative, an INVALID_ARGUMENT is returned. + * This can only be set for `search` events. Other event types should not set + * this field. Otherwise, an INVALID_ARGUMENT error is returned. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\UserEvent::initOnce(); + parent::__construct($data); + } + + /** + * The user's search query. + * See + * [SearchRequest.query][google.cloud.discoveryengine.v1beta.SearchRequest.query] + * for definition. + * The value must be a UTF-8 encoded string with a length limit of 5,000 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * At least one of + * [search_query][google.cloud.discoveryengine.v1beta.SearchInfo.search_query] + * or + * [PageInfo.page_category][google.cloud.discoveryengine.v1beta.PageInfo.page_category] + * is required for `search` events. Other event types should not set this + * field. Otherwise, an INVALID_ARGUMENT error is returned. + * + * Generated from protobuf field string search_query = 1; + * @return string + */ + public function getSearchQuery() + { + return $this->search_query; + } + + /** + * The user's search query. + * See + * [SearchRequest.query][google.cloud.discoveryengine.v1beta.SearchRequest.query] + * for definition. + * The value must be a UTF-8 encoded string with a length limit of 5,000 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * At least one of + * [search_query][google.cloud.discoveryengine.v1beta.SearchInfo.search_query] + * or + * [PageInfo.page_category][google.cloud.discoveryengine.v1beta.PageInfo.page_category] + * is required for `search` events. Other event types should not set this + * field. Otherwise, an INVALID_ARGUMENT error is returned. + * + * Generated from protobuf field string search_query = 1; + * @param string $var + * @return $this + */ + public function setSearchQuery($var) + { + GPBUtil::checkString($var, True); + $this->search_query = $var; + + return $this; + } + + /** + * The order in which products are returned, if applicable. + * See + * [SearchRequest.order_by][google.cloud.discoveryengine.v1beta.SearchRequest.order_by] + * for definition and syntax. + * The value must be a UTF-8 encoded string with a length limit of 1,000 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * This can only be set for `search` events. Other event types should not set + * this field. Otherwise, an INVALID_ARGUMENT error is returned. + * + * Generated from protobuf field string order_by = 2; + * @return string + */ + public function getOrderBy() + { + return $this->order_by; + } + + /** + * The order in which products are returned, if applicable. + * See + * [SearchRequest.order_by][google.cloud.discoveryengine.v1beta.SearchRequest.order_by] + * for definition and syntax. + * The value must be a UTF-8 encoded string with a length limit of 1,000 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * This can only be set for `search` events. Other event types should not set + * this field. Otherwise, an INVALID_ARGUMENT error is returned. + * + * Generated from protobuf field string order_by = 2; + * @param string $var + * @return $this + */ + public function setOrderBy($var) + { + GPBUtil::checkString($var, True); + $this->order_by = $var; + + return $this; + } + + /** + * An integer that specifies the current offset for pagination (the 0-indexed + * starting location, amongst the products deemed by the API as relevant). + * See + * [SearchRequest.offset][google.cloud.discoveryengine.v1beta.SearchRequest.offset] + * for definition. + * If this field is negative, an INVALID_ARGUMENT is returned. + * This can only be set for `search` events. Other event types should not set + * this field. Otherwise, an INVALID_ARGUMENT error is returned. + * + * Generated from protobuf field optional int32 offset = 3; + * @return int + */ + public function getOffset() + { + return isset($this->offset) ? $this->offset : 0; + } + + public function hasOffset() + { + return isset($this->offset); + } + + public function clearOffset() + { + unset($this->offset); + } + + /** + * An integer that specifies the current offset for pagination (the 0-indexed + * starting location, amongst the products deemed by the API as relevant). + * See + * [SearchRequest.offset][google.cloud.discoveryengine.v1beta.SearchRequest.offset] + * for definition. + * If this field is negative, an INVALID_ARGUMENT is returned. + * This can only be set for `search` events. Other event types should not set + * this field. Otherwise, an INVALID_ARGUMENT error is returned. + * + * Generated from protobuf field optional int32 offset = 3; + * @param int $var + * @return $this + */ + public function setOffset($var) + { + GPBUtil::checkInt32($var); + $this->offset = $var; + + return $this; + } + +} + diff --git a/DiscoveryEngine/src/V1beta/SearchRequest.php b/DiscoveryEngine/src/V1beta/SearchRequest.php new file mode 100644 index 000000000000..f9f8a75c0482 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/SearchRequest.php @@ -0,0 +1,969 @@ +google.cloud.discoveryengine.v1beta.SearchRequest + */ +class SearchRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The resource name of the Search serving config, such as + * `projects/*/locations/global/collections/default_collection/dataStores/default_data_store/servingConfigs/default_serving_config`. + * This field is used to identify the serving configuration name, set + * of models used to make the search. + * + * Generated from protobuf field string serving_config = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $serving_config = ''; + /** + * The branch resource name, such as + * `projects/*/locations/global/collections/default_collection/dataStores/default_data_store/branches/0`. + * Use `default_branch` as the branch ID or leave this field empty, to search + * documents under the default branch. + * + * Generated from protobuf field string branch = 2 [(.google.api.resource_reference) = { + */ + protected $branch = ''; + /** + * Raw search query. + * + * Generated from protobuf field string query = 3; + */ + protected $query = ''; + /** + * Maximum number of [Document][google.cloud.discoveryengine.v1beta.Document]s + * to return. If unspecified, defaults to a reasonable value. The maximum + * allowed value is 100. Values above 100 will be coerced to 100. + * If this field is negative, an `INVALID_ARGUMENT` is returned. + * + * Generated from protobuf field int32 page_size = 4; + */ + protected $page_size = 0; + /** + * A page token received from a previous + * [SearchService.Search][google.cloud.discoveryengine.v1beta.SearchService.Search] + * call. Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to + * [SearchService.Search][google.cloud.discoveryengine.v1beta.SearchService.Search] + * must match the call that provided the page token. Otherwise, an + * `INVALID_ARGUMENT` error is returned. + * + * Generated from protobuf field string page_token = 5; + */ + protected $page_token = ''; + /** + * A 0-indexed integer that specifies the current offset (that is, starting + * result location, amongst the + * [Document][google.cloud.discoveryengine.v1beta.Document]s deemed by the API + * as relevant) in search results. This field is only considered if + * [page_token][google.cloud.discoveryengine.v1beta.SearchRequest.page_token] + * is unset. + * If this field is negative, an `INVALID_ARGUMENT` is returned. + * + * Generated from protobuf field int32 offset = 6; + */ + protected $offset = 0; + /** + * The filter syntax consists of an expression language for constructing a + * predicate from one or more fields of the documents being filtered. Filter + * expression is case-sensitive. + * If this field is unrecognizable, an `INVALID_ARGUMENT` is returned. + * + * Generated from protobuf field string filter = 7; + */ + protected $filter = ''; + /** + * The order in which documents are returned. Document can be ordered by + * a field in an [Document][google.cloud.discoveryengine.v1beta.Document] + * object. Leave it unset if ordered by relevance. OrderBy expression is + * case-sensitive. + * If this field is unrecognizable, an `INVALID_ARGUMENT` is returned. + * + * Generated from protobuf field string order_by = 8; + */ + protected $order_by = ''; + /** + * Information about the end user. + * Highly recommended for analytics. The user_agent string in UserInfo will + * be used to deduce device_type for analytics. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.UserInfo user_info = 21; + */ + protected $user_info = null; + /** + * Facet specifications for faceted search. If empty, no facets are returned. + * A maximum of 100 values are allowed. Otherwise, an `INVALID_ARGUMENT` + * error is returned. + * + * Generated from protobuf field repeated .google.cloud.discoveryengine.v1beta.SearchRequest.FacetSpec facet_specs = 9; + */ + private $facet_specs; + /** + * Boost specification to boost certain documents. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.SearchRequest.BoostSpec boost_spec = 10; + */ + protected $boost_spec = null; + /** + * Additional search parameters. + * For + * [IndustryVertical.SITE_SEARCH][google.cloud.discoveryengine.v1beta.IndustryVertical.SITE_SEARCH] + * vertical, supported values are: + * * `user_country_code`: string. Default empty. If set to non-empty, results + * are restricted or boosted based on the location provided. + * * `search_type`: double. Default empty. Enables non-webpage searching + * depending on the value. The only valid non-default value is 1, + * which enables image searching. + * + * Generated from protobuf field map params = 11; + */ + private $params; + /** + * The query expansion specification that specifies the conditions under which + * query expansion will occur. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.SearchRequest.QueryExpansionSpec query_expansion_spec = 13; + */ + protected $query_expansion_spec = null; + /** + * The spell correction specification that specifies the mode under + * which spell correction will take effect. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.SearchRequest.SpellCorrectionSpec spell_correction_spec = 14; + */ + protected $spell_correction_spec = null; + /** + * A unique identifier for tracking visitors. For example, this could be + * implemented with an HTTP cookie, which should be able to uniquely identify + * a visitor on a single device. This unique identifier should not change if + * the visitor logs in or out of the website. + * This field should NOT have a fixed value such as `unknown_visitor`. + * This should be the same identifier as + * [UserEvent.user_pseudo_id][google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id] + * and + * [CompleteQueryRequest.user_pseudo_id][google.cloud.discoveryengine.v1beta.CompleteQueryRequest.user_pseudo_id] + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an `INVALID_ARGUMENT` error is returned. + * + * Generated from protobuf field string user_pseudo_id = 15; + */ + protected $user_pseudo_id = ''; + /** + * The content search spec that configs the desired behavior of content + * search. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec content_search_spec = 24; + */ + protected $content_search_spec = null; + /** + * Whether to turn on safe search. This is only supported for + * [ContentConfig.PUBLIC_WEBSITE][]. + * + * Generated from protobuf field bool safe_search = 20; + */ + protected $safe_search = false; + /** + * The user labels applied to a resource must meet the following requirements: + * * Each resource can have multiple labels, up to a maximum of 64. + * * Each label must be a key-value pair. + * * Keys have a minimum length of 1 character and a maximum length of 63 + * characters and cannot be empty. Values can be empty and have a maximum + * length of 63 characters. + * * Keys and values can contain only lowercase letters, numeric characters, + * underscores, and dashes. All characters must use UTF-8 encoding, and + * international characters are allowed. + * * The key portion of a label must be unique. However, you can use the same + * key with multiple resources. + * * Keys must start with a lowercase letter or international character. + * See [Google Cloud + * Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + * for more details. + * + * Generated from protobuf field map user_label = 22; + */ + private $user_label; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $serving_config + * Required. The resource name of the Search serving config, such as + * `projects/*/locations/global/collections/default_collection/dataStores/default_data_store/servingConfigs/default_serving_config`. + * This field is used to identify the serving configuration name, set + * of models used to make the search. + * @type string $branch + * The branch resource name, such as + * `projects/*/locations/global/collections/default_collection/dataStores/default_data_store/branches/0`. + * Use `default_branch` as the branch ID or leave this field empty, to search + * documents under the default branch. + * @type string $query + * Raw search query. + * @type int $page_size + * Maximum number of [Document][google.cloud.discoveryengine.v1beta.Document]s + * to return. If unspecified, defaults to a reasonable value. The maximum + * allowed value is 100. Values above 100 will be coerced to 100. + * If this field is negative, an `INVALID_ARGUMENT` is returned. + * @type string $page_token + * A page token received from a previous + * [SearchService.Search][google.cloud.discoveryengine.v1beta.SearchService.Search] + * call. Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to + * [SearchService.Search][google.cloud.discoveryengine.v1beta.SearchService.Search] + * must match the call that provided the page token. Otherwise, an + * `INVALID_ARGUMENT` error is returned. + * @type int $offset + * A 0-indexed integer that specifies the current offset (that is, starting + * result location, amongst the + * [Document][google.cloud.discoveryengine.v1beta.Document]s deemed by the API + * as relevant) in search results. This field is only considered if + * [page_token][google.cloud.discoveryengine.v1beta.SearchRequest.page_token] + * is unset. + * If this field is negative, an `INVALID_ARGUMENT` is returned. + * @type string $filter + * The filter syntax consists of an expression language for constructing a + * predicate from one or more fields of the documents being filtered. Filter + * expression is case-sensitive. + * If this field is unrecognizable, an `INVALID_ARGUMENT` is returned. + * @type string $order_by + * The order in which documents are returned. Document can be ordered by + * a field in an [Document][google.cloud.discoveryengine.v1beta.Document] + * object. Leave it unset if ordered by relevance. OrderBy expression is + * case-sensitive. + * If this field is unrecognizable, an `INVALID_ARGUMENT` is returned. + * @type \Google\Cloud\DiscoveryEngine\V1beta\UserInfo $user_info + * Information about the end user. + * Highly recommended for analytics. The user_agent string in UserInfo will + * be used to deduce device_type for analytics. + * @type array<\Google\Cloud\DiscoveryEngine\V1beta\SearchRequest\FacetSpec>|\Google\Protobuf\Internal\RepeatedField $facet_specs + * Facet specifications for faceted search. If empty, no facets are returned. + * A maximum of 100 values are allowed. Otherwise, an `INVALID_ARGUMENT` + * error is returned. + * @type \Google\Cloud\DiscoveryEngine\V1beta\SearchRequest\BoostSpec $boost_spec + * Boost specification to boost certain documents. + * @type array|\Google\Protobuf\Internal\MapField $params + * Additional search parameters. + * For + * [IndustryVertical.SITE_SEARCH][google.cloud.discoveryengine.v1beta.IndustryVertical.SITE_SEARCH] + * vertical, supported values are: + * * `user_country_code`: string. Default empty. If set to non-empty, results + * are restricted or boosted based on the location provided. + * * `search_type`: double. Default empty. Enables non-webpage searching + * depending on the value. The only valid non-default value is 1, + * which enables image searching. + * @type \Google\Cloud\DiscoveryEngine\V1beta\SearchRequest\QueryExpansionSpec $query_expansion_spec + * The query expansion specification that specifies the conditions under which + * query expansion will occur. + * @type \Google\Cloud\DiscoveryEngine\V1beta\SearchRequest\SpellCorrectionSpec $spell_correction_spec + * The spell correction specification that specifies the mode under + * which spell correction will take effect. + * @type string $user_pseudo_id + * A unique identifier for tracking visitors. For example, this could be + * implemented with an HTTP cookie, which should be able to uniquely identify + * a visitor on a single device. This unique identifier should not change if + * the visitor logs in or out of the website. + * This field should NOT have a fixed value such as `unknown_visitor`. + * This should be the same identifier as + * [UserEvent.user_pseudo_id][google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id] + * and + * [CompleteQueryRequest.user_pseudo_id][google.cloud.discoveryengine.v1beta.CompleteQueryRequest.user_pseudo_id] + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an `INVALID_ARGUMENT` error is returned. + * @type \Google\Cloud\DiscoveryEngine\V1beta\SearchRequest\ContentSearchSpec $content_search_spec + * The content search spec that configs the desired behavior of content + * search. + * @type bool $safe_search + * Whether to turn on safe search. This is only supported for + * [ContentConfig.PUBLIC_WEBSITE][]. + * @type array|\Google\Protobuf\Internal\MapField $user_label + * The user labels applied to a resource must meet the following requirements: + * * Each resource can have multiple labels, up to a maximum of 64. + * * Each label must be a key-value pair. + * * Keys have a minimum length of 1 character and a maximum length of 63 + * characters and cannot be empty. Values can be empty and have a maximum + * length of 63 characters. + * * Keys and values can contain only lowercase letters, numeric characters, + * underscores, and dashes. All characters must use UTF-8 encoding, and + * international characters are allowed. + * * The key portion of a label must be unique. However, you can use the same + * key with multiple resources. + * * Keys must start with a lowercase letter or international character. + * See [Google Cloud + * Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + * for more details. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\SearchService::initOnce(); + parent::__construct($data); + } + + /** + * Required. The resource name of the Search serving config, such as + * `projects/*/locations/global/collections/default_collection/dataStores/default_data_store/servingConfigs/default_serving_config`. + * This field is used to identify the serving configuration name, set + * of models used to make the search. + * + * Generated from protobuf field string serving_config = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getServingConfig() + { + return $this->serving_config; + } + + /** + * Required. The resource name of the Search serving config, such as + * `projects/*/locations/global/collections/default_collection/dataStores/default_data_store/servingConfigs/default_serving_config`. + * This field is used to identify the serving configuration name, set + * of models used to make the search. + * + * Generated from protobuf field string serving_config = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setServingConfig($var) + { + GPBUtil::checkString($var, True); + $this->serving_config = $var; + + return $this; + } + + /** + * The branch resource name, such as + * `projects/*/locations/global/collections/default_collection/dataStores/default_data_store/branches/0`. + * Use `default_branch` as the branch ID or leave this field empty, to search + * documents under the default branch. + * + * Generated from protobuf field string branch = 2 [(.google.api.resource_reference) = { + * @return string + */ + public function getBranch() + { + return $this->branch; + } + + /** + * The branch resource name, such as + * `projects/*/locations/global/collections/default_collection/dataStores/default_data_store/branches/0`. + * Use `default_branch` as the branch ID or leave this field empty, to search + * documents under the default branch. + * + * Generated from protobuf field string branch = 2 [(.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setBranch($var) + { + GPBUtil::checkString($var, True); + $this->branch = $var; + + return $this; + } + + /** + * Raw search query. + * + * Generated from protobuf field string query = 3; + * @return string + */ + public function getQuery() + { + return $this->query; + } + + /** + * Raw search query. + * + * Generated from protobuf field string query = 3; + * @param string $var + * @return $this + */ + public function setQuery($var) + { + GPBUtil::checkString($var, True); + $this->query = $var; + + return $this; + } + + /** + * Maximum number of [Document][google.cloud.discoveryengine.v1beta.Document]s + * to return. If unspecified, defaults to a reasonable value. The maximum + * allowed value is 100. Values above 100 will be coerced to 100. + * If this field is negative, an `INVALID_ARGUMENT` is returned. + * + * Generated from protobuf field int32 page_size = 4; + * @return int + */ + public function getPageSize() + { + return $this->page_size; + } + + /** + * Maximum number of [Document][google.cloud.discoveryengine.v1beta.Document]s + * to return. If unspecified, defaults to a reasonable value. The maximum + * allowed value is 100. Values above 100 will be coerced to 100. + * If this field is negative, an `INVALID_ARGUMENT` is returned. + * + * Generated from protobuf field int32 page_size = 4; + * @param int $var + * @return $this + */ + public function setPageSize($var) + { + GPBUtil::checkInt32($var); + $this->page_size = $var; + + return $this; + } + + /** + * A page token received from a previous + * [SearchService.Search][google.cloud.discoveryengine.v1beta.SearchService.Search] + * call. Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to + * [SearchService.Search][google.cloud.discoveryengine.v1beta.SearchService.Search] + * must match the call that provided the page token. Otherwise, an + * `INVALID_ARGUMENT` error is returned. + * + * Generated from protobuf field string page_token = 5; + * @return string + */ + public function getPageToken() + { + return $this->page_token; + } + + /** + * A page token received from a previous + * [SearchService.Search][google.cloud.discoveryengine.v1beta.SearchService.Search] + * call. Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to + * [SearchService.Search][google.cloud.discoveryengine.v1beta.SearchService.Search] + * must match the call that provided the page token. Otherwise, an + * `INVALID_ARGUMENT` error is returned. + * + * Generated from protobuf field string page_token = 5; + * @param string $var + * @return $this + */ + public function setPageToken($var) + { + GPBUtil::checkString($var, True); + $this->page_token = $var; + + return $this; + } + + /** + * A 0-indexed integer that specifies the current offset (that is, starting + * result location, amongst the + * [Document][google.cloud.discoveryengine.v1beta.Document]s deemed by the API + * as relevant) in search results. This field is only considered if + * [page_token][google.cloud.discoveryengine.v1beta.SearchRequest.page_token] + * is unset. + * If this field is negative, an `INVALID_ARGUMENT` is returned. + * + * Generated from protobuf field int32 offset = 6; + * @return int + */ + public function getOffset() + { + return $this->offset; + } + + /** + * A 0-indexed integer that specifies the current offset (that is, starting + * result location, amongst the + * [Document][google.cloud.discoveryengine.v1beta.Document]s deemed by the API + * as relevant) in search results. This field is only considered if + * [page_token][google.cloud.discoveryengine.v1beta.SearchRequest.page_token] + * is unset. + * If this field is negative, an `INVALID_ARGUMENT` is returned. + * + * Generated from protobuf field int32 offset = 6; + * @param int $var + * @return $this + */ + public function setOffset($var) + { + GPBUtil::checkInt32($var); + $this->offset = $var; + + return $this; + } + + /** + * The filter syntax consists of an expression language for constructing a + * predicate from one or more fields of the documents being filtered. Filter + * expression is case-sensitive. + * If this field is unrecognizable, an `INVALID_ARGUMENT` is returned. + * + * Generated from protobuf field string filter = 7; + * @return string + */ + public function getFilter() + { + return $this->filter; + } + + /** + * The filter syntax consists of an expression language for constructing a + * predicate from one or more fields of the documents being filtered. Filter + * expression is case-sensitive. + * If this field is unrecognizable, an `INVALID_ARGUMENT` is returned. + * + * Generated from protobuf field string filter = 7; + * @param string $var + * @return $this + */ + public function setFilter($var) + { + GPBUtil::checkString($var, True); + $this->filter = $var; + + return $this; + } + + /** + * The order in which documents are returned. Document can be ordered by + * a field in an [Document][google.cloud.discoveryengine.v1beta.Document] + * object. Leave it unset if ordered by relevance. OrderBy expression is + * case-sensitive. + * If this field is unrecognizable, an `INVALID_ARGUMENT` is returned. + * + * Generated from protobuf field string order_by = 8; + * @return string + */ + public function getOrderBy() + { + return $this->order_by; + } + + /** + * The order in which documents are returned. Document can be ordered by + * a field in an [Document][google.cloud.discoveryengine.v1beta.Document] + * object. Leave it unset if ordered by relevance. OrderBy expression is + * case-sensitive. + * If this field is unrecognizable, an `INVALID_ARGUMENT` is returned. + * + * Generated from protobuf field string order_by = 8; + * @param string $var + * @return $this + */ + public function setOrderBy($var) + { + GPBUtil::checkString($var, True); + $this->order_by = $var; + + return $this; + } + + /** + * Information about the end user. + * Highly recommended for analytics. The user_agent string in UserInfo will + * be used to deduce device_type for analytics. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.UserInfo user_info = 21; + * @return \Google\Cloud\DiscoveryEngine\V1beta\UserInfo|null + */ + public function getUserInfo() + { + return $this->user_info; + } + + public function hasUserInfo() + { + return isset($this->user_info); + } + + public function clearUserInfo() + { + unset($this->user_info); + } + + /** + * Information about the end user. + * Highly recommended for analytics. The user_agent string in UserInfo will + * be used to deduce device_type for analytics. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.UserInfo user_info = 21; + * @param \Google\Cloud\DiscoveryEngine\V1beta\UserInfo $var + * @return $this + */ + public function setUserInfo($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\DiscoveryEngine\V1beta\UserInfo::class); + $this->user_info = $var; + + return $this; + } + + /** + * Facet specifications for faceted search. If empty, no facets are returned. + * A maximum of 100 values are allowed. Otherwise, an `INVALID_ARGUMENT` + * error is returned. + * + * Generated from protobuf field repeated .google.cloud.discoveryengine.v1beta.SearchRequest.FacetSpec facet_specs = 9; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getFacetSpecs() + { + return $this->facet_specs; + } + + /** + * Facet specifications for faceted search. If empty, no facets are returned. + * A maximum of 100 values are allowed. Otherwise, an `INVALID_ARGUMENT` + * error is returned. + * + * Generated from protobuf field repeated .google.cloud.discoveryengine.v1beta.SearchRequest.FacetSpec facet_specs = 9; + * @param array<\Google\Cloud\DiscoveryEngine\V1beta\SearchRequest\FacetSpec>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setFacetSpecs($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\DiscoveryEngine\V1beta\SearchRequest\FacetSpec::class); + $this->facet_specs = $arr; + + return $this; + } + + /** + * Boost specification to boost certain documents. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.SearchRequest.BoostSpec boost_spec = 10; + * @return \Google\Cloud\DiscoveryEngine\V1beta\SearchRequest\BoostSpec|null + */ + public function getBoostSpec() + { + return $this->boost_spec; + } + + public function hasBoostSpec() + { + return isset($this->boost_spec); + } + + public function clearBoostSpec() + { + unset($this->boost_spec); + } + + /** + * Boost specification to boost certain documents. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.SearchRequest.BoostSpec boost_spec = 10; + * @param \Google\Cloud\DiscoveryEngine\V1beta\SearchRequest\BoostSpec $var + * @return $this + */ + public function setBoostSpec($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\DiscoveryEngine\V1beta\SearchRequest\BoostSpec::class); + $this->boost_spec = $var; + + return $this; + } + + /** + * Additional search parameters. + * For + * [IndustryVertical.SITE_SEARCH][google.cloud.discoveryengine.v1beta.IndustryVertical.SITE_SEARCH] + * vertical, supported values are: + * * `user_country_code`: string. Default empty. If set to non-empty, results + * are restricted or boosted based on the location provided. + * * `search_type`: double. Default empty. Enables non-webpage searching + * depending on the value. The only valid non-default value is 1, + * which enables image searching. + * + * Generated from protobuf field map params = 11; + * @return \Google\Protobuf\Internal\MapField + */ + public function getParams() + { + return $this->params; + } + + /** + * Additional search parameters. + * For + * [IndustryVertical.SITE_SEARCH][google.cloud.discoveryengine.v1beta.IndustryVertical.SITE_SEARCH] + * vertical, supported values are: + * * `user_country_code`: string. Default empty. If set to non-empty, results + * are restricted or boosted based on the location provided. + * * `search_type`: double. Default empty. Enables non-webpage searching + * depending on the value. The only valid non-default value is 1, + * which enables image searching. + * + * Generated from protobuf field map params = 11; + * @param array|\Google\Protobuf\Internal\MapField $var + * @return $this + */ + public function setParams($var) + { + $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Value::class); + $this->params = $arr; + + return $this; + } + + /** + * The query expansion specification that specifies the conditions under which + * query expansion will occur. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.SearchRequest.QueryExpansionSpec query_expansion_spec = 13; + * @return \Google\Cloud\DiscoveryEngine\V1beta\SearchRequest\QueryExpansionSpec|null + */ + public function getQueryExpansionSpec() + { + return $this->query_expansion_spec; + } + + public function hasQueryExpansionSpec() + { + return isset($this->query_expansion_spec); + } + + public function clearQueryExpansionSpec() + { + unset($this->query_expansion_spec); + } + + /** + * The query expansion specification that specifies the conditions under which + * query expansion will occur. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.SearchRequest.QueryExpansionSpec query_expansion_spec = 13; + * @param \Google\Cloud\DiscoveryEngine\V1beta\SearchRequest\QueryExpansionSpec $var + * @return $this + */ + public function setQueryExpansionSpec($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\DiscoveryEngine\V1beta\SearchRequest\QueryExpansionSpec::class); + $this->query_expansion_spec = $var; + + return $this; + } + + /** + * The spell correction specification that specifies the mode under + * which spell correction will take effect. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.SearchRequest.SpellCorrectionSpec spell_correction_spec = 14; + * @return \Google\Cloud\DiscoveryEngine\V1beta\SearchRequest\SpellCorrectionSpec|null + */ + public function getSpellCorrectionSpec() + { + return $this->spell_correction_spec; + } + + public function hasSpellCorrectionSpec() + { + return isset($this->spell_correction_spec); + } + + public function clearSpellCorrectionSpec() + { + unset($this->spell_correction_spec); + } + + /** + * The spell correction specification that specifies the mode under + * which spell correction will take effect. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.SearchRequest.SpellCorrectionSpec spell_correction_spec = 14; + * @param \Google\Cloud\DiscoveryEngine\V1beta\SearchRequest\SpellCorrectionSpec $var + * @return $this + */ + public function setSpellCorrectionSpec($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\DiscoveryEngine\V1beta\SearchRequest\SpellCorrectionSpec::class); + $this->spell_correction_spec = $var; + + return $this; + } + + /** + * A unique identifier for tracking visitors. For example, this could be + * implemented with an HTTP cookie, which should be able to uniquely identify + * a visitor on a single device. This unique identifier should not change if + * the visitor logs in or out of the website. + * This field should NOT have a fixed value such as `unknown_visitor`. + * This should be the same identifier as + * [UserEvent.user_pseudo_id][google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id] + * and + * [CompleteQueryRequest.user_pseudo_id][google.cloud.discoveryengine.v1beta.CompleteQueryRequest.user_pseudo_id] + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an `INVALID_ARGUMENT` error is returned. + * + * Generated from protobuf field string user_pseudo_id = 15; + * @return string + */ + public function getUserPseudoId() + { + return $this->user_pseudo_id; + } + + /** + * A unique identifier for tracking visitors. For example, this could be + * implemented with an HTTP cookie, which should be able to uniquely identify + * a visitor on a single device. This unique identifier should not change if + * the visitor logs in or out of the website. + * This field should NOT have a fixed value such as `unknown_visitor`. + * This should be the same identifier as + * [UserEvent.user_pseudo_id][google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id] + * and + * [CompleteQueryRequest.user_pseudo_id][google.cloud.discoveryengine.v1beta.CompleteQueryRequest.user_pseudo_id] + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an `INVALID_ARGUMENT` error is returned. + * + * Generated from protobuf field string user_pseudo_id = 15; + * @param string $var + * @return $this + */ + public function setUserPseudoId($var) + { + GPBUtil::checkString($var, True); + $this->user_pseudo_id = $var; + + return $this; + } + + /** + * The content search spec that configs the desired behavior of content + * search. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec content_search_spec = 24; + * @return \Google\Cloud\DiscoveryEngine\V1beta\SearchRequest\ContentSearchSpec|null + */ + public function getContentSearchSpec() + { + return $this->content_search_spec; + } + + public function hasContentSearchSpec() + { + return isset($this->content_search_spec); + } + + public function clearContentSearchSpec() + { + unset($this->content_search_spec); + } + + /** + * The content search spec that configs the desired behavior of content + * search. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec content_search_spec = 24; + * @param \Google\Cloud\DiscoveryEngine\V1beta\SearchRequest\ContentSearchSpec $var + * @return $this + */ + public function setContentSearchSpec($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\DiscoveryEngine\V1beta\SearchRequest\ContentSearchSpec::class); + $this->content_search_spec = $var; + + return $this; + } + + /** + * Whether to turn on safe search. This is only supported for + * [ContentConfig.PUBLIC_WEBSITE][]. + * + * Generated from protobuf field bool safe_search = 20; + * @return bool + */ + public function getSafeSearch() + { + return $this->safe_search; + } + + /** + * Whether to turn on safe search. This is only supported for + * [ContentConfig.PUBLIC_WEBSITE][]. + * + * Generated from protobuf field bool safe_search = 20; + * @param bool $var + * @return $this + */ + public function setSafeSearch($var) + { + GPBUtil::checkBool($var); + $this->safe_search = $var; + + return $this; + } + + /** + * The user labels applied to a resource must meet the following requirements: + * * Each resource can have multiple labels, up to a maximum of 64. + * * Each label must be a key-value pair. + * * Keys have a minimum length of 1 character and a maximum length of 63 + * characters and cannot be empty. Values can be empty and have a maximum + * length of 63 characters. + * * Keys and values can contain only lowercase letters, numeric characters, + * underscores, and dashes. All characters must use UTF-8 encoding, and + * international characters are allowed. + * * The key portion of a label must be unique. However, you can use the same + * key with multiple resources. + * * Keys must start with a lowercase letter or international character. + * See [Google Cloud + * Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + * for more details. + * + * Generated from protobuf field map user_label = 22; + * @return \Google\Protobuf\Internal\MapField + */ + public function getUserLabel() + { + return $this->user_label; + } + + /** + * The user labels applied to a resource must meet the following requirements: + * * Each resource can have multiple labels, up to a maximum of 64. + * * Each label must be a key-value pair. + * * Keys have a minimum length of 1 character and a maximum length of 63 + * characters and cannot be empty. Values can be empty and have a maximum + * length of 63 characters. + * * Keys and values can contain only lowercase letters, numeric characters, + * underscores, and dashes. All characters must use UTF-8 encoding, and + * international characters are allowed. + * * The key portion of a label must be unique. However, you can use the same + * key with multiple resources. + * * Keys must start with a lowercase letter or international character. + * See [Google Cloud + * Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + * for more details. + * + * Generated from protobuf field map user_label = 22; + * @param array|\Google\Protobuf\Internal\MapField $var + * @return $this + */ + public function setUserLabel($var) + { + $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::STRING); + $this->user_label = $arr; + + return $this; + } + +} + diff --git a/DiscoveryEngine/src/V1beta/SearchRequest/BoostSpec.php b/DiscoveryEngine/src/V1beta/SearchRequest/BoostSpec.php new file mode 100644 index 000000000000..1f99ea7b06ed --- /dev/null +++ b/DiscoveryEngine/src/V1beta/SearchRequest/BoostSpec.php @@ -0,0 +1,80 @@ +google.cloud.discoveryengine.v1beta.SearchRequest.BoostSpec + */ +class BoostSpec extends \Google\Protobuf\Internal\Message +{ + /** + * Condition boost specifications. If a document matches multiple conditions + * in the specifictions, boost scores from these specifications are all + * applied and combined in a non-linear way. Maximum number of + * specifications is 20. + * + * Generated from protobuf field repeated .google.cloud.discoveryengine.v1beta.SearchRequest.BoostSpec.ConditionBoostSpec condition_boost_specs = 1; + */ + private $condition_boost_specs; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\Google\Cloud\DiscoveryEngine\V1beta\SearchRequest\BoostSpec\ConditionBoostSpec>|\Google\Protobuf\Internal\RepeatedField $condition_boost_specs + * Condition boost specifications. If a document matches multiple conditions + * in the specifictions, boost scores from these specifications are all + * applied and combined in a non-linear way. Maximum number of + * specifications is 20. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\SearchService::initOnce(); + parent::__construct($data); + } + + /** + * Condition boost specifications. If a document matches multiple conditions + * in the specifictions, boost scores from these specifications are all + * applied and combined in a non-linear way. Maximum number of + * specifications is 20. + * + * Generated from protobuf field repeated .google.cloud.discoveryengine.v1beta.SearchRequest.BoostSpec.ConditionBoostSpec condition_boost_specs = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getConditionBoostSpecs() + { + return $this->condition_boost_specs; + } + + /** + * Condition boost specifications. If a document matches multiple conditions + * in the specifictions, boost scores from these specifications are all + * applied and combined in a non-linear way. Maximum number of + * specifications is 20. + * + * Generated from protobuf field repeated .google.cloud.discoveryengine.v1beta.SearchRequest.BoostSpec.ConditionBoostSpec condition_boost_specs = 1; + * @param array<\Google\Cloud\DiscoveryEngine\V1beta\SearchRequest\BoostSpec\ConditionBoostSpec>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setConditionBoostSpecs($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\DiscoveryEngine\V1beta\SearchRequest\BoostSpec\ConditionBoostSpec::class); + $this->condition_boost_specs = $arr; + + return $this; + } + +} + + diff --git a/DiscoveryEngine/src/V1beta/SearchRequest/BoostSpec/ConditionBoostSpec.php b/DiscoveryEngine/src/V1beta/SearchRequest/BoostSpec/ConditionBoostSpec.php new file mode 100644 index 000000000000..f5d085dea4d2 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/SearchRequest/BoostSpec/ConditionBoostSpec.php @@ -0,0 +1,186 @@ +google.cloud.discoveryengine.v1beta.SearchRequest.BoostSpec.ConditionBoostSpec + */ +class ConditionBoostSpec extends \Google\Protobuf\Internal\Message +{ + /** + * An expression which specifies a boost condition. The syntax and + * supported fields are the same as a filter expression. See + * [SearchRequest.filter][google.cloud.discoveryengine.v1beta.SearchRequest.filter] + * for detail syntax and limitations. + * Examples: + * * To boost documents with document ID "doc_1" or "doc_2", and + * color + * "Red" or "Blue": + * * (id: ANY("doc_1", "doc_2")) AND (color: ANY("Red","Blue")) + * + * Generated from protobuf field string condition = 1; + */ + protected $condition = ''; + /** + * Strength of the condition boost, which should be in [-1, 1]. Negative + * boost means demotion. Default is 0.0. + * Setting to 1.0 gives the document a big promotion. However, it does not + * necessarily mean that the boosted document will be the top result at + * all times, nor that other documents will be excluded. Results could + * still be shown even when none of them matches the condition. And + * results that are significantly more relevant to the search query can + * still trump your heavily favored but irrelevant documents. + * Setting to -1.0 gives the document a big demotion. However, results + * that are deeply relevant might still be shown. The document will have + * an upstream battle to get a fairly high ranking, but it is not blocked + * out completely. + * Setting to 0.0 means no boost applied. The boosting condition is + * ignored. + * + * Generated from protobuf field float boost = 2; + */ + protected $boost = 0.0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $condition + * An expression which specifies a boost condition. The syntax and + * supported fields are the same as a filter expression. See + * [SearchRequest.filter][google.cloud.discoveryengine.v1beta.SearchRequest.filter] + * for detail syntax and limitations. + * Examples: + * * To boost documents with document ID "doc_1" or "doc_2", and + * color + * "Red" or "Blue": + * * (id: ANY("doc_1", "doc_2")) AND (color: ANY("Red","Blue")) + * @type float $boost + * Strength of the condition boost, which should be in [-1, 1]. Negative + * boost means demotion. Default is 0.0. + * Setting to 1.0 gives the document a big promotion. However, it does not + * necessarily mean that the boosted document will be the top result at + * all times, nor that other documents will be excluded. Results could + * still be shown even when none of them matches the condition. And + * results that are significantly more relevant to the search query can + * still trump your heavily favored but irrelevant documents. + * Setting to -1.0 gives the document a big demotion. However, results + * that are deeply relevant might still be shown. The document will have + * an upstream battle to get a fairly high ranking, but it is not blocked + * out completely. + * Setting to 0.0 means no boost applied. The boosting condition is + * ignored. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\SearchService::initOnce(); + parent::__construct($data); + } + + /** + * An expression which specifies a boost condition. The syntax and + * supported fields are the same as a filter expression. See + * [SearchRequest.filter][google.cloud.discoveryengine.v1beta.SearchRequest.filter] + * for detail syntax and limitations. + * Examples: + * * To boost documents with document ID "doc_1" or "doc_2", and + * color + * "Red" or "Blue": + * * (id: ANY("doc_1", "doc_2")) AND (color: ANY("Red","Blue")) + * + * Generated from protobuf field string condition = 1; + * @return string + */ + public function getCondition() + { + return $this->condition; + } + + /** + * An expression which specifies a boost condition. The syntax and + * supported fields are the same as a filter expression. See + * [SearchRequest.filter][google.cloud.discoveryengine.v1beta.SearchRequest.filter] + * for detail syntax and limitations. + * Examples: + * * To boost documents with document ID "doc_1" or "doc_2", and + * color + * "Red" or "Blue": + * * (id: ANY("doc_1", "doc_2")) AND (color: ANY("Red","Blue")) + * + * Generated from protobuf field string condition = 1; + * @param string $var + * @return $this + */ + public function setCondition($var) + { + GPBUtil::checkString($var, True); + $this->condition = $var; + + return $this; + } + + /** + * Strength of the condition boost, which should be in [-1, 1]. Negative + * boost means demotion. Default is 0.0. + * Setting to 1.0 gives the document a big promotion. However, it does not + * necessarily mean that the boosted document will be the top result at + * all times, nor that other documents will be excluded. Results could + * still be shown even when none of them matches the condition. And + * results that are significantly more relevant to the search query can + * still trump your heavily favored but irrelevant documents. + * Setting to -1.0 gives the document a big demotion. However, results + * that are deeply relevant might still be shown. The document will have + * an upstream battle to get a fairly high ranking, but it is not blocked + * out completely. + * Setting to 0.0 means no boost applied. The boosting condition is + * ignored. + * + * Generated from protobuf field float boost = 2; + * @return float + */ + public function getBoost() + { + return $this->boost; + } + + /** + * Strength of the condition boost, which should be in [-1, 1]. Negative + * boost means demotion. Default is 0.0. + * Setting to 1.0 gives the document a big promotion. However, it does not + * necessarily mean that the boosted document will be the top result at + * all times, nor that other documents will be excluded. Results could + * still be shown even when none of them matches the condition. And + * results that are significantly more relevant to the search query can + * still trump your heavily favored but irrelevant documents. + * Setting to -1.0 gives the document a big demotion. However, results + * that are deeply relevant might still be shown. The document will have + * an upstream battle to get a fairly high ranking, but it is not blocked + * out completely. + * Setting to 0.0 means no boost applied. The boosting condition is + * ignored. + * + * Generated from protobuf field float boost = 2; + * @param float $var + * @return $this + */ + public function setBoost($var) + { + GPBUtil::checkFloat($var); + $this->boost = $var; + + return $this; + } + +} + + diff --git a/DiscoveryEngine/src/V1beta/SearchRequest/ContentSearchSpec.php b/DiscoveryEngine/src/V1beta/SearchRequest/ContentSearchSpec.php new file mode 100644 index 000000000000..144b0748735e --- /dev/null +++ b/DiscoveryEngine/src/V1beta/SearchRequest/ContentSearchSpec.php @@ -0,0 +1,131 @@ +google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec + */ +class ContentSearchSpec extends \Google\Protobuf\Internal\Message +{ + /** + * If there is no snippet spec provided, there will be no snippet in the + * search result. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.SnippetSpec snippet_spec = 1; + */ + protected $snippet_spec = null; + /** + * If there is no summary spec provided, there will be no summary in the + * search response. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.SummarySpec summary_spec = 2; + */ + protected $summary_spec = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\DiscoveryEngine\V1beta\SearchRequest\ContentSearchSpec\SnippetSpec $snippet_spec + * If there is no snippet spec provided, there will be no snippet in the + * search result. + * @type \Google\Cloud\DiscoveryEngine\V1beta\SearchRequest\ContentSearchSpec\SummarySpec $summary_spec + * If there is no summary spec provided, there will be no summary in the + * search response. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\SearchService::initOnce(); + parent::__construct($data); + } + + /** + * If there is no snippet spec provided, there will be no snippet in the + * search result. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.SnippetSpec snippet_spec = 1; + * @return \Google\Cloud\DiscoveryEngine\V1beta\SearchRequest\ContentSearchSpec\SnippetSpec|null + */ + public function getSnippetSpec() + { + return $this->snippet_spec; + } + + public function hasSnippetSpec() + { + return isset($this->snippet_spec); + } + + public function clearSnippetSpec() + { + unset($this->snippet_spec); + } + + /** + * If there is no snippet spec provided, there will be no snippet in the + * search result. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.SnippetSpec snippet_spec = 1; + * @param \Google\Cloud\DiscoveryEngine\V1beta\SearchRequest\ContentSearchSpec\SnippetSpec $var + * @return $this + */ + public function setSnippetSpec($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\DiscoveryEngine\V1beta\SearchRequest\ContentSearchSpec\SnippetSpec::class); + $this->snippet_spec = $var; + + return $this; + } + + /** + * If there is no summary spec provided, there will be no summary in the + * search response. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.SummarySpec summary_spec = 2; + * @return \Google\Cloud\DiscoveryEngine\V1beta\SearchRequest\ContentSearchSpec\SummarySpec|null + */ + public function getSummarySpec() + { + return $this->summary_spec; + } + + public function hasSummarySpec() + { + return isset($this->summary_spec); + } + + public function clearSummarySpec() + { + unset($this->summary_spec); + } + + /** + * If there is no summary spec provided, there will be no summary in the + * search response. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.SummarySpec summary_spec = 2; + * @param \Google\Cloud\DiscoveryEngine\V1beta\SearchRequest\ContentSearchSpec\SummarySpec $var + * @return $this + */ + public function setSummarySpec($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\DiscoveryEngine\V1beta\SearchRequest\ContentSearchSpec\SummarySpec::class); + $this->summary_spec = $var; + + return $this; + } + +} + + diff --git a/DiscoveryEngine/src/V1beta/SearchRequest/ContentSearchSpec/SnippetSpec.php b/DiscoveryEngine/src/V1beta/SearchRequest/ContentSearchSpec/SnippetSpec.php new file mode 100644 index 000000000000..4871fa805e76 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/SearchRequest/ContentSearchSpec/SnippetSpec.php @@ -0,0 +1,114 @@ +google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.SnippetSpec + */ +class SnippetSpec extends \Google\Protobuf\Internal\Message +{ + /** + * Max number of snippets returned in each search result. + * If the matching snippets is less than the max_snippet_count, return all + * of the snippets; otherwise, return the max_snippet_count. + * At most 5 snippets will be returned for each SearchResult. + * + * Generated from protobuf field int32 max_snippet_count = 1; + */ + protected $max_snippet_count = 0; + /** + * if true, only snippet reference is returned. + * + * Generated from protobuf field bool reference_only = 2; + */ + protected $reference_only = false; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int $max_snippet_count + * Max number of snippets returned in each search result. + * If the matching snippets is less than the max_snippet_count, return all + * of the snippets; otherwise, return the max_snippet_count. + * At most 5 snippets will be returned for each SearchResult. + * @type bool $reference_only + * if true, only snippet reference is returned. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\SearchService::initOnce(); + parent::__construct($data); + } + + /** + * Max number of snippets returned in each search result. + * If the matching snippets is less than the max_snippet_count, return all + * of the snippets; otherwise, return the max_snippet_count. + * At most 5 snippets will be returned for each SearchResult. + * + * Generated from protobuf field int32 max_snippet_count = 1; + * @return int + */ + public function getMaxSnippetCount() + { + return $this->max_snippet_count; + } + + /** + * Max number of snippets returned in each search result. + * If the matching snippets is less than the max_snippet_count, return all + * of the snippets; otherwise, return the max_snippet_count. + * At most 5 snippets will be returned for each SearchResult. + * + * Generated from protobuf field int32 max_snippet_count = 1; + * @param int $var + * @return $this + */ + public function setMaxSnippetCount($var) + { + GPBUtil::checkInt32($var); + $this->max_snippet_count = $var; + + return $this; + } + + /** + * if true, only snippet reference is returned. + * + * Generated from protobuf field bool reference_only = 2; + * @return bool + */ + public function getReferenceOnly() + { + return $this->reference_only; + } + + /** + * if true, only snippet reference is returned. + * + * Generated from protobuf field bool reference_only = 2; + * @param bool $var + * @return $this + */ + public function setReferenceOnly($var) + { + GPBUtil::checkBool($var); + $this->reference_only = $var; + + return $this; + } + +} + + diff --git a/DiscoveryEngine/src/V1beta/SearchRequest/ContentSearchSpec/SummarySpec.php b/DiscoveryEngine/src/V1beta/SearchRequest/ContentSearchSpec/SummarySpec.php new file mode 100644 index 000000000000..5d16576b9e69 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/SearchRequest/ContentSearchSpec/SummarySpec.php @@ -0,0 +1,84 @@ +google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.SummarySpec + */ +class SummarySpec extends \Google\Protobuf\Internal\Message +{ + /** + * The number of top results the summary should be generated from. + * If the number of returned results is less than summary_result_count, + * then the summary would be derived from all the results; otherwise, the + * summary would be derived from the top results. + * At most 5 results can be used for generating summary. + * + * Generated from protobuf field int32 summary_result_count = 1; + */ + protected $summary_result_count = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int $summary_result_count + * The number of top results the summary should be generated from. + * If the number of returned results is less than summary_result_count, + * then the summary would be derived from all the results; otherwise, the + * summary would be derived from the top results. + * At most 5 results can be used for generating summary. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\SearchService::initOnce(); + parent::__construct($data); + } + + /** + * The number of top results the summary should be generated from. + * If the number of returned results is less than summary_result_count, + * then the summary would be derived from all the results; otherwise, the + * summary would be derived from the top results. + * At most 5 results can be used for generating summary. + * + * Generated from protobuf field int32 summary_result_count = 1; + * @return int + */ + public function getSummaryResultCount() + { + return $this->summary_result_count; + } + + /** + * The number of top results the summary should be generated from. + * If the number of returned results is less than summary_result_count, + * then the summary would be derived from all the results; otherwise, the + * summary would be derived from the top results. + * At most 5 results can be used for generating summary. + * + * Generated from protobuf field int32 summary_result_count = 1; + * @param int $var + * @return $this + */ + public function setSummaryResultCount($var) + { + GPBUtil::checkInt32($var); + $this->summary_result_count = $var; + + return $this; + } + +} + + diff --git a/DiscoveryEngine/src/V1beta/SearchRequest/FacetSpec.php b/DiscoveryEngine/src/V1beta/SearchRequest/FacetSpec.php new file mode 100644 index 000000000000..55a24f30cd6e --- /dev/null +++ b/DiscoveryEngine/src/V1beta/SearchRequest/FacetSpec.php @@ -0,0 +1,360 @@ +google.cloud.discoveryengine.v1beta.SearchRequest.FacetSpec + */ +class FacetSpec extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The facet key specification. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.SearchRequest.FacetSpec.FacetKey facet_key = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $facet_key = null; + /** + * Maximum of facet values that should be returned for this facet. If + * unspecified, defaults to 20. The maximum allowed value is 300. Values + * above 300 will be coerced to 300. + * If this field is negative, an `INVALID_ARGUMENT` is returned. + * + * Generated from protobuf field int32 limit = 2; + */ + protected $limit = 0; + /** + * List of keys to exclude when faceting. + * By default, + * [FacetKey.key][google.cloud.discoveryengine.v1beta.SearchRequest.FacetSpec.FacetKey.key] + * is not excluded from the filter unless it is listed in this field. + * Listing a facet key in this field allows its values to appear as facet + * results, even when they are filtered out of search results. Using this + * field does not affect what search results are returned. + * For example, suppose there are 100 documents with the color facet "Red" + * and 200 documents with the color facet "Blue". A query containing the + * filter "color:ANY("Red")" and having "color" as + * [FacetKey.key][google.cloud.discoveryengine.v1beta.SearchRequest.FacetSpec.FacetKey.key] + * would by default return only "Red" documents in the search results, and + * also return "Red" with count 100 as the only color facet. Although there + * are also blue documents available, "Blue" would not be shown as an + * available facet value. + * If "color" is listed in "excludedFilterKeys", then the query returns the + * facet values "Red" with count 100 and "Blue" with count 200, because the + * "color" key is now excluded from the filter. Because this field doesn't + * affect search results, the search results are still correctly filtered to + * return only "Red" documents. + * A maximum of 100 values are allowed. Otherwise, an `INVALID_ARGUMENT` + * error is returned. + * + * Generated from protobuf field repeated string excluded_filter_keys = 3; + */ + private $excluded_filter_keys; + /** + * Enables dynamic position for this facet. If set to true, the position of + * this facet among all facets in the response is determined automatically. + * It will be ordered together with dynamic facets if dynamic + * facets is enabled. If set to false, the position of this facet in the + * response will be the same as in the request, and it will be ranked before + * the facets with dynamic position enable and all dynamic facets. + * For example, you may always want to have rating facet returned in + * the response, but it's not necessarily to always display the rating facet + * at the top. In that case, you can set enable_dynamic_position to true so + * that the position of rating facet in response will be determined + * automatically. + * Another example, assuming you have the following facets in the request: + * * "rating", enable_dynamic_position = true + * * "price", enable_dynamic_position = false + * * "brands", enable_dynamic_position = false + * And also you have a dynamic facets enable, which will generate a facet + * 'gender'. Then the final order of the facets in the response can be + * ("price", "brands", "rating", "gender") or ("price", "brands", "gender", + * "rating") depends on how API orders "gender" and "rating" facets. + * However, notice that "price" and "brands" will always be + * ranked at 1st and 2nd position since their enable_dynamic_position are + * false. + * + * Generated from protobuf field bool enable_dynamic_position = 4; + */ + protected $enable_dynamic_position = false; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\DiscoveryEngine\V1beta\SearchRequest\FacetSpec\FacetKey $facet_key + * Required. The facet key specification. + * @type int $limit + * Maximum of facet values that should be returned for this facet. If + * unspecified, defaults to 20. The maximum allowed value is 300. Values + * above 300 will be coerced to 300. + * If this field is negative, an `INVALID_ARGUMENT` is returned. + * @type array|\Google\Protobuf\Internal\RepeatedField $excluded_filter_keys + * List of keys to exclude when faceting. + * By default, + * [FacetKey.key][google.cloud.discoveryengine.v1beta.SearchRequest.FacetSpec.FacetKey.key] + * is not excluded from the filter unless it is listed in this field. + * Listing a facet key in this field allows its values to appear as facet + * results, even when they are filtered out of search results. Using this + * field does not affect what search results are returned. + * For example, suppose there are 100 documents with the color facet "Red" + * and 200 documents with the color facet "Blue". A query containing the + * filter "color:ANY("Red")" and having "color" as + * [FacetKey.key][google.cloud.discoveryengine.v1beta.SearchRequest.FacetSpec.FacetKey.key] + * would by default return only "Red" documents in the search results, and + * also return "Red" with count 100 as the only color facet. Although there + * are also blue documents available, "Blue" would not be shown as an + * available facet value. + * If "color" is listed in "excludedFilterKeys", then the query returns the + * facet values "Red" with count 100 and "Blue" with count 200, because the + * "color" key is now excluded from the filter. Because this field doesn't + * affect search results, the search results are still correctly filtered to + * return only "Red" documents. + * A maximum of 100 values are allowed. Otherwise, an `INVALID_ARGUMENT` + * error is returned. + * @type bool $enable_dynamic_position + * Enables dynamic position for this facet. If set to true, the position of + * this facet among all facets in the response is determined automatically. + * It will be ordered together with dynamic facets if dynamic + * facets is enabled. If set to false, the position of this facet in the + * response will be the same as in the request, and it will be ranked before + * the facets with dynamic position enable and all dynamic facets. + * For example, you may always want to have rating facet returned in + * the response, but it's not necessarily to always display the rating facet + * at the top. In that case, you can set enable_dynamic_position to true so + * that the position of rating facet in response will be determined + * automatically. + * Another example, assuming you have the following facets in the request: + * * "rating", enable_dynamic_position = true + * * "price", enable_dynamic_position = false + * * "brands", enable_dynamic_position = false + * And also you have a dynamic facets enable, which will generate a facet + * 'gender'. Then the final order of the facets in the response can be + * ("price", "brands", "rating", "gender") or ("price", "brands", "gender", + * "rating") depends on how API orders "gender" and "rating" facets. + * However, notice that "price" and "brands" will always be + * ranked at 1st and 2nd position since their enable_dynamic_position are + * false. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\SearchService::initOnce(); + parent::__construct($data); + } + + /** + * Required. The facet key specification. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.SearchRequest.FacetSpec.FacetKey facet_key = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\DiscoveryEngine\V1beta\SearchRequest\FacetSpec\FacetKey|null + */ + public function getFacetKey() + { + return $this->facet_key; + } + + public function hasFacetKey() + { + return isset($this->facet_key); + } + + public function clearFacetKey() + { + unset($this->facet_key); + } + + /** + * Required. The facet key specification. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.SearchRequest.FacetSpec.FacetKey facet_key = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\DiscoveryEngine\V1beta\SearchRequest\FacetSpec\FacetKey $var + * @return $this + */ + public function setFacetKey($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\DiscoveryEngine\V1beta\SearchRequest\FacetSpec\FacetKey::class); + $this->facet_key = $var; + + return $this; + } + + /** + * Maximum of facet values that should be returned for this facet. If + * unspecified, defaults to 20. The maximum allowed value is 300. Values + * above 300 will be coerced to 300. + * If this field is negative, an `INVALID_ARGUMENT` is returned. + * + * Generated from protobuf field int32 limit = 2; + * @return int + */ + public function getLimit() + { + return $this->limit; + } + + /** + * Maximum of facet values that should be returned for this facet. If + * unspecified, defaults to 20. The maximum allowed value is 300. Values + * above 300 will be coerced to 300. + * If this field is negative, an `INVALID_ARGUMENT` is returned. + * + * Generated from protobuf field int32 limit = 2; + * @param int $var + * @return $this + */ + public function setLimit($var) + { + GPBUtil::checkInt32($var); + $this->limit = $var; + + return $this; + } + + /** + * List of keys to exclude when faceting. + * By default, + * [FacetKey.key][google.cloud.discoveryengine.v1beta.SearchRequest.FacetSpec.FacetKey.key] + * is not excluded from the filter unless it is listed in this field. + * Listing a facet key in this field allows its values to appear as facet + * results, even when they are filtered out of search results. Using this + * field does not affect what search results are returned. + * For example, suppose there are 100 documents with the color facet "Red" + * and 200 documents with the color facet "Blue". A query containing the + * filter "color:ANY("Red")" and having "color" as + * [FacetKey.key][google.cloud.discoveryengine.v1beta.SearchRequest.FacetSpec.FacetKey.key] + * would by default return only "Red" documents in the search results, and + * also return "Red" with count 100 as the only color facet. Although there + * are also blue documents available, "Blue" would not be shown as an + * available facet value. + * If "color" is listed in "excludedFilterKeys", then the query returns the + * facet values "Red" with count 100 and "Blue" with count 200, because the + * "color" key is now excluded from the filter. Because this field doesn't + * affect search results, the search results are still correctly filtered to + * return only "Red" documents. + * A maximum of 100 values are allowed. Otherwise, an `INVALID_ARGUMENT` + * error is returned. + * + * Generated from protobuf field repeated string excluded_filter_keys = 3; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getExcludedFilterKeys() + { + return $this->excluded_filter_keys; + } + + /** + * List of keys to exclude when faceting. + * By default, + * [FacetKey.key][google.cloud.discoveryengine.v1beta.SearchRequest.FacetSpec.FacetKey.key] + * is not excluded from the filter unless it is listed in this field. + * Listing a facet key in this field allows its values to appear as facet + * results, even when they are filtered out of search results. Using this + * field does not affect what search results are returned. + * For example, suppose there are 100 documents with the color facet "Red" + * and 200 documents with the color facet "Blue". A query containing the + * filter "color:ANY("Red")" and having "color" as + * [FacetKey.key][google.cloud.discoveryengine.v1beta.SearchRequest.FacetSpec.FacetKey.key] + * would by default return only "Red" documents in the search results, and + * also return "Red" with count 100 as the only color facet. Although there + * are also blue documents available, "Blue" would not be shown as an + * available facet value. + * If "color" is listed in "excludedFilterKeys", then the query returns the + * facet values "Red" with count 100 and "Blue" with count 200, because the + * "color" key is now excluded from the filter. Because this field doesn't + * affect search results, the search results are still correctly filtered to + * return only "Red" documents. + * A maximum of 100 values are allowed. Otherwise, an `INVALID_ARGUMENT` + * error is returned. + * + * Generated from protobuf field repeated string excluded_filter_keys = 3; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setExcludedFilterKeys($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->excluded_filter_keys = $arr; + + return $this; + } + + /** + * Enables dynamic position for this facet. If set to true, the position of + * this facet among all facets in the response is determined automatically. + * It will be ordered together with dynamic facets if dynamic + * facets is enabled. If set to false, the position of this facet in the + * response will be the same as in the request, and it will be ranked before + * the facets with dynamic position enable and all dynamic facets. + * For example, you may always want to have rating facet returned in + * the response, but it's not necessarily to always display the rating facet + * at the top. In that case, you can set enable_dynamic_position to true so + * that the position of rating facet in response will be determined + * automatically. + * Another example, assuming you have the following facets in the request: + * * "rating", enable_dynamic_position = true + * * "price", enable_dynamic_position = false + * * "brands", enable_dynamic_position = false + * And also you have a dynamic facets enable, which will generate a facet + * 'gender'. Then the final order of the facets in the response can be + * ("price", "brands", "rating", "gender") or ("price", "brands", "gender", + * "rating") depends on how API orders "gender" and "rating" facets. + * However, notice that "price" and "brands" will always be + * ranked at 1st and 2nd position since their enable_dynamic_position are + * false. + * + * Generated from protobuf field bool enable_dynamic_position = 4; + * @return bool + */ + public function getEnableDynamicPosition() + { + return $this->enable_dynamic_position; + } + + /** + * Enables dynamic position for this facet. If set to true, the position of + * this facet among all facets in the response is determined automatically. + * It will be ordered together with dynamic facets if dynamic + * facets is enabled. If set to false, the position of this facet in the + * response will be the same as in the request, and it will be ranked before + * the facets with dynamic position enable and all dynamic facets. + * For example, you may always want to have rating facet returned in + * the response, but it's not necessarily to always display the rating facet + * at the top. In that case, you can set enable_dynamic_position to true so + * that the position of rating facet in response will be determined + * automatically. + * Another example, assuming you have the following facets in the request: + * * "rating", enable_dynamic_position = true + * * "price", enable_dynamic_position = false + * * "brands", enable_dynamic_position = false + * And also you have a dynamic facets enable, which will generate a facet + * 'gender'. Then the final order of the facets in the response can be + * ("price", "brands", "rating", "gender") or ("price", "brands", "gender", + * "rating") depends on how API orders "gender" and "rating" facets. + * However, notice that "price" and "brands" will always be + * ranked at 1st and 2nd position since their enable_dynamic_position are + * false. + * + * Generated from protobuf field bool enable_dynamic_position = 4; + * @param bool $var + * @return $this + */ + public function setEnableDynamicPosition($var) + { + GPBUtil::checkBool($var); + $this->enable_dynamic_position = $var; + + return $this; + } + +} + + diff --git a/DiscoveryEngine/src/V1beta/SearchRequest/FacetSpec/FacetKey.php b/DiscoveryEngine/src/V1beta/SearchRequest/FacetSpec/FacetKey.php new file mode 100644 index 000000000000..2d5c50382fe2 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/SearchRequest/FacetSpec/FacetKey.php @@ -0,0 +1,392 @@ +google.cloud.discoveryengine.v1beta.SearchRequest.FacetSpec.FacetKey + */ +class FacetKey extends \Google\Protobuf\Internal\Message +{ + /** + * Required. Supported textual and numerical facet keys in + * [Document][google.cloud.discoveryengine.v1beta.Document] object, over + * which the facet values are computed. Facet key is case-sensitive. + * + * Generated from protobuf field string key = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $key = ''; + /** + * Set only if values should be bucketized into intervals. Must be set + * for facets with numerical values. Must not be set for facet with text + * values. Maximum number of intervals is 30. + * + * Generated from protobuf field repeated .google.cloud.discoveryengine.v1beta.Interval intervals = 2; + */ + private $intervals; + /** + * Only get facet for the given restricted values. Only supported on + * textual fields. For example, suppose "category" has three values + * "Action > 2022", "Action > 2021" and "Sci-Fi > 2022". If set + * "restricted_values" to "Action > 2022", the "category" facet will only + * contain "Action > 2022". Only supported on textual fields. Maximum + * is 10. + * + * Generated from protobuf field repeated string restricted_values = 3; + */ + private $restricted_values; + /** + * Only get facet values that start with the given string prefix. For + * example, suppose "category" has three values "Action > 2022", + * "Action > 2021" and "Sci-Fi > 2022". If set "prefixes" to "Action", the + * "category" facet will only contain "Action > 2022" and "Action > 2021". + * Only supported on textual fields. Maximum is 10. + * + * Generated from protobuf field repeated string prefixes = 4; + */ + private $prefixes; + /** + * Only get facet values that contains the given strings. For example, + * suppose "category" has three values "Action > 2022", + * "Action > 2021" and "Sci-Fi > 2022". If set "contains" to "2022", the + * "category" facet will only contain "Action > 2022" and "Sci-Fi > 2022". + * Only supported on textual fields. Maximum is 10. + * + * Generated from protobuf field repeated string contains = 5; + */ + private $contains; + /** + * True to make facet keys case insensitive when getting faceting + * values with prefixes or contains; false otherwise. + * + * Generated from protobuf field bool case_insensitive = 6; + */ + protected $case_insensitive = false; + /** + * The order in which documents are returned. + * Allowed values are: + * * "count desc", which means order by + * [SearchResponse.Facet.values.count][google.cloud.discoveryengine.v1beta.SearchResponse.Facet.FacetValue.count] + * descending. + * * "value desc", which means order by + * [SearchResponse.Facet.values.value][google.cloud.discoveryengine.v1beta.SearchResponse.Facet.FacetValue.value] + * descending. + * Only applies to textual facets. + * If not set, textual values are sorted in [natural + * order](https://en.wikipedia.org/wiki/Natural_sort_order); numerical + * intervals are sorted in the order given by + * [FacetSpec.FacetKey.intervals][google.cloud.discoveryengine.v1beta.SearchRequest.FacetSpec.FacetKey.intervals]. + * + * Generated from protobuf field string order_by = 7; + */ + protected $order_by = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $key + * Required. Supported textual and numerical facet keys in + * [Document][google.cloud.discoveryengine.v1beta.Document] object, over + * which the facet values are computed. Facet key is case-sensitive. + * @type array<\Google\Cloud\DiscoveryEngine\V1beta\Interval>|\Google\Protobuf\Internal\RepeatedField $intervals + * Set only if values should be bucketized into intervals. Must be set + * for facets with numerical values. Must not be set for facet with text + * values. Maximum number of intervals is 30. + * @type array|\Google\Protobuf\Internal\RepeatedField $restricted_values + * Only get facet for the given restricted values. Only supported on + * textual fields. For example, suppose "category" has three values + * "Action > 2022", "Action > 2021" and "Sci-Fi > 2022". If set + * "restricted_values" to "Action > 2022", the "category" facet will only + * contain "Action > 2022". Only supported on textual fields. Maximum + * is 10. + * @type array|\Google\Protobuf\Internal\RepeatedField $prefixes + * Only get facet values that start with the given string prefix. For + * example, suppose "category" has three values "Action > 2022", + * "Action > 2021" and "Sci-Fi > 2022". If set "prefixes" to "Action", the + * "category" facet will only contain "Action > 2022" and "Action > 2021". + * Only supported on textual fields. Maximum is 10. + * @type array|\Google\Protobuf\Internal\RepeatedField $contains + * Only get facet values that contains the given strings. For example, + * suppose "category" has three values "Action > 2022", + * "Action > 2021" and "Sci-Fi > 2022". If set "contains" to "2022", the + * "category" facet will only contain "Action > 2022" and "Sci-Fi > 2022". + * Only supported on textual fields. Maximum is 10. + * @type bool $case_insensitive + * True to make facet keys case insensitive when getting faceting + * values with prefixes or contains; false otherwise. + * @type string $order_by + * The order in which documents are returned. + * Allowed values are: + * * "count desc", which means order by + * [SearchResponse.Facet.values.count][google.cloud.discoveryengine.v1beta.SearchResponse.Facet.FacetValue.count] + * descending. + * * "value desc", which means order by + * [SearchResponse.Facet.values.value][google.cloud.discoveryengine.v1beta.SearchResponse.Facet.FacetValue.value] + * descending. + * Only applies to textual facets. + * If not set, textual values are sorted in [natural + * order](https://en.wikipedia.org/wiki/Natural_sort_order); numerical + * intervals are sorted in the order given by + * [FacetSpec.FacetKey.intervals][google.cloud.discoveryengine.v1beta.SearchRequest.FacetSpec.FacetKey.intervals]. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\SearchService::initOnce(); + parent::__construct($data); + } + + /** + * Required. Supported textual and numerical facet keys in + * [Document][google.cloud.discoveryengine.v1beta.Document] object, over + * which the facet values are computed. Facet key is case-sensitive. + * + * Generated from protobuf field string key = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getKey() + { + return $this->key; + } + + /** + * Required. Supported textual and numerical facet keys in + * [Document][google.cloud.discoveryengine.v1beta.Document] object, over + * which the facet values are computed. Facet key is case-sensitive. + * + * Generated from protobuf field string key = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setKey($var) + { + GPBUtil::checkString($var, True); + $this->key = $var; + + return $this; + } + + /** + * Set only if values should be bucketized into intervals. Must be set + * for facets with numerical values. Must not be set for facet with text + * values. Maximum number of intervals is 30. + * + * Generated from protobuf field repeated .google.cloud.discoveryengine.v1beta.Interval intervals = 2; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getIntervals() + { + return $this->intervals; + } + + /** + * Set only if values should be bucketized into intervals. Must be set + * for facets with numerical values. Must not be set for facet with text + * values. Maximum number of intervals is 30. + * + * Generated from protobuf field repeated .google.cloud.discoveryengine.v1beta.Interval intervals = 2; + * @param array<\Google\Cloud\DiscoveryEngine\V1beta\Interval>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setIntervals($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\DiscoveryEngine\V1beta\Interval::class); + $this->intervals = $arr; + + return $this; + } + + /** + * Only get facet for the given restricted values. Only supported on + * textual fields. For example, suppose "category" has three values + * "Action > 2022", "Action > 2021" and "Sci-Fi > 2022". If set + * "restricted_values" to "Action > 2022", the "category" facet will only + * contain "Action > 2022". Only supported on textual fields. Maximum + * is 10. + * + * Generated from protobuf field repeated string restricted_values = 3; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getRestrictedValues() + { + return $this->restricted_values; + } + + /** + * Only get facet for the given restricted values. Only supported on + * textual fields. For example, suppose "category" has three values + * "Action > 2022", "Action > 2021" and "Sci-Fi > 2022". If set + * "restricted_values" to "Action > 2022", the "category" facet will only + * contain "Action > 2022". Only supported on textual fields. Maximum + * is 10. + * + * Generated from protobuf field repeated string restricted_values = 3; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setRestrictedValues($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->restricted_values = $arr; + + return $this; + } + + /** + * Only get facet values that start with the given string prefix. For + * example, suppose "category" has three values "Action > 2022", + * "Action > 2021" and "Sci-Fi > 2022". If set "prefixes" to "Action", the + * "category" facet will only contain "Action > 2022" and "Action > 2021". + * Only supported on textual fields. Maximum is 10. + * + * Generated from protobuf field repeated string prefixes = 4; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getPrefixes() + { + return $this->prefixes; + } + + /** + * Only get facet values that start with the given string prefix. For + * example, suppose "category" has three values "Action > 2022", + * "Action > 2021" and "Sci-Fi > 2022". If set "prefixes" to "Action", the + * "category" facet will only contain "Action > 2022" and "Action > 2021". + * Only supported on textual fields. Maximum is 10. + * + * Generated from protobuf field repeated string prefixes = 4; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setPrefixes($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->prefixes = $arr; + + return $this; + } + + /** + * Only get facet values that contains the given strings. For example, + * suppose "category" has three values "Action > 2022", + * "Action > 2021" and "Sci-Fi > 2022". If set "contains" to "2022", the + * "category" facet will only contain "Action > 2022" and "Sci-Fi > 2022". + * Only supported on textual fields. Maximum is 10. + * + * Generated from protobuf field repeated string contains = 5; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getContains() + { + return $this->contains; + } + + /** + * Only get facet values that contains the given strings. For example, + * suppose "category" has three values "Action > 2022", + * "Action > 2021" and "Sci-Fi > 2022". If set "contains" to "2022", the + * "category" facet will only contain "Action > 2022" and "Sci-Fi > 2022". + * Only supported on textual fields. Maximum is 10. + * + * Generated from protobuf field repeated string contains = 5; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setContains($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->contains = $arr; + + return $this; + } + + /** + * True to make facet keys case insensitive when getting faceting + * values with prefixes or contains; false otherwise. + * + * Generated from protobuf field bool case_insensitive = 6; + * @return bool + */ + public function getCaseInsensitive() + { + return $this->case_insensitive; + } + + /** + * True to make facet keys case insensitive when getting faceting + * values with prefixes or contains; false otherwise. + * + * Generated from protobuf field bool case_insensitive = 6; + * @param bool $var + * @return $this + */ + public function setCaseInsensitive($var) + { + GPBUtil::checkBool($var); + $this->case_insensitive = $var; + + return $this; + } + + /** + * The order in which documents are returned. + * Allowed values are: + * * "count desc", which means order by + * [SearchResponse.Facet.values.count][google.cloud.discoveryengine.v1beta.SearchResponse.Facet.FacetValue.count] + * descending. + * * "value desc", which means order by + * [SearchResponse.Facet.values.value][google.cloud.discoveryengine.v1beta.SearchResponse.Facet.FacetValue.value] + * descending. + * Only applies to textual facets. + * If not set, textual values are sorted in [natural + * order](https://en.wikipedia.org/wiki/Natural_sort_order); numerical + * intervals are sorted in the order given by + * [FacetSpec.FacetKey.intervals][google.cloud.discoveryengine.v1beta.SearchRequest.FacetSpec.FacetKey.intervals]. + * + * Generated from protobuf field string order_by = 7; + * @return string + */ + public function getOrderBy() + { + return $this->order_by; + } + + /** + * The order in which documents are returned. + * Allowed values are: + * * "count desc", which means order by + * [SearchResponse.Facet.values.count][google.cloud.discoveryengine.v1beta.SearchResponse.Facet.FacetValue.count] + * descending. + * * "value desc", which means order by + * [SearchResponse.Facet.values.value][google.cloud.discoveryengine.v1beta.SearchResponse.Facet.FacetValue.value] + * descending. + * Only applies to textual facets. + * If not set, textual values are sorted in [natural + * order](https://en.wikipedia.org/wiki/Natural_sort_order); numerical + * intervals are sorted in the order given by + * [FacetSpec.FacetKey.intervals][google.cloud.discoveryengine.v1beta.SearchRequest.FacetSpec.FacetKey.intervals]. + * + * Generated from protobuf field string order_by = 7; + * @param string $var + * @return $this + */ + public function setOrderBy($var) + { + GPBUtil::checkString($var, True); + $this->order_by = $var; + + return $this; + } + +} + + diff --git a/DiscoveryEngine/src/V1beta/SearchRequest/QueryExpansionSpec.php b/DiscoveryEngine/src/V1beta/SearchRequest/QueryExpansionSpec.php new file mode 100644 index 000000000000..185865c16996 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/SearchRequest/QueryExpansionSpec.php @@ -0,0 +1,73 @@ +google.cloud.discoveryengine.v1beta.SearchRequest.QueryExpansionSpec + */ +class QueryExpansionSpec extends \Google\Protobuf\Internal\Message +{ + /** + * The condition under which query expansion should occur. Default to + * [Condition.DISABLED][google.cloud.discoveryengine.v1beta.SearchRequest.QueryExpansionSpec.Condition.DISABLED]. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.SearchRequest.QueryExpansionSpec.Condition condition = 1; + */ + protected $condition = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int $condition + * The condition under which query expansion should occur. Default to + * [Condition.DISABLED][google.cloud.discoveryengine.v1beta.SearchRequest.QueryExpansionSpec.Condition.DISABLED]. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\SearchService::initOnce(); + parent::__construct($data); + } + + /** + * The condition under which query expansion should occur. Default to + * [Condition.DISABLED][google.cloud.discoveryengine.v1beta.SearchRequest.QueryExpansionSpec.Condition.DISABLED]. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.SearchRequest.QueryExpansionSpec.Condition condition = 1; + * @return int + */ + public function getCondition() + { + return $this->condition; + } + + /** + * The condition under which query expansion should occur. Default to + * [Condition.DISABLED][google.cloud.discoveryengine.v1beta.SearchRequest.QueryExpansionSpec.Condition.DISABLED]. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.SearchRequest.QueryExpansionSpec.Condition condition = 1; + * @param int $var + * @return $this + */ + public function setCondition($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\DiscoveryEngine\V1beta\SearchRequest\QueryExpansionSpec\Condition::class); + $this->condition = $var; + + return $this; + } + +} + + diff --git a/DiscoveryEngine/src/V1beta/SearchRequest/QueryExpansionSpec/Condition.php b/DiscoveryEngine/src/V1beta/SearchRequest/QueryExpansionSpec/Condition.php new file mode 100644 index 000000000000..72ef89efed02 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/SearchRequest/QueryExpansionSpec/Condition.php @@ -0,0 +1,66 @@ +google.cloud.discoveryengine.v1beta.SearchRequest.QueryExpansionSpec.Condition + */ +class Condition +{ + /** + * Unspecified query expansion condition. In this case, server behavior + * defaults to + * [Condition.DISABLED][google.cloud.discoveryengine.v1beta.SearchRequest.QueryExpansionSpec.Condition.DISABLED]. + * + * Generated from protobuf enum CONDITION_UNSPECIFIED = 0; + */ + const CONDITION_UNSPECIFIED = 0; + /** + * Disabled query expansion. Only the exact search query is used, even if + * [SearchResponse.total_size][google.cloud.discoveryengine.v1beta.SearchResponse.total_size] + * is zero. + * + * Generated from protobuf enum DISABLED = 1; + */ + const DISABLED = 1; + /** + * Automatic query expansion built by the Search API. + * + * Generated from protobuf enum AUTO = 2; + */ + const AUTO = 2; + + private static $valueToName = [ + self::CONDITION_UNSPECIFIED => 'CONDITION_UNSPECIFIED', + self::DISABLED => 'DISABLED', + self::AUTO => 'AUTO', + ]; + + 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/DiscoveryEngine/src/V1beta/SearchRequest/SpellCorrectionSpec.php b/DiscoveryEngine/src/V1beta/SearchRequest/SpellCorrectionSpec.php new file mode 100644 index 000000000000..a9d063e6f598 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/SearchRequest/SpellCorrectionSpec.php @@ -0,0 +1,76 @@ +google.cloud.discoveryengine.v1beta.SearchRequest.SpellCorrectionSpec + */ +class SpellCorrectionSpec extends \Google\Protobuf\Internal\Message +{ + /** + * The mode under which spell correction should take effect to + * replace the original search query. Default to + * [Mode.AUTO][google.cloud.discoveryengine.v1beta.SearchRequest.SpellCorrectionSpec.Mode.AUTO]. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.SearchRequest.SpellCorrectionSpec.Mode mode = 1; + */ + protected $mode = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int $mode + * The mode under which spell correction should take effect to + * replace the original search query. Default to + * [Mode.AUTO][google.cloud.discoveryengine.v1beta.SearchRequest.SpellCorrectionSpec.Mode.AUTO]. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\SearchService::initOnce(); + parent::__construct($data); + } + + /** + * The mode under which spell correction should take effect to + * replace the original search query. Default to + * [Mode.AUTO][google.cloud.discoveryengine.v1beta.SearchRequest.SpellCorrectionSpec.Mode.AUTO]. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.SearchRequest.SpellCorrectionSpec.Mode mode = 1; + * @return int + */ + public function getMode() + { + return $this->mode; + } + + /** + * The mode under which spell correction should take effect to + * replace the original search query. Default to + * [Mode.AUTO][google.cloud.discoveryengine.v1beta.SearchRequest.SpellCorrectionSpec.Mode.AUTO]. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.SearchRequest.SpellCorrectionSpec.Mode mode = 1; + * @param int $var + * @return $this + */ + public function setMode($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\DiscoveryEngine\V1beta\SearchRequest\SpellCorrectionSpec\Mode::class); + $this->mode = $var; + + return $this; + } + +} + + diff --git a/DiscoveryEngine/src/V1beta/SearchRequest/SpellCorrectionSpec/Mode.php b/DiscoveryEngine/src/V1beta/SearchRequest/SpellCorrectionSpec/Mode.php new file mode 100644 index 000000000000..8297f114d490 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/SearchRequest/SpellCorrectionSpec/Mode.php @@ -0,0 +1,68 @@ +google.cloud.discoveryengine.v1beta.SearchRequest.SpellCorrectionSpec.Mode + */ +class Mode +{ + /** + * Unspecified spell correction mode. In this case, server behavior + * defaults to + * [Mode.AUTO][google.cloud.discoveryengine.v1beta.SearchRequest.SpellCorrectionSpec.Mode.AUTO]. + * + * Generated from protobuf enum MODE_UNSPECIFIED = 0; + */ + const MODE_UNSPECIFIED = 0; + /** + * Search API will try to find a spell suggestion if there + * is any and put in the + * [SearchResponse.corrected_query][google.cloud.discoveryengine.v1beta.SearchResponse.corrected_query]. + * The spell suggestion will not be used as the search query. + * + * Generated from protobuf enum SUGGESTION_ONLY = 1; + */ + const SUGGESTION_ONLY = 1; + /** + * Automatic spell correction built by the Search API. Search will + * be based on the corrected query if found. + * + * Generated from protobuf enum AUTO = 2; + */ + const AUTO = 2; + + private static $valueToName = [ + self::MODE_UNSPECIFIED => 'MODE_UNSPECIFIED', + self::SUGGESTION_ONLY => 'SUGGESTION_ONLY', + self::AUTO => 'AUTO', + ]; + + 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/DiscoveryEngine/src/V1beta/SearchResponse.php b/DiscoveryEngine/src/V1beta/SearchResponse.php new file mode 100644 index 000000000000..4555707bc2b5 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/SearchResponse.php @@ -0,0 +1,425 @@ +google.cloud.discoveryengine.v1beta.SearchResponse + */ +class SearchResponse extends \Google\Protobuf\Internal\Message +{ + /** + * A list of matched documents. The order represents the ranking. + * + * Generated from protobuf field repeated .google.cloud.discoveryengine.v1beta.SearchResponse.SearchResult results = 1; + */ + private $results; + /** + * Results of facets requested by user. + * + * Generated from protobuf field repeated .google.cloud.discoveryengine.v1beta.SearchResponse.Facet facets = 2; + */ + private $facets; + /** + * Guided search result. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.SearchResponse.GuidedSearchResult guided_search_result = 8; + */ + protected $guided_search_result = null; + /** + * The estimated total count of matched items irrespective of pagination. The + * count of + * [results][google.cloud.discoveryengine.v1beta.SearchResponse.results] + * returned by pagination may be less than the + * [total_size][google.cloud.discoveryengine.v1beta.SearchResponse.total_size] + * that matches. + * + * Generated from protobuf field int32 total_size = 3; + */ + protected $total_size = 0; + /** + * A unique search token. This should be included in the + * [UserEvent][google.cloud.discoveryengine.v1beta.UserEvent] logs resulting + * from this search, which enables accurate attribution of search model + * performance. + * + * Generated from protobuf field string attribution_token = 4; + */ + protected $attribution_token = ''; + /** + * A token that can be sent as + * [SearchRequest.page_token][google.cloud.discoveryengine.v1beta.SearchRequest.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 = 5; + */ + protected $next_page_token = ''; + /** + * Contains the spell corrected query, if found. If the spell correction type + * is AUTOMATIC, then the search results are based on corrected_query. + * Otherwise the original query is used for search. + * + * Generated from protobuf field string corrected_query = 7; + */ + protected $corrected_query = ''; + /** + * A summary as part of the search results. + * This field is only returned if + * [SearchRequest.ContentSearchSpec.summary_spec][google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.summary_spec] + * is set. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.SearchResponse.Summary summary = 9; + */ + protected $summary = null; + /** + * Controls applied as part of the Control service. + * + * Generated from protobuf field repeated string applied_controls = 10; + */ + private $applied_controls; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\Google\Cloud\DiscoveryEngine\V1beta\SearchResponse\SearchResult>|\Google\Protobuf\Internal\RepeatedField $results + * A list of matched documents. The order represents the ranking. + * @type array<\Google\Cloud\DiscoveryEngine\V1beta\SearchResponse\Facet>|\Google\Protobuf\Internal\RepeatedField $facets + * Results of facets requested by user. + * @type \Google\Cloud\DiscoveryEngine\V1beta\SearchResponse\GuidedSearchResult $guided_search_result + * Guided search result. + * @type int $total_size + * The estimated total count of matched items irrespective of pagination. The + * count of + * [results][google.cloud.discoveryengine.v1beta.SearchResponse.results] + * returned by pagination may be less than the + * [total_size][google.cloud.discoveryengine.v1beta.SearchResponse.total_size] + * that matches. + * @type string $attribution_token + * A unique search token. This should be included in the + * [UserEvent][google.cloud.discoveryengine.v1beta.UserEvent] logs resulting + * from this search, which enables accurate attribution of search model + * performance. + * @type string $next_page_token + * A token that can be sent as + * [SearchRequest.page_token][google.cloud.discoveryengine.v1beta.SearchRequest.page_token] + * to retrieve the next page. If this field is omitted, there are no + * subsequent pages. + * @type string $corrected_query + * Contains the spell corrected query, if found. If the spell correction type + * is AUTOMATIC, then the search results are based on corrected_query. + * Otherwise the original query is used for search. + * @type \Google\Cloud\DiscoveryEngine\V1beta\SearchResponse\Summary $summary + * A summary as part of the search results. + * This field is only returned if + * [SearchRequest.ContentSearchSpec.summary_spec][google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.summary_spec] + * is set. + * @type array|\Google\Protobuf\Internal\RepeatedField $applied_controls + * Controls applied as part of the Control service. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\SearchService::initOnce(); + parent::__construct($data); + } + + /** + * A list of matched documents. The order represents the ranking. + * + * Generated from protobuf field repeated .google.cloud.discoveryengine.v1beta.SearchResponse.SearchResult results = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getResults() + { + return $this->results; + } + + /** + * A list of matched documents. The order represents the ranking. + * + * Generated from protobuf field repeated .google.cloud.discoveryengine.v1beta.SearchResponse.SearchResult results = 1; + * @param array<\Google\Cloud\DiscoveryEngine\V1beta\SearchResponse\SearchResult>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setResults($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\DiscoveryEngine\V1beta\SearchResponse\SearchResult::class); + $this->results = $arr; + + return $this; + } + + /** + * Results of facets requested by user. + * + * Generated from protobuf field repeated .google.cloud.discoveryengine.v1beta.SearchResponse.Facet facets = 2; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getFacets() + { + return $this->facets; + } + + /** + * Results of facets requested by user. + * + * Generated from protobuf field repeated .google.cloud.discoveryengine.v1beta.SearchResponse.Facet facets = 2; + * @param array<\Google\Cloud\DiscoveryEngine\V1beta\SearchResponse\Facet>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setFacets($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\DiscoveryEngine\V1beta\SearchResponse\Facet::class); + $this->facets = $arr; + + return $this; + } + + /** + * Guided search result. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.SearchResponse.GuidedSearchResult guided_search_result = 8; + * @return \Google\Cloud\DiscoveryEngine\V1beta\SearchResponse\GuidedSearchResult|null + */ + public function getGuidedSearchResult() + { + return $this->guided_search_result; + } + + public function hasGuidedSearchResult() + { + return isset($this->guided_search_result); + } + + public function clearGuidedSearchResult() + { + unset($this->guided_search_result); + } + + /** + * Guided search result. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.SearchResponse.GuidedSearchResult guided_search_result = 8; + * @param \Google\Cloud\DiscoveryEngine\V1beta\SearchResponse\GuidedSearchResult $var + * @return $this + */ + public function setGuidedSearchResult($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\DiscoveryEngine\V1beta\SearchResponse\GuidedSearchResult::class); + $this->guided_search_result = $var; + + return $this; + } + + /** + * The estimated total count of matched items irrespective of pagination. The + * count of + * [results][google.cloud.discoveryengine.v1beta.SearchResponse.results] + * returned by pagination may be less than the + * [total_size][google.cloud.discoveryengine.v1beta.SearchResponse.total_size] + * that matches. + * + * Generated from protobuf field int32 total_size = 3; + * @return int + */ + public function getTotalSize() + { + return $this->total_size; + } + + /** + * The estimated total count of matched items irrespective of pagination. The + * count of + * [results][google.cloud.discoveryengine.v1beta.SearchResponse.results] + * returned by pagination may be less than the + * [total_size][google.cloud.discoveryengine.v1beta.SearchResponse.total_size] + * that matches. + * + * Generated from protobuf field int32 total_size = 3; + * @param int $var + * @return $this + */ + public function setTotalSize($var) + { + GPBUtil::checkInt32($var); + $this->total_size = $var; + + return $this; + } + + /** + * A unique search token. This should be included in the + * [UserEvent][google.cloud.discoveryengine.v1beta.UserEvent] logs resulting + * from this search, which enables accurate attribution of search model + * performance. + * + * Generated from protobuf field string attribution_token = 4; + * @return string + */ + public function getAttributionToken() + { + return $this->attribution_token; + } + + /** + * A unique search token. This should be included in the + * [UserEvent][google.cloud.discoveryengine.v1beta.UserEvent] logs resulting + * from this search, which enables accurate attribution of search model + * performance. + * + * Generated from protobuf field string attribution_token = 4; + * @param string $var + * @return $this + */ + public function setAttributionToken($var) + { + GPBUtil::checkString($var, True); + $this->attribution_token = $var; + + return $this; + } + + /** + * A token that can be sent as + * [SearchRequest.page_token][google.cloud.discoveryengine.v1beta.SearchRequest.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 = 5; + * @return string + */ + public function getNextPageToken() + { + return $this->next_page_token; + } + + /** + * A token that can be sent as + * [SearchRequest.page_token][google.cloud.discoveryengine.v1beta.SearchRequest.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 = 5; + * @param string $var + * @return $this + */ + public function setNextPageToken($var) + { + GPBUtil::checkString($var, True); + $this->next_page_token = $var; + + return $this; + } + + /** + * Contains the spell corrected query, if found. If the spell correction type + * is AUTOMATIC, then the search results are based on corrected_query. + * Otherwise the original query is used for search. + * + * Generated from protobuf field string corrected_query = 7; + * @return string + */ + public function getCorrectedQuery() + { + return $this->corrected_query; + } + + /** + * Contains the spell corrected query, if found. If the spell correction type + * is AUTOMATIC, then the search results are based on corrected_query. + * Otherwise the original query is used for search. + * + * Generated from protobuf field string corrected_query = 7; + * @param string $var + * @return $this + */ + public function setCorrectedQuery($var) + { + GPBUtil::checkString($var, True); + $this->corrected_query = $var; + + return $this; + } + + /** + * A summary as part of the search results. + * This field is only returned if + * [SearchRequest.ContentSearchSpec.summary_spec][google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.summary_spec] + * is set. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.SearchResponse.Summary summary = 9; + * @return \Google\Cloud\DiscoveryEngine\V1beta\SearchResponse\Summary|null + */ + public function getSummary() + { + return $this->summary; + } + + public function hasSummary() + { + return isset($this->summary); + } + + public function clearSummary() + { + unset($this->summary); + } + + /** + * A summary as part of the search results. + * This field is only returned if + * [SearchRequest.ContentSearchSpec.summary_spec][google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.summary_spec] + * is set. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.SearchResponse.Summary summary = 9; + * @param \Google\Cloud\DiscoveryEngine\V1beta\SearchResponse\Summary $var + * @return $this + */ + public function setSummary($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\DiscoveryEngine\V1beta\SearchResponse\Summary::class); + $this->summary = $var; + + return $this; + } + + /** + * Controls applied as part of the Control service. + * + * Generated from protobuf field repeated string applied_controls = 10; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getAppliedControls() + { + return $this->applied_controls; + } + + /** + * Controls applied as part of the Control service. + * + * Generated from protobuf field repeated string applied_controls = 10; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setAppliedControls($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->applied_controls = $arr; + + return $this; + } + +} + diff --git a/DiscoveryEngine/src/V1beta/SearchResponse/Facet.php b/DiscoveryEngine/src/V1beta/SearchResponse/Facet.php new file mode 100644 index 000000000000..ec096c76d86f --- /dev/null +++ b/DiscoveryEngine/src/V1beta/SearchResponse/Facet.php @@ -0,0 +1,140 @@ +google.cloud.discoveryengine.v1beta.SearchResponse.Facet + */ +class Facet extends \Google\Protobuf\Internal\Message +{ + /** + * The key for this facet. E.g., "colors" or "price". It matches + * [SearchRequest.FacetSpec.FacetKey.key][google.cloud.discoveryengine.v1beta.SearchRequest.FacetSpec.FacetKey.key]. + * + * Generated from protobuf field string key = 1; + */ + protected $key = ''; + /** + * The facet values for this field. + * + * Generated from protobuf field repeated .google.cloud.discoveryengine.v1beta.SearchResponse.Facet.FacetValue values = 2; + */ + private $values; + /** + * Whether the facet is dynamically generated. + * + * Generated from protobuf field bool dynamic_facet = 3; + */ + protected $dynamic_facet = false; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $key + * The key for this facet. E.g., "colors" or "price". It matches + * [SearchRequest.FacetSpec.FacetKey.key][google.cloud.discoveryengine.v1beta.SearchRequest.FacetSpec.FacetKey.key]. + * @type array<\Google\Cloud\DiscoveryEngine\V1beta\SearchResponse\Facet\FacetValue>|\Google\Protobuf\Internal\RepeatedField $values + * The facet values for this field. + * @type bool $dynamic_facet + * Whether the facet is dynamically generated. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\SearchService::initOnce(); + parent::__construct($data); + } + + /** + * The key for this facet. E.g., "colors" or "price". It matches + * [SearchRequest.FacetSpec.FacetKey.key][google.cloud.discoveryengine.v1beta.SearchRequest.FacetSpec.FacetKey.key]. + * + * Generated from protobuf field string key = 1; + * @return string + */ + public function getKey() + { + return $this->key; + } + + /** + * The key for this facet. E.g., "colors" or "price". It matches + * [SearchRequest.FacetSpec.FacetKey.key][google.cloud.discoveryengine.v1beta.SearchRequest.FacetSpec.FacetKey.key]. + * + * Generated from protobuf field string key = 1; + * @param string $var + * @return $this + */ + public function setKey($var) + { + GPBUtil::checkString($var, True); + $this->key = $var; + + return $this; + } + + /** + * The facet values for this field. + * + * Generated from protobuf field repeated .google.cloud.discoveryengine.v1beta.SearchResponse.Facet.FacetValue values = 2; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getValues() + { + return $this->values; + } + + /** + * The facet values for this field. + * + * Generated from protobuf field repeated .google.cloud.discoveryengine.v1beta.SearchResponse.Facet.FacetValue values = 2; + * @param array<\Google\Cloud\DiscoveryEngine\V1beta\SearchResponse\Facet\FacetValue>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setValues($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\DiscoveryEngine\V1beta\SearchResponse\Facet\FacetValue::class); + $this->values = $arr; + + return $this; + } + + /** + * Whether the facet is dynamically generated. + * + * Generated from protobuf field bool dynamic_facet = 3; + * @return bool + */ + public function getDynamicFacet() + { + return $this->dynamic_facet; + } + + /** + * Whether the facet is dynamically generated. + * + * Generated from protobuf field bool dynamic_facet = 3; + * @param bool $var + * @return $this + */ + public function setDynamicFacet($var) + { + GPBUtil::checkBool($var); + $this->dynamic_facet = $var; + + return $this; + } + +} + + diff --git a/DiscoveryEngine/src/V1beta/SearchResponse/Facet/FacetValue.php b/DiscoveryEngine/src/V1beta/SearchResponse/Facet/FacetValue.php new file mode 100644 index 000000000000..68398022ee43 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/SearchResponse/Facet/FacetValue.php @@ -0,0 +1,149 @@ +google.cloud.discoveryengine.v1beta.SearchResponse.Facet.FacetValue + */ +class FacetValue extends \Google\Protobuf\Internal\Message +{ + /** + * Number of items that have this facet value. + * + * Generated from protobuf field int64 count = 3; + */ + protected $count = 0; + protected $facet_value; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $value + * Text value of a facet, such as "Black" for facet "colors". + * @type \Google\Cloud\DiscoveryEngine\V1beta\Interval $interval + * Interval value for a facet, such as [10, 20) for facet "price". It + * matches + * [SearchRequest.FacetSpec.FacetKey.intervals][google.cloud.discoveryengine.v1beta.SearchRequest.FacetSpec.FacetKey.intervals]. + * @type int|string $count + * Number of items that have this facet value. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\SearchService::initOnce(); + parent::__construct($data); + } + + /** + * Text value of a facet, such as "Black" for facet "colors". + * + * Generated from protobuf field string value = 1; + * @return string + */ + public function getValue() + { + return $this->readOneof(1); + } + + public function hasValue() + { + return $this->hasOneof(1); + } + + /** + * Text value of a facet, such as "Black" for facet "colors". + * + * Generated from protobuf field string value = 1; + * @param string $var + * @return $this + */ + public function setValue($var) + { + GPBUtil::checkString($var, True); + $this->writeOneof(1, $var); + + return $this; + } + + /** + * Interval value for a facet, such as [10, 20) for facet "price". It + * matches + * [SearchRequest.FacetSpec.FacetKey.intervals][google.cloud.discoveryengine.v1beta.SearchRequest.FacetSpec.FacetKey.intervals]. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.Interval interval = 2; + * @return \Google\Cloud\DiscoveryEngine\V1beta\Interval|null + */ + public function getInterval() + { + return $this->readOneof(2); + } + + public function hasInterval() + { + return $this->hasOneof(2); + } + + /** + * Interval value for a facet, such as [10, 20) for facet "price". It + * matches + * [SearchRequest.FacetSpec.FacetKey.intervals][google.cloud.discoveryengine.v1beta.SearchRequest.FacetSpec.FacetKey.intervals]. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.Interval interval = 2; + * @param \Google\Cloud\DiscoveryEngine\V1beta\Interval $var + * @return $this + */ + public function setInterval($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\DiscoveryEngine\V1beta\Interval::class); + $this->writeOneof(2, $var); + + return $this; + } + + /** + * Number of items that have this facet value. + * + * Generated from protobuf field int64 count = 3; + * @return int|string + */ + public function getCount() + { + return $this->count; + } + + /** + * Number of items that have this facet value. + * + * Generated from protobuf field int64 count = 3; + * @param int|string $var + * @return $this + */ + public function setCount($var) + { + GPBUtil::checkInt64($var); + $this->count = $var; + + return $this; + } + + /** + * @return string + */ + public function getFacetValue() + { + return $this->whichOneof("facet_value"); + } + +} + + diff --git a/DiscoveryEngine/src/V1beta/SearchResponse/GuidedSearchResult.php b/DiscoveryEngine/src/V1beta/SearchResponse/GuidedSearchResult.php new file mode 100644 index 000000000000..125a8e66d8af --- /dev/null +++ b/DiscoveryEngine/src/V1beta/SearchResponse/GuidedSearchResult.php @@ -0,0 +1,69 @@ +google.cloud.discoveryengine.v1beta.SearchResponse.GuidedSearchResult + */ +class GuidedSearchResult extends \Google\Protobuf\Internal\Message +{ + /** + * A list of ranked refinement attributes. + * + * Generated from protobuf field repeated .google.cloud.discoveryengine.v1beta.SearchResponse.GuidedSearchResult.RefinementAttribute refinement_attributes = 1; + */ + private $refinement_attributes; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\Google\Cloud\DiscoveryEngine\V1beta\SearchResponse\GuidedSearchResult\RefinementAttribute>|\Google\Protobuf\Internal\RepeatedField $refinement_attributes + * A list of ranked refinement attributes. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\SearchService::initOnce(); + parent::__construct($data); + } + + /** + * A list of ranked refinement attributes. + * + * Generated from protobuf field repeated .google.cloud.discoveryengine.v1beta.SearchResponse.GuidedSearchResult.RefinementAttribute refinement_attributes = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getRefinementAttributes() + { + return $this->refinement_attributes; + } + + /** + * A list of ranked refinement attributes. + * + * Generated from protobuf field repeated .google.cloud.discoveryengine.v1beta.SearchResponse.GuidedSearchResult.RefinementAttribute refinement_attributes = 1; + * @param array<\Google\Cloud\DiscoveryEngine\V1beta\SearchResponse\GuidedSearchResult\RefinementAttribute>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setRefinementAttributes($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\DiscoveryEngine\V1beta\SearchResponse\GuidedSearchResult\RefinementAttribute::class); + $this->refinement_attributes = $arr; + + return $this; + } + +} + + diff --git a/DiscoveryEngine/src/V1beta/SearchResponse/GuidedSearchResult/RefinementAttribute.php b/DiscoveryEngine/src/V1beta/SearchResponse/GuidedSearchResult/RefinementAttribute.php new file mode 100644 index 000000000000..ae150056ed8c --- /dev/null +++ b/DiscoveryEngine/src/V1beta/SearchResponse/GuidedSearchResult/RefinementAttribute.php @@ -0,0 +1,102 @@ +google.cloud.discoveryengine.v1beta.SearchResponse.GuidedSearchResult.RefinementAttribute + */ +class RefinementAttribute extends \Google\Protobuf\Internal\Message +{ + /** + * Attribute key used to refine the results e.g. 'movie_type'. + * + * Generated from protobuf field string attribute_key = 1; + */ + protected $attribute_key = ''; + /** + * Attribute value used to refine the results e.g. 'drama'. + * + * Generated from protobuf field string attribute_value = 2; + */ + protected $attribute_value = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $attribute_key + * Attribute key used to refine the results e.g. 'movie_type'. + * @type string $attribute_value + * Attribute value used to refine the results e.g. 'drama'. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\SearchService::initOnce(); + parent::__construct($data); + } + + /** + * Attribute key used to refine the results e.g. 'movie_type'. + * + * Generated from protobuf field string attribute_key = 1; + * @return string + */ + public function getAttributeKey() + { + return $this->attribute_key; + } + + /** + * Attribute key used to refine the results e.g. 'movie_type'. + * + * Generated from protobuf field string attribute_key = 1; + * @param string $var + * @return $this + */ + public function setAttributeKey($var) + { + GPBUtil::checkString($var, True); + $this->attribute_key = $var; + + return $this; + } + + /** + * Attribute value used to refine the results e.g. 'drama'. + * + * Generated from protobuf field string attribute_value = 2; + * @return string + */ + public function getAttributeValue() + { + return $this->attribute_value; + } + + /** + * Attribute value used to refine the results e.g. 'drama'. + * + * Generated from protobuf field string attribute_value = 2; + * @param string $var + * @return $this + */ + public function setAttributeValue($var) + { + GPBUtil::checkString($var, True); + $this->attribute_value = $var; + + return $this; + } + +} + + diff --git a/DiscoveryEngine/src/V1beta/SearchResponse/SearchResult.php b/DiscoveryEngine/src/V1beta/SearchResponse/SearchResult.php new file mode 100644 index 000000000000..914252064ea3 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/SearchResponse/SearchResult.php @@ -0,0 +1,120 @@ +google.cloud.discoveryengine.v1beta.SearchResponse.SearchResult + */ +class SearchResult extends \Google\Protobuf\Internal\Message +{ + /** + * [Document.id][google.cloud.discoveryengine.v1beta.Document.id] of the + * searched [Document][google.cloud.discoveryengine.v1beta.Document]. + * + * Generated from protobuf field string id = 1; + */ + protected $id = ''; + /** + * The document data snippet in the search response. Only fields that are + * marked as retrievable are populated. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.Document document = 2; + */ + protected $document = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $id + * [Document.id][google.cloud.discoveryengine.v1beta.Document.id] of the + * searched [Document][google.cloud.discoveryengine.v1beta.Document]. + * @type \Google\Cloud\DiscoveryEngine\V1beta\Document $document + * The document data snippet in the search response. Only fields that are + * marked as retrievable are populated. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\SearchService::initOnce(); + parent::__construct($data); + } + + /** + * [Document.id][google.cloud.discoveryengine.v1beta.Document.id] of the + * searched [Document][google.cloud.discoveryengine.v1beta.Document]. + * + * Generated from protobuf field string id = 1; + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * [Document.id][google.cloud.discoveryengine.v1beta.Document.id] of the + * searched [Document][google.cloud.discoveryengine.v1beta.Document]. + * + * Generated from protobuf field string id = 1; + * @param string $var + * @return $this + */ + public function setId($var) + { + GPBUtil::checkString($var, True); + $this->id = $var; + + return $this; + } + + /** + * The document data snippet in the search response. Only fields that are + * marked as retrievable are populated. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.Document document = 2; + * @return \Google\Cloud\DiscoveryEngine\V1beta\Document|null + */ + public function getDocument() + { + return $this->document; + } + + public function hasDocument() + { + return isset($this->document); + } + + public function clearDocument() + { + unset($this->document); + } + + /** + * The document data snippet in the search response. Only fields that are + * marked as retrievable are populated. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.Document document = 2; + * @param \Google\Cloud\DiscoveryEngine\V1beta\Document $var + * @return $this + */ + public function setDocument($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\DiscoveryEngine\V1beta\Document::class); + $this->document = $var; + + return $this; + } + +} + + diff --git a/DiscoveryEngine/src/V1beta/SearchResponse/Summary.php b/DiscoveryEngine/src/V1beta/SearchResponse/Summary.php new file mode 100644 index 000000000000..ca51cb45c3a1 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/SearchResponse/Summary.php @@ -0,0 +1,68 @@ +google.cloud.discoveryengine.v1beta.SearchResponse.Summary + */ +class Summary extends \Google\Protobuf\Internal\Message +{ + /** + * The summary content. + * + * Generated from protobuf field string summary_text = 1; + */ + protected $summary_text = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $summary_text + * The summary content. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\SearchService::initOnce(); + parent::__construct($data); + } + + /** + * The summary content. + * + * Generated from protobuf field string summary_text = 1; + * @return string + */ + public function getSummaryText() + { + return $this->summary_text; + } + + /** + * The summary content. + * + * Generated from protobuf field string summary_text = 1; + * @param string $var + * @return $this + */ + public function setSummaryText($var) + { + GPBUtil::checkString($var, True); + $this->summary_text = $var; + + return $this; + } + +} + + diff --git a/DiscoveryEngine/src/V1beta/TransactionInfo.php b/DiscoveryEngine/src/V1beta/TransactionInfo.php new file mode 100644 index 000000000000..cf9532eaddbb --- /dev/null +++ b/DiscoveryEngine/src/V1beta/TransactionInfo.php @@ -0,0 +1,377 @@ +google.cloud.discoveryengine.v1beta.TransactionInfo + */ +class TransactionInfo extends \Google\Protobuf\Internal\Message +{ + /** + * Required. Total non-zero value associated with the transaction. This value + * may include shipping, tax, or other adjustments to the total value that you + * want to include. + * + * Generated from protobuf field optional float value = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $value = null; + /** + * Required. Currency code. Use three-character ISO-4217 code. + * + * Generated from protobuf field string currency = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $currency = ''; + /** + * The transaction ID with a length limit of 128 characters. + * + * Generated from protobuf field string transaction_id = 3; + */ + protected $transaction_id = ''; + /** + * All the taxes associated with the transaction. + * + * Generated from protobuf field optional float tax = 4; + */ + protected $tax = null; + /** + * All the costs associated with the products. These can be manufacturing + * costs, shipping expenses not borne by the end user, or any other costs, + * such that: + * * Profit = + * [value][google.cloud.discoveryengine.v1beta.TransactionInfo.value] - + * [tax][google.cloud.discoveryengine.v1beta.TransactionInfo.tax] - + * [cost][google.cloud.discoveryengine.v1beta.TransactionInfo.cost] + * + * Generated from protobuf field optional float cost = 5; + */ + protected $cost = null; + /** + * The total discount(s) value applied to this transaction. + * This figure should be excluded from + * [TransactionInfo.value][google.cloud.discoveryengine.v1beta.TransactionInfo.value] + * For example, if a user paid + * [TransactionInfo.value][google.cloud.discoveryengine.v1beta.TransactionInfo.value] + * amount, then nominal (pre-discount) value of the transaction is the sum of + * [TransactionInfo.value][google.cloud.discoveryengine.v1beta.TransactionInfo.value] + * and + * [TransactionInfo.discount_value][google.cloud.discoveryengine.v1beta.TransactionInfo.discount_value] + * This means that profit is calculated the same way, regardless of the + * discount value, and that + * [TransactionInfo.discount_value][google.cloud.discoveryengine.v1beta.TransactionInfo.discount_value] + * can be larger than + * [TransactionInfo.value][google.cloud.discoveryengine.v1beta.TransactionInfo.value]: + * * Profit = + * [value][google.cloud.discoveryengine.v1beta.TransactionInfo.value] - + * [tax][google.cloud.discoveryengine.v1beta.TransactionInfo.tax] - + * [cost][google.cloud.discoveryengine.v1beta.TransactionInfo.cost] + * + * Generated from protobuf field optional float discount_value = 6; + */ + protected $discount_value = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type float $value + * Required. Total non-zero value associated with the transaction. This value + * may include shipping, tax, or other adjustments to the total value that you + * want to include. + * @type string $currency + * Required. Currency code. Use three-character ISO-4217 code. + * @type string $transaction_id + * The transaction ID with a length limit of 128 characters. + * @type float $tax + * All the taxes associated with the transaction. + * @type float $cost + * All the costs associated with the products. These can be manufacturing + * costs, shipping expenses not borne by the end user, or any other costs, + * such that: + * * Profit = + * [value][google.cloud.discoveryengine.v1beta.TransactionInfo.value] - + * [tax][google.cloud.discoveryengine.v1beta.TransactionInfo.tax] - + * [cost][google.cloud.discoveryengine.v1beta.TransactionInfo.cost] + * @type float $discount_value + * The total discount(s) value applied to this transaction. + * This figure should be excluded from + * [TransactionInfo.value][google.cloud.discoveryengine.v1beta.TransactionInfo.value] + * For example, if a user paid + * [TransactionInfo.value][google.cloud.discoveryengine.v1beta.TransactionInfo.value] + * amount, then nominal (pre-discount) value of the transaction is the sum of + * [TransactionInfo.value][google.cloud.discoveryengine.v1beta.TransactionInfo.value] + * and + * [TransactionInfo.discount_value][google.cloud.discoveryengine.v1beta.TransactionInfo.discount_value] + * This means that profit is calculated the same way, regardless of the + * discount value, and that + * [TransactionInfo.discount_value][google.cloud.discoveryengine.v1beta.TransactionInfo.discount_value] + * can be larger than + * [TransactionInfo.value][google.cloud.discoveryengine.v1beta.TransactionInfo.value]: + * * Profit = + * [value][google.cloud.discoveryengine.v1beta.TransactionInfo.value] - + * [tax][google.cloud.discoveryengine.v1beta.TransactionInfo.tax] - + * [cost][google.cloud.discoveryengine.v1beta.TransactionInfo.cost] + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\UserEvent::initOnce(); + parent::__construct($data); + } + + /** + * Required. Total non-zero value associated with the transaction. This value + * may include shipping, tax, or other adjustments to the total value that you + * want to include. + * + * Generated from protobuf field optional float value = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return float + */ + public function getValue() + { + return isset($this->value) ? $this->value : 0.0; + } + + public function hasValue() + { + return isset($this->value); + } + + public function clearValue() + { + unset($this->value); + } + + /** + * Required. Total non-zero value associated with the transaction. This value + * may include shipping, tax, or other adjustments to the total value that you + * want to include. + * + * Generated from protobuf field optional float value = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param float $var + * @return $this + */ + public function setValue($var) + { + GPBUtil::checkFloat($var); + $this->value = $var; + + return $this; + } + + /** + * Required. Currency code. Use three-character ISO-4217 code. + * + * Generated from protobuf field string currency = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getCurrency() + { + return $this->currency; + } + + /** + * Required. Currency code. Use three-character ISO-4217 code. + * + * Generated from protobuf field string currency = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setCurrency($var) + { + GPBUtil::checkString($var, True); + $this->currency = $var; + + return $this; + } + + /** + * The transaction ID with a length limit of 128 characters. + * + * Generated from protobuf field string transaction_id = 3; + * @return string + */ + public function getTransactionId() + { + return $this->transaction_id; + } + + /** + * The transaction ID with a length limit of 128 characters. + * + * Generated from protobuf field string transaction_id = 3; + * @param string $var + * @return $this + */ + public function setTransactionId($var) + { + GPBUtil::checkString($var, True); + $this->transaction_id = $var; + + return $this; + } + + /** + * All the taxes associated with the transaction. + * + * Generated from protobuf field optional float tax = 4; + * @return float + */ + public function getTax() + { + return isset($this->tax) ? $this->tax : 0.0; + } + + public function hasTax() + { + return isset($this->tax); + } + + public function clearTax() + { + unset($this->tax); + } + + /** + * All the taxes associated with the transaction. + * + * Generated from protobuf field optional float tax = 4; + * @param float $var + * @return $this + */ + public function setTax($var) + { + GPBUtil::checkFloat($var); + $this->tax = $var; + + return $this; + } + + /** + * All the costs associated with the products. These can be manufacturing + * costs, shipping expenses not borne by the end user, or any other costs, + * such that: + * * Profit = + * [value][google.cloud.discoveryengine.v1beta.TransactionInfo.value] - + * [tax][google.cloud.discoveryengine.v1beta.TransactionInfo.tax] - + * [cost][google.cloud.discoveryengine.v1beta.TransactionInfo.cost] + * + * Generated from protobuf field optional float cost = 5; + * @return float + */ + public function getCost() + { + return isset($this->cost) ? $this->cost : 0.0; + } + + public function hasCost() + { + return isset($this->cost); + } + + public function clearCost() + { + unset($this->cost); + } + + /** + * All the costs associated with the products. These can be manufacturing + * costs, shipping expenses not borne by the end user, or any other costs, + * such that: + * * Profit = + * [value][google.cloud.discoveryengine.v1beta.TransactionInfo.value] - + * [tax][google.cloud.discoveryengine.v1beta.TransactionInfo.tax] - + * [cost][google.cloud.discoveryengine.v1beta.TransactionInfo.cost] + * + * Generated from protobuf field optional float cost = 5; + * @param float $var + * @return $this + */ + public function setCost($var) + { + GPBUtil::checkFloat($var); + $this->cost = $var; + + return $this; + } + + /** + * The total discount(s) value applied to this transaction. + * This figure should be excluded from + * [TransactionInfo.value][google.cloud.discoveryengine.v1beta.TransactionInfo.value] + * For example, if a user paid + * [TransactionInfo.value][google.cloud.discoveryengine.v1beta.TransactionInfo.value] + * amount, then nominal (pre-discount) value of the transaction is the sum of + * [TransactionInfo.value][google.cloud.discoveryengine.v1beta.TransactionInfo.value] + * and + * [TransactionInfo.discount_value][google.cloud.discoveryengine.v1beta.TransactionInfo.discount_value] + * This means that profit is calculated the same way, regardless of the + * discount value, and that + * [TransactionInfo.discount_value][google.cloud.discoveryengine.v1beta.TransactionInfo.discount_value] + * can be larger than + * [TransactionInfo.value][google.cloud.discoveryengine.v1beta.TransactionInfo.value]: + * * Profit = + * [value][google.cloud.discoveryengine.v1beta.TransactionInfo.value] - + * [tax][google.cloud.discoveryengine.v1beta.TransactionInfo.tax] - + * [cost][google.cloud.discoveryengine.v1beta.TransactionInfo.cost] + * + * Generated from protobuf field optional float discount_value = 6; + * @return float + */ + public function getDiscountValue() + { + return isset($this->discount_value) ? $this->discount_value : 0.0; + } + + public function hasDiscountValue() + { + return isset($this->discount_value); + } + + public function clearDiscountValue() + { + unset($this->discount_value); + } + + /** + * The total discount(s) value applied to this transaction. + * This figure should be excluded from + * [TransactionInfo.value][google.cloud.discoveryengine.v1beta.TransactionInfo.value] + * For example, if a user paid + * [TransactionInfo.value][google.cloud.discoveryengine.v1beta.TransactionInfo.value] + * amount, then nominal (pre-discount) value of the transaction is the sum of + * [TransactionInfo.value][google.cloud.discoveryengine.v1beta.TransactionInfo.value] + * and + * [TransactionInfo.discount_value][google.cloud.discoveryengine.v1beta.TransactionInfo.discount_value] + * This means that profit is calculated the same way, regardless of the + * discount value, and that + * [TransactionInfo.discount_value][google.cloud.discoveryengine.v1beta.TransactionInfo.discount_value] + * can be larger than + * [TransactionInfo.value][google.cloud.discoveryengine.v1beta.TransactionInfo.value]: + * * Profit = + * [value][google.cloud.discoveryengine.v1beta.TransactionInfo.value] - + * [tax][google.cloud.discoveryengine.v1beta.TransactionInfo.tax] - + * [cost][google.cloud.discoveryengine.v1beta.TransactionInfo.cost] + * + * Generated from protobuf field optional float discount_value = 6; + * @param float $var + * @return $this + */ + public function setDiscountValue($var) + { + GPBUtil::checkFloat($var); + $this->discount_value = $var; + + return $this; + } + +} + diff --git a/DiscoveryEngine/src/V1beta/UpdateDocumentRequest.php b/DiscoveryEngine/src/V1beta/UpdateDocumentRequest.php new file mode 100644 index 000000000000..7911356efc97 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/UpdateDocumentRequest.php @@ -0,0 +1,153 @@ +google.cloud.discoveryengine.v1beta.UpdateDocumentRequest + */ +class UpdateDocumentRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The document to update/create. + * If the caller does not have permission to update the + * [Document][google.cloud.discoveryengine.v1beta.Document], regardless of + * whether or not it exists, a `PERMISSION_DENIED` error is returned. + * If the [Document][google.cloud.discoveryengine.v1beta.Document] to update + * does not exist and + * [allow_missing][google.cloud.discoveryengine.v1beta.UpdateDocumentRequest.allow_missing] + * is not set, a `NOT_FOUND` error is returned. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.Document document = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $document = null; + /** + * If set to true, and the + * [Document][google.cloud.discoveryengine.v1beta.Document] is not found, a + * new [Document][google.cloud.discoveryengine.v1beta.Document] will be + * created. + * + * Generated from protobuf field bool allow_missing = 2; + */ + protected $allow_missing = false; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\DiscoveryEngine\V1beta\Document $document + * Required. The document to update/create. + * If the caller does not have permission to update the + * [Document][google.cloud.discoveryengine.v1beta.Document], regardless of + * whether or not it exists, a `PERMISSION_DENIED` error is returned. + * If the [Document][google.cloud.discoveryengine.v1beta.Document] to update + * does not exist and + * [allow_missing][google.cloud.discoveryengine.v1beta.UpdateDocumentRequest.allow_missing] + * is not set, a `NOT_FOUND` error is returned. + * @type bool $allow_missing + * If set to true, and the + * [Document][google.cloud.discoveryengine.v1beta.Document] is not found, a + * new [Document][google.cloud.discoveryengine.v1beta.Document] will be + * created. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\DocumentService::initOnce(); + parent::__construct($data); + } + + /** + * Required. The document to update/create. + * If the caller does not have permission to update the + * [Document][google.cloud.discoveryengine.v1beta.Document], regardless of + * whether or not it exists, a `PERMISSION_DENIED` error is returned. + * If the [Document][google.cloud.discoveryengine.v1beta.Document] to update + * does not exist and + * [allow_missing][google.cloud.discoveryengine.v1beta.UpdateDocumentRequest.allow_missing] + * is not set, a `NOT_FOUND` error is returned. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.Document document = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\DiscoveryEngine\V1beta\Document|null + */ + public function getDocument() + { + return $this->document; + } + + public function hasDocument() + { + return isset($this->document); + } + + public function clearDocument() + { + unset($this->document); + } + + /** + * Required. The document to update/create. + * If the caller does not have permission to update the + * [Document][google.cloud.discoveryengine.v1beta.Document], regardless of + * whether or not it exists, a `PERMISSION_DENIED` error is returned. + * If the [Document][google.cloud.discoveryengine.v1beta.Document] to update + * does not exist and + * [allow_missing][google.cloud.discoveryengine.v1beta.UpdateDocumentRequest.allow_missing] + * is not set, a `NOT_FOUND` error is returned. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.Document document = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\DiscoveryEngine\V1beta\Document $var + * @return $this + */ + public function setDocument($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\DiscoveryEngine\V1beta\Document::class); + $this->document = $var; + + return $this; + } + + /** + * If set to true, and the + * [Document][google.cloud.discoveryengine.v1beta.Document] is not found, a + * new [Document][google.cloud.discoveryengine.v1beta.Document] will be + * created. + * + * Generated from protobuf field bool allow_missing = 2; + * @return bool + */ + public function getAllowMissing() + { + return $this->allow_missing; + } + + /** + * If set to true, and the + * [Document][google.cloud.discoveryengine.v1beta.Document] is not found, a + * new [Document][google.cloud.discoveryengine.v1beta.Document] will be + * created. + * + * Generated from protobuf field bool allow_missing = 2; + * @param bool $var + * @return $this + */ + public function setAllowMissing($var) + { + GPBUtil::checkBool($var); + $this->allow_missing = $var; + + return $this; + } + +} + diff --git a/DiscoveryEngine/src/V1beta/UpdateSchemaMetadata.php b/DiscoveryEngine/src/V1beta/UpdateSchemaMetadata.php new file mode 100644 index 000000000000..dd16a0254cfe --- /dev/null +++ b/DiscoveryEngine/src/V1beta/UpdateSchemaMetadata.php @@ -0,0 +1,125 @@ +google.cloud.discoveryengine.v1beta.UpdateSchemaMetadata + */ +class UpdateSchemaMetadata extends \Google\Protobuf\Internal\Message +{ + /** + * Operation create time. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 1; + */ + protected $create_time = null; + /** + * Operation last update time. If the operation is done, this is also the + * finish time. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 2; + */ + protected $update_time = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Protobuf\Timestamp $create_time + * Operation create time. + * @type \Google\Protobuf\Timestamp $update_time + * Operation last update time. If the operation is done, this is also the + * finish time. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\SchemaService::initOnce(); + parent::__construct($data); + } + + /** + * Operation create time. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 1; + * @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); + } + + /** + * Operation create time. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 1; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setCreateTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->create_time = $var; + + return $this; + } + + /** + * Operation last update time. If the operation is done, this is also the + * finish time. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 2; + * @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); + } + + /** + * Operation last update time. If the operation is done, this is also the + * finish time. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 2; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setUpdateTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->update_time = $var; + + return $this; + } + +} + diff --git a/DiscoveryEngine/src/V1beta/UpdateSchemaRequest.php b/DiscoveryEngine/src/V1beta/UpdateSchemaRequest.php new file mode 100644 index 000000000000..86c984cde2e3 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/UpdateSchemaRequest.php @@ -0,0 +1,129 @@ +google.cloud.discoveryengine.v1beta.UpdateSchemaRequest + */ +class UpdateSchemaRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The [Schema][google.cloud.discoveryengine.v1beta.Schema] to + * update. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.Schema schema = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $schema = null; + /** + * If set to true, and the + * [Schema][google.cloud.discoveryengine.v1beta.Schema] is not found, a new + * [Schema][google.cloud.discoveryengine.v1beta.Schema] will be created. In + * this situation, `update_mask` is ignored. + * + * Generated from protobuf field bool allow_missing = 3; + */ + protected $allow_missing = false; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\DiscoveryEngine\V1beta\Schema $schema + * Required. The [Schema][google.cloud.discoveryengine.v1beta.Schema] to + * update. + * @type bool $allow_missing + * If set to true, and the + * [Schema][google.cloud.discoveryengine.v1beta.Schema] is not found, a new + * [Schema][google.cloud.discoveryengine.v1beta.Schema] will be created. In + * this situation, `update_mask` is ignored. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\SchemaService::initOnce(); + parent::__construct($data); + } + + /** + * Required. The [Schema][google.cloud.discoveryengine.v1beta.Schema] to + * update. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.Schema schema = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\DiscoveryEngine\V1beta\Schema|null + */ + public function getSchema() + { + return $this->schema; + } + + public function hasSchema() + { + return isset($this->schema); + } + + public function clearSchema() + { + unset($this->schema); + } + + /** + * Required. The [Schema][google.cloud.discoveryengine.v1beta.Schema] to + * update. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.Schema schema = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\DiscoveryEngine\V1beta\Schema $var + * @return $this + */ + public function setSchema($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\DiscoveryEngine\V1beta\Schema::class); + $this->schema = $var; + + return $this; + } + + /** + * If set to true, and the + * [Schema][google.cloud.discoveryengine.v1beta.Schema] is not found, a new + * [Schema][google.cloud.discoveryengine.v1beta.Schema] will be created. In + * this situation, `update_mask` is ignored. + * + * Generated from protobuf field bool allow_missing = 3; + * @return bool + */ + public function getAllowMissing() + { + return $this->allow_missing; + } + + /** + * If set to true, and the + * [Schema][google.cloud.discoveryengine.v1beta.Schema] is not found, a new + * [Schema][google.cloud.discoveryengine.v1beta.Schema] will be created. In + * this situation, `update_mask` is ignored. + * + * Generated from protobuf field bool allow_missing = 3; + * @param bool $var + * @return $this + */ + public function setAllowMissing($var) + { + GPBUtil::checkBool($var); + $this->allow_missing = $var; + + return $this; + } + +} + diff --git a/DiscoveryEngine/src/V1beta/UserEvent.php b/DiscoveryEngine/src/V1beta/UserEvent.php new file mode 100644 index 000000000000..8298838f99c1 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/UserEvent.php @@ -0,0 +1,1174 @@ +google.cloud.discoveryengine.v1beta.UserEvent + */ +class UserEvent extends \Google\Protobuf\Internal\Message +{ + /** + * Required. User event type. Allowed values are: + * Generic values: + * * `search`: Search for Documents. + * * `view-item`: Detailed page view of a Document. + * * `view-item-list`: View of a panel or ordered list of Documents. + * * `view-home-page`: View of the home page. + * * `view-category-page`: View of a category page, e.g. Home > Men > Jeans + * Retail-related values: + * * `add-to-cart`: Add an item(s) to cart, e.g. in Retail online shopping + * * `purchase`: Purchase an item(s) + * Media-related values: + * * `media-play`: Start/resume watching a video, playing a song, etc. + * * `media-complete`: Finished or stopped midway through a video, song, etc. + * + * Generated from protobuf field string event_type = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $event_type = ''; + /** + * Required. A unique identifier for tracking visitors. + * For example, this could be implemented with an HTTP cookie, which should be + * able to uniquely identify a visitor on a single device. This unique + * identifier should not change if the visitor log in/out of the website. + * Do not set the field to the same fixed ID for different users. This mixes + * the event history of those users together, which results in degraded model + * quality. + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * The field should not contain PII or user-data. We recommend to use Google + * Analytics [Client + * ID](https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#clientId) + * for this field. + * + * Generated from protobuf field string user_pseudo_id = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $user_pseudo_id = ''; + /** + * Only required for + * [UserEventService.ImportUserEvents][google.cloud.discoveryengine.v1beta.UserEventService.ImportUserEvents] + * method. Timestamp of when the user event happened. + * + * Generated from protobuf field .google.protobuf.Timestamp event_time = 3; + */ + protected $event_time = null; + /** + * Information about the end user. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.UserInfo user_info = 4; + */ + protected $user_info = null; + /** + * Should set to true if the request is made directly from the end user, in + * which case the + * [UserEvent.user_info.user_agent][google.cloud.discoveryengine.v1beta.UserInfo.user_agent] + * can be populated from the HTTP request. + * This flag should be set only if the API request is made directly from the + * end user such as a mobile app (and not if a gateway or a server is + * processing and pushing the user events). + * This should not be set when using the JavaScript tag in + * [UserEventService.CollectUserEvent][google.cloud.discoveryengine.v1beta.UserEventService.CollectUserEvent]. + * + * Generated from protobuf field bool direct_user_request = 5; + */ + protected $direct_user_request = false; + /** + * A unique identifier for tracking a visitor session with a length limit of + * 128 bytes. A session is an aggregation of an end user behavior in a time + * span. + * A general guideline to populate the session_id: + * 1. If user has no activity for 30 min, a new session_id should be assigned. + * 2. The session_id should be unique across users, suggest use uuid or add + * [UserEvent.user_pseudo_id][google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id] + * as prefix. + * + * Generated from protobuf field string session_id = 6; + */ + protected $session_id = ''; + /** + * Page metadata such as categories and other critical information for certain + * event types such as `view-category-page`. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.PageInfo page_info = 7; + */ + protected $page_info = null; + /** + * Token to attribute an API response to user action(s) to trigger the event. + * Highly recommended for user events that are the result of + * [RecommendationService.Recommend][google.cloud.discoveryengine.v1beta.RecommendationService.Recommend]. + * This field enables accurate attribution of recommendation model + * performance. + * The value must be one of: + * * [PredictResponse.attribution_token][] for events that are the result of + * [RecommendationService.Recommend][google.cloud.discoveryengine.v1beta.RecommendationService.Recommend]. + * * [SearchResponse.attribution_token][google.cloud.discoveryengine.v1beta.SearchResponse.attribution_token] for events that are the result of + * [SearchService.Search][google.cloud.discoveryengine.v1beta.SearchService.Search]. + * * [CompleteQueryResponse.attribution_token][] for events that are the + * result of + * [CompletionService.CompleteQuery][google.cloud.discoveryengine.v1beta.CompletionService.CompleteQuery]. + * This token enables us to accurately attribute page view or conversion + * completion back to the event and the particular predict response containing + * this clicked/purchased product. If user clicks on product K in the + * recommendation results, pass [PredictResponse.attribution_token][] as a URL + * parameter to product K's page. When recording events on product K's page, + * log the [PredictResponse.attribution_token][] to this field. + * + * Generated from protobuf field string attribution_token = 8; + */ + protected $attribution_token = ''; + /** + * The filter syntax consists of an expression language for constructing a + * predicate from one or more fields of the documents being filtered. + * One example is for `search` events, the associated + * [SearchRequest][google.cloud.discoveryengine.v1beta.SearchRequest] may + * contain a filter expression in + * [SearchRequest.filter][google.cloud.discoveryengine.v1beta.SearchRequest.filter] + * conforming to https://google.aip.dev/160#filtering. + * Similarly, for `view-item-list` events that are generated from a + * [RecommendationService.RecommendRequest][], this field may be populated + * directly from [RecommendationService.RecommendRequest.filter][] conforming + * to https://google.aip.dev/160#filtering. + * The value must be a UTF-8 encoded string with a length limit of 1,000 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * + * Generated from protobuf field string filter = 9; + */ + protected $filter = ''; + /** + * List of Documents associated with this user event. + * This field is optional except for the following event types: + * * `view-item` + * * `add-to-cart` + * * `purchase` + * * `media-play` + * * `media-complete` + * In a `search` event, this field represents the documents returned to the + * end user on the current page (the end user may have not finished browsing + * the whole page yet). When a new page is returned to the end user, after + * pagination/filtering/ordering even for the same query, a new `search` event + * with different + * [UserEvent.documents][google.cloud.discoveryengine.v1beta.UserEvent.documents] + * is desired. + * + * Generated from protobuf field repeated .google.cloud.discoveryengine.v1beta.DocumentInfo documents = 10; + */ + private $documents; + /** + * Panel metadata associated with this user event. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.PanelInfo panel = 11; + */ + protected $panel = null; + /** + * Search API details related to the event. + * This field should be set for `search` event. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.SearchInfo search_info = 12; + */ + protected $search_info = null; + /** + * CompleteQuery API details related to the event. + * This field should be set for `search` event when autocomplete function is + * enabled and the user clicks a suggestion for search. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.CompletionInfo completion_info = 13; + */ + protected $completion_info = null; + /** + * The transaction metadata (if any) associated with this user event. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.TransactionInfo transaction_info = 14; + */ + protected $transaction_info = null; + /** + * A list of identifiers for the independent experiment groups this user event + * belongs to. This is used to distinguish between user events associated with + * different experiment setups on the customer end. + * + * Generated from protobuf field repeated string tag_ids = 15; + */ + private $tag_ids; + /** + * The promotion IDs if this is an event associated with promotions. + * Currently, this field is restricted to at most one ID. + * + * Generated from protobuf field repeated string promotion_ids = 16; + */ + private $promotion_ids; + /** + * Extra user event features to include in the recommendation model. + * These attributes must NOT contain data that needs to be parsed or processed + * further, e.g. JSON or other encodings. + * If you provide custom attributes for ingested user events, also include + * them in the user events that you associate with prediction requests. Custom + * attribute formatting must be consistent between imported events and events + * provided with prediction requests. This lets the Discovery Engine API use + * those custom attributes when training models and serving predictions, which + * helps improve recommendation quality. + * This field needs to pass all below criteria, otherwise an + * `INVALID_ARGUMENT` error is returned: + * * The key must be a UTF-8 encoded string with a length limit of 5,000 + * characters. + * * For text attributes, at most 400 values are allowed. Empty values are not + * allowed. Each value must be a UTF-8 encoded string with a length limit of + * 256 characters. + * * For number attributes, at most 400 values are allowed. + * For product recommendations, an example of extra user information is + * ` traffic_channel`, which is how a user arrives at the site. Users can + * arrive + * at the site by coming to the site directly, coming through Google + * search, or in other ways. + * + * Generated from protobuf field map attributes = 17; + */ + private $attributes; + /** + * Media-specific info. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.MediaInfo media_info = 18; + */ + protected $media_info = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $event_type + * Required. User event type. Allowed values are: + * Generic values: + * * `search`: Search for Documents. + * * `view-item`: Detailed page view of a Document. + * * `view-item-list`: View of a panel or ordered list of Documents. + * * `view-home-page`: View of the home page. + * * `view-category-page`: View of a category page, e.g. Home > Men > Jeans + * Retail-related values: + * * `add-to-cart`: Add an item(s) to cart, e.g. in Retail online shopping + * * `purchase`: Purchase an item(s) + * Media-related values: + * * `media-play`: Start/resume watching a video, playing a song, etc. + * * `media-complete`: Finished or stopped midway through a video, song, etc. + * @type string $user_pseudo_id + * Required. A unique identifier for tracking visitors. + * For example, this could be implemented with an HTTP cookie, which should be + * able to uniquely identify a visitor on a single device. This unique + * identifier should not change if the visitor log in/out of the website. + * Do not set the field to the same fixed ID for different users. This mixes + * the event history of those users together, which results in degraded model + * quality. + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * The field should not contain PII or user-data. We recommend to use Google + * Analytics [Client + * ID](https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#clientId) + * for this field. + * @type \Google\Protobuf\Timestamp $event_time + * Only required for + * [UserEventService.ImportUserEvents][google.cloud.discoveryengine.v1beta.UserEventService.ImportUserEvents] + * method. Timestamp of when the user event happened. + * @type \Google\Cloud\DiscoveryEngine\V1beta\UserInfo $user_info + * Information about the end user. + * @type bool $direct_user_request + * Should set to true if the request is made directly from the end user, in + * which case the + * [UserEvent.user_info.user_agent][google.cloud.discoveryengine.v1beta.UserInfo.user_agent] + * can be populated from the HTTP request. + * This flag should be set only if the API request is made directly from the + * end user such as a mobile app (and not if a gateway or a server is + * processing and pushing the user events). + * This should not be set when using the JavaScript tag in + * [UserEventService.CollectUserEvent][google.cloud.discoveryengine.v1beta.UserEventService.CollectUserEvent]. + * @type string $session_id + * A unique identifier for tracking a visitor session with a length limit of + * 128 bytes. A session is an aggregation of an end user behavior in a time + * span. + * A general guideline to populate the session_id: + * 1. If user has no activity for 30 min, a new session_id should be assigned. + * 2. The session_id should be unique across users, suggest use uuid or add + * [UserEvent.user_pseudo_id][google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id] + * as prefix. + * @type \Google\Cloud\DiscoveryEngine\V1beta\PageInfo $page_info + * Page metadata such as categories and other critical information for certain + * event types such as `view-category-page`. + * @type string $attribution_token + * Token to attribute an API response to user action(s) to trigger the event. + * Highly recommended for user events that are the result of + * [RecommendationService.Recommend][google.cloud.discoveryengine.v1beta.RecommendationService.Recommend]. + * This field enables accurate attribution of recommendation model + * performance. + * The value must be one of: + * * [PredictResponse.attribution_token][] for events that are the result of + * [RecommendationService.Recommend][google.cloud.discoveryengine.v1beta.RecommendationService.Recommend]. + * * [SearchResponse.attribution_token][google.cloud.discoveryengine.v1beta.SearchResponse.attribution_token] for events that are the result of + * [SearchService.Search][google.cloud.discoveryengine.v1beta.SearchService.Search]. + * * [CompleteQueryResponse.attribution_token][] for events that are the + * result of + * [CompletionService.CompleteQuery][google.cloud.discoveryengine.v1beta.CompletionService.CompleteQuery]. + * This token enables us to accurately attribute page view or conversion + * completion back to the event and the particular predict response containing + * this clicked/purchased product. If user clicks on product K in the + * recommendation results, pass [PredictResponse.attribution_token][] as a URL + * parameter to product K's page. When recording events on product K's page, + * log the [PredictResponse.attribution_token][] to this field. + * @type string $filter + * The filter syntax consists of an expression language for constructing a + * predicate from one or more fields of the documents being filtered. + * One example is for `search` events, the associated + * [SearchRequest][google.cloud.discoveryengine.v1beta.SearchRequest] may + * contain a filter expression in + * [SearchRequest.filter][google.cloud.discoveryengine.v1beta.SearchRequest.filter] + * conforming to https://google.aip.dev/160#filtering. + * Similarly, for `view-item-list` events that are generated from a + * [RecommendationService.RecommendRequest][], this field may be populated + * directly from [RecommendationService.RecommendRequest.filter][] conforming + * to https://google.aip.dev/160#filtering. + * The value must be a UTF-8 encoded string with a length limit of 1,000 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * @type array<\Google\Cloud\DiscoveryEngine\V1beta\DocumentInfo>|\Google\Protobuf\Internal\RepeatedField $documents + * List of Documents associated with this user event. + * This field is optional except for the following event types: + * * `view-item` + * * `add-to-cart` + * * `purchase` + * * `media-play` + * * `media-complete` + * In a `search` event, this field represents the documents returned to the + * end user on the current page (the end user may have not finished browsing + * the whole page yet). When a new page is returned to the end user, after + * pagination/filtering/ordering even for the same query, a new `search` event + * with different + * [UserEvent.documents][google.cloud.discoveryengine.v1beta.UserEvent.documents] + * is desired. + * @type \Google\Cloud\DiscoveryEngine\V1beta\PanelInfo $panel + * Panel metadata associated with this user event. + * @type \Google\Cloud\DiscoveryEngine\V1beta\SearchInfo $search_info + * Search API details related to the event. + * This field should be set for `search` event. + * @type \Google\Cloud\DiscoveryEngine\V1beta\CompletionInfo $completion_info + * CompleteQuery API details related to the event. + * This field should be set for `search` event when autocomplete function is + * enabled and the user clicks a suggestion for search. + * @type \Google\Cloud\DiscoveryEngine\V1beta\TransactionInfo $transaction_info + * The transaction metadata (if any) associated with this user event. + * @type array|\Google\Protobuf\Internal\RepeatedField $tag_ids + * A list of identifiers for the independent experiment groups this user event + * belongs to. This is used to distinguish between user events associated with + * different experiment setups on the customer end. + * @type array|\Google\Protobuf\Internal\RepeatedField $promotion_ids + * The promotion IDs if this is an event associated with promotions. + * Currently, this field is restricted to at most one ID. + * @type array|\Google\Protobuf\Internal\MapField $attributes + * Extra user event features to include in the recommendation model. + * These attributes must NOT contain data that needs to be parsed or processed + * further, e.g. JSON or other encodings. + * If you provide custom attributes for ingested user events, also include + * them in the user events that you associate with prediction requests. Custom + * attribute formatting must be consistent between imported events and events + * provided with prediction requests. This lets the Discovery Engine API use + * those custom attributes when training models and serving predictions, which + * helps improve recommendation quality. + * This field needs to pass all below criteria, otherwise an + * `INVALID_ARGUMENT` error is returned: + * * The key must be a UTF-8 encoded string with a length limit of 5,000 + * characters. + * * For text attributes, at most 400 values are allowed. Empty values are not + * allowed. Each value must be a UTF-8 encoded string with a length limit of + * 256 characters. + * * For number attributes, at most 400 values are allowed. + * For product recommendations, an example of extra user information is + * ` traffic_channel`, which is how a user arrives at the site. Users can + * arrive + * at the site by coming to the site directly, coming through Google + * search, or in other ways. + * @type \Google\Cloud\DiscoveryEngine\V1beta\MediaInfo $media_info + * Media-specific info. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\UserEvent::initOnce(); + parent::__construct($data); + } + + /** + * Required. User event type. Allowed values are: + * Generic values: + * * `search`: Search for Documents. + * * `view-item`: Detailed page view of a Document. + * * `view-item-list`: View of a panel or ordered list of Documents. + * * `view-home-page`: View of the home page. + * * `view-category-page`: View of a category page, e.g. Home > Men > Jeans + * Retail-related values: + * * `add-to-cart`: Add an item(s) to cart, e.g. in Retail online shopping + * * `purchase`: Purchase an item(s) + * Media-related values: + * * `media-play`: Start/resume watching a video, playing a song, etc. + * * `media-complete`: Finished or stopped midway through a video, song, etc. + * + * Generated from protobuf field string event_type = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getEventType() + { + return $this->event_type; + } + + /** + * Required. User event type. Allowed values are: + * Generic values: + * * `search`: Search for Documents. + * * `view-item`: Detailed page view of a Document. + * * `view-item-list`: View of a panel or ordered list of Documents. + * * `view-home-page`: View of the home page. + * * `view-category-page`: View of a category page, e.g. Home > Men > Jeans + * Retail-related values: + * * `add-to-cart`: Add an item(s) to cart, e.g. in Retail online shopping + * * `purchase`: Purchase an item(s) + * Media-related values: + * * `media-play`: Start/resume watching a video, playing a song, etc. + * * `media-complete`: Finished or stopped midway through a video, song, etc. + * + * Generated from protobuf field string event_type = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setEventType($var) + { + GPBUtil::checkString($var, True); + $this->event_type = $var; + + return $this; + } + + /** + * Required. A unique identifier for tracking visitors. + * For example, this could be implemented with an HTTP cookie, which should be + * able to uniquely identify a visitor on a single device. This unique + * identifier should not change if the visitor log in/out of the website. + * Do not set the field to the same fixed ID for different users. This mixes + * the event history of those users together, which results in degraded model + * quality. + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * The field should not contain PII or user-data. We recommend to use Google + * Analytics [Client + * ID](https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#clientId) + * for this field. + * + * Generated from protobuf field string user_pseudo_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getUserPseudoId() + { + return $this->user_pseudo_id; + } + + /** + * Required. A unique identifier for tracking visitors. + * For example, this could be implemented with an HTTP cookie, which should be + * able to uniquely identify a visitor on a single device. This unique + * identifier should not change if the visitor log in/out of the website. + * Do not set the field to the same fixed ID for different users. This mixes + * the event history of those users together, which results in degraded model + * quality. + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * The field should not contain PII or user-data. We recommend to use Google + * Analytics [Client + * ID](https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#clientId) + * for this field. + * + * Generated from protobuf field string user_pseudo_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setUserPseudoId($var) + { + GPBUtil::checkString($var, True); + $this->user_pseudo_id = $var; + + return $this; + } + + /** + * Only required for + * [UserEventService.ImportUserEvents][google.cloud.discoveryengine.v1beta.UserEventService.ImportUserEvents] + * method. Timestamp of when the user event happened. + * + * Generated from protobuf field .google.protobuf.Timestamp event_time = 3; + * @return \Google\Protobuf\Timestamp|null + */ + public function getEventTime() + { + return $this->event_time; + } + + public function hasEventTime() + { + return isset($this->event_time); + } + + public function clearEventTime() + { + unset($this->event_time); + } + + /** + * Only required for + * [UserEventService.ImportUserEvents][google.cloud.discoveryengine.v1beta.UserEventService.ImportUserEvents] + * method. Timestamp of when the user event happened. + * + * Generated from protobuf field .google.protobuf.Timestamp event_time = 3; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setEventTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->event_time = $var; + + return $this; + } + + /** + * Information about the end user. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.UserInfo user_info = 4; + * @return \Google\Cloud\DiscoveryEngine\V1beta\UserInfo|null + */ + public function getUserInfo() + { + return $this->user_info; + } + + public function hasUserInfo() + { + return isset($this->user_info); + } + + public function clearUserInfo() + { + unset($this->user_info); + } + + /** + * Information about the end user. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.UserInfo user_info = 4; + * @param \Google\Cloud\DiscoveryEngine\V1beta\UserInfo $var + * @return $this + */ + public function setUserInfo($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\DiscoveryEngine\V1beta\UserInfo::class); + $this->user_info = $var; + + return $this; + } + + /** + * Should set to true if the request is made directly from the end user, in + * which case the + * [UserEvent.user_info.user_agent][google.cloud.discoveryengine.v1beta.UserInfo.user_agent] + * can be populated from the HTTP request. + * This flag should be set only if the API request is made directly from the + * end user such as a mobile app (and not if a gateway or a server is + * processing and pushing the user events). + * This should not be set when using the JavaScript tag in + * [UserEventService.CollectUserEvent][google.cloud.discoveryengine.v1beta.UserEventService.CollectUserEvent]. + * + * Generated from protobuf field bool direct_user_request = 5; + * @return bool + */ + public function getDirectUserRequest() + { + return $this->direct_user_request; + } + + /** + * Should set to true if the request is made directly from the end user, in + * which case the + * [UserEvent.user_info.user_agent][google.cloud.discoveryengine.v1beta.UserInfo.user_agent] + * can be populated from the HTTP request. + * This flag should be set only if the API request is made directly from the + * end user such as a mobile app (and not if a gateway or a server is + * processing and pushing the user events). + * This should not be set when using the JavaScript tag in + * [UserEventService.CollectUserEvent][google.cloud.discoveryengine.v1beta.UserEventService.CollectUserEvent]. + * + * Generated from protobuf field bool direct_user_request = 5; + * @param bool $var + * @return $this + */ + public function setDirectUserRequest($var) + { + GPBUtil::checkBool($var); + $this->direct_user_request = $var; + + return $this; + } + + /** + * A unique identifier for tracking a visitor session with a length limit of + * 128 bytes. A session is an aggregation of an end user behavior in a time + * span. + * A general guideline to populate the session_id: + * 1. If user has no activity for 30 min, a new session_id should be assigned. + * 2. The session_id should be unique across users, suggest use uuid or add + * [UserEvent.user_pseudo_id][google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id] + * as prefix. + * + * Generated from protobuf field string session_id = 6; + * @return string + */ + public function getSessionId() + { + return $this->session_id; + } + + /** + * A unique identifier for tracking a visitor session with a length limit of + * 128 bytes. A session is an aggregation of an end user behavior in a time + * span. + * A general guideline to populate the session_id: + * 1. If user has no activity for 30 min, a new session_id should be assigned. + * 2. The session_id should be unique across users, suggest use uuid or add + * [UserEvent.user_pseudo_id][google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id] + * as prefix. + * + * Generated from protobuf field string session_id = 6; + * @param string $var + * @return $this + */ + public function setSessionId($var) + { + GPBUtil::checkString($var, True); + $this->session_id = $var; + + return $this; + } + + /** + * Page metadata such as categories and other critical information for certain + * event types such as `view-category-page`. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.PageInfo page_info = 7; + * @return \Google\Cloud\DiscoveryEngine\V1beta\PageInfo|null + */ + public function getPageInfo() + { + return $this->page_info; + } + + public function hasPageInfo() + { + return isset($this->page_info); + } + + public function clearPageInfo() + { + unset($this->page_info); + } + + /** + * Page metadata such as categories and other critical information for certain + * event types such as `view-category-page`. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.PageInfo page_info = 7; + * @param \Google\Cloud\DiscoveryEngine\V1beta\PageInfo $var + * @return $this + */ + public function setPageInfo($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\DiscoveryEngine\V1beta\PageInfo::class); + $this->page_info = $var; + + return $this; + } + + /** + * Token to attribute an API response to user action(s) to trigger the event. + * Highly recommended for user events that are the result of + * [RecommendationService.Recommend][google.cloud.discoveryengine.v1beta.RecommendationService.Recommend]. + * This field enables accurate attribution of recommendation model + * performance. + * The value must be one of: + * * [PredictResponse.attribution_token][] for events that are the result of + * [RecommendationService.Recommend][google.cloud.discoveryengine.v1beta.RecommendationService.Recommend]. + * * [SearchResponse.attribution_token][google.cloud.discoveryengine.v1beta.SearchResponse.attribution_token] for events that are the result of + * [SearchService.Search][google.cloud.discoveryengine.v1beta.SearchService.Search]. + * * [CompleteQueryResponse.attribution_token][] for events that are the + * result of + * [CompletionService.CompleteQuery][google.cloud.discoveryengine.v1beta.CompletionService.CompleteQuery]. + * This token enables us to accurately attribute page view or conversion + * completion back to the event and the particular predict response containing + * this clicked/purchased product. If user clicks on product K in the + * recommendation results, pass [PredictResponse.attribution_token][] as a URL + * parameter to product K's page. When recording events on product K's page, + * log the [PredictResponse.attribution_token][] to this field. + * + * Generated from protobuf field string attribution_token = 8; + * @return string + */ + public function getAttributionToken() + { + return $this->attribution_token; + } + + /** + * Token to attribute an API response to user action(s) to trigger the event. + * Highly recommended for user events that are the result of + * [RecommendationService.Recommend][google.cloud.discoveryengine.v1beta.RecommendationService.Recommend]. + * This field enables accurate attribution of recommendation model + * performance. + * The value must be one of: + * * [PredictResponse.attribution_token][] for events that are the result of + * [RecommendationService.Recommend][google.cloud.discoveryengine.v1beta.RecommendationService.Recommend]. + * * [SearchResponse.attribution_token][google.cloud.discoveryengine.v1beta.SearchResponse.attribution_token] for events that are the result of + * [SearchService.Search][google.cloud.discoveryengine.v1beta.SearchService.Search]. + * * [CompleteQueryResponse.attribution_token][] for events that are the + * result of + * [CompletionService.CompleteQuery][google.cloud.discoveryengine.v1beta.CompletionService.CompleteQuery]. + * This token enables us to accurately attribute page view or conversion + * completion back to the event and the particular predict response containing + * this clicked/purchased product. If user clicks on product K in the + * recommendation results, pass [PredictResponse.attribution_token][] as a URL + * parameter to product K's page. When recording events on product K's page, + * log the [PredictResponse.attribution_token][] to this field. + * + * Generated from protobuf field string attribution_token = 8; + * @param string $var + * @return $this + */ + public function setAttributionToken($var) + { + GPBUtil::checkString($var, True); + $this->attribution_token = $var; + + return $this; + } + + /** + * The filter syntax consists of an expression language for constructing a + * predicate from one or more fields of the documents being filtered. + * One example is for `search` events, the associated + * [SearchRequest][google.cloud.discoveryengine.v1beta.SearchRequest] may + * contain a filter expression in + * [SearchRequest.filter][google.cloud.discoveryengine.v1beta.SearchRequest.filter] + * conforming to https://google.aip.dev/160#filtering. + * Similarly, for `view-item-list` events that are generated from a + * [RecommendationService.RecommendRequest][], this field may be populated + * directly from [RecommendationService.RecommendRequest.filter][] conforming + * to https://google.aip.dev/160#filtering. + * The value must be a UTF-8 encoded string with a length limit of 1,000 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * + * Generated from protobuf field string filter = 9; + * @return string + */ + public function getFilter() + { + return $this->filter; + } + + /** + * The filter syntax consists of an expression language for constructing a + * predicate from one or more fields of the documents being filtered. + * One example is for `search` events, the associated + * [SearchRequest][google.cloud.discoveryengine.v1beta.SearchRequest] may + * contain a filter expression in + * [SearchRequest.filter][google.cloud.discoveryengine.v1beta.SearchRequest.filter] + * conforming to https://google.aip.dev/160#filtering. + * Similarly, for `view-item-list` events that are generated from a + * [RecommendationService.RecommendRequest][], this field may be populated + * directly from [RecommendationService.RecommendRequest.filter][] conforming + * to https://google.aip.dev/160#filtering. + * The value must be a UTF-8 encoded string with a length limit of 1,000 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * + * Generated from protobuf field string filter = 9; + * @param string $var + * @return $this + */ + public function setFilter($var) + { + GPBUtil::checkString($var, True); + $this->filter = $var; + + return $this; + } + + /** + * List of Documents associated with this user event. + * This field is optional except for the following event types: + * * `view-item` + * * `add-to-cart` + * * `purchase` + * * `media-play` + * * `media-complete` + * In a `search` event, this field represents the documents returned to the + * end user on the current page (the end user may have not finished browsing + * the whole page yet). When a new page is returned to the end user, after + * pagination/filtering/ordering even for the same query, a new `search` event + * with different + * [UserEvent.documents][google.cloud.discoveryengine.v1beta.UserEvent.documents] + * is desired. + * + * Generated from protobuf field repeated .google.cloud.discoveryengine.v1beta.DocumentInfo documents = 10; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getDocuments() + { + return $this->documents; + } + + /** + * List of Documents associated with this user event. + * This field is optional except for the following event types: + * * `view-item` + * * `add-to-cart` + * * `purchase` + * * `media-play` + * * `media-complete` + * In a `search` event, this field represents the documents returned to the + * end user on the current page (the end user may have not finished browsing + * the whole page yet). When a new page is returned to the end user, after + * pagination/filtering/ordering even for the same query, a new `search` event + * with different + * [UserEvent.documents][google.cloud.discoveryengine.v1beta.UserEvent.documents] + * is desired. + * + * Generated from protobuf field repeated .google.cloud.discoveryengine.v1beta.DocumentInfo documents = 10; + * @param array<\Google\Cloud\DiscoveryEngine\V1beta\DocumentInfo>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setDocuments($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\DiscoveryEngine\V1beta\DocumentInfo::class); + $this->documents = $arr; + + return $this; + } + + /** + * Panel metadata associated with this user event. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.PanelInfo panel = 11; + * @return \Google\Cloud\DiscoveryEngine\V1beta\PanelInfo|null + */ + public function getPanel() + { + return $this->panel; + } + + public function hasPanel() + { + return isset($this->panel); + } + + public function clearPanel() + { + unset($this->panel); + } + + /** + * Panel metadata associated with this user event. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.PanelInfo panel = 11; + * @param \Google\Cloud\DiscoveryEngine\V1beta\PanelInfo $var + * @return $this + */ + public function setPanel($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\DiscoveryEngine\V1beta\PanelInfo::class); + $this->panel = $var; + + return $this; + } + + /** + * Search API details related to the event. + * This field should be set for `search` event. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.SearchInfo search_info = 12; + * @return \Google\Cloud\DiscoveryEngine\V1beta\SearchInfo|null + */ + public function getSearchInfo() + { + return $this->search_info; + } + + public function hasSearchInfo() + { + return isset($this->search_info); + } + + public function clearSearchInfo() + { + unset($this->search_info); + } + + /** + * Search API details related to the event. + * This field should be set for `search` event. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.SearchInfo search_info = 12; + * @param \Google\Cloud\DiscoveryEngine\V1beta\SearchInfo $var + * @return $this + */ + public function setSearchInfo($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\DiscoveryEngine\V1beta\SearchInfo::class); + $this->search_info = $var; + + return $this; + } + + /** + * CompleteQuery API details related to the event. + * This field should be set for `search` event when autocomplete function is + * enabled and the user clicks a suggestion for search. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.CompletionInfo completion_info = 13; + * @return \Google\Cloud\DiscoveryEngine\V1beta\CompletionInfo|null + */ + public function getCompletionInfo() + { + return $this->completion_info; + } + + public function hasCompletionInfo() + { + return isset($this->completion_info); + } + + public function clearCompletionInfo() + { + unset($this->completion_info); + } + + /** + * CompleteQuery API details related to the event. + * This field should be set for `search` event when autocomplete function is + * enabled and the user clicks a suggestion for search. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.CompletionInfo completion_info = 13; + * @param \Google\Cloud\DiscoveryEngine\V1beta\CompletionInfo $var + * @return $this + */ + public function setCompletionInfo($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\DiscoveryEngine\V1beta\CompletionInfo::class); + $this->completion_info = $var; + + return $this; + } + + /** + * The transaction metadata (if any) associated with this user event. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.TransactionInfo transaction_info = 14; + * @return \Google\Cloud\DiscoveryEngine\V1beta\TransactionInfo|null + */ + public function getTransactionInfo() + { + return $this->transaction_info; + } + + public function hasTransactionInfo() + { + return isset($this->transaction_info); + } + + public function clearTransactionInfo() + { + unset($this->transaction_info); + } + + /** + * The transaction metadata (if any) associated with this user event. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.TransactionInfo transaction_info = 14; + * @param \Google\Cloud\DiscoveryEngine\V1beta\TransactionInfo $var + * @return $this + */ + public function setTransactionInfo($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\DiscoveryEngine\V1beta\TransactionInfo::class); + $this->transaction_info = $var; + + return $this; + } + + /** + * A list of identifiers for the independent experiment groups this user event + * belongs to. This is used to distinguish between user events associated with + * different experiment setups on the customer end. + * + * Generated from protobuf field repeated string tag_ids = 15; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getTagIds() + { + return $this->tag_ids; + } + + /** + * A list of identifiers for the independent experiment groups this user event + * belongs to. This is used to distinguish between user events associated with + * different experiment setups on the customer end. + * + * Generated from protobuf field repeated string tag_ids = 15; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setTagIds($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->tag_ids = $arr; + + return $this; + } + + /** + * The promotion IDs if this is an event associated with promotions. + * Currently, this field is restricted to at most one ID. + * + * Generated from protobuf field repeated string promotion_ids = 16; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getPromotionIds() + { + return $this->promotion_ids; + } + + /** + * The promotion IDs if this is an event associated with promotions. + * Currently, this field is restricted to at most one ID. + * + * Generated from protobuf field repeated string promotion_ids = 16; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setPromotionIds($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->promotion_ids = $arr; + + return $this; + } + + /** + * Extra user event features to include in the recommendation model. + * These attributes must NOT contain data that needs to be parsed or processed + * further, e.g. JSON or other encodings. + * If you provide custom attributes for ingested user events, also include + * them in the user events that you associate with prediction requests. Custom + * attribute formatting must be consistent between imported events and events + * provided with prediction requests. This lets the Discovery Engine API use + * those custom attributes when training models and serving predictions, which + * helps improve recommendation quality. + * This field needs to pass all below criteria, otherwise an + * `INVALID_ARGUMENT` error is returned: + * * The key must be a UTF-8 encoded string with a length limit of 5,000 + * characters. + * * For text attributes, at most 400 values are allowed. Empty values are not + * allowed. Each value must be a UTF-8 encoded string with a length limit of + * 256 characters. + * * For number attributes, at most 400 values are allowed. + * For product recommendations, an example of extra user information is + * ` traffic_channel`, which is how a user arrives at the site. Users can + * arrive + * at the site by coming to the site directly, coming through Google + * search, or in other ways. + * + * Generated from protobuf field map attributes = 17; + * @return \Google\Protobuf\Internal\MapField + */ + public function getAttributes() + { + return $this->attributes; + } + + /** + * Extra user event features to include in the recommendation model. + * These attributes must NOT contain data that needs to be parsed or processed + * further, e.g. JSON or other encodings. + * If you provide custom attributes for ingested user events, also include + * them in the user events that you associate with prediction requests. Custom + * attribute formatting must be consistent between imported events and events + * provided with prediction requests. This lets the Discovery Engine API use + * those custom attributes when training models and serving predictions, which + * helps improve recommendation quality. + * This field needs to pass all below criteria, otherwise an + * `INVALID_ARGUMENT` error is returned: + * * The key must be a UTF-8 encoded string with a length limit of 5,000 + * characters. + * * For text attributes, at most 400 values are allowed. Empty values are not + * allowed. Each value must be a UTF-8 encoded string with a length limit of + * 256 characters. + * * For number attributes, at most 400 values are allowed. + * For product recommendations, an example of extra user information is + * ` traffic_channel`, which is how a user arrives at the site. Users can + * arrive + * at the site by coming to the site directly, coming through Google + * search, or in other ways. + * + * Generated from protobuf field map attributes = 17; + * @param array|\Google\Protobuf\Internal\MapField $var + * @return $this + */ + public function setAttributes($var) + { + $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\DiscoveryEngine\V1beta\CustomAttribute::class); + $this->attributes = $arr; + + return $this; + } + + /** + * Media-specific info. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.MediaInfo media_info = 18; + * @return \Google\Cloud\DiscoveryEngine\V1beta\MediaInfo|null + */ + public function getMediaInfo() + { + return $this->media_info; + } + + public function hasMediaInfo() + { + return isset($this->media_info); + } + + public function clearMediaInfo() + { + unset($this->media_info); + } + + /** + * Media-specific info. + * + * Generated from protobuf field .google.cloud.discoveryengine.v1beta.MediaInfo media_info = 18; + * @param \Google\Cloud\DiscoveryEngine\V1beta\MediaInfo $var + * @return $this + */ + public function setMediaInfo($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\DiscoveryEngine\V1beta\MediaInfo::class); + $this->media_info = $var; + + return $this; + } + +} + diff --git a/DiscoveryEngine/src/V1beta/UserInfo.php b/DiscoveryEngine/src/V1beta/UserInfo.php new file mode 100644 index 000000000000..37a1b603b851 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/UserInfo.php @@ -0,0 +1,165 @@ +google.cloud.discoveryengine.v1beta.UserInfo + */ +class UserInfo extends \Google\Protobuf\Internal\Message +{ + /** + * Highly recommended for logged-in users. Unique identifier for logged-in + * user, such as a user name. Don't set for anonymous users. + * Always use a hashed value for this ID. + * Don't set the field to the same fixed ID for different users. This mixes + * the event history of those users together, which results in degraded + * model quality. + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an `INVALID_ARGUMENT` error is returned. + * + * Generated from protobuf field string user_id = 1; + */ + protected $user_id = ''; + /** + * User agent as included in the HTTP header. Required for getting + * [SearchResponse.sponsored_results][]. + * The field must be a UTF-8 encoded string with a length limit of 1,000 + * characters. Otherwise, an `INVALID_ARGUMENT` error is returned. + * This should not be set when using the client side event reporting with + * GTM or JavaScript tag in + * [UserEventService.CollectUserEvent][google.cloud.discoveryengine.v1beta.UserEventService.CollectUserEvent] + * or if + * [UserEvent.direct_user_request][google.cloud.discoveryengine.v1beta.UserEvent.direct_user_request] + * is set. + * + * Generated from protobuf field string user_agent = 2; + */ + protected $user_agent = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $user_id + * Highly recommended for logged-in users. Unique identifier for logged-in + * user, such as a user name. Don't set for anonymous users. + * Always use a hashed value for this ID. + * Don't set the field to the same fixed ID for different users. This mixes + * the event history of those users together, which results in degraded + * model quality. + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an `INVALID_ARGUMENT` error is returned. + * @type string $user_agent + * User agent as included in the HTTP header. Required for getting + * [SearchResponse.sponsored_results][]. + * The field must be a UTF-8 encoded string with a length limit of 1,000 + * characters. Otherwise, an `INVALID_ARGUMENT` error is returned. + * This should not be set when using the client side event reporting with + * GTM or JavaScript tag in + * [UserEventService.CollectUserEvent][google.cloud.discoveryengine.v1beta.UserEventService.CollectUserEvent] + * or if + * [UserEvent.direct_user_request][google.cloud.discoveryengine.v1beta.UserEvent.direct_user_request] + * is set. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\Common::initOnce(); + parent::__construct($data); + } + + /** + * Highly recommended for logged-in users. Unique identifier for logged-in + * user, such as a user name. Don't set for anonymous users. + * Always use a hashed value for this ID. + * Don't set the field to the same fixed ID for different users. This mixes + * the event history of those users together, which results in degraded + * model quality. + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an `INVALID_ARGUMENT` error is returned. + * + * Generated from protobuf field string user_id = 1; + * @return string + */ + public function getUserId() + { + return $this->user_id; + } + + /** + * Highly recommended for logged-in users. Unique identifier for logged-in + * user, such as a user name. Don't set for anonymous users. + * Always use a hashed value for this ID. + * Don't set the field to the same fixed ID for different users. This mixes + * the event history of those users together, which results in degraded + * model quality. + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an `INVALID_ARGUMENT` error is returned. + * + * Generated from protobuf field string user_id = 1; + * @param string $var + * @return $this + */ + public function setUserId($var) + { + GPBUtil::checkString($var, True); + $this->user_id = $var; + + return $this; + } + + /** + * User agent as included in the HTTP header. Required for getting + * [SearchResponse.sponsored_results][]. + * The field must be a UTF-8 encoded string with a length limit of 1,000 + * characters. Otherwise, an `INVALID_ARGUMENT` error is returned. + * This should not be set when using the client side event reporting with + * GTM or JavaScript tag in + * [UserEventService.CollectUserEvent][google.cloud.discoveryengine.v1beta.UserEventService.CollectUserEvent] + * or if + * [UserEvent.direct_user_request][google.cloud.discoveryengine.v1beta.UserEvent.direct_user_request] + * is set. + * + * Generated from protobuf field string user_agent = 2; + * @return string + */ + public function getUserAgent() + { + return $this->user_agent; + } + + /** + * User agent as included in the HTTP header. Required for getting + * [SearchResponse.sponsored_results][]. + * The field must be a UTF-8 encoded string with a length limit of 1,000 + * characters. Otherwise, an `INVALID_ARGUMENT` error is returned. + * This should not be set when using the client side event reporting with + * GTM or JavaScript tag in + * [UserEventService.CollectUserEvent][google.cloud.discoveryengine.v1beta.UserEventService.CollectUserEvent] + * or if + * [UserEvent.direct_user_request][google.cloud.discoveryengine.v1beta.UserEvent.direct_user_request] + * is set. + * + * Generated from protobuf field string user_agent = 2; + * @param string $var + * @return $this + */ + public function setUserAgent($var) + { + GPBUtil::checkString($var, True); + $this->user_agent = $var; + + return $this; + } + +} + diff --git a/DiscoveryEngine/src/V1beta/WriteUserEventRequest.php b/DiscoveryEngine/src/V1beta/WriteUserEventRequest.php new file mode 100644 index 000000000000..0160c406ea4a --- /dev/null +++ b/DiscoveryEngine/src/V1beta/WriteUserEventRequest.php @@ -0,0 +1,115 @@ +google.cloud.discoveryengine.v1beta.WriteUserEventRequest + */ +class WriteUserEventRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The parent DataStore resource name, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $parent = ''; + /** + * Required. User event to write. + * + * Generated from protobuf field optional .google.cloud.discoveryengine.v1beta.UserEvent user_event = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $user_event = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. The parent DataStore resource name, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. + * @type \Google\Cloud\DiscoveryEngine\V1beta\UserEvent $user_event + * Required. User event to write. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Discoveryengine\V1Beta\UserEventService::initOnce(); + parent::__construct($data); + } + + /** + * Required. The parent DataStore resource name, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. + * + * 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 DataStore resource name, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. + * + * 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. User event to write. + * + * Generated from protobuf field optional .google.cloud.discoveryengine.v1beta.UserEvent user_event = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\DiscoveryEngine\V1beta\UserEvent|null + */ + public function getUserEvent() + { + return $this->user_event; + } + + public function hasUserEvent() + { + return isset($this->user_event); + } + + public function clearUserEvent() + { + unset($this->user_event); + } + + /** + * Required. User event to write. + * + * Generated from protobuf field optional .google.cloud.discoveryengine.v1beta.UserEvent user_event = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\DiscoveryEngine\V1beta\UserEvent $var + * @return $this + */ + public function setUserEvent($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\DiscoveryEngine\V1beta\UserEvent::class); + $this->user_event = $var; + + return $this; + } + +} + diff --git a/DiscoveryEngine/src/V1beta/gapic_metadata.json b/DiscoveryEngine/src/V1beta/gapic_metadata.json new file mode 100644 index 000000000000..152941eb8b1a --- /dev/null +++ b/DiscoveryEngine/src/V1beta/gapic_metadata.json @@ -0,0 +1,153 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services\/RPCs to the corresponding library clients\/methods", + "language": "php", + "protoPackage": "google.cloud.discoveryengine.v1beta", + "libraryPackage": "Google\\Cloud\\DiscoveryEngine\\V1beta", + "services": { + "CompletionService": { + "clients": { + "grpc": { + "libraryClient": "CompletionServiceGapicClient", + "rpcs": { + "CompleteQuery": { + "methods": [ + "completeQuery" + ] + } + } + } + } + }, + "DocumentService": { + "clients": { + "grpc": { + "libraryClient": "DocumentServiceGapicClient", + "rpcs": { + "CreateDocument": { + "methods": [ + "createDocument" + ] + }, + "DeleteDocument": { + "methods": [ + "deleteDocument" + ] + }, + "GetDocument": { + "methods": [ + "getDocument" + ] + }, + "ImportDocuments": { + "methods": [ + "importDocuments" + ] + }, + "ListDocuments": { + "methods": [ + "listDocuments" + ] + }, + "PurgeDocuments": { + "methods": [ + "purgeDocuments" + ] + }, + "UpdateDocument": { + "methods": [ + "updateDocument" + ] + } + } + } + } + }, + "RecommendationService": { + "clients": { + "grpc": { + "libraryClient": "RecommendationServiceGapicClient", + "rpcs": { + "Recommend": { + "methods": [ + "recommend" + ] + } + } + } + } + }, + "SchemaService": { + "clients": { + "grpc": { + "libraryClient": "SchemaServiceGapicClient", + "rpcs": { + "CreateSchema": { + "methods": [ + "createSchema" + ] + }, + "DeleteSchema": { + "methods": [ + "deleteSchema" + ] + }, + "GetSchema": { + "methods": [ + "getSchema" + ] + }, + "ListSchemas": { + "methods": [ + "listSchemas" + ] + }, + "UpdateSchema": { + "methods": [ + "updateSchema" + ] + } + } + } + } + }, + "SearchService": { + "clients": { + "grpc": { + "libraryClient": "SearchServiceGapicClient", + "rpcs": { + "Search": { + "methods": [ + "search" + ] + } + } + } + } + }, + "UserEventService": { + "clients": { + "grpc": { + "libraryClient": "UserEventServiceGapicClient", + "rpcs": { + "CollectUserEvent": { + "methods": [ + "collectUserEvent" + ] + }, + "ImportUserEvents": { + "methods": [ + "importUserEvents" + ] + }, + "WriteUserEvent": { + "methods": [ + "writeUserEvent" + ] + } + } + } + } + } + } +} \ No newline at end of file diff --git a/DiscoveryEngine/src/V1beta/resources/completion_service_client_config.json b/DiscoveryEngine/src/V1beta/resources/completion_service_client_config.json new file mode 100644 index 000000000000..7a3194a4a377 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/resources/completion_service_client_config.json @@ -0,0 +1,39 @@ +{ + "interfaces": { + "google.cloud.discoveryengine.v1beta.CompletionService": { + "retry_codes": { + "no_retry_codes": [], + "retry_policy_1_codes": [ + "UNAVAILABLE" + ] + }, + "retry_params": { + "no_retry_params": { + "initial_retry_delay_millis": 0, + "retry_delay_multiplier": 0.0, + "max_retry_delay_millis": 0, + "initial_rpc_timeout_millis": 0, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 0, + "total_timeout_millis": 0 + }, + "retry_policy_1_params": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 5000, + "initial_rpc_timeout_millis": 5000, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 5000, + "total_timeout_millis": 5000 + } + }, + "methods": { + "CompleteQuery": { + "timeout_millis": 5000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + } + } + } + } +} diff --git a/DiscoveryEngine/src/V1beta/resources/completion_service_descriptor_config.php b/DiscoveryEngine/src/V1beta/resources/completion_service_descriptor_config.php new file mode 100644 index 000000000000..3d8820a5cdd7 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/resources/completion_service_descriptor_config.php @@ -0,0 +1,25 @@ + [ + 'google.cloud.discoveryengine.v1beta.CompletionService' => [ + 'CompleteQuery' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\DiscoveryEngine\V1beta\CompleteQueryResponse', + 'headerParams' => [ + [ + 'keyName' => 'data_store', + 'fieldAccessors' => [ + 'getDataStore', + ], + ], + ], + ], + 'templateMap' => [ + 'dataStore' => 'projects/{project}/locations/{location}/dataStores/{data_store}', + 'projectLocationCollectionDataStore' => 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}', + 'projectLocationDataStore' => 'projects/{project}/locations/{location}/dataStores/{data_store}', + ], + ], + ], +]; diff --git a/DiscoveryEngine/src/V1beta/resources/completion_service_rest_client_config.php b/DiscoveryEngine/src/V1beta/resources/completion_service_rest_client_config.php new file mode 100644 index 000000000000..ad97ed367998 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/resources/completion_service_rest_client_config.php @@ -0,0 +1,118 @@ + [ + 'google.cloud.discoveryengine.v1beta.CompletionService' => [ + 'CompleteQuery' => [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{data_store=projects/*/locations/*/dataStores/*}:completeQuery', + 'additionalBindings' => [ + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{data_store=projects/*/locations/*/collections/*/dataStores/*}:completeQuery', + ], + ], + 'placeholders' => [ + 'data_store' => [ + 'getters' => [ + 'getDataStore', + ], + ], + ], + ], + ], + 'google.longrunning.Operations' => [ + 'GetOperation' => [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/branches/*/operations/*}', + 'additionalBindings' => [ + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/models/*/operations/*}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/operations/*}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/collections/*/operations/*}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/dataStores/*/branches/*/operations/*}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/dataStores/*/models/*/operations/*}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/dataStores/*/operations/*}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/operations/*}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/operations/*}', + ], + ], + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'ListOperations' => [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/branches/*}/operations', + 'additionalBindings' => [ + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/models/*}/operations', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*}/operations', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/collections/*}/operations', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/dataStores/*/branches/*}/operations', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/dataStores/*/models/*}/operations', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/dataStores/*}/operations', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*}/operations', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*}/operations', + ], + ], + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + ], + ], + 'numericEnums' => true, +]; diff --git a/DiscoveryEngine/src/V1beta/resources/document_service_client_config.json b/DiscoveryEngine/src/V1beta/resources/document_service_client_config.json new file mode 100644 index 000000000000..f31c7d6b35f0 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/resources/document_service_client_config.json @@ -0,0 +1,81 @@ +{ + "interfaces": { + "google.cloud.discoveryengine.v1beta.DocumentService": { + "retry_codes": { + "no_retry_codes": [], + "retry_policy_2_codes": [ + "UNAVAILABLE" + ], + "retry_policy_3_codes": [ + "UNAVAILABLE" + ] + }, + "retry_params": { + "no_retry_params": { + "initial_retry_delay_millis": 0, + "retry_delay_multiplier": 0.0, + "max_retry_delay_millis": 0, + "initial_rpc_timeout_millis": 0, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 0, + "total_timeout_millis": 0 + }, + "retry_policy_2_params": { + "initial_retry_delay_millis": 1000, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 10000, + "initial_rpc_timeout_millis": 30000, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 30000, + "total_timeout_millis": 30000 + }, + "retry_policy_3_params": { + "initial_retry_delay_millis": 1000, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 30000, + "initial_rpc_timeout_millis": 300000, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 300000, + "total_timeout_millis": 300000 + } + }, + "methods": { + "CreateDocument": { + "timeout_millis": 30000, + "retry_codes_name": "retry_policy_2_codes", + "retry_params_name": "retry_policy_2_params" + }, + "DeleteDocument": { + "timeout_millis": 30000, + "retry_codes_name": "retry_policy_2_codes", + "retry_params_name": "retry_policy_2_params" + }, + "GetDocument": { + "timeout_millis": 30000, + "retry_codes_name": "retry_policy_2_codes", + "retry_params_name": "retry_policy_2_params" + }, + "ImportDocuments": { + "timeout_millis": 300000, + "retry_codes_name": "retry_policy_3_codes", + "retry_params_name": "retry_policy_3_params" + }, + "ListDocuments": { + "timeout_millis": 30000, + "retry_codes_name": "retry_policy_2_codes", + "retry_params_name": "retry_policy_2_params" + }, + "PurgeDocuments": { + "timeout_millis": 30000, + "retry_codes_name": "retry_policy_2_codes", + "retry_params_name": "retry_policy_2_params" + }, + "UpdateDocument": { + "timeout_millis": 30000, + "retry_codes_name": "retry_policy_2_codes", + "retry_params_name": "retry_policy_2_params" + } + } + } + } +} diff --git a/DiscoveryEngine/src/V1beta/resources/document_service_descriptor_config.php b/DiscoveryEngine/src/V1beta/resources/document_service_descriptor_config.php new file mode 100644 index 000000000000..743e3dc11bb5 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/resources/document_service_descriptor_config.php @@ -0,0 +1,123 @@ + [ + 'google.cloud.discoveryengine.v1beta.DocumentService' => [ + 'ImportDocuments' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Cloud\DiscoveryEngine\V1beta\ImportDocumentsResponse', + 'metadataReturnType' => '\Google\Cloud\DiscoveryEngine\V1beta\ImportDocumentsMetadata', + 'initialPollDelayMillis' => '500', + 'pollDelayMultiplier' => '1.5', + 'maxPollDelayMillis' => '5000', + 'totalPollTimeoutMillis' => '300000', + ], + 'callType' => \Google\ApiCore\Call::LONGRUNNING_CALL, + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'PurgeDocuments' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Cloud\DiscoveryEngine\V1beta\PurgeDocumentsResponse', + 'metadataReturnType' => '\Google\Cloud\DiscoveryEngine\V1beta\PurgeDocumentsMetadata', + 'initialPollDelayMillis' => '500', + 'pollDelayMultiplier' => '1.5', + 'maxPollDelayMillis' => '5000', + 'totalPollTimeoutMillis' => '300000', + ], + 'callType' => \Google\ApiCore\Call::LONGRUNNING_CALL, + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'CreateDocument' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\DiscoveryEngine\V1beta\Document', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'DeleteDocument' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Protobuf\GPBEmpty', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], + 'GetDocument' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\DiscoveryEngine\V1beta\Document', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], + 'ListDocuments' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getDocuments', + ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\DiscoveryEngine\V1beta\ListDocumentsResponse', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'UpdateDocument' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\DiscoveryEngine\V1beta\Document', + 'headerParams' => [ + [ + 'keyName' => 'document.name', + 'fieldAccessors' => [ + 'getDocument', + 'getName', + ], + ], + ], + ], + 'templateMap' => [ + 'branch' => 'projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}', + 'document' => 'projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document}', + 'projectLocationCollectionDataStoreBranch' => 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}', + 'projectLocationCollectionDataStoreBranchDocument' => 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}', + 'projectLocationDataStoreBranch' => 'projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}', + 'projectLocationDataStoreBranchDocument' => 'projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document}', + ], + ], + ], +]; diff --git a/DiscoveryEngine/src/V1beta/resources/document_service_rest_client_config.php b/DiscoveryEngine/src/V1beta/resources/document_service_rest_client_config.php new file mode 100644 index 000000000000..99e7af53ddde --- /dev/null +++ b/DiscoveryEngine/src/V1beta/resources/document_service_rest_client_config.php @@ -0,0 +1,235 @@ + [ + 'google.cloud.discoveryengine.v1beta.DocumentService' => [ + 'CreateDocument' => [ + 'method' => 'post', + 'uriTemplate' => '/v1beta/{parent=projects/*/locations/*/dataStores/*/branches/*}/documents', + 'body' => 'document', + 'additionalBindings' => [ + [ + 'method' => 'post', + 'uriTemplate' => '/v1beta/{parent=projects/*/locations/*/collections/*/dataStores/*/branches/*}/documents', + 'body' => 'document', + 'queryParams' => [ + 'document_id', + ], + ], + ], + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + 'queryParams' => [ + 'document_id', + ], + ], + 'DeleteDocument' => [ + 'method' => 'delete', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/dataStores/*/branches/*/documents/*}', + 'additionalBindings' => [ + [ + 'method' => 'delete', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/branches/*/documents/*}', + ], + ], + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'GetDocument' => [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/dataStores/*/branches/*/documents/*}', + 'additionalBindings' => [ + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/branches/*/documents/*}', + ], + ], + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'ImportDocuments' => [ + 'method' => 'post', + 'uriTemplate' => '/v1beta/{parent=projects/*/locations/*/dataStores/*/branches/*}/documents:import', + 'body' => '*', + 'additionalBindings' => [ + [ + 'method' => 'post', + 'uriTemplate' => '/v1beta/{parent=projects/*/locations/*/collections/*/dataStores/*/branches/*}/documents:import', + 'body' => '*', + ], + ], + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + 'ListDocuments' => [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{parent=projects/*/locations/*/dataStores/*/branches/*}/documents', + 'additionalBindings' => [ + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{parent=projects/*/locations/*/collections/*/dataStores/*/branches/*}/documents', + ], + ], + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + 'PurgeDocuments' => [ + 'method' => 'post', + 'uriTemplate' => '/v1beta/{parent=projects/*/locations/*/dataStores/*/branches/*}/documents:purge', + 'body' => '*', + 'additionalBindings' => [ + [ + 'method' => 'post', + 'uriTemplate' => '/v1beta/{parent=projects/*/locations/*/collections/*/dataStores/*/branches/*}/documents:purge', + 'body' => '*', + ], + ], + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + 'UpdateDocument' => [ + 'method' => 'patch', + 'uriTemplate' => '/v1beta/{document.name=projects/*/locations/*/dataStores/*/branches/*/documents/*}', + 'body' => 'document', + 'additionalBindings' => [ + [ + 'method' => 'patch', + 'uriTemplate' => '/v1beta/{document.name=projects/*/locations/*/collections/*/dataStores/*/branches/*/documents/*}', + 'body' => 'document', + ], + ], + 'placeholders' => [ + 'document.name' => [ + 'getters' => [ + 'getDocument', + 'getName', + ], + ], + ], + ], + ], + 'google.longrunning.Operations' => [ + 'GetOperation' => [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/branches/*/operations/*}', + 'additionalBindings' => [ + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/models/*/operations/*}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/operations/*}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/collections/*/operations/*}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/dataStores/*/branches/*/operations/*}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/dataStores/*/models/*/operations/*}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/dataStores/*/operations/*}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/operations/*}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/operations/*}', + ], + ], + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'ListOperations' => [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/branches/*}/operations', + 'additionalBindings' => [ + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/models/*}/operations', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*}/operations', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/collections/*}/operations', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/dataStores/*/branches/*}/operations', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/dataStores/*/models/*}/operations', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/dataStores/*}/operations', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*}/operations', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*}/operations', + ], + ], + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + ], + ], + 'numericEnums' => true, +]; diff --git a/DiscoveryEngine/src/V1beta/resources/recommendation_service_client_config.json b/DiscoveryEngine/src/V1beta/resources/recommendation_service_client_config.json new file mode 100644 index 000000000000..2e290adf1745 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/resources/recommendation_service_client_config.json @@ -0,0 +1,39 @@ +{ + "interfaces": { + "google.cloud.discoveryengine.v1beta.RecommendationService": { + "retry_codes": { + "no_retry_codes": [], + "retry_policy_1_codes": [ + "UNAVAILABLE" + ] + }, + "retry_params": { + "no_retry_params": { + "initial_retry_delay_millis": 0, + "retry_delay_multiplier": 0.0, + "max_retry_delay_millis": 0, + "initial_rpc_timeout_millis": 0, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 0, + "total_timeout_millis": 0 + }, + "retry_policy_1_params": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 5000, + "initial_rpc_timeout_millis": 5000, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 5000, + "total_timeout_millis": 5000 + } + }, + "methods": { + "Recommend": { + "timeout_millis": 5000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + } + } + } + } +} diff --git a/DiscoveryEngine/src/V1beta/resources/recommendation_service_descriptor_config.php b/DiscoveryEngine/src/V1beta/resources/recommendation_service_descriptor_config.php new file mode 100644 index 000000000000..5dc3021feb5d --- /dev/null +++ b/DiscoveryEngine/src/V1beta/resources/recommendation_service_descriptor_config.php @@ -0,0 +1,28 @@ + [ + 'google.cloud.discoveryengine.v1beta.RecommendationService' => [ + 'Recommend' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\DiscoveryEngine\V1beta\RecommendResponse', + 'headerParams' => [ + [ + 'keyName' => 'serving_config', + 'fieldAccessors' => [ + 'getServingConfig', + ], + ], + ], + ], + 'templateMap' => [ + 'document' => 'projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document}', + 'projectLocationCollectionDataStoreBranchDocument' => 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}', + 'projectLocationCollectionDataStoreServingConfig' => 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/servingConfigs/{serving_config}', + 'projectLocationDataStoreBranchDocument' => 'projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document}', + 'projectLocationDataStoreServingConfig' => 'projects/{project}/locations/{location}/dataStores/{data_store}/servingConfigs/{serving_config}', + 'servingConfig' => 'projects/{project}/locations/{location}/dataStores/{data_store}/servingConfigs/{serving_config}', + ], + ], + ], +]; diff --git a/DiscoveryEngine/src/V1beta/resources/recommendation_service_rest_client_config.php b/DiscoveryEngine/src/V1beta/resources/recommendation_service_rest_client_config.php new file mode 100644 index 000000000000..1c8af1306fc4 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/resources/recommendation_service_rest_client_config.php @@ -0,0 +1,120 @@ + [ + 'google.cloud.discoveryengine.v1beta.RecommendationService' => [ + 'Recommend' => [ + 'method' => 'post', + 'uriTemplate' => '/v1beta/{serving_config=projects/*/locations/*/dataStores/*/servingConfigs/*}:recommend', + 'body' => '*', + 'additionalBindings' => [ + [ + 'method' => 'post', + 'uriTemplate' => '/v1beta/{serving_config=projects/*/locations/*/collections/*/dataStores/*/servingConfigs/*}:recommend', + 'body' => '*', + ], + ], + 'placeholders' => [ + 'serving_config' => [ + 'getters' => [ + 'getServingConfig', + ], + ], + ], + ], + ], + 'google.longrunning.Operations' => [ + 'GetOperation' => [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/branches/*/operations/*}', + 'additionalBindings' => [ + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/models/*/operations/*}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/operations/*}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/collections/*/operations/*}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/dataStores/*/branches/*/operations/*}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/dataStores/*/models/*/operations/*}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/dataStores/*/operations/*}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/operations/*}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/operations/*}', + ], + ], + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'ListOperations' => [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/branches/*}/operations', + 'additionalBindings' => [ + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/models/*}/operations', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*}/operations', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/collections/*}/operations', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/dataStores/*/branches/*}/operations', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/dataStores/*/models/*}/operations', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/dataStores/*}/operations', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*}/operations', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*}/operations', + ], + ], + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + ], + ], + 'numericEnums' => true, +]; diff --git a/DiscoveryEngine/src/V1beta/resources/schema_service_client_config.json b/DiscoveryEngine/src/V1beta/resources/schema_service_client_config.json new file mode 100644 index 000000000000..a125a00926a2 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/resources/schema_service_client_config.json @@ -0,0 +1,59 @@ +{ + "interfaces": { + "google.cloud.discoveryengine.v1beta.SchemaService": { + "retry_codes": { + "no_retry_codes": [], + "retry_policy_2_codes": [ + "UNAVAILABLE" + ] + }, + "retry_params": { + "no_retry_params": { + "initial_retry_delay_millis": 0, + "retry_delay_multiplier": 0.0, + "max_retry_delay_millis": 0, + "initial_rpc_timeout_millis": 0, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 0, + "total_timeout_millis": 0 + }, + "retry_policy_2_params": { + "initial_retry_delay_millis": 1000, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 10000, + "initial_rpc_timeout_millis": 30000, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 30000, + "total_timeout_millis": 30000 + } + }, + "methods": { + "CreateSchema": { + "timeout_millis": 30000, + "retry_codes_name": "retry_policy_2_codes", + "retry_params_name": "retry_policy_2_params" + }, + "DeleteSchema": { + "timeout_millis": 30000, + "retry_codes_name": "retry_policy_2_codes", + "retry_params_name": "retry_policy_2_params" + }, + "GetSchema": { + "timeout_millis": 30000, + "retry_codes_name": "retry_policy_2_codes", + "retry_params_name": "retry_policy_2_params" + }, + "ListSchemas": { + "timeout_millis": 30000, + "retry_codes_name": "retry_policy_2_codes", + "retry_params_name": "retry_policy_2_params" + }, + "UpdateSchema": { + "timeout_millis": 30000, + "retry_codes_name": "retry_policy_2_codes", + "retry_params_name": "retry_policy_2_params" + } + } + } + } +} diff --git a/DiscoveryEngine/src/V1beta/resources/schema_service_descriptor_config.php b/DiscoveryEngine/src/V1beta/resources/schema_service_descriptor_config.php new file mode 100644 index 000000000000..190825f414a2 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/resources/schema_service_descriptor_config.php @@ -0,0 +1,106 @@ + [ + 'google.cloud.discoveryengine.v1beta.SchemaService' => [ + 'CreateSchema' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Cloud\DiscoveryEngine\V1beta\Schema', + 'metadataReturnType' => '\Google\Cloud\DiscoveryEngine\V1beta\CreateSchemaMetadata', + 'initialPollDelayMillis' => '500', + 'pollDelayMultiplier' => '1.5', + 'maxPollDelayMillis' => '5000', + 'totalPollTimeoutMillis' => '300000', + ], + 'callType' => \Google\ApiCore\Call::LONGRUNNING_CALL, + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'DeleteSchema' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Protobuf\GPBEmpty', + 'metadataReturnType' => '\Google\Cloud\DiscoveryEngine\V1beta\DeleteSchemaMetadata', + 'initialPollDelayMillis' => '500', + 'pollDelayMultiplier' => '1.5', + 'maxPollDelayMillis' => '5000', + 'totalPollTimeoutMillis' => '300000', + ], + 'callType' => \Google\ApiCore\Call::LONGRUNNING_CALL, + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], + 'UpdateSchema' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Cloud\DiscoveryEngine\V1beta\Schema', + 'metadataReturnType' => '\Google\Cloud\DiscoveryEngine\V1beta\UpdateSchemaMetadata', + 'initialPollDelayMillis' => '500', + 'pollDelayMultiplier' => '1.5', + 'maxPollDelayMillis' => '5000', + 'totalPollTimeoutMillis' => '300000', + ], + 'callType' => \Google\ApiCore\Call::LONGRUNNING_CALL, + 'headerParams' => [ + [ + 'keyName' => 'schema.name', + 'fieldAccessors' => [ + 'getSchema', + 'getName', + ], + ], + ], + ], + 'GetSchema' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\DiscoveryEngine\V1beta\Schema', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], + 'ListSchemas' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getSchemas', + ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\DiscoveryEngine\V1beta\ListSchemasResponse', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'templateMap' => [ + 'dataStore' => 'projects/{project}/locations/{location}/dataStores/{data_store}', + 'projectLocationCollectionDataStore' => 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}', + 'projectLocationCollectionDataStoreSchema' => 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}', + 'projectLocationDataStore' => 'projects/{project}/locations/{location}/dataStores/{data_store}', + 'projectLocationDataStoreSchema' => 'projects/{project}/locations/{location}/dataStores/{data_store}/schemas/{schema}', + 'schema' => 'projects/{project}/locations/{location}/dataStores/{data_store}/schemas/{schema}', + ], + ], + ], +]; diff --git a/DiscoveryEngine/src/V1beta/resources/schema_service_rest_client_config.php b/DiscoveryEngine/src/V1beta/resources/schema_service_rest_client_config.php new file mode 100644 index 000000000000..2d534b0cece3 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/resources/schema_service_rest_client_config.php @@ -0,0 +1,197 @@ + [ + 'google.cloud.discoveryengine.v1beta.SchemaService' => [ + 'CreateSchema' => [ + 'method' => 'post', + 'uriTemplate' => '/v1beta/{parent=projects/*/locations/*/dataStores/*}/schemas', + 'body' => 'schema', + 'additionalBindings' => [ + [ + 'method' => 'post', + 'uriTemplate' => '/v1beta/{parent=projects/*/locations/*/collections/*/dataStores/*}/schemas', + 'body' => 'schema', + 'queryParams' => [ + 'schema_id', + ], + ], + ], + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + 'queryParams' => [ + 'schema_id', + ], + ], + 'DeleteSchema' => [ + 'method' => 'delete', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/dataStores/*/schemas/*}', + 'additionalBindings' => [ + [ + 'method' => 'delete', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/schemas/*}', + ], + ], + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'GetSchema' => [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/dataStores/*/schemas/*}', + 'additionalBindings' => [ + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/schemas/*}', + ], + ], + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'ListSchemas' => [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{parent=projects/*/locations/*/dataStores/*}/schemas', + 'additionalBindings' => [ + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{parent=projects/*/locations/*/collections/*/dataStores/*}/schemas', + ], + ], + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + 'UpdateSchema' => [ + 'method' => 'patch', + 'uriTemplate' => '/v1beta/{schema.name=projects/*/locations/*/dataStores/*/schemas/*}', + 'body' => 'schema', + 'additionalBindings' => [ + [ + 'method' => 'patch', + 'uriTemplate' => '/v1beta/{schema.name=projects/*/locations/*/collections/*/dataStores/*/schemas/*}', + 'body' => 'schema', + ], + ], + 'placeholders' => [ + 'schema.name' => [ + 'getters' => [ + 'getSchema', + 'getName', + ], + ], + ], + ], + ], + 'google.longrunning.Operations' => [ + 'GetOperation' => [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/branches/*/operations/*}', + 'additionalBindings' => [ + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/models/*/operations/*}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/operations/*}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/collections/*/operations/*}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/dataStores/*/branches/*/operations/*}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/dataStores/*/models/*/operations/*}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/dataStores/*/operations/*}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/operations/*}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/operations/*}', + ], + ], + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'ListOperations' => [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/branches/*}/operations', + 'additionalBindings' => [ + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/models/*}/operations', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*}/operations', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/collections/*}/operations', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/dataStores/*/branches/*}/operations', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/dataStores/*/models/*}/operations', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/dataStores/*}/operations', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*}/operations', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*}/operations', + ], + ], + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + ], + ], + 'numericEnums' => true, +]; diff --git a/DiscoveryEngine/src/V1beta/resources/search_service_client_config.json b/DiscoveryEngine/src/V1beta/resources/search_service_client_config.json new file mode 100644 index 000000000000..f98ea3de4901 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/resources/search_service_client_config.json @@ -0,0 +1,39 @@ +{ + "interfaces": { + "google.cloud.discoveryengine.v1beta.SearchService": { + "retry_codes": { + "no_retry_codes": [], + "retry_policy_1_codes": [ + "UNAVAILABLE" + ] + }, + "retry_params": { + "no_retry_params": { + "initial_retry_delay_millis": 0, + "retry_delay_multiplier": 0.0, + "max_retry_delay_millis": 0, + "initial_rpc_timeout_millis": 0, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 0, + "total_timeout_millis": 0 + }, + "retry_policy_1_params": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 5000, + "initial_rpc_timeout_millis": 5000, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 5000, + "total_timeout_millis": 5000 + } + }, + "methods": { + "Search": { + "timeout_millis": 5000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + } + } + } + } +} diff --git a/DiscoveryEngine/src/V1beta/resources/search_service_descriptor_config.php b/DiscoveryEngine/src/V1beta/resources/search_service_descriptor_config.php new file mode 100644 index 000000000000..a75a6ceae41e --- /dev/null +++ b/DiscoveryEngine/src/V1beta/resources/search_service_descriptor_config.php @@ -0,0 +1,36 @@ + [ + 'google.cloud.discoveryengine.v1beta.SearchService' => [ + 'Search' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getResults', + ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\DiscoveryEngine\V1beta\SearchResponse', + 'headerParams' => [ + [ + 'keyName' => 'serving_config', + 'fieldAccessors' => [ + 'getServingConfig', + ], + ], + ], + ], + 'templateMap' => [ + 'branch' => 'projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}', + 'projectLocationCollectionDataStoreBranch' => 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}', + 'projectLocationCollectionDataStoreServingConfig' => 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/servingConfigs/{serving_config}', + 'projectLocationDataStoreBranch' => 'projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}', + 'projectLocationDataStoreServingConfig' => 'projects/{project}/locations/{location}/dataStores/{data_store}/servingConfigs/{serving_config}', + 'servingConfig' => 'projects/{project}/locations/{location}/dataStores/{data_store}/servingConfigs/{serving_config}', + ], + ], + ], +]; diff --git a/DiscoveryEngine/src/V1beta/resources/search_service_rest_client_config.php b/DiscoveryEngine/src/V1beta/resources/search_service_rest_client_config.php new file mode 100644 index 000000000000..79b53dc4f8b8 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/resources/search_service_rest_client_config.php @@ -0,0 +1,120 @@ + [ + 'google.cloud.discoveryengine.v1beta.SearchService' => [ + 'Search' => [ + 'method' => 'post', + 'uriTemplate' => '/v1beta/{serving_config=projects/*/locations/*/dataStores/*/servingConfigs/*}:search', + 'body' => '*', + 'additionalBindings' => [ + [ + 'method' => 'post', + 'uriTemplate' => '/v1beta/{serving_config=projects/*/locations/*/collections/*/dataStores/*/servingConfigs/*}:search', + 'body' => '*', + ], + ], + 'placeholders' => [ + 'serving_config' => [ + 'getters' => [ + 'getServingConfig', + ], + ], + ], + ], + ], + 'google.longrunning.Operations' => [ + 'GetOperation' => [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/branches/*/operations/*}', + 'additionalBindings' => [ + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/models/*/operations/*}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/operations/*}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/collections/*/operations/*}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/dataStores/*/branches/*/operations/*}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/dataStores/*/models/*/operations/*}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/dataStores/*/operations/*}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/operations/*}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/operations/*}', + ], + ], + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'ListOperations' => [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/branches/*}/operations', + 'additionalBindings' => [ + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/models/*}/operations', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*}/operations', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/collections/*}/operations', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/dataStores/*/branches/*}/operations', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/dataStores/*/models/*}/operations', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/dataStores/*}/operations', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*}/operations', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*}/operations', + ], + ], + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + ], + ], + 'numericEnums' => true, +]; diff --git a/DiscoveryEngine/src/V1beta/resources/user_event_service_client_config.json b/DiscoveryEngine/src/V1beta/resources/user_event_service_client_config.json new file mode 100644 index 000000000000..5fe27d73fa58 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/resources/user_event_service_client_config.json @@ -0,0 +1,61 @@ +{ + "interfaces": { + "google.cloud.discoveryengine.v1beta.UserEventService": { + "retry_codes": { + "no_retry_codes": [], + "retry_policy_2_codes": [ + "UNAVAILABLE" + ], + "retry_policy_3_codes": [ + "UNAVAILABLE" + ] + }, + "retry_params": { + "no_retry_params": { + "initial_retry_delay_millis": 0, + "retry_delay_multiplier": 0.0, + "max_retry_delay_millis": 0, + "initial_rpc_timeout_millis": 0, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 0, + "total_timeout_millis": 0 + }, + "retry_policy_2_params": { + "initial_retry_delay_millis": 1000, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 10000, + "initial_rpc_timeout_millis": 30000, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 30000, + "total_timeout_millis": 30000 + }, + "retry_policy_3_params": { + "initial_retry_delay_millis": 1000, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 30000, + "initial_rpc_timeout_millis": 300000, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 300000, + "total_timeout_millis": 300000 + } + }, + "methods": { + "CollectUserEvent": { + "timeout_millis": 30000, + "retry_codes_name": "retry_policy_2_codes", + "retry_params_name": "retry_policy_2_params" + }, + "ImportUserEvents": { + "timeout_millis": 300000, + "retry_codes_name": "retry_policy_3_codes", + "retry_params_name": "retry_policy_3_params" + }, + "WriteUserEvent": { + "timeout_millis": 30000, + "retry_codes_name": "retry_policy_2_codes", + "retry_params_name": "retry_policy_2_params" + } + } + } + } +} diff --git a/DiscoveryEngine/src/V1beta/resources/user_event_service_descriptor_config.php b/DiscoveryEngine/src/V1beta/resources/user_event_service_descriptor_config.php new file mode 100644 index 000000000000..2cb4429f2d60 --- /dev/null +++ b/DiscoveryEngine/src/V1beta/resources/user_event_service_descriptor_config.php @@ -0,0 +1,59 @@ + [ + 'google.cloud.discoveryengine.v1beta.UserEventService' => [ + 'ImportUserEvents' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Cloud\DiscoveryEngine\V1beta\ImportUserEventsResponse', + 'metadataReturnType' => '\Google\Cloud\DiscoveryEngine\V1beta\ImportUserEventsMetadata', + 'initialPollDelayMillis' => '500', + 'pollDelayMultiplier' => '1.5', + 'maxPollDelayMillis' => '5000', + 'totalPollTimeoutMillis' => '300000', + ], + 'callType' => \Google\ApiCore\Call::LONGRUNNING_CALL, + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'CollectUserEvent' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Api\HttpBody', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'WriteUserEvent' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\DiscoveryEngine\V1beta\UserEvent', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'templateMap' => [ + 'dataStore' => 'projects/{project}/locations/{location}/dataStores/{data_store}', + 'document' => 'projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document}', + 'projectLocationCollectionDataStore' => 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}', + 'projectLocationCollectionDataStoreBranchDocument' => 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}', + 'projectLocationDataStore' => 'projects/{project}/locations/{location}/dataStores/{data_store}', + 'projectLocationDataStoreBranchDocument' => 'projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document}', + ], + ], + ], +]; diff --git a/DiscoveryEngine/src/V1beta/resources/user_event_service_rest_client_config.php b/DiscoveryEngine/src/V1beta/resources/user_event_service_rest_client_config.php new file mode 100644 index 000000000000..e44ac4562ddc --- /dev/null +++ b/DiscoveryEngine/src/V1beta/resources/user_event_service_rest_client_config.php @@ -0,0 +1,156 @@ + [ + 'google.cloud.discoveryengine.v1beta.UserEventService' => [ + 'CollectUserEvent' => [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{parent=projects/*/locations/*/dataStores/*}/userEvents:collect', + 'additionalBindings' => [ + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{parent=projects/*/locations/*/collections/*/dataStores/*}/userEvents:collect', + ], + ], + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + 'ImportUserEvents' => [ + 'method' => 'post', + 'uriTemplate' => '/v1beta/{parent=projects/*/locations/*/dataStores/*}/userEvents:import', + 'body' => '*', + 'additionalBindings' => [ + [ + 'method' => 'post', + 'uriTemplate' => '/v1beta/{parent=projects/*/locations/*/collections/*/dataStores/*}/userEvents:import', + 'body' => '*', + ], + ], + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + 'WriteUserEvent' => [ + 'method' => 'post', + 'uriTemplate' => '/v1beta/{parent=projects/*/locations/*/dataStores/*}/userEvents:write', + 'body' => 'user_event', + 'additionalBindings' => [ + [ + 'method' => 'post', + 'uriTemplate' => '/v1beta/{parent=projects/*/locations/*/collections/*/dataStores/*}/userEvents:write', + 'body' => 'user_event', + ], + ], + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + ], + 'google.longrunning.Operations' => [ + 'GetOperation' => [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/branches/*/operations/*}', + 'additionalBindings' => [ + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/models/*/operations/*}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/operations/*}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/collections/*/operations/*}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/dataStores/*/branches/*/operations/*}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/dataStores/*/models/*/operations/*}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/dataStores/*/operations/*}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/operations/*}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/operations/*}', + ], + ], + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'ListOperations' => [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/branches/*}/operations', + 'additionalBindings' => [ + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/models/*}/operations', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*}/operations', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/collections/*}/operations', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/dataStores/*/branches/*}/operations', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/dataStores/*/models/*}/operations', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*/dataStores/*}/operations', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*/locations/*}/operations', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=projects/*}/operations', + ], + ], + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + ], + ], + 'numericEnums' => true, +]; diff --git a/DiscoveryEngine/tests/Unit/V1beta/Client/CompletionServiceClientTest.php b/DiscoveryEngine/tests/Unit/V1beta/Client/CompletionServiceClientTest.php new file mode 100644 index 000000000000..be6f186e5a2a --- /dev/null +++ b/DiscoveryEngine/tests/Unit/V1beta/Client/CompletionServiceClientTest.php @@ -0,0 +1,161 @@ +getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + } + + /** @return CompletionServiceClient */ + private function createClient(array $options = []) + { + $options += [ + 'credentials' => $this->createCredentials(), + ]; + return new CompletionServiceClient($options); + } + + /** @test */ + public function completeQueryTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new CompleteQueryResponse(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedDataStore = $gapicClient->dataStoreName('[PROJECT]', '[LOCATION]', '[DATA_STORE]'); + $query = 'query107944136'; + $request = (new CompleteQueryRequest()) + ->setDataStore($formattedDataStore) + ->setQuery($query); + $response = $gapicClient->completeQuery($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.discoveryengine.v1beta.CompletionService/CompleteQuery', $actualFuncCall); + $actualValue = $actualRequestObject->getDataStore(); + $this->assertProtobufEquals($formattedDataStore, $actualValue); + $actualValue = $actualRequestObject->getQuery(); + $this->assertProtobufEquals($query, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function completeQueryExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedDataStore = $gapicClient->dataStoreName('[PROJECT]', '[LOCATION]', '[DATA_STORE]'); + $query = 'query107944136'; + $request = (new CompleteQueryRequest()) + ->setDataStore($formattedDataStore) + ->setQuery($query); + try { + $gapicClient->completeQuery($request); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function completeQueryAsyncTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new CompleteQueryResponse(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedDataStore = $gapicClient->dataStoreName('[PROJECT]', '[LOCATION]', '[DATA_STORE]'); + $query = 'query107944136'; + $request = (new CompleteQueryRequest()) + ->setDataStore($formattedDataStore) + ->setQuery($query); + $response = $gapicClient->completeQueryAsync($request)->wait(); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.discoveryengine.v1beta.CompletionService/CompleteQuery', $actualFuncCall); + $actualValue = $actualRequestObject->getDataStore(); + $this->assertProtobufEquals($formattedDataStore, $actualValue); + $actualValue = $actualRequestObject->getQuery(); + $this->assertProtobufEquals($query, $actualValue); + $this->assertTrue($transport->isExhausted()); + } +} diff --git a/DiscoveryEngine/tests/Unit/V1beta/Client/DocumentServiceClientTest.php b/DiscoveryEngine/tests/Unit/V1beta/Client/DocumentServiceClientTest.php new file mode 100644 index 000000000000..7ca4b1e05398 --- /dev/null +++ b/DiscoveryEngine/tests/Unit/V1beta/Client/DocumentServiceClientTest.php @@ -0,0 +1,732 @@ +getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + } + + /** @return DocumentServiceClient */ + private function createClient(array $options = []) + { + $options += [ + 'credentials' => $this->createCredentials(), + ]; + return new DocumentServiceClient($options); + } + + /** @test */ + public function createDocumentTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $jsonData = 'jsonData-1083208543'; + $name = 'name3373707'; + $id = 'id3355'; + $schemaId = 'schemaId-153006983'; + $parentDocumentId = 'parentDocumentId-1870594390'; + $expectedResponse = new Document(); + $expectedResponse->setJsonData($jsonData); + $expectedResponse->setName($name); + $expectedResponse->setId($id); + $expectedResponse->setSchemaId($schemaId); + $expectedResponse->setParentDocumentId($parentDocumentId); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->branchName('[PROJECT]', '[LOCATION]', '[DATA_STORE]', '[BRANCH]'); + $document = new Document(); + $documentId = 'documentId506676927'; + $request = (new CreateDocumentRequest()) + ->setParent($formattedParent) + ->setDocument($document) + ->setDocumentId($documentId); + $response = $gapicClient->createDocument($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.discoveryengine.v1beta.DocumentService/CreateDocument', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualRequestObject->getDocument(); + $this->assertProtobufEquals($document, $actualValue); + $actualValue = $actualRequestObject->getDocumentId(); + $this->assertProtobufEquals($documentId, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function createDocumentExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedParent = $gapicClient->branchName('[PROJECT]', '[LOCATION]', '[DATA_STORE]', '[BRANCH]'); + $document = new Document(); + $documentId = 'documentId506676927'; + $request = (new CreateDocumentRequest()) + ->setParent($formattedParent) + ->setDocument($document) + ->setDocumentId($documentId); + try { + $gapicClient->createDocument($request); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function deleteDocumentTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new GPBEmpty(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->documentName('[PROJECT]', '[LOCATION]', '[DATA_STORE]', '[BRANCH]', '[DOCUMENT]'); + $request = (new DeleteDocumentRequest()) + ->setName($formattedName); + $gapicClient->deleteDocument($request); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.discoveryengine.v1beta.DocumentService/DeleteDocument', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function deleteDocumentExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedName = $gapicClient->documentName('[PROJECT]', '[LOCATION]', '[DATA_STORE]', '[BRANCH]', '[DOCUMENT]'); + $request = (new DeleteDocumentRequest()) + ->setName($formattedName); + try { + $gapicClient->deleteDocument($request); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getDocumentTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $jsonData = 'jsonData-1083208543'; + $name2 = 'name2-1052831874'; + $id = 'id3355'; + $schemaId = 'schemaId-153006983'; + $parentDocumentId = 'parentDocumentId-1870594390'; + $expectedResponse = new Document(); + $expectedResponse->setJsonData($jsonData); + $expectedResponse->setName($name2); + $expectedResponse->setId($id); + $expectedResponse->setSchemaId($schemaId); + $expectedResponse->setParentDocumentId($parentDocumentId); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->documentName('[PROJECT]', '[LOCATION]', '[DATA_STORE]', '[BRANCH]', '[DOCUMENT]'); + $request = (new GetDocumentRequest()) + ->setName($formattedName); + $response = $gapicClient->getDocument($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.discoveryengine.v1beta.DocumentService/GetDocument', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getDocumentExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedName = $gapicClient->documentName('[PROJECT]', '[LOCATION]', '[DATA_STORE]', '[BRANCH]', '[DOCUMENT]'); + $request = (new GetDocumentRequest()) + ->setName($formattedName); + try { + $gapicClient->getDocument($request); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function importDocumentsTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/importDocumentsTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $expectedResponse = new ImportDocumentsResponse(); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/importDocumentsTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $formattedParent = $gapicClient->branchName('[PROJECT]', '[LOCATION]', '[DATA_STORE]', '[BRANCH]'); + $request = (new ImportDocumentsRequest()) + ->setParent($formattedParent); + $response = $gapicClient->importDocuments($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.discoveryengine.v1beta.DocumentService/ImportDocuments', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/importDocumentsTest'); + $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 importDocumentsExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/importDocumentsTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $operationsTransport->addResponse(null, $status); + // Mock request + $formattedParent = $gapicClient->branchName('[PROJECT]', '[LOCATION]', '[DATA_STORE]', '[BRANCH]'); + $request = (new ImportDocumentsRequest()) + ->setParent($formattedParent); + $response = $gapicClient->importDocuments($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/importDocumentsTest'); + 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 listDocumentsTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $documentsElement = new Document(); + $documents = [ + $documentsElement, + ]; + $expectedResponse = new ListDocumentsResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setDocuments($documents); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->branchName('[PROJECT]', '[LOCATION]', '[DATA_STORE]', '[BRANCH]'); + $request = (new ListDocumentsRequest()) + ->setParent($formattedParent); + $response = $gapicClient->listDocuments($request); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getDocuments()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.discoveryengine.v1beta.DocumentService/ListDocuments', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listDocumentsExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedParent = $gapicClient->branchName('[PROJECT]', '[LOCATION]', '[DATA_STORE]', '[BRANCH]'); + $request = (new ListDocumentsRequest()) + ->setParent($formattedParent); + try { + $gapicClient->listDocuments($request); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function purgeDocumentsTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/purgeDocumentsTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $purgeCount = 575305851; + $expectedResponse = new PurgeDocumentsResponse(); + $expectedResponse->setPurgeCount($purgeCount); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/purgeDocumentsTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $formattedParent = $gapicClient->branchName('[PROJECT]', '[LOCATION]', '[DATA_STORE]', '[BRANCH]'); + $filter = 'filter-1274492040'; + $request = (new PurgeDocumentsRequest()) + ->setParent($formattedParent) + ->setFilter($filter); + $response = $gapicClient->purgeDocuments($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.discoveryengine.v1beta.DocumentService/PurgeDocuments', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualApiRequestObject->getFilter(); + $this->assertProtobufEquals($filter, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/purgeDocumentsTest'); + $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 purgeDocumentsExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/purgeDocumentsTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $operationsTransport->addResponse(null, $status); + // Mock request + $formattedParent = $gapicClient->branchName('[PROJECT]', '[LOCATION]', '[DATA_STORE]', '[BRANCH]'); + $filter = 'filter-1274492040'; + $request = (new PurgeDocumentsRequest()) + ->setParent($formattedParent) + ->setFilter($filter); + $response = $gapicClient->purgeDocuments($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/purgeDocumentsTest'); + 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 updateDocumentTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $jsonData = 'jsonData-1083208543'; + $name = 'name3373707'; + $id = 'id3355'; + $schemaId = 'schemaId-153006983'; + $parentDocumentId = 'parentDocumentId-1870594390'; + $expectedResponse = new Document(); + $expectedResponse->setJsonData($jsonData); + $expectedResponse->setName($name); + $expectedResponse->setId($id); + $expectedResponse->setSchemaId($schemaId); + $expectedResponse->setParentDocumentId($parentDocumentId); + $transport->addResponse($expectedResponse); + // Mock request + $document = new Document(); + $request = (new UpdateDocumentRequest()) + ->setDocument($document); + $response = $gapicClient->updateDocument($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.discoveryengine.v1beta.DocumentService/UpdateDocument', $actualFuncCall); + $actualValue = $actualRequestObject->getDocument(); + $this->assertProtobufEquals($document, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function updateDocumentExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $document = new Document(); + $request = (new UpdateDocumentRequest()) + ->setDocument($document); + try { + $gapicClient->updateDocument($request); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function createDocumentAsyncTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $jsonData = 'jsonData-1083208543'; + $name = 'name3373707'; + $id = 'id3355'; + $schemaId = 'schemaId-153006983'; + $parentDocumentId = 'parentDocumentId-1870594390'; + $expectedResponse = new Document(); + $expectedResponse->setJsonData($jsonData); + $expectedResponse->setName($name); + $expectedResponse->setId($id); + $expectedResponse->setSchemaId($schemaId); + $expectedResponse->setParentDocumentId($parentDocumentId); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->branchName('[PROJECT]', '[LOCATION]', '[DATA_STORE]', '[BRANCH]'); + $document = new Document(); + $documentId = 'documentId506676927'; + $request = (new CreateDocumentRequest()) + ->setParent($formattedParent) + ->setDocument($document) + ->setDocumentId($documentId); + $response = $gapicClient->createDocumentAsync($request)->wait(); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.discoveryengine.v1beta.DocumentService/CreateDocument', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualRequestObject->getDocument(); + $this->assertProtobufEquals($document, $actualValue); + $actualValue = $actualRequestObject->getDocumentId(); + $this->assertProtobufEquals($documentId, $actualValue); + $this->assertTrue($transport->isExhausted()); + } +} diff --git a/DiscoveryEngine/tests/Unit/V1beta/Client/RecommendationServiceClientTest.php b/DiscoveryEngine/tests/Unit/V1beta/Client/RecommendationServiceClientTest.php new file mode 100644 index 000000000000..b4878ec743cb --- /dev/null +++ b/DiscoveryEngine/tests/Unit/V1beta/Client/RecommendationServiceClientTest.php @@ -0,0 +1,182 @@ +getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + } + + /** @return RecommendationServiceClient */ + private function createClient(array $options = []) + { + $options += [ + 'credentials' => $this->createCredentials(), + ]; + return new RecommendationServiceClient($options); + } + + /** @test */ + public function recommendTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $attributionToken = 'attributionToken-729411015'; + $validateOnly2 = true; + $expectedResponse = new RecommendResponse(); + $expectedResponse->setAttributionToken($attributionToken); + $expectedResponse->setValidateOnly($validateOnly2); + $transport->addResponse($expectedResponse); + // Mock request + $formattedServingConfig = $gapicClient->servingConfigName('[PROJECT]', '[LOCATION]', '[DATA_STORE]', '[SERVING_CONFIG]'); + $userEvent = new UserEvent(); + $userEventEventType = 'userEventEventType341658661'; + $userEvent->setEventType($userEventEventType); + $userEventUserPseudoId = 'userEventUserPseudoId-1929667693'; + $userEvent->setUserPseudoId($userEventUserPseudoId); + $request = (new RecommendRequest()) + ->setServingConfig($formattedServingConfig) + ->setUserEvent($userEvent); + $response = $gapicClient->recommend($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.discoveryengine.v1beta.RecommendationService/Recommend', $actualFuncCall); + $actualValue = $actualRequestObject->getServingConfig(); + $this->assertProtobufEquals($formattedServingConfig, $actualValue); + $actualValue = $actualRequestObject->getUserEvent(); + $this->assertProtobufEquals($userEvent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function recommendExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedServingConfig = $gapicClient->servingConfigName('[PROJECT]', '[LOCATION]', '[DATA_STORE]', '[SERVING_CONFIG]'); + $userEvent = new UserEvent(); + $userEventEventType = 'userEventEventType341658661'; + $userEvent->setEventType($userEventEventType); + $userEventUserPseudoId = 'userEventUserPseudoId-1929667693'; + $userEvent->setUserPseudoId($userEventUserPseudoId); + $request = (new RecommendRequest()) + ->setServingConfig($formattedServingConfig) + ->setUserEvent($userEvent); + try { + $gapicClient->recommend($request); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function recommendAsyncTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $attributionToken = 'attributionToken-729411015'; + $validateOnly2 = true; + $expectedResponse = new RecommendResponse(); + $expectedResponse->setAttributionToken($attributionToken); + $expectedResponse->setValidateOnly($validateOnly2); + $transport->addResponse($expectedResponse); + // Mock request + $formattedServingConfig = $gapicClient->servingConfigName('[PROJECT]', '[LOCATION]', '[DATA_STORE]', '[SERVING_CONFIG]'); + $userEvent = new UserEvent(); + $userEventEventType = 'userEventEventType341658661'; + $userEvent->setEventType($userEventEventType); + $userEventUserPseudoId = 'userEventUserPseudoId-1929667693'; + $userEvent->setUserPseudoId($userEventUserPseudoId); + $request = (new RecommendRequest()) + ->setServingConfig($formattedServingConfig) + ->setUserEvent($userEvent); + $response = $gapicClient->recommendAsync($request)->wait(); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.discoveryengine.v1beta.RecommendationService/Recommend', $actualFuncCall); + $actualValue = $actualRequestObject->getServingConfig(); + $this->assertProtobufEquals($formattedServingConfig, $actualValue); + $actualValue = $actualRequestObject->getUserEvent(); + $this->assertProtobufEquals($userEvent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } +} diff --git a/DiscoveryEngine/tests/Unit/V1beta/Client/SchemaServiceClientTest.php b/DiscoveryEngine/tests/Unit/V1beta/Client/SchemaServiceClientTest.php new file mode 100644 index 000000000000..47c87263a568 --- /dev/null +++ b/DiscoveryEngine/tests/Unit/V1beta/Client/SchemaServiceClientTest.php @@ -0,0 +1,669 @@ +getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + } + + /** @return SchemaServiceClient */ + private function createClient(array $options = []) + { + $options += [ + 'credentials' => $this->createCredentials(), + ]; + return new SchemaServiceClient($options); + } + + /** @test */ + public function createSchemaTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/createSchemaTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $jsonSchema = 'jsonSchema-1150390056'; + $name = 'name3373707'; + $expectedResponse = new Schema(); + $expectedResponse->setJsonSchema($jsonSchema); + $expectedResponse->setName($name); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/createSchemaTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $formattedParent = $gapicClient->dataStoreName('[PROJECT]', '[LOCATION]', '[DATA_STORE]'); + $schema = new Schema(); + $schemaId = 'schemaId-153006983'; + $request = (new CreateSchemaRequest()) + ->setParent($formattedParent) + ->setSchema($schema) + ->setSchemaId($schemaId); + $response = $gapicClient->createSchema($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.discoveryengine.v1beta.SchemaService/CreateSchema', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualApiRequestObject->getSchema(); + $this->assertProtobufEquals($schema, $actualValue); + $actualValue = $actualApiRequestObject->getSchemaId(); + $this->assertProtobufEquals($schemaId, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/createSchemaTest'); + $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 createSchemaExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/createSchemaTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $operationsTransport->addResponse(null, $status); + // Mock request + $formattedParent = $gapicClient->dataStoreName('[PROJECT]', '[LOCATION]', '[DATA_STORE]'); + $schema = new Schema(); + $schemaId = 'schemaId-153006983'; + $request = (new CreateSchemaRequest()) + ->setParent($formattedParent) + ->setSchema($schema) + ->setSchemaId($schemaId); + $response = $gapicClient->createSchema($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/createSchemaTest'); + 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 deleteSchemaTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/deleteSchemaTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $expectedResponse = new GPBEmpty(); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/deleteSchemaTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $formattedName = $gapicClient->schemaName('[PROJECT]', '[LOCATION]', '[DATA_STORE]', '[SCHEMA]'); + $request = (new DeleteSchemaRequest()) + ->setName($formattedName); + $response = $gapicClient->deleteSchema($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.discoveryengine.v1beta.SchemaService/DeleteSchema', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/deleteSchemaTest'); + $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 deleteSchemaExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/deleteSchemaTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $operationsTransport->addResponse(null, $status); + // Mock request + $formattedName = $gapicClient->schemaName('[PROJECT]', '[LOCATION]', '[DATA_STORE]', '[SCHEMA]'); + $request = (new DeleteSchemaRequest()) + ->setName($formattedName); + $response = $gapicClient->deleteSchema($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/deleteSchemaTest'); + 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 getSchemaTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $jsonSchema = 'jsonSchema-1150390056'; + $name2 = 'name2-1052831874'; + $expectedResponse = new Schema(); + $expectedResponse->setJsonSchema($jsonSchema); + $expectedResponse->setName($name2); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->schemaName('[PROJECT]', '[LOCATION]', '[DATA_STORE]', '[SCHEMA]'); + $request = (new GetSchemaRequest()) + ->setName($formattedName); + $response = $gapicClient->getSchema($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.discoveryengine.v1beta.SchemaService/GetSchema', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getSchemaExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedName = $gapicClient->schemaName('[PROJECT]', '[LOCATION]', '[DATA_STORE]', '[SCHEMA]'); + $request = (new GetSchemaRequest()) + ->setName($formattedName); + try { + $gapicClient->getSchema($request); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listSchemasTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $schemasElement = new Schema(); + $schemas = [ + $schemasElement, + ]; + $expectedResponse = new ListSchemasResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setSchemas($schemas); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->dataStoreName('[PROJECT]', '[LOCATION]', '[DATA_STORE]'); + $request = (new ListSchemasRequest()) + ->setParent($formattedParent); + $response = $gapicClient->listSchemas($request); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getSchemas()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.discoveryengine.v1beta.SchemaService/ListSchemas', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listSchemasExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedParent = $gapicClient->dataStoreName('[PROJECT]', '[LOCATION]', '[DATA_STORE]'); + $request = (new ListSchemasRequest()) + ->setParent($formattedParent); + try { + $gapicClient->listSchemas($request); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function updateSchemaTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/updateSchemaTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $jsonSchema = 'jsonSchema-1150390056'; + $name = 'name3373707'; + $expectedResponse = new Schema(); + $expectedResponse->setJsonSchema($jsonSchema); + $expectedResponse->setName($name); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/updateSchemaTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $schema = new Schema(); + $request = (new UpdateSchemaRequest()) + ->setSchema($schema); + $response = $gapicClient->updateSchema($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.discoveryengine.v1beta.SchemaService/UpdateSchema', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getSchema(); + $this->assertProtobufEquals($schema, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/updateSchemaTest'); + $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 updateSchemaExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/updateSchemaTest'); + $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 + $schema = new Schema(); + $request = (new UpdateSchemaRequest()) + ->setSchema($schema); + $response = $gapicClient->updateSchema($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/updateSchemaTest'); + 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 createSchemaAsyncTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/createSchemaTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $jsonSchema = 'jsonSchema-1150390056'; + $name = 'name3373707'; + $expectedResponse = new Schema(); + $expectedResponse->setJsonSchema($jsonSchema); + $expectedResponse->setName($name); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/createSchemaTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $formattedParent = $gapicClient->dataStoreName('[PROJECT]', '[LOCATION]', '[DATA_STORE]'); + $schema = new Schema(); + $schemaId = 'schemaId-153006983'; + $request = (new CreateSchemaRequest()) + ->setParent($formattedParent) + ->setSchema($schema) + ->setSchemaId($schemaId); + $response = $gapicClient->createSchemaAsync($request)->wait(); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.discoveryengine.v1beta.SchemaService/CreateSchema', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualApiRequestObject->getSchema(); + $this->assertProtobufEquals($schema, $actualValue); + $actualValue = $actualApiRequestObject->getSchemaId(); + $this->assertProtobufEquals($schemaId, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/createSchemaTest'); + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $transport->popReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsTransport->popReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } +} diff --git a/DiscoveryEngine/tests/Unit/V1beta/Client/SearchServiceClientTest.php b/DiscoveryEngine/tests/Unit/V1beta/Client/SearchServiceClientTest.php new file mode 100644 index 000000000000..32eca1694d2e --- /dev/null +++ b/DiscoveryEngine/tests/Unit/V1beta/Client/SearchServiceClientTest.php @@ -0,0 +1,184 @@ +getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + } + + /** @return SearchServiceClient */ + private function createClient(array $options = []) + { + $options += [ + 'credentials' => $this->createCredentials(), + ]; + return new SearchServiceClient($options); + } + + /** @test */ + public function searchTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $totalSize = 705419236; + $attributionToken = 'attributionToken-729411015'; + $nextPageToken = ''; + $correctedQuery = 'correctedQuery107869074'; + $resultsElement = new SearchResult(); + $results = [ + $resultsElement, + ]; + $expectedResponse = new SearchResponse(); + $expectedResponse->setTotalSize($totalSize); + $expectedResponse->setAttributionToken($attributionToken); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setCorrectedQuery($correctedQuery); + $expectedResponse->setResults($results); + $transport->addResponse($expectedResponse); + // Mock request + $formattedServingConfig = $gapicClient->servingConfigName('[PROJECT]', '[LOCATION]', '[DATA_STORE]', '[SERVING_CONFIG]'); + $request = (new SearchRequest()) + ->setServingConfig($formattedServingConfig); + $response = $gapicClient->search($request); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getResults()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.discoveryengine.v1beta.SearchService/Search', $actualFuncCall); + $actualValue = $actualRequestObject->getServingConfig(); + $this->assertProtobufEquals($formattedServingConfig, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function searchExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedServingConfig = $gapicClient->servingConfigName('[PROJECT]', '[LOCATION]', '[DATA_STORE]', '[SERVING_CONFIG]'); + $request = (new SearchRequest()) + ->setServingConfig($formattedServingConfig); + try { + $gapicClient->search($request); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function searchAsyncTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $totalSize = 705419236; + $attributionToken = 'attributionToken-729411015'; + $nextPageToken = ''; + $correctedQuery = 'correctedQuery107869074'; + $resultsElement = new SearchResult(); + $results = [ + $resultsElement, + ]; + $expectedResponse = new SearchResponse(); + $expectedResponse->setTotalSize($totalSize); + $expectedResponse->setAttributionToken($attributionToken); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setCorrectedQuery($correctedQuery); + $expectedResponse->setResults($results); + $transport->addResponse($expectedResponse); + // Mock request + $formattedServingConfig = $gapicClient->servingConfigName('[PROJECT]', '[LOCATION]', '[DATA_STORE]', '[SERVING_CONFIG]'); + $request = (new SearchRequest()) + ->setServingConfig($formattedServingConfig); + $response = $gapicClient->searchAsync($request)->wait(); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getResults()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.discoveryengine.v1beta.SearchService/Search', $actualFuncCall); + $actualValue = $actualRequestObject->getServingConfig(); + $this->assertProtobufEquals($formattedServingConfig, $actualValue); + $this->assertTrue($transport->isExhausted()); + } +} diff --git a/DiscoveryEngine/tests/Unit/V1beta/Client/UserEventServiceClientTest.php b/DiscoveryEngine/tests/Unit/V1beta/Client/UserEventServiceClientTest.php new file mode 100644 index 000000000000..8daf85748803 --- /dev/null +++ b/DiscoveryEngine/tests/Unit/V1beta/Client/UserEventServiceClientTest.php @@ -0,0 +1,401 @@ +getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + } + + /** @return UserEventServiceClient */ + private function createClient(array $options = []) + { + $options += [ + 'credentials' => $this->createCredentials(), + ]; + return new UserEventServiceClient($options); + } + + /** @test */ + public function collectUserEventTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $contentType = 'contentType831846208'; + $data = '-86'; + $expectedResponse = new HttpBody(); + $expectedResponse->setContentType($contentType); + $expectedResponse->setData($data); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->dataStoreName('[PROJECT]', '[LOCATION]', '[DATA_STORE]'); + $userEvent = 'userEvent1921940774'; + $request = (new CollectUserEventRequest()) + ->setParent($formattedParent) + ->setUserEvent($userEvent); + $response = $gapicClient->collectUserEvent($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.discoveryengine.v1beta.UserEventService/CollectUserEvent', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualRequestObject->getUserEvent(); + $this->assertProtobufEquals($userEvent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function collectUserEventExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedParent = $gapicClient->dataStoreName('[PROJECT]', '[LOCATION]', '[DATA_STORE]'); + $userEvent = 'userEvent1921940774'; + $request = (new CollectUserEventRequest()) + ->setParent($formattedParent) + ->setUserEvent($userEvent); + try { + $gapicClient->collectUserEvent($request); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function importUserEventsTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/importUserEventsTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $joinedEventsCount = 720068705; + $unjoinedEventsCount = 512159846; + $expectedResponse = new ImportUserEventsResponse(); + $expectedResponse->setJoinedEventsCount($joinedEventsCount); + $expectedResponse->setUnjoinedEventsCount($unjoinedEventsCount); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/importUserEventsTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $inlineSource = new InlineSource(); + $inlineSourceUserEvents = []; + $inlineSource->setUserEvents($inlineSourceUserEvents); + $formattedParent = $gapicClient->dataStoreName('[PROJECT]', '[LOCATION]', '[DATA_STORE]'); + $request = (new ImportUserEventsRequest()) + ->setInlineSource($inlineSource) + ->setParent($formattedParent); + $response = $gapicClient->importUserEvents($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.discoveryengine.v1beta.UserEventService/ImportUserEvents', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getInlineSource(); + $this->assertProtobufEquals($inlineSource, $actualValue); + $actualValue = $actualApiRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/importUserEventsTest'); + $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 importUserEventsExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/importUserEventsTest'); + $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 + $inlineSource = new InlineSource(); + $inlineSourceUserEvents = []; + $inlineSource->setUserEvents($inlineSourceUserEvents); + $formattedParent = $gapicClient->dataStoreName('[PROJECT]', '[LOCATION]', '[DATA_STORE]'); + $request = (new ImportUserEventsRequest()) + ->setInlineSource($inlineSource) + ->setParent($formattedParent); + $response = $gapicClient->importUserEvents($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/importUserEventsTest'); + 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 writeUserEventTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $eventType = 'eventType984376767'; + $userPseudoId = 'userPseudoId-1850666040'; + $directUserRequest = false; + $sessionId = 'sessionId1661853540'; + $attributionToken = 'attributionToken-729411015'; + $filter = 'filter-1274492040'; + $expectedResponse = new UserEvent(); + $expectedResponse->setEventType($eventType); + $expectedResponse->setUserPseudoId($userPseudoId); + $expectedResponse->setDirectUserRequest($directUserRequest); + $expectedResponse->setSessionId($sessionId); + $expectedResponse->setAttributionToken($attributionToken); + $expectedResponse->setFilter($filter); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->dataStoreName('[PROJECT]', '[LOCATION]', '[DATA_STORE]'); + $userEvent = new UserEvent(); + $userEventEventType = 'userEventEventType341658661'; + $userEvent->setEventType($userEventEventType); + $userEventUserPseudoId = 'userEventUserPseudoId-1929667693'; + $userEvent->setUserPseudoId($userEventUserPseudoId); + $request = (new WriteUserEventRequest()) + ->setParent($formattedParent) + ->setUserEvent($userEvent); + $response = $gapicClient->writeUserEvent($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.discoveryengine.v1beta.UserEventService/WriteUserEvent', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualRequestObject->getUserEvent(); + $this->assertProtobufEquals($userEvent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function writeUserEventExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedParent = $gapicClient->dataStoreName('[PROJECT]', '[LOCATION]', '[DATA_STORE]'); + $userEvent = new UserEvent(); + $userEventEventType = 'userEventEventType341658661'; + $userEvent->setEventType($userEventEventType); + $userEventUserPseudoId = 'userEventUserPseudoId-1929667693'; + $userEvent->setUserPseudoId($userEventUserPseudoId); + $request = (new WriteUserEventRequest()) + ->setParent($formattedParent) + ->setUserEvent($userEvent); + try { + $gapicClient->writeUserEvent($request); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function collectUserEventAsyncTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $contentType = 'contentType831846208'; + $data = '-86'; + $expectedResponse = new HttpBody(); + $expectedResponse->setContentType($contentType); + $expectedResponse->setData($data); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->dataStoreName('[PROJECT]', '[LOCATION]', '[DATA_STORE]'); + $userEvent = 'userEvent1921940774'; + $request = (new CollectUserEventRequest()) + ->setParent($formattedParent) + ->setUserEvent($userEvent); + $response = $gapicClient->collectUserEventAsync($request)->wait(); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.discoveryengine.v1beta.UserEventService/CollectUserEvent', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualRequestObject->getUserEvent(); + $this->assertProtobufEquals($userEvent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } +} diff --git a/composer.json b/composer.json index 16f70d825b2f..4ab6f6b24b95 100644 --- a/composer.json +++ b/composer.json @@ -130,6 +130,7 @@ "google/cloud-debugger": "1.4.16", "google/cloud-deploy": "0.5.0", "google/cloud-dialogflow": "1.3.2", + "google/cloud-discoveryengine": "0.0.0", "google/cloud-dlp": "1.8.6", "google/cloud-dms": "1.0.5", "google/cloud-document-ai": "1.2.2", @@ -280,6 +281,7 @@ "GPBMetadata\\Google\\Cloud\\Datastream\\": "Datastream/metadata", "GPBMetadata\\Google\\Cloud\\Deploy\\": "Deploy/metadata", "GPBMetadata\\Google\\Cloud\\Dialogflow\\": "Dialogflow/metadata", + "GPBMetadata\\Google\\Cloud\\Discoveryengine\\": "DiscoveryEngine/metadata", "GPBMetadata\\Google\\Cloud\\Documentai\\": "DocumentAi/metadata", "GPBMetadata\\Google\\Cloud\\Domains\\": "Domains/metadata", "GPBMetadata\\Google\\Cloud\\Essentialcontacts\\": "EssentialContacts/metadata", @@ -445,6 +447,7 @@ "Google\\Cloud\\Debugger\\": "Debugger/src", "Google\\Cloud\\Deploy\\": "Deploy/src", "Google\\Cloud\\Dialogflow\\": "Dialogflow/src", + "Google\\Cloud\\DiscoveryEngine\\": "DiscoveryEngine/src", "Google\\Cloud\\Dlp\\": "Dlp/src", "Google\\Cloud\\DocumentAI\\": "DocumentAi/src", "Google\\Cloud\\Domains\\": "Domains/src",