diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 2de6556019bf..ce52c6485db5 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -817,6 +817,8 @@ "google-maps-fleet_engine-delivery-v1+FILLER": "0.0.0", "google-maps-fleet_engine-v1": "0.2.1", "google-maps-fleet_engine-v1+FILLER": "0.0.0", + "google-shopping-css-v1": "0.0.1", + "google-shopping-css-v1+FILLER": "0.0.0", "google-shopping-merchant-accounts": "0.1.0", "google-shopping-merchant-accounts+FILLER": "0.0.0", "google-shopping-merchant-accounts-v1beta": "0.1.0", diff --git a/google-shopping-css-v1/.OwlBot.yaml b/google-shopping-css-v1/.OwlBot.yaml new file mode 100644 index 000000000000..c1a433aee39c --- /dev/null +++ b/google-shopping-css-v1/.OwlBot.yaml @@ -0,0 +1,3 @@ +deep-copy-regex: + - source: /google/shopping/css/v1/[^/]+-ruby/(.*) + dest: /owl-bot-staging/google-shopping-css-v1/$1 diff --git a/google-shopping-css-v1/.gitignore b/google-shopping-css-v1/.gitignore new file mode 100644 index 000000000000..0135b6bc6cfc --- /dev/null +++ b/google-shopping-css-v1/.gitignore @@ -0,0 +1,22 @@ +# Ignore bundler lockfiles +Gemfile.lock +gems.locked + +# Ignore documentation output +doc/* +.yardoc/* + +# Ignore test output +coverage/* + +# Ignore build artifacts +pkg/* + +# Ignore files commonly present in certain dev environments +.vagrant +.DS_STORE +.idea +*.iml + +# Ignore synth output +__pycache__ diff --git a/google-shopping-css-v1/.owlbot-manifest.json b/google-shopping-css-v1/.owlbot-manifest.json new file mode 100644 index 000000000000..fc6de19cdbf7 --- /dev/null +++ b/google-shopping-css-v1/.owlbot-manifest.json @@ -0,0 +1,101 @@ +{ + "generated": [ + ".gitignore", + ".repo-metadata.json", + ".rubocop.yml", + ".toys.rb", + ".yardopts", + "AUTHENTICATION.md", + "CHANGELOG.md", + "Gemfile", + "LICENSE.md", + "README.md", + "Rakefile", + "gapic_metadata.json", + "google-shopping-css-v1.gemspec", + "lib/google-shopping-css-v1.rb", + "lib/google/shopping/css/v1.rb", + "lib/google/shopping/css/v1/account_labels_service.rb", + "lib/google/shopping/css/v1/account_labels_service/client.rb", + "lib/google/shopping/css/v1/account_labels_service/credentials.rb", + "lib/google/shopping/css/v1/account_labels_service/paths.rb", + "lib/google/shopping/css/v1/account_labels_service/rest.rb", + "lib/google/shopping/css/v1/account_labels_service/rest/client.rb", + "lib/google/shopping/css/v1/account_labels_service/rest/service_stub.rb", + "lib/google/shopping/css/v1/accounts_labels_pb.rb", + "lib/google/shopping/css/v1/accounts_labels_services_pb.rb", + "lib/google/shopping/css/v1/accounts_pb.rb", + "lib/google/shopping/css/v1/accounts_service.rb", + "lib/google/shopping/css/v1/accounts_service/client.rb", + "lib/google/shopping/css/v1/accounts_service/credentials.rb", + "lib/google/shopping/css/v1/accounts_service/paths.rb", + "lib/google/shopping/css/v1/accounts_service/rest.rb", + "lib/google/shopping/css/v1/accounts_service/rest/client.rb", + "lib/google/shopping/css/v1/accounts_service/rest/service_stub.rb", + "lib/google/shopping/css/v1/accounts_services_pb.rb", + "lib/google/shopping/css/v1/css_product_common_pb.rb", + "lib/google/shopping/css/v1/css_product_inputs_pb.rb", + "lib/google/shopping/css/v1/css_product_inputs_service.rb", + "lib/google/shopping/css/v1/css_product_inputs_service/client.rb", + "lib/google/shopping/css/v1/css_product_inputs_service/credentials.rb", + "lib/google/shopping/css/v1/css_product_inputs_service/paths.rb", + "lib/google/shopping/css/v1/css_product_inputs_service/rest.rb", + "lib/google/shopping/css/v1/css_product_inputs_service/rest/client.rb", + "lib/google/shopping/css/v1/css_product_inputs_service/rest/service_stub.rb", + "lib/google/shopping/css/v1/css_product_inputs_services_pb.rb", + "lib/google/shopping/css/v1/css_products_pb.rb", + "lib/google/shopping/css/v1/css_products_service.rb", + "lib/google/shopping/css/v1/css_products_service/client.rb", + "lib/google/shopping/css/v1/css_products_service/credentials.rb", + "lib/google/shopping/css/v1/css_products_service/paths.rb", + "lib/google/shopping/css/v1/css_products_service/rest.rb", + "lib/google/shopping/css/v1/css_products_service/rest/client.rb", + "lib/google/shopping/css/v1/css_products_service/rest/service_stub.rb", + "lib/google/shopping/css/v1/css_products_services_pb.rb", + "lib/google/shopping/css/v1/rest.rb", + "lib/google/shopping/css/v1/version.rb", + "proto_docs/README.md", + "proto_docs/google/api/client.rb", + "proto_docs/google/api/field_behavior.rb", + "proto_docs/google/api/launch_stage.rb", + "proto_docs/google/api/resource.rb", + "proto_docs/google/protobuf/duration.rb", + "proto_docs/google/protobuf/empty.rb", + "proto_docs/google/protobuf/timestamp.rb", + "proto_docs/google/shopping/css/v1/accounts.rb", + "proto_docs/google/shopping/css/v1/accounts_labels.rb", + "proto_docs/google/shopping/css/v1/css_product_common.rb", + "proto_docs/google/shopping/css/v1/css_product_inputs.rb", + "proto_docs/google/shopping/css/v1/css_products.rb", + "proto_docs/google/shopping/type/types.rb", + "snippets/Gemfile", + "snippets/account_labels_service/create_account_label.rb", + "snippets/account_labels_service/delete_account_label.rb", + "snippets/account_labels_service/list_account_labels.rb", + "snippets/account_labels_service/update_account_label.rb", + "snippets/accounts_service/get_account.rb", + "snippets/accounts_service/list_child_accounts.rb", + "snippets/accounts_service/update_labels.rb", + "snippets/css_product_inputs_service/delete_css_product_input.rb", + "snippets/css_product_inputs_service/insert_css_product_input.rb", + "snippets/css_products_service/get_css_product.rb", + "snippets/css_products_service/list_css_products.rb", + "snippets/snippet_metadata_google.shopping.css.v1.json", + "test/google/shopping/css/v1/account_labels_service_paths_test.rb", + "test/google/shopping/css/v1/account_labels_service_rest_test.rb", + "test/google/shopping/css/v1/account_labels_service_test.rb", + "test/google/shopping/css/v1/accounts_service_paths_test.rb", + "test/google/shopping/css/v1/accounts_service_rest_test.rb", + "test/google/shopping/css/v1/accounts_service_test.rb", + "test/google/shopping/css/v1/css_product_inputs_service_paths_test.rb", + "test/google/shopping/css/v1/css_product_inputs_service_rest_test.rb", + "test/google/shopping/css/v1/css_product_inputs_service_test.rb", + "test/google/shopping/css/v1/css_products_service_paths_test.rb", + "test/google/shopping/css/v1/css_products_service_rest_test.rb", + "test/google/shopping/css/v1/css_products_service_test.rb", + "test/helper.rb" + ], + "static": [ + ".OwlBot.yaml" + ] +} diff --git a/google-shopping-css-v1/.repo-metadata.json b/google-shopping-css-v1/.repo-metadata.json new file mode 100644 index 000000000000..4ce57214d802 --- /dev/null +++ b/google-shopping-css-v1/.repo-metadata.json @@ -0,0 +1,17 @@ +{ + "api_id": "css.googleapis.com", + "api_shortname": "css", + "client_documentation": "https://rubydoc.info/gems/google-shopping-css-v1", + "distribution_name": "google-shopping-css-v1", + "is_cloud": false, + "language": "ruby", + "name": "css", + "name_pretty": "CSS V1 API", + "product_documentation": "https://developers.google.com/comparison-shopping-services/api", + "release_level": "unreleased", + "repo": "googleapis/google-cloud-ruby", + "requires_billing": true, + "ruby-cloud-description": "Programmatically manage your Comparison Shopping Service (CSS) account data at scale. Note that google-shopping-css-v1 is a version-specific client library. For most uses, we recommend installing the main client library google-shopping-css instead. See the readme for more details.", + "ruby-cloud-product-url": "https://developers.google.com/comparison-shopping-services/api", + "library_type": "GAPIC_AUTO" +} diff --git a/google-shopping-css-v1/.rubocop.yml b/google-shopping-css-v1/.rubocop.yml new file mode 100644 index 000000000000..b53d398f0a64 --- /dev/null +++ b/google-shopping-css-v1/.rubocop.yml @@ -0,0 +1,33 @@ +inherit_gem: + google-style: google-style.yml + +AllCops: + Exclude: + - "google-shopping-css-v1.gemspec" + - "lib/**/*_pb.rb" + - "proto_docs/**/*" + - "test/**/*" + - "acceptance/**/*" + - "samples/acceptance/**/*" + - "Rakefile" + +Layout/LineLength: + Enabled: false +Metrics/AbcSize: + Enabled: false +Metrics/ClassLength: + Enabled: false +Metrics/CyclomaticComplexity: + Enabled: false +Metrics/MethodLength: + Enabled: false +Metrics/ModuleLength: + Enabled: false +Metrics/PerceivedComplexity: + Enabled: false +Naming/AccessorMethodName: + Exclude: + - "snippets/**/*.rb" +Naming/FileName: + Exclude: + - "lib/google-shopping-css-v1.rb" diff --git a/google-shopping-css-v1/.toys.rb b/google-shopping-css-v1/.toys.rb new file mode 100644 index 000000000000..23434bdd5d5b --- /dev/null +++ b/google-shopping-css-v1/.toys.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +toys_version! ">= 0.15.3" + +if ENV["RUBY_COMMON_TOOLS"] + common_tools_dir = File.expand_path ENV["RUBY_COMMON_TOOLS"] + load File.join(common_tools_dir, "toys", "gapic") +else + load_git remote: "https://github.com/googleapis/ruby-common-tools.git", + path: "toys/gapic", + update: true +end diff --git a/google-shopping-css-v1/.yardopts b/google-shopping-css-v1/.yardopts new file mode 100644 index 000000000000..f293265f462f --- /dev/null +++ b/google-shopping-css-v1/.yardopts @@ -0,0 +1,12 @@ +--no-private +--title="CSS V1 API" +--exclude _pb\.rb$ +--markup markdown +--markup-provider redcarpet + +./lib/**/*.rb +./proto_docs/**/*.rb +- +README.md +LICENSE.md +AUTHENTICATION.md diff --git a/google-shopping-css-v1/AUTHENTICATION.md b/google-shopping-css-v1/AUTHENTICATION.md new file mode 100644 index 000000000000..bd124d2e6f59 --- /dev/null +++ b/google-shopping-css-v1/AUTHENTICATION.md @@ -0,0 +1,122 @@ +# Authentication + +The recommended way to authenticate to the google-shopping-css-v1 library is to use +[Application Default Credentials (ADC)](https://cloud.google.com/docs/authentication/application-default-credentials). +To review all of your authentication options, see [Credentials lookup](#credential-lookup). + +## Quickstart + +The following example shows how to set up authentication for a local development +environment with your user credentials. + +**NOTE:** This method is _not_ recommended for running in production. User credentials +should be used only during development. + +1. [Download and install the Google Cloud CLI](https://cloud.google.com/sdk). +2. Set up a local ADC file with your user credentials: + +```sh +gcloud auth application-default login +``` + +3. Write code as if already authenticated. + +For more information about setting up authentication for a local development environment, see +[Set up Application Default Credentials](https://cloud.google.com/docs/authentication/provide-credentials-adc#local-dev). + +## Credential Lookup + +The google-shopping-css-v1 library provides several mechanisms to configure your system. +Generally, using Application Default Credentials to facilitate automatic +credentials discovery is the easist method. But if you need to explicitly specify +credentials, there are several methods available to you. + +Credentials are accepted in the following ways, in the following order or precedence: + +1. Credentials specified in method arguments +2. Credentials specified in configuration +3. Credentials pointed to or included in environment variables +4. Credentials found in local ADC file +5. Credentials returned by the metadata server for the attached service account (GCP) + +### Configuration + +You can configure a path to a JSON credentials file, either for an individual client object or +globally, for all client objects. The JSON file can contain credentials created for +[workload identity federation](https://cloud.google.com/iam/docs/workload-identity-federation), +[workforce identity federation](https://cloud.google.com/iam/docs/workforce-identity-federation), or a +[service account key](https://cloud.google.com/docs/authentication/provide-credentials-adc#local-key). + +Note: Service account keys are a security risk if not managed correctly. You should +[choose a more secure alternative to service account keys](https://cloud.google.com/docs/authentication#auth-decision-tree) +whenever possible. + +To configure a credentials file for an individual client initialization: + +```ruby +require "google/shopping/css/v1" + +client = ::Google::Shopping::Css::V1::AccountsService::Client.new do |config| + config.credentials = "path/to/credentialfile.json" +end +``` + +To configure a credentials file globally for all clients: + +```ruby +require "google/shopping/css/v1" + +::Google::Shopping::Css::V1::AccountsService::Client.configure do |config| + config.credentials = "path/to/credentialfile.json" +end + +client = ::Google::Shopping::Css::V1::AccountsService::Client.new +``` + +### Environment Variables + +You can also use an environment variable to provide a JSON credentials file. +The environment variable can contain a path to the credentials file or, for +environments such as Docker containers where writing files is not encouraged, +you can include the credentials file itself. + +The JSON file can contain credentials created for +[workload identity federation](https://cloud.google.com/iam/docs/workload-identity-federation), +[workforce identity federation](https://cloud.google.com/iam/docs/workforce-identity-federation), or a +[service account key](https://cloud.google.com/docs/authentication/provide-credentials-adc#local-key). + +Note: Service account keys are a security risk if not managed correctly. You should +[choose a more secure alternative to service account keys](https://cloud.google.com/docs/authentication#auth-decision-tree) +whenever possible. + +The environment variables that google-shopping-css-v1 +checks for credentials are: + +* `GOOGLE_CLOUD_CREDENTIALS` - Path to JSON file, or JSON contents +* `GOOGLE_APPLICATION_CREDENTIALS` - Path to JSON file + +```ruby +require "google/shopping/css/v1" + +ENV["GOOGLE_APPLICATION_CREDENTIALS"] = "path/to/credentialfile.json" + +client = ::Google::Shopping::Css::V1::AccountsService::Client.new +``` + +### Local ADC file + +You can set up a local ADC file with your user credentials for authentication during +development. If credentials are not provided in code or in environment variables, +then the local ADC credentials are discovered. + +Follow the steps in [Quickstart](#quickstart) to set up a local ADC file. + +### Google Cloud Platform environments + +When running on Google Cloud Platform (GCP), including Google Compute Engine +(GCE), Google Kubernetes Engine (GKE), Google App Engine (GAE), Google Cloud +Functions (GCF) and Cloud Run, credentials are retrieved from the attached +service account automatically. Code should be written as if already authenticated. + +For more information, see +[Set up ADC for Google Cloud services](https://cloud.google.com/docs/authentication/provide-credentials-adc#attached-sa). diff --git a/google-shopping-css-v1/CHANGELOG.md b/google-shopping-css-v1/CHANGELOG.md new file mode 100644 index 000000000000..f88957a62ba2 --- /dev/null +++ b/google-shopping-css-v1/CHANGELOG.md @@ -0,0 +1,2 @@ +# Release History + diff --git a/google-shopping-css-v1/Gemfile b/google-shopping-css-v1/Gemfile new file mode 100644 index 000000000000..95163a6d11f8 --- /dev/null +++ b/google-shopping-css-v1/Gemfile @@ -0,0 +1,11 @@ +source "https://rubygems.org" + +gemspec + +gem "google-style", "~> 1.27.1" +gem "minitest", "~> 5.22" +gem "minitest-focus", "~> 1.4" +gem "minitest-rg", "~> 5.3" +gem "rake", ">= 13.0" +gem "redcarpet", "~> 3.6" +gem "yard", "~> 0.9" diff --git a/google-shopping-css-v1/LICENSE.md b/google-shopping-css-v1/LICENSE.md new file mode 100644 index 000000000000..c261857ba6ad --- /dev/null +++ b/google-shopping-css-v1/LICENSE.md @@ -0,0 +1,201 @@ + 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/google-shopping-css-v1/README.md b/google-shopping-css-v1/README.md new file mode 100644 index 000000000000..d6e55913cc2d --- /dev/null +++ b/google-shopping-css-v1/README.md @@ -0,0 +1,144 @@ +# Ruby Client for the CSS V1 API + +Programmatically manage your Comparison Shopping Service (CSS) account data at scale. + +Programmatically manage your Comparison Shopping Service (CSS) account data at scale. + +https://github.com/googleapis/google-cloud-ruby + +This gem is a _versioned_ client. It provides basic client classes for a +specific version of the CSS V1 API. Most users should consider using +the main client gem, +[google-shopping-css](https://rubygems.org/gems/google-shopping-css). +See the section below titled *Which client should I use?* for more information. + +## Installation + +``` +$ gem install google-shopping-css-v1 +``` + +## Before You Begin + +In order to use this library, you first need to go through the following steps: + +1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project) +1. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project) +1. [Enable the API.](https://console.cloud.google.com/apis/library/css.googleapis.com) +1. [Set up authentication.](AUTHENTICATION.md) + +## Quick Start + +```ruby +require "google/shopping/css/v1" + +client = ::Google::Shopping::Css::V1::AccountsService::Client.new +request = ::Google::Shopping::Css::V1::ListChildAccountsRequest.new # (request fields as keyword arguments...) +response = client.list_child_accounts request +``` + +View the [Client Library Documentation](https://rubydoc.info/gems/google-shopping-css-v1) +for class and method documentation. + +See also the [Product Documentation](https://developers.google.com/comparison-shopping-services/api) +for general usage information. + +## Enabling Logging + +To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library. +The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/current/stdlibs/logger/Logger.html) as shown below, +or a [`Google::Cloud::Logging::Logger`](https://cloud.google.com/ruby/docs/reference/google-cloud-logging/latest) +that will write logs to [Cloud Logging](https://cloud.google.com/logging/). See [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb) +and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information. + +Configuring a Ruby stdlib logger: + +```ruby +require "logger" + +module MyLogger + LOGGER = Logger.new $stderr, level: Logger::WARN + def logger + LOGGER + end +end + +# Define a gRPC module-level logger method before grpc/logconfig.rb loads. +module GRPC + extend MyLogger +end +``` + + +## Google Cloud Samples + +To browse ready to use code samples check [Google Cloud Samples](https://cloud.google.com/docs/samples). + +## Supported Ruby Versions + +This library is supported on Ruby 2.7+. + +Google provides official support for Ruby versions that are actively supported +by Ruby Core—that is, Ruby versions that are either in normal maintenance or +in security maintenance, and not end of life. Older versions of Ruby _may_ +still work, but are unsupported and not recommended. See +https://www.ruby-lang.org/en/downloads/branches/ for details about the Ruby +support schedule. + +## Which client should I use? + +Most modern Ruby client libraries for Google APIs come in two flavors: the main +client library with a name such as `google-shopping-css`, +and lower-level _versioned_ client libraries with names such as +`google-shopping-css-v1`. +_In most cases, you should install the main client._ + +### What's the difference between the main client and a versioned client? + +A _versioned client_ provides a basic set of data types and client classes for +a _single version_ of a specific service. (That is, for a service with multiple +versions, there might be a separate versioned client for each service version.) +Most versioned clients are written and maintained by a code generator. + +The _main client_ is designed to provide you with the _recommended_ client +interfaces for the service. There will be only one main client for any given +service, even a service with multiple versions. The main client includes +factory methods for constructing the client objects we recommend for most +users. In some cases, those will be classes provided by an underlying versioned +client; in other cases, they will be handwritten higher-level client objects +with additional capabilities, convenience methods, or best practices built in. +Generally, the main client will default to a recommended service version, +although in some cases you can override this if you need to talk to a specific +service version. + +### Why would I want to use the main client? + +We recommend that most users install the main client gem for a service. You can +identify this gem as the one _without_ a version in its name, e.g. +`google-shopping-css`. +The main client is recommended because it will embody the best practices for +accessing the service, and may also provide more convenient interfaces or +tighter integration into frameworks and third-party libraries. In addition, the +documentation and samples published by Google will generally demonstrate use of +the main client. + +### Why would I want to use a versioned client? + +You can use a versioned client if you are content with a possibly lower-level +class interface, you explicitly want to avoid features provided by the main +client, or you want to access a specific service version not be covered by the +main client. You can identify versioned client gems because the service version +is part of the name, e.g. `google-shopping-css-v1`. + +### What about the google-apis- clients? + +Client library gems with names that begin with `google-apis-` are based on an +older code generation technology. They talk to a REST/JSON backend (whereas +most modern clients talk to a [gRPC](https://grpc.io/) backend) and they may +not offer the same performance, features, and ease of use provided by more +modern clients. + +The `google-apis-` clients have wide coverage across Google services, so you +might need to use one if there is no modern client available for the service. +However, if a modern client is available, we generally recommend it over the +older `google-apis-` clients. diff --git a/google-shopping-css-v1/Rakefile b/google-shopping-css-v1/Rakefile new file mode 100644 index 000000000000..029f2bd284f0 --- /dev/null +++ b/google-shopping-css-v1/Rakefile @@ -0,0 +1,169 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "bundler/setup" +require "bundler/gem_tasks" + +require "rubocop/rake_task" +RuboCop::RakeTask.new + +require "rake/testtask" +desc "Run tests." +Rake::TestTask.new do |t| + t.libs << "test" + t.test_files = FileList["test/**/*_test.rb"] + t.warning = false +end + +desc "Runs the smoke tests." +Rake::TestTask.new :smoke_test do |t| + t.test_files = FileList["acceptance/**/*smoke_test.rb"] + t.warning = false +end + +# Acceptance tests +desc "Run the google-shopping-css-v1 acceptance tests." +task :acceptance, :project, :keyfile do |t, args| + project = args[:project] + project ||= + ENV["GOOGLE_CLOUD_TEST_PROJECT"] || + ENV["GCLOUD_TEST_PROJECT"] + keyfile = args[:keyfile] + keyfile ||= + ENV["GOOGLE_CLOUD_TEST_KEYFILE"] || + ENV["GCLOUD_TEST_KEYFILE"] + if keyfile + keyfile = File.read keyfile + else + keyfile ||= + ENV["GOOGLE_CLOUD_TEST_KEYFILE_JSON"] || + ENV["GCLOUD_TEST_KEYFILE_JSON"] + end + if project.nil? || keyfile.nil? + fail "You must provide a project and keyfile. e.g. rake acceptance[test123, /path/to/keyfile.json] or GOOGLE_CLOUD_TEST_PROJECT=test123 GOOGLE_CLOUD_TEST_KEYFILE=/path/to/keyfile.json rake acceptance" + end + require "google/shopping/css/v1/accounts_service/credentials" + ::Google::Shopping::Css::V1::AccountsService::Credentials.env_vars.each do |path| + ENV[path] = nil + end + ENV["GOOGLE_CLOUD_PROJECT"] = project + ENV["GOOGLE_CLOUD_TEST_PROJECT"] = project + ENV["GOOGLE_CLOUD_KEYFILE_JSON"] = keyfile + + Rake::Task["acceptance:run"].invoke +end + +namespace :acceptance do + task :run do + if File.directory? "acceptance" + Rake::Task[:smoke_test].invoke + else + puts "The google-shopping-css-v1 gem has no acceptance tests." + end + end + + desc "Run acceptance cleanup." + task :cleanup do + end +end + +task :samples do + Rake::Task["samples:latest"].invoke +end + +namespace :samples do + task :latest do + if File.directory? "samples" + Dir.chdir "samples" do + Bundler.with_clean_env do + ENV["GOOGLE_CLOUD_SAMPLES_TEST"] = "not_master" + sh "bundle update" + sh "bundle exec rake test" + end + end + else + puts "The google-shopping-css-v1 gem has no samples to test." + end + end + + task :master do + if File.directory? "samples" + Dir.chdir "samples" do + Bundler.with_clean_env do + ENV["GOOGLE_CLOUD_SAMPLES_TEST"] = "master" + sh "bundle update" + sh "bundle exec rake test" + end + end + else + puts "The google-shopping-css-v1 gem has no samples to test." + end + end +end + +require "yard" +require "yard/rake/yardoc_task" +YARD::Rake::YardocTask.new do |y| + y.options << "--fail-on-warning" +end + +desc "Run yard-doctest example tests." +task :doctest do + puts "The google-shopping-css-v1 gem does not have doctest tests." +end + +desc "Run the CI build" +task :ci do + header "BUILDING google-shopping-css-v1" + header "google-shopping-css-v1 rubocop", "*" + Rake::Task[:rubocop].invoke + header "google-shopping-css-v1 yard", "*" + Rake::Task[:yard].invoke + header "google-shopping-css-v1 test", "*" + Rake::Task[:test].invoke +end + +namespace :ci do + desc "Run the CI build, with smoke tests." + task :smoke_test do + Rake::Task[:ci].invoke + header "google-shopping-css-v1 smoke_test", "*" + Rake::Task[:smoke_test].invoke + end + desc "Run the CI build, with acceptance tests." + task :acceptance do + Rake::Task[:ci].invoke + header "google-shopping-css-v1 acceptance", "*" + Rake::Task[:acceptance].invoke + end + task :a do + # This is a handy shortcut to save typing + Rake::Task["ci:acceptance"].invoke + end +end + +task default: :test + +def header str, token = "#" + line_length = str.length + 8 + puts "" + puts token * line_length + puts "#{token * 3} #{str} #{token * 3}" + puts token * line_length + puts "" +end diff --git a/google-shopping-css-v1/gapic_metadata.json b/google-shopping-css-v1/gapic_metadata.json new file mode 100644 index 000000000000..64248e5d746f --- /dev/null +++ b/google-shopping-css-v1/gapic_metadata.json @@ -0,0 +1,100 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "ruby", + "protoPackage": "google.shopping.css.v1", + "libraryPackage": "::Google::Shopping::Css::V1", + "services": { + "AccountsService": { + "clients": { + "grpc": { + "libraryClient": "::Google::Shopping::Css::V1::AccountsService::Client", + "rpcs": { + "ListChildAccounts": { + "methods": [ + "list_child_accounts" + ] + }, + "GetAccount": { + "methods": [ + "get_account" + ] + }, + "UpdateLabels": { + "methods": [ + "update_labels" + ] + } + } + } + } + }, + "AccountLabelsService": { + "clients": { + "grpc": { + "libraryClient": "::Google::Shopping::Css::V1::AccountLabelsService::Client", + "rpcs": { + "ListAccountLabels": { + "methods": [ + "list_account_labels" + ] + }, + "CreateAccountLabel": { + "methods": [ + "create_account_label" + ] + }, + "UpdateAccountLabel": { + "methods": [ + "update_account_label" + ] + }, + "DeleteAccountLabel": { + "methods": [ + "delete_account_label" + ] + } + } + } + } + }, + "CssProductInputsService": { + "clients": { + "grpc": { + "libraryClient": "::Google::Shopping::Css::V1::CssProductInputsService::Client", + "rpcs": { + "InsertCssProductInput": { + "methods": [ + "insert_css_product_input" + ] + }, + "DeleteCssProductInput": { + "methods": [ + "delete_css_product_input" + ] + } + } + } + } + }, + "CssProductsService": { + "clients": { + "grpc": { + "libraryClient": "::Google::Shopping::Css::V1::CssProductsService::Client", + "rpcs": { + "GetCssProduct": { + "methods": [ + "get_css_product" + ] + }, + "ListCssProducts": { + "methods": [ + "list_css_products" + ] + } + } + } + } + } + } +} diff --git a/google-shopping-css-v1/google-shopping-css-v1.gemspec b/google-shopping-css-v1/google-shopping-css-v1.gemspec new file mode 100644 index 000000000000..68039eb7c559 --- /dev/null +++ b/google-shopping-css-v1/google-shopping-css-v1.gemspec @@ -0,0 +1,29 @@ +# -*- ruby -*- +# encoding: utf-8 + +require File.expand_path("lib/google/shopping/css/v1/version", __dir__) + +Gem::Specification.new do |gem| + gem.name = "google-shopping-css-v1" + gem.version = Google::Shopping::Css::V1::VERSION + + gem.authors = ["Google LLC"] + gem.email = "googleapis-packages@google.com" + gem.description = "Programmatically manage your Comparison Shopping Service (CSS) account data at scale. Note that google-shopping-css-v1 is a version-specific client library. For most uses, we recommend installing the main client library google-shopping-css instead. See the readme for more details." + gem.summary = "Programmatically manage your Comparison Shopping Service (CSS) account data at scale." + gem.homepage = "https://github.com/googleapis/google-cloud-ruby" + gem.license = "Apache-2.0" + + gem.platform = Gem::Platform::RUBY + + gem.files = `git ls-files -- lib/*`.split("\n") + + `git ls-files -- proto_docs/*`.split("\n") + + ["README.md", "LICENSE.md", "AUTHENTICATION.md", ".yardopts"] + gem.require_paths = ["lib"] + + gem.required_ruby_version = ">= 2.7" + + gem.add_dependency "gapic-common", ">= 0.21.1", "< 2.a" + gem.add_dependency "google-cloud-errors", "~> 1.0" + gem.add_dependency "google-shopping-type", "> 0.0", "< 2.a" +end diff --git a/google-shopping-css-v1/lib/google-shopping-css-v1.rb b/google-shopping-css-v1/lib/google-shopping-css-v1.rb new file mode 100644 index 000000000000..31bc0c3fadd9 --- /dev/null +++ b/google-shopping-css-v1/lib/google-shopping-css-v1.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# This gem does not autoload during Bundler.require. To load this gem, +# issue explicit require statements for the packages desired, e.g.: +# require "google/shopping/css/v1" diff --git a/google-shopping-css-v1/lib/google/shopping/css/v1.rb b/google-shopping-css-v1/lib/google/shopping/css/v1.rb new file mode 100644 index 000000000000..328c7a3aec7c --- /dev/null +++ b/google-shopping-css-v1/lib/google/shopping/css/v1.rb @@ -0,0 +1,48 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/shopping/css/v1/accounts_service" +require "google/shopping/css/v1/account_labels_service" +require "google/shopping/css/v1/css_product_inputs_service" +require "google/shopping/css/v1/css_products_service" +require "google/shopping/css/v1/version" + +module Google + module Shopping + module Css + ## + # API client module. + # + # @example Load this package, including all its services, and instantiate a gRPC client + # + # require "google/shopping/css/v1" + # client = ::Google::Shopping::Css::V1::AccountsService::Client.new + # + # @example Load this package, including all its services, and instantiate a REST client + # + # require "google/shopping/css/v1" + # client = ::Google::Shopping::Css::V1::AccountsService::Rest::Client.new + # + module V1 + end + end + end +end + +helper_path = ::File.join __dir__, "v1", "_helpers.rb" +require "google/shopping/css/v1/_helpers" if ::File.file? helper_path diff --git a/google-shopping-css-v1/lib/google/shopping/css/v1/account_labels_service.rb b/google-shopping-css-v1/lib/google/shopping/css/v1/account_labels_service.rb new file mode 100644 index 000000000000..901944542f9e --- /dev/null +++ b/google-shopping-css-v1/lib/google/shopping/css/v1/account_labels_service.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "gapic/common" +require "gapic/config" +require "gapic/config/method" + +require "google/shopping/css/v1/version" + +require "google/shopping/css/v1/account_labels_service/credentials" +require "google/shopping/css/v1/account_labels_service/paths" +require "google/shopping/css/v1/account_labels_service/client" +require "google/shopping/css/v1/account_labels_service/rest" + +module Google + module Shopping + module Css + module V1 + ## + # Manages Merchant Center and CSS accounts labels. + # + # @example Load this service and instantiate a gRPC client + # + # require "google/shopping/css/v1/account_labels_service" + # client = ::Google::Shopping::Css::V1::AccountLabelsService::Client.new + # + # @example Load this service and instantiate a REST client + # + # require "google/shopping/css/v1/account_labels_service/rest" + # client = ::Google::Shopping::Css::V1::AccountLabelsService::Rest::Client.new + # + module AccountLabelsService + end + end + end + end +end + +helper_path = ::File.join __dir__, "account_labels_service", "helpers.rb" +require "google/shopping/css/v1/account_labels_service/helpers" if ::File.file? helper_path diff --git a/google-shopping-css-v1/lib/google/shopping/css/v1/account_labels_service/client.rb b/google-shopping-css-v1/lib/google/shopping/css/v1/account_labels_service/client.rb new file mode 100644 index 000000000000..6fcc24d11774 --- /dev/null +++ b/google-shopping-css-v1/lib/google/shopping/css/v1/account_labels_service/client.rb @@ -0,0 +1,736 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/cloud/errors" +require "google/shopping/css/v1/accounts_labels_pb" + +module Google + module Shopping + module Css + module V1 + module AccountLabelsService + ## + # Client for the AccountLabelsService service. + # + # Manages Merchant Center and CSS accounts labels. + # + class Client + # @private + API_VERSION = "" + + # @private + DEFAULT_ENDPOINT_TEMPLATE = "css.$UNIVERSE_DOMAIN$" + + include Paths + + # @private + attr_reader :account_labels_service_stub + + ## + # Configure the AccountLabelsService Client class. + # + # See {::Google::Shopping::Css::V1::AccountLabelsService::Client::Configuration} + # for a description of the configuration fields. + # + # @example + # + # # Modify the configuration for all AccountLabelsService clients + # ::Google::Shopping::Css::V1::AccountLabelsService::Client.configure do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def self.configure + @configure ||= begin + namespace = ["Google", "Shopping", "Css", "V1"] + parent_config = while namespace.any? + parent_name = namespace.join "::" + parent_const = const_get parent_name + break parent_const.configure if parent_const.respond_to? :configure + namespace.pop + end + default_config = Client::Configuration.new parent_config + + default_config.rpcs.list_account_labels.timeout = 60.0 + default_config.rpcs.list_account_labels.retry_policy = { + initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14] + } + + default_config.rpcs.create_account_label.timeout = 60.0 + + default_config.rpcs.update_account_label.timeout = 60.0 + + default_config.rpcs.delete_account_label.timeout = 60.0 + + default_config + end + yield @configure if block_given? + @configure + end + + ## + # Configure the AccountLabelsService Client instance. + # + # The configuration is set to the derived mode, meaning that values can be changed, + # but structural changes (adding new fields, etc.) are not allowed. Structural changes + # should be made on {Client.configure}. + # + # See {::Google::Shopping::Css::V1::AccountLabelsService::Client::Configuration} + # for a description of the configuration fields. + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def configure + yield @config if block_given? + @config + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @account_labels_service_stub.universe_domain + end + + ## + # Create a new AccountLabelsService client object. + # + # @example + # + # # Create a client using the default configuration + # client = ::Google::Shopping::Css::V1::AccountLabelsService::Client.new + # + # # Create a client using a custom configuration + # client = ::Google::Shopping::Css::V1::AccountLabelsService::Client.new do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the AccountLabelsService client. + # @yieldparam config [Client::Configuration] + # + def initialize + # These require statements are intentionally placed here to initialize + # the gRPC module only when it's required. + # See https://github.com/googleapis/toolkit/issues/446 + require "gapic/grpc" + require "google/shopping/css/v1/accounts_labels_services_pb" + + # Create the configuration object + @config = Configuration.new Client.configure + + # Yield the configuration if needed + yield @config if block_given? + + # Create credentials + credentials = @config.credentials + # Use self-signed JWT if the endpoint is unchanged from default, + # but only if the default endpoint does not have a region prefix. + enable_self_signed_jwt = @config.endpoint.nil? || + (@config.endpoint == Configuration::DEFAULT_ENDPOINT && + !@config.endpoint.split(".").first.include?("-")) + credentials ||= Credentials.default scope: @config.scope, + enable_self_signed_jwt: enable_self_signed_jwt + if credentials.is_a?(::String) || credentials.is_a?(::Hash) + credentials = Credentials.new credentials, scope: @config.scope + end + @quota_project_id = @config.quota_project + @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id + + @account_labels_service_stub = ::Gapic::ServiceStub.new( + ::Google::Shopping::Css::V1::AccountLabelsService::Stub, + credentials: credentials, + endpoint: @config.endpoint, + endpoint_template: DEFAULT_ENDPOINT_TEMPLATE, + universe_domain: @config.universe_domain, + channel_args: @config.channel_args, + interceptors: @config.interceptors, + channel_pool_config: @config.channel_pool + ) + end + + # Service calls + + ## + # Lists the labels assigned to an account. + # + # @overload list_account_labels(request, options = nil) + # Pass arguments to `list_account_labels` via a request object, either of type + # {::Google::Shopping::Css::V1::ListAccountLabelsRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Css::V1::ListAccountLabelsRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload list_account_labels(parent: nil, page_size: nil, page_token: nil) + # Pass arguments to `list_account_labels` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param parent [::String] + # Required. The parent account. + # Format: accounts/\\{account} + # @param page_size [::Integer] + # The maximum number of labels to return. The service may return fewer than + # this value. + # If unspecified, at most 50 labels will be returned. + # The maximum value is 1000; values above 1000 will be coerced to 1000. + # @param page_token [::String] + # A page token, received from a previous `ListAccountLabels` call. + # Provide this to retrieve the subsequent page. + # + # When paginating, all other parameters provided to `ListAccountLabels` must + # match the call that provided the page token. + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Gapic::PagedEnumerable<::Google::Shopping::Css::V1::AccountLabel>] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Gapic::PagedEnumerable<::Google::Shopping::Css::V1::AccountLabel>] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/shopping/css/v1" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Css::V1::AccountLabelsService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Css::V1::ListAccountLabelsRequest.new + # + # # Call the list_account_labels method. + # result = client.list_account_labels request + # + # # The returned object is of type Gapic::PagedEnumerable. You can iterate + # # over elements, and API calls will be issued to fetch pages as needed. + # result.each do |item| + # # Each element is of type ::Google::Shopping::Css::V1::AccountLabel. + # p item + # end + # + def list_account_labels request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Css::V1::ListAccountLabelsRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + metadata = @config.rpcs.list_account_labels.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Css::V1::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + header_params = {} + if request.parent + header_params["parent"] = request.parent + end + + request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") + metadata[:"x-goog-request-params"] ||= request_params_header + + options.apply_defaults timeout: @config.rpcs.list_account_labels.timeout, + metadata: metadata, + retry_policy: @config.rpcs.list_account_labels.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @account_labels_service_stub.call_rpc :list_account_labels, request, options: options do |response, operation| + response = ::Gapic::PagedEnumerable.new @account_labels_service_stub, :list_account_labels, request, response, operation, options + yield response, operation if block_given? + return response + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Creates a new label, not assigned to any account. + # + # @overload create_account_label(request, options = nil) + # Pass arguments to `create_account_label` via a request object, either of type + # {::Google::Shopping::Css::V1::CreateAccountLabelRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Css::V1::CreateAccountLabelRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload create_account_label(parent: nil, account_label: nil) + # Pass arguments to `create_account_label` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param parent [::String] + # Required. The parent account. + # Format: accounts/\\{account} + # @param account_label [::Google::Shopping::Css::V1::AccountLabel, ::Hash] + # Required. The label to create. + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Google::Shopping::Css::V1::AccountLabel] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Google::Shopping::Css::V1::AccountLabel] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/shopping/css/v1" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Css::V1::AccountLabelsService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Css::V1::CreateAccountLabelRequest.new + # + # # Call the create_account_label method. + # result = client.create_account_label request + # + # # The returned object is of type Google::Shopping::Css::V1::AccountLabel. + # p result + # + def create_account_label request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Css::V1::CreateAccountLabelRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + metadata = @config.rpcs.create_account_label.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Css::V1::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + header_params = {} + if request.parent + header_params["parent"] = request.parent + end + + request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") + metadata[:"x-goog-request-params"] ||= request_params_header + + options.apply_defaults timeout: @config.rpcs.create_account_label.timeout, + metadata: metadata, + retry_policy: @config.rpcs.create_account_label.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @account_labels_service_stub.call_rpc :create_account_label, request, options: options do |response, operation| + yield response, operation if block_given? + return response + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Updates a label. + # + # @overload update_account_label(request, options = nil) + # Pass arguments to `update_account_label` via a request object, either of type + # {::Google::Shopping::Css::V1::UpdateAccountLabelRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Css::V1::UpdateAccountLabelRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload update_account_label(account_label: nil) + # Pass arguments to `update_account_label` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param account_label [::Google::Shopping::Css::V1::AccountLabel, ::Hash] + # Required. The updated label. All fields must be provided. + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Google::Shopping::Css::V1::AccountLabel] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Google::Shopping::Css::V1::AccountLabel] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/shopping/css/v1" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Css::V1::AccountLabelsService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Css::V1::UpdateAccountLabelRequest.new + # + # # Call the update_account_label method. + # result = client.update_account_label request + # + # # The returned object is of type Google::Shopping::Css::V1::AccountLabel. + # p result + # + def update_account_label request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Css::V1::UpdateAccountLabelRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + metadata = @config.rpcs.update_account_label.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Css::V1::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + header_params = {} + if request.account_label&.name + header_params["account_label.name"] = request.account_label.name + end + + request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") + metadata[:"x-goog-request-params"] ||= request_params_header + + options.apply_defaults timeout: @config.rpcs.update_account_label.timeout, + metadata: metadata, + retry_policy: @config.rpcs.update_account_label.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @account_labels_service_stub.call_rpc :update_account_label, request, options: options do |response, operation| + yield response, operation if block_given? + return response + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Deletes a label and removes it from all accounts to which it was assigned. + # + # @overload delete_account_label(request, options = nil) + # Pass arguments to `delete_account_label` via a request object, either of type + # {::Google::Shopping::Css::V1::DeleteAccountLabelRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Css::V1::DeleteAccountLabelRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload delete_account_label(name: nil) + # Pass arguments to `delete_account_label` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param name [::String] + # Required. The name of the label to delete. + # Format: accounts/\\{account}/labels/\\{label} + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Google::Protobuf::Empty] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Google::Protobuf::Empty] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/shopping/css/v1" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Css::V1::AccountLabelsService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Css::V1::DeleteAccountLabelRequest.new + # + # # Call the delete_account_label method. + # result = client.delete_account_label request + # + # # The returned object is of type Google::Protobuf::Empty. + # p result + # + def delete_account_label request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Css::V1::DeleteAccountLabelRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + metadata = @config.rpcs.delete_account_label.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Css::V1::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + header_params = {} + if request.name + header_params["name"] = request.name + end + + request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") + metadata[:"x-goog-request-params"] ||= request_params_header + + options.apply_defaults timeout: @config.rpcs.delete_account_label.timeout, + metadata: metadata, + retry_policy: @config.rpcs.delete_account_label.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @account_labels_service_stub.call_rpc :delete_account_label, request, options: options do |response, operation| + yield response, operation if block_given? + return response + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Configuration class for the AccountLabelsService API. + # + # This class represents the configuration for AccountLabelsService, + # providing control over timeouts, retry behavior, logging, transport + # parameters, and other low-level controls. Certain parameters can also be + # applied individually to specific RPCs. See + # {::Google::Shopping::Css::V1::AccountLabelsService::Client::Configuration::Rpcs} + # for a list of RPCs that can be configured independently. + # + # Configuration can be applied globally to all clients, or to a single client + # on construction. + # + # @example + # + # # Modify the global config, setting the timeout for + # # list_account_labels to 20 seconds, + # # and all remaining timeouts to 10 seconds. + # ::Google::Shopping::Css::V1::AccountLabelsService::Client.configure do |config| + # config.timeout = 10.0 + # config.rpcs.list_account_labels.timeout = 20.0 + # end + # + # # Apply the above configuration only to a new client. + # client = ::Google::Shopping::Css::V1::AccountLabelsService::Client.new do |config| + # config.timeout = 10.0 + # config.rpcs.list_account_labels.timeout = 20.0 + # end + # + # @!attribute [rw] endpoint + # A custom service endpoint, as a hostname or hostname:port. The default is + # nil, indicating to use the default endpoint in the current universe domain. + # @return [::String,nil] + # @!attribute [rw] credentials + # Credentials to send with calls. You may provide any of the following types: + # * (`String`) The path to a service account key file in JSON format + # * (`Hash`) A service account key as a Hash + # * (`Google::Auth::Credentials`) A googleauth credentials object + # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials)) + # * (`Signet::OAuth2::Client`) A signet oauth2 client object + # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client)) + # * (`GRPC::Core::Channel`) a gRPC channel with included credentials + # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object + # * (`nil`) indicating no credentials + # @return [::Object] + # @!attribute [rw] scope + # The OAuth scopes + # @return [::Array<::String>] + # @!attribute [rw] lib_name + # The library name as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] lib_version + # The library version as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] channel_args + # Extra parameters passed to the gRPC channel. Note: this is ignored if a + # `GRPC::Core::Channel` object is provided as the credential. + # @return [::Hash] + # @!attribute [rw] interceptors + # An array of interceptors that are run before calls are executed. + # @return [::Array<::GRPC::ClientInterceptor>] + # @!attribute [rw] timeout + # The call timeout in seconds. + # @return [::Numeric] + # @!attribute [rw] metadata + # Additional gRPC headers to be sent with the call. + # @return [::Hash{::Symbol=>::String}] + # @!attribute [rw] retry_policy + # The retry policy. The value is a hash with the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # @return [::Hash] + # @!attribute [rw] quota_project + # A separate project against which to charge quota. + # @return [::String] + # @!attribute [rw] universe_domain + # The universe domain within which to make requests. This determines the + # default endpoint URL. The default value of nil uses the environment + # universe (usually the default "googleapis.com" universe). + # @return [::String,nil] + # + class Configuration + extend ::Gapic::Config + + # @private + # The endpoint specific to the default "googleapis.com" universe. Deprecated. + DEFAULT_ENDPOINT = "css.googleapis.com" + + config_attr :endpoint, nil, ::String, nil + config_attr :credentials, nil do |value| + allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil] + allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC + allowed.any? { |klass| klass === value } + end + config_attr :scope, nil, ::String, ::Array, nil + config_attr :lib_name, nil, ::String, nil + config_attr :lib_version, nil, ::String, nil + config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil) + config_attr :interceptors, nil, ::Array, nil + config_attr :timeout, nil, ::Numeric, nil + config_attr :metadata, nil, ::Hash, nil + config_attr :retry_policy, nil, ::Hash, ::Proc, nil + config_attr :quota_project, nil, ::String, nil + config_attr :universe_domain, nil, ::String, nil + + # @private + def initialize parent_config = nil + @parent_config = parent_config unless parent_config.nil? + + yield self if block_given? + end + + ## + # Configurations for individual RPCs + # @return [Rpcs] + # + def rpcs + @rpcs ||= begin + parent_rpcs = nil + parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs) + Rpcs.new parent_rpcs + end + end + + ## + # Configuration for the channel pool + # @return [::Gapic::ServiceStub::ChannelPool::Configuration] + # + def channel_pool + @channel_pool ||= ::Gapic::ServiceStub::ChannelPool::Configuration.new + end + + ## + # Configuration RPC class for the AccountLabelsService API. + # + # Includes fields providing the configuration for each RPC in this service. + # Each configuration object is of type `Gapic::Config::Method` and includes + # the following configuration fields: + # + # * `timeout` (*type:* `Numeric`) - The call timeout in seconds + # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers + # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields + # include the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # + class Rpcs + ## + # RPC-specific configuration for `list_account_labels` + # @return [::Gapic::Config::Method] + # + attr_reader :list_account_labels + ## + # RPC-specific configuration for `create_account_label` + # @return [::Gapic::Config::Method] + # + attr_reader :create_account_label + ## + # RPC-specific configuration for `update_account_label` + # @return [::Gapic::Config::Method] + # + attr_reader :update_account_label + ## + # RPC-specific configuration for `delete_account_label` + # @return [::Gapic::Config::Method] + # + attr_reader :delete_account_label + + # @private + def initialize parent_rpcs = nil + list_account_labels_config = parent_rpcs.list_account_labels if parent_rpcs.respond_to? :list_account_labels + @list_account_labels = ::Gapic::Config::Method.new list_account_labels_config + create_account_label_config = parent_rpcs.create_account_label if parent_rpcs.respond_to? :create_account_label + @create_account_label = ::Gapic::Config::Method.new create_account_label_config + update_account_label_config = parent_rpcs.update_account_label if parent_rpcs.respond_to? :update_account_label + @update_account_label = ::Gapic::Config::Method.new update_account_label_config + delete_account_label_config = parent_rpcs.delete_account_label if parent_rpcs.respond_to? :delete_account_label + @delete_account_label = ::Gapic::Config::Method.new delete_account_label_config + + yield self if block_given? + end + end + end + end + end + end + end + end +end diff --git a/google-shopping-css-v1/lib/google/shopping/css/v1/account_labels_service/credentials.rb b/google-shopping-css-v1/lib/google/shopping/css/v1/account_labels_service/credentials.rb new file mode 100644 index 000000000000..8688d205f360 --- /dev/null +++ b/google-shopping-css-v1/lib/google/shopping/css/v1/account_labels_service/credentials.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "googleauth" + +module Google + module Shopping + module Css + module V1 + module AccountLabelsService + # Credentials for the AccountLabelsService API. + class Credentials < ::Google::Auth::Credentials + self.scope = [ + "https://www.googleapis.com/auth/content" + ] + self.env_vars = [ + "GOOGLE_CLOUD_CREDENTIALS", + "GOOGLE_CLOUD_KEYFILE", + "GCLOUD_KEYFILE", + "GOOGLE_CLOUD_CREDENTIALS_JSON", + "GOOGLE_CLOUD_KEYFILE_JSON", + "GCLOUD_KEYFILE_JSON" + ] + self.paths = [ + "~/.config/google_cloud/application_default_credentials.json" + ] + end + end + end + end + end +end diff --git a/google-shopping-css-v1/lib/google/shopping/css/v1/account_labels_service/paths.rb b/google-shopping-css-v1/lib/google/shopping/css/v1/account_labels_service/paths.rb new file mode 100644 index 000000000000..64582404452c --- /dev/null +++ b/google-shopping-css-v1/lib/google/shopping/css/v1/account_labels_service/paths.rb @@ -0,0 +1,64 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Shopping + module Css + module V1 + module AccountLabelsService + # Path helper methods for the AccountLabelsService API. + module Paths + ## + # Create a fully-qualified Account resource string. + # + # The resource will be in the following format: + # + # `accounts/{account}` + # + # @param account [String] + # + # @return [::String] + def account_path account: + "accounts/#{account}" + end + + ## + # Create a fully-qualified AccountLabel resource string. + # + # The resource will be in the following format: + # + # `accounts/{account}/labels/{label}` + # + # @param account [String] + # @param label [String] + # + # @return [::String] + def account_label_path account:, label: + raise ::ArgumentError, "account cannot contain /" if account.to_s.include? "/" + + "accounts/#{account}/labels/#{label}" + end + + extend self + end + end + end + end + end +end diff --git a/google-shopping-css-v1/lib/google/shopping/css/v1/account_labels_service/rest.rb b/google-shopping-css-v1/lib/google/shopping/css/v1/account_labels_service/rest.rb new file mode 100644 index 000000000000..f245618b15b3 --- /dev/null +++ b/google-shopping-css-v1/lib/google/shopping/css/v1/account_labels_service/rest.rb @@ -0,0 +1,52 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "gapic/rest" +require "gapic/config" +require "gapic/config/method" + +require "google/shopping/css/v1/version" + +require "google/shopping/css/v1/account_labels_service/credentials" +require "google/shopping/css/v1/account_labels_service/paths" +require "google/shopping/css/v1/account_labels_service/rest/client" + +module Google + module Shopping + module Css + module V1 + ## + # Manages Merchant Center and CSS accounts labels. + # + # To load this service and instantiate a REST client: + # + # require "google/shopping/css/v1/account_labels_service/rest" + # client = ::Google::Shopping::Css::V1::AccountLabelsService::Rest::Client.new + # + module AccountLabelsService + # Client for the REST transport + module Rest + end + end + end + end + end +end + +helper_path = ::File.join __dir__, "rest", "helpers.rb" +require "google/shopping/css/v1/account_labels_service/rest/helpers" if ::File.file? helper_path diff --git a/google-shopping-css-v1/lib/google/shopping/css/v1/account_labels_service/rest/client.rb b/google-shopping-css-v1/lib/google/shopping/css/v1/account_labels_service/rest/client.rb new file mode 100644 index 000000000000..9f1d95c99a78 --- /dev/null +++ b/google-shopping-css-v1/lib/google/shopping/css/v1/account_labels_service/rest/client.rb @@ -0,0 +1,682 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/cloud/errors" +require "google/shopping/css/v1/accounts_labels_pb" +require "google/shopping/css/v1/account_labels_service/rest/service_stub" + +module Google + module Shopping + module Css + module V1 + module AccountLabelsService + module Rest + ## + # REST client for the AccountLabelsService service. + # + # Manages Merchant Center and CSS accounts labels. + # + class Client + # @private + API_VERSION = "" + + # @private + DEFAULT_ENDPOINT_TEMPLATE = "css.$UNIVERSE_DOMAIN$" + + include Paths + + # @private + attr_reader :account_labels_service_stub + + ## + # Configure the AccountLabelsService Client class. + # + # See {::Google::Shopping::Css::V1::AccountLabelsService::Rest::Client::Configuration} + # for a description of the configuration fields. + # + # @example + # + # # Modify the configuration for all AccountLabelsService clients + # ::Google::Shopping::Css::V1::AccountLabelsService::Rest::Client.configure do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def self.configure + @configure ||= begin + namespace = ["Google", "Shopping", "Css", "V1"] + parent_config = while namespace.any? + parent_name = namespace.join "::" + parent_const = const_get parent_name + break parent_const.configure if parent_const.respond_to? :configure + namespace.pop + end + default_config = Client::Configuration.new parent_config + + default_config.rpcs.list_account_labels.timeout = 60.0 + default_config.rpcs.list_account_labels.retry_policy = { + initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14] + } + + default_config.rpcs.create_account_label.timeout = 60.0 + + default_config.rpcs.update_account_label.timeout = 60.0 + + default_config.rpcs.delete_account_label.timeout = 60.0 + + default_config + end + yield @configure if block_given? + @configure + end + + ## + # Configure the AccountLabelsService Client instance. + # + # The configuration is set to the derived mode, meaning that values can be changed, + # but structural changes (adding new fields, etc.) are not allowed. Structural changes + # should be made on {Client.configure}. + # + # See {::Google::Shopping::Css::V1::AccountLabelsService::Rest::Client::Configuration} + # for a description of the configuration fields. + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def configure + yield @config if block_given? + @config + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @account_labels_service_stub.universe_domain + end + + ## + # Create a new AccountLabelsService REST client object. + # + # @example + # + # # Create a client using the default configuration + # client = ::Google::Shopping::Css::V1::AccountLabelsService::Rest::Client.new + # + # # Create a client using a custom configuration + # client = ::Google::Shopping::Css::V1::AccountLabelsService::Rest::Client.new do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the AccountLabelsService client. + # @yieldparam config [Client::Configuration] + # + def initialize + # Create the configuration object + @config = Configuration.new Client.configure + + # Yield the configuration if needed + yield @config if block_given? + + # Create credentials + credentials = @config.credentials + # Use self-signed JWT if the endpoint is unchanged from default, + # but only if the default endpoint does not have a region prefix. + enable_self_signed_jwt = @config.endpoint.nil? || + (@config.endpoint == Configuration::DEFAULT_ENDPOINT && + !@config.endpoint.split(".").first.include?("-")) + credentials ||= Credentials.default scope: @config.scope, + enable_self_signed_jwt: enable_self_signed_jwt + if credentials.is_a?(::String) || credentials.is_a?(::Hash) + credentials = Credentials.new credentials, scope: @config.scope + end + + @quota_project_id = @config.quota_project + @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id + + @account_labels_service_stub = ::Google::Shopping::Css::V1::AccountLabelsService::Rest::ServiceStub.new( + endpoint: @config.endpoint, + endpoint_template: DEFAULT_ENDPOINT_TEMPLATE, + universe_domain: @config.universe_domain, + credentials: credentials + ) + end + + # Service calls + + ## + # Lists the labels assigned to an account. + # + # @overload list_account_labels(request, options = nil) + # Pass arguments to `list_account_labels` via a request object, either of type + # {::Google::Shopping::Css::V1::ListAccountLabelsRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Css::V1::ListAccountLabelsRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload list_account_labels(parent: nil, page_size: nil, page_token: nil) + # Pass arguments to `list_account_labels` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param parent [::String] + # Required. The parent account. + # Format: accounts/\\{account} + # @param page_size [::Integer] + # The maximum number of labels to return. The service may return fewer than + # this value. + # If unspecified, at most 50 labels will be returned. + # The maximum value is 1000; values above 1000 will be coerced to 1000. + # @param page_token [::String] + # A page token, received from a previous `ListAccountLabels` call. + # Provide this to retrieve the subsequent page. + # + # When paginating, all other parameters provided to `ListAccountLabels` must + # match the call that provided the page token. + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Shopping::Css::V1::AccountLabel>] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Gapic::Rest::PagedEnumerable<::Google::Shopping::Css::V1::AccountLabel>] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/shopping/css/v1" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Css::V1::AccountLabelsService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Css::V1::ListAccountLabelsRequest.new + # + # # Call the list_account_labels method. + # result = client.list_account_labels request + # + # # The returned object is of type Gapic::PagedEnumerable. You can iterate + # # over elements, and API calls will be issued to fetch pages as needed. + # result.each do |item| + # # Each element is of type ::Google::Shopping::Css::V1::AccountLabel. + # p item + # end + # + def list_account_labels request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Css::V1::ListAccountLabelsRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.list_account_labels.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Css::V1::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.list_account_labels.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.list_account_labels.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @account_labels_service_stub.list_account_labels request, options do |result, operation| + result = ::Gapic::Rest::PagedEnumerable.new @account_labels_service_stub, :list_account_labels, "account_labels", request, result, options + yield result, operation if block_given? + return result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Creates a new label, not assigned to any account. + # + # @overload create_account_label(request, options = nil) + # Pass arguments to `create_account_label` via a request object, either of type + # {::Google::Shopping::Css::V1::CreateAccountLabelRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Css::V1::CreateAccountLabelRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload create_account_label(parent: nil, account_label: nil) + # Pass arguments to `create_account_label` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param parent [::String] + # Required. The parent account. + # Format: accounts/\\{account} + # @param account_label [::Google::Shopping::Css::V1::AccountLabel, ::Hash] + # Required. The label to create. + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Css::V1::AccountLabel] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Css::V1::AccountLabel] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/shopping/css/v1" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Css::V1::AccountLabelsService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Css::V1::CreateAccountLabelRequest.new + # + # # Call the create_account_label method. + # result = client.create_account_label request + # + # # The returned object is of type Google::Shopping::Css::V1::AccountLabel. + # p result + # + def create_account_label request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Css::V1::CreateAccountLabelRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.create_account_label.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Css::V1::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.create_account_label.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.create_account_label.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @account_labels_service_stub.create_account_label request, options do |result, operation| + yield result, operation if block_given? + return result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Updates a label. + # + # @overload update_account_label(request, options = nil) + # Pass arguments to `update_account_label` via a request object, either of type + # {::Google::Shopping::Css::V1::UpdateAccountLabelRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Css::V1::UpdateAccountLabelRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload update_account_label(account_label: nil) + # Pass arguments to `update_account_label` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param account_label [::Google::Shopping::Css::V1::AccountLabel, ::Hash] + # Required. The updated label. All fields must be provided. + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Css::V1::AccountLabel] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Css::V1::AccountLabel] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/shopping/css/v1" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Css::V1::AccountLabelsService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Css::V1::UpdateAccountLabelRequest.new + # + # # Call the update_account_label method. + # result = client.update_account_label request + # + # # The returned object is of type Google::Shopping::Css::V1::AccountLabel. + # p result + # + def update_account_label request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Css::V1::UpdateAccountLabelRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.update_account_label.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Css::V1::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.update_account_label.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.update_account_label.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @account_labels_service_stub.update_account_label request, options do |result, operation| + yield result, operation if block_given? + return result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Deletes a label and removes it from all accounts to which it was assigned. + # + # @overload delete_account_label(request, options = nil) + # Pass arguments to `delete_account_label` via a request object, either of type + # {::Google::Shopping::Css::V1::DeleteAccountLabelRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Css::V1::DeleteAccountLabelRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload delete_account_label(name: nil) + # Pass arguments to `delete_account_label` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param name [::String] + # Required. The name of the label to delete. + # Format: accounts/\\{account}/labels/\\{label} + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Protobuf::Empty] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Protobuf::Empty] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/shopping/css/v1" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Css::V1::AccountLabelsService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Css::V1::DeleteAccountLabelRequest.new + # + # # Call the delete_account_label method. + # result = client.delete_account_label request + # + # # The returned object is of type Google::Protobuf::Empty. + # p result + # + def delete_account_label request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Css::V1::DeleteAccountLabelRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.delete_account_label.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Css::V1::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.delete_account_label.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.delete_account_label.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @account_labels_service_stub.delete_account_label request, options do |result, operation| + yield result, operation if block_given? + return result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Configuration class for the AccountLabelsService REST API. + # + # This class represents the configuration for AccountLabelsService REST, + # providing control over timeouts, retry behavior, logging, transport + # parameters, and other low-level controls. Certain parameters can also be + # applied individually to specific RPCs. See + # {::Google::Shopping::Css::V1::AccountLabelsService::Rest::Client::Configuration::Rpcs} + # for a list of RPCs that can be configured independently. + # + # Configuration can be applied globally to all clients, or to a single client + # on construction. + # + # @example + # + # # Modify the global config, setting the timeout for + # # list_account_labels to 20 seconds, + # # and all remaining timeouts to 10 seconds. + # ::Google::Shopping::Css::V1::AccountLabelsService::Rest::Client.configure do |config| + # config.timeout = 10.0 + # config.rpcs.list_account_labels.timeout = 20.0 + # end + # + # # Apply the above configuration only to a new client. + # client = ::Google::Shopping::Css::V1::AccountLabelsService::Rest::Client.new do |config| + # config.timeout = 10.0 + # config.rpcs.list_account_labels.timeout = 20.0 + # end + # + # @!attribute [rw] endpoint + # A custom service endpoint, as a hostname or hostname:port. The default is + # nil, indicating to use the default endpoint in the current universe domain. + # @return [::String,nil] + # @!attribute [rw] credentials + # Credentials to send with calls. You may provide any of the following types: + # * (`String`) The path to a service account key file in JSON format + # * (`Hash`) A service account key as a Hash + # * (`Google::Auth::Credentials`) A googleauth credentials object + # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials)) + # * (`Signet::OAuth2::Client`) A signet oauth2 client object + # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client)) + # * (`nil`) indicating no credentials + # @return [::Object] + # @!attribute [rw] scope + # The OAuth scopes + # @return [::Array<::String>] + # @!attribute [rw] lib_name + # The library name as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] lib_version + # The library version as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] timeout + # The call timeout in seconds. + # @return [::Numeric] + # @!attribute [rw] metadata + # Additional headers to be sent with the call. + # @return [::Hash{::Symbol=>::String}] + # @!attribute [rw] retry_policy + # The retry policy. The value is a hash with the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # @return [::Hash] + # @!attribute [rw] quota_project + # A separate project against which to charge quota. + # @return [::String] + # @!attribute [rw] universe_domain + # The universe domain within which to make requests. This determines the + # default endpoint URL. The default value of nil uses the environment + # universe (usually the default "googleapis.com" universe). + # @return [::String,nil] + # + class Configuration + extend ::Gapic::Config + + # @private + # The endpoint specific to the default "googleapis.com" universe. Deprecated. + DEFAULT_ENDPOINT = "css.googleapis.com" + + config_attr :endpoint, nil, ::String, nil + config_attr :credentials, nil do |value| + allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil] + allowed.any? { |klass| klass === value } + end + config_attr :scope, nil, ::String, ::Array, nil + config_attr :lib_name, nil, ::String, nil + config_attr :lib_version, nil, ::String, nil + config_attr :timeout, nil, ::Numeric, nil + config_attr :metadata, nil, ::Hash, nil + config_attr :retry_policy, nil, ::Hash, ::Proc, nil + config_attr :quota_project, nil, ::String, nil + config_attr :universe_domain, nil, ::String, nil + + # @private + def initialize parent_config = nil + @parent_config = parent_config unless parent_config.nil? + + yield self if block_given? + end + + ## + # Configurations for individual RPCs + # @return [Rpcs] + # + def rpcs + @rpcs ||= begin + parent_rpcs = nil + parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs) + Rpcs.new parent_rpcs + end + end + + ## + # Configuration RPC class for the AccountLabelsService API. + # + # Includes fields providing the configuration for each RPC in this service. + # Each configuration object is of type `Gapic::Config::Method` and includes + # the following configuration fields: + # + # * `timeout` (*type:* `Numeric`) - The call timeout in seconds + # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers + # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields + # include the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # + class Rpcs + ## + # RPC-specific configuration for `list_account_labels` + # @return [::Gapic::Config::Method] + # + attr_reader :list_account_labels + ## + # RPC-specific configuration for `create_account_label` + # @return [::Gapic::Config::Method] + # + attr_reader :create_account_label + ## + # RPC-specific configuration for `update_account_label` + # @return [::Gapic::Config::Method] + # + attr_reader :update_account_label + ## + # RPC-specific configuration for `delete_account_label` + # @return [::Gapic::Config::Method] + # + attr_reader :delete_account_label + + # @private + def initialize parent_rpcs = nil + list_account_labels_config = parent_rpcs.list_account_labels if parent_rpcs.respond_to? :list_account_labels + @list_account_labels = ::Gapic::Config::Method.new list_account_labels_config + create_account_label_config = parent_rpcs.create_account_label if parent_rpcs.respond_to? :create_account_label + @create_account_label = ::Gapic::Config::Method.new create_account_label_config + update_account_label_config = parent_rpcs.update_account_label if parent_rpcs.respond_to? :update_account_label + @update_account_label = ::Gapic::Config::Method.new update_account_label_config + delete_account_label_config = parent_rpcs.delete_account_label if parent_rpcs.respond_to? :delete_account_label + @delete_account_label = ::Gapic::Config::Method.new delete_account_label_config + + yield self if block_given? + end + end + end + end + end + end + end + end + end +end diff --git a/google-shopping-css-v1/lib/google/shopping/css/v1/account_labels_service/rest/service_stub.rb b/google-shopping-css-v1/lib/google/shopping/css/v1/account_labels_service/rest/service_stub.rb new file mode 100644 index 000000000000..280a32417060 --- /dev/null +++ b/google-shopping-css-v1/lib/google/shopping/css/v1/account_labels_service/rest/service_stub.rb @@ -0,0 +1,307 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/shopping/css/v1/accounts_labels_pb" + +module Google + module Shopping + module Css + module V1 + module AccountLabelsService + module Rest + ## + # REST service stub for the AccountLabelsService service. + # Service stub contains baseline method implementations + # including transcoding, making the REST call, and deserialing the response. + # + class ServiceStub + def initialize endpoint:, endpoint_template:, universe_domain:, credentials: + # These require statements are intentionally placed here to initialize + # the REST modules only when it's required. + require "gapic/rest" + + @client_stub = ::Gapic::Rest::ClientStub.new endpoint: endpoint, + endpoint_template: endpoint_template, + universe_domain: universe_domain, + credentials: credentials, + numeric_enums: true, + raise_faraday_errors: false + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @client_stub.universe_domain + end + + ## + # The effective endpoint + # + # @return [String] + # + def endpoint + @client_stub.endpoint + end + + ## + # Baseline implementation for the list_account_labels REST call + # + # @param request_pb [::Google::Shopping::Css::V1::ListAccountLabelsRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Css::V1::ListAccountLabelsResponse] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Css::V1::ListAccountLabelsResponse] + # A result object deserialized from the server's reply + def list_account_labels request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_list_account_labels_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Shopping::Css::V1::ListAccountLabelsResponse.decode_json response.body, ignore_unknown_fields: true + + yield result, operation if block_given? + result + end + + ## + # Baseline implementation for the create_account_label REST call + # + # @param request_pb [::Google::Shopping::Css::V1::CreateAccountLabelRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Css::V1::AccountLabel] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Css::V1::AccountLabel] + # A result object deserialized from the server's reply + def create_account_label request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_create_account_label_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Shopping::Css::V1::AccountLabel.decode_json response.body, ignore_unknown_fields: true + + yield result, operation if block_given? + result + end + + ## + # Baseline implementation for the update_account_label REST call + # + # @param request_pb [::Google::Shopping::Css::V1::UpdateAccountLabelRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Css::V1::AccountLabel] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Css::V1::AccountLabel] + # A result object deserialized from the server's reply + def update_account_label request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_update_account_label_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Shopping::Css::V1::AccountLabel.decode_json response.body, ignore_unknown_fields: true + + yield result, operation if block_given? + result + end + + ## + # Baseline implementation for the delete_account_label REST call + # + # @param request_pb [::Google::Shopping::Css::V1::DeleteAccountLabelRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Protobuf::Empty] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Protobuf::Empty] + # A result object deserialized from the server's reply + def delete_account_label request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_delete_account_label_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Protobuf::Empty.decode_json response.body, ignore_unknown_fields: true + + yield result, operation if block_given? + result + end + + ## + # @private + # + # GRPC transcoding helper method for the list_account_labels REST call + # + # @param request_pb [::Google::Shopping::Css::V1::ListAccountLabelsRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_list_account_labels_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :get, + uri_template: "/v1/{parent}/labels", + matches: [ + ["parent", %r{^accounts/[^/]+/?$}, false] + ] + ) + transcoder.transcode request_pb + end + + ## + # @private + # + # GRPC transcoding helper method for the create_account_label REST call + # + # @param request_pb [::Google::Shopping::Css::V1::CreateAccountLabelRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_create_account_label_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :post, + uri_template: "/v1/{parent}/labels", + body: "account_label", + matches: [ + ["parent", %r{^accounts/[^/]+/?$}, false] + ] + ) + transcoder.transcode request_pb + end + + ## + # @private + # + # GRPC transcoding helper method for the update_account_label REST call + # + # @param request_pb [::Google::Shopping::Css::V1::UpdateAccountLabelRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_update_account_label_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :patch, + uri_template: "/v1/{account_label.name}", + body: "account_label", + matches: [ + ["account_label.name", %r{^accounts/[^/]+/labels/[^/]+/?$}, false] + ] + ) + transcoder.transcode request_pb + end + + ## + # @private + # + # GRPC transcoding helper method for the delete_account_label REST call + # + # @param request_pb [::Google::Shopping::Css::V1::DeleteAccountLabelRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_delete_account_label_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :delete, + uri_template: "/v1/{name}", + matches: [ + ["name", %r{^accounts/[^/]+/labels/[^/]+/?$}, false] + ] + ) + transcoder.transcode request_pb + end + end + end + end + end + end + end +end diff --git a/google-shopping-css-v1/lib/google/shopping/css/v1/accounts_labels_pb.rb b/google-shopping-css-v1/lib/google/shopping/css/v1/accounts_labels_pb.rb new file mode 100644 index 000000000000..4092a4a8740a --- /dev/null +++ b/google-shopping-css-v1/lib/google/shopping/css/v1/accounts_labels_pb.rb @@ -0,0 +1,54 @@ +# frozen_string_literal: true +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/shopping/css/v1/accounts_labels.proto + +require 'google/protobuf' + +require 'google/api/annotations_pb' +require 'google/api/client_pb' +require 'google/api/field_behavior_pb' +require 'google/api/resource_pb' +require 'google/protobuf/empty_pb' + + +descriptor_data = "\n,google/shopping/css/v1/accounts_labels.proto\x12\x16google.shopping.css.v1\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a\x1bgoogle/protobuf/empty.proto\"\x95\x03\n\x0c\x41\x63\x63ountLabel\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x15\n\x08label_id\x18\x02 \x01(\x03\x42\x03\xe0\x41\x03\x12\x17\n\naccount_id\x18\x03 \x01(\x03\x42\x03\xe0\x41\x03\x12\x19\n\x0c\x64isplay_name\x18\x04 \x01(\tH\x00\x88\x01\x01\x12\x18\n\x0b\x64\x65scription\x18\x05 \x01(\tH\x01\x88\x01\x01\x12G\n\nlabel_type\x18\x06 \x01(\x0e\x32..google.shopping.css.v1.AccountLabel.LabelTypeB\x03\xe0\x41\x03\"B\n\tLabelType\x12\x1a\n\x16LABEL_TYPE_UNSPECIFIED\x10\x00\x12\n\n\x06MANUAL\x10\x01\x12\r\n\tAUTOMATIC\x10\x02:d\xea\x41\x61\n\x1f\x63ss.googleapis.com/AccountLabel\x12!accounts/{account}/labels/{label}*\raccountLabels2\x0c\x61\x63\x63ountLabelB\x0f\n\r_display_nameB\x0e\n\x0c_description\"z\n\x18ListAccountLabelsRequest\x12\x37\n\x06parent\x18\x01 \x01(\tB\'\xe0\x41\x02\xfa\x41!\x12\x1f\x63ss.googleapis.com/AccountLabel\x12\x11\n\tpage_size\x18\x02 \x01(\x05\x12\x12\n\npage_token\x18\x03 \x01(\t\"r\n\x19ListAccountLabelsResponse\x12<\n\x0e\x61\x63\x63ount_labels\x18\x01 \x03(\x0b\x32$.google.shopping.css.v1.AccountLabel\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t\"\x96\x01\n\x19\x43reateAccountLabelRequest\x12\x37\n\x06parent\x18\x01 \x01(\tB\'\xe0\x41\x02\xfa\x41!\x12\x1f\x63ss.googleapis.com/AccountLabel\x12@\n\raccount_label\x18\x02 \x01(\x0b\x32$.google.shopping.css.v1.AccountLabelB\x03\xe0\x41\x02\"]\n\x19UpdateAccountLabelRequest\x12@\n\raccount_label\x18\x01 \x01(\x0b\x32$.google.shopping.css.v1.AccountLabelB\x03\xe0\x41\x02\"R\n\x19\x44\x65leteAccountLabelRequest\x12\x35\n\x04name\x18\x01 \x01(\tB\'\xe0\x41\x02\xfa\x41!\n\x1f\x63ss.googleapis.com/AccountLabel2\x97\x06\n\x14\x41\x63\x63ountLabelsService\x12\xa9\x01\n\x11ListAccountLabels\x12\x30.google.shopping.css.v1.ListAccountLabelsRequest\x1a\x31.google.shopping.css.v1.ListAccountLabelsResponse\"/\xda\x41\x06parent\x82\xd3\xe4\x93\x02 \x12\x1e/v1/{parent=accounts/*}/labels\x12\xbb\x01\n\x12\x43reateAccountLabel\x12\x31.google.shopping.css.v1.CreateAccountLabelRequest\x1a$.google.shopping.css.v1.AccountLabel\"L\xda\x41\x14parent,account_label\x82\xd3\xe4\x93\x02/\"\x1e/v1/{parent=accounts/*}/labels:\raccount_label\x12\xc2\x01\n\x12UpdateAccountLabel\x12\x31.google.shopping.css.v1.UpdateAccountLabelRequest\x1a$.google.shopping.css.v1.AccountLabel\"S\xda\x41\raccount_label\x82\xd3\xe4\x93\x02=2,/v1/{account_label.name=accounts/*/labels/*}:\raccount_label\x12\x8e\x01\n\x12\x44\x65leteAccountLabel\x12\x31.google.shopping.css.v1.DeleteAccountLabelRequest\x1a\x16.google.protobuf.Empty\"-\xda\x41\x04name\x82\xd3\xe4\x93\x02 *\x1e/v1/{name=accounts/*/labels/*}\x1a?\xca\x41\x12\x63ss.googleapis.com\xd2\x41\'https://www.googleapis.com/auth/contentB\xb5\x01\n\x1a\x63om.google.shopping.css.v1B\x13\x41\x63\x63ountsLabelsProtoP\x01Z2cloud.google.com/go/shopping/css/apiv1/csspb;csspb\xaa\x02\x16Google.Shopping.Css.V1\xca\x02\x16Google\\Shopping\\Css\\V1\xea\x02\x19Google::Shopping::Css::V1b\x06proto3" + +pool = Google::Protobuf::DescriptorPool.generated_pool + +begin + pool.add_serialized_file(descriptor_data) +rescue TypeError + # Compatibility code: will be removed in the next major version. + require 'google/protobuf/descriptor_pb' + parsed = Google::Protobuf::FileDescriptorProto.decode(descriptor_data) + parsed.clear_dependency + serialized = parsed.class.encode(parsed) + file = pool.add_serialized_file(serialized) + warn "Warning: Protobuf detected an import path issue while loading generated file #{__FILE__}" + imports = [ + ] + imports.each do |type_name, expected_filename| + import_file = pool.lookup(type_name).file_descriptor + if import_file.name != expected_filename + warn "- #{file.name} imports #{expected_filename}, but that import was loaded as #{import_file.name}" + end + end + warn "Each proto file must use a consistent fully-qualified name." + warn "This will become an error in the next major version." +end + +module Google + module Shopping + module Css + module V1 + AccountLabel = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.css.v1.AccountLabel").msgclass + AccountLabel::LabelType = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.css.v1.AccountLabel.LabelType").enummodule + ListAccountLabelsRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.css.v1.ListAccountLabelsRequest").msgclass + ListAccountLabelsResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.css.v1.ListAccountLabelsResponse").msgclass + CreateAccountLabelRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.css.v1.CreateAccountLabelRequest").msgclass + UpdateAccountLabelRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.css.v1.UpdateAccountLabelRequest").msgclass + DeleteAccountLabelRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.css.v1.DeleteAccountLabelRequest").msgclass + end + end + end +end diff --git a/google-shopping-css-v1/lib/google/shopping/css/v1/accounts_labels_services_pb.rb b/google-shopping-css-v1/lib/google/shopping/css/v1/accounts_labels_services_pb.rb new file mode 100644 index 000000000000..11682e2aafe0 --- /dev/null +++ b/google-shopping-css-v1/lib/google/shopping/css/v1/accounts_labels_services_pb.rb @@ -0,0 +1,51 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# Source: google/shopping/css/v1/accounts_labels.proto for package 'Google.Shopping.Css.V1' +# Original file comments: +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +require 'grpc' +require 'google/shopping/css/v1/accounts_labels_pb' + +module Google + module Shopping + module Css + module V1 + module AccountLabelsService + # Manages Merchant Center and CSS accounts labels. + class Service + + include ::GRPC::GenericService + + self.marshal_class_method = :encode + self.unmarshal_class_method = :decode + self.service_name = 'google.shopping.css.v1.AccountLabelsService' + + # Lists the labels assigned to an account. + rpc :ListAccountLabels, ::Google::Shopping::Css::V1::ListAccountLabelsRequest, ::Google::Shopping::Css::V1::ListAccountLabelsResponse + # Creates a new label, not assigned to any account. + rpc :CreateAccountLabel, ::Google::Shopping::Css::V1::CreateAccountLabelRequest, ::Google::Shopping::Css::V1::AccountLabel + # Updates a label. + rpc :UpdateAccountLabel, ::Google::Shopping::Css::V1::UpdateAccountLabelRequest, ::Google::Shopping::Css::V1::AccountLabel + # Deletes a label and removes it from all accounts to which it was assigned. + rpc :DeleteAccountLabel, ::Google::Shopping::Css::V1::DeleteAccountLabelRequest, ::Google::Protobuf::Empty + end + + Stub = Service.rpc_stub_class + end + end + end + end +end diff --git a/google-shopping-css-v1/lib/google/shopping/css/v1/accounts_pb.rb b/google-shopping-css-v1/lib/google/shopping/css/v1/accounts_pb.rb new file mode 100644 index 000000000000..19165f228a29 --- /dev/null +++ b/google-shopping-css-v1/lib/google/shopping/css/v1/accounts_pb.rb @@ -0,0 +1,52 @@ +# frozen_string_literal: true +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/shopping/css/v1/accounts.proto + +require 'google/protobuf' + +require 'google/api/annotations_pb' +require 'google/api/client_pb' +require 'google/api/field_behavior_pb' +require 'google/api/resource_pb' + + +descriptor_data = "\n%google/shopping/css/v1/accounts.proto\x12\x16google.shopping.css.v1\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\"\xc9\x01\n\x18ListChildAccountsRequest\x12\x32\n\x06parent\x18\x01 \x01(\tB\"\xe0\x41\x02\xfa\x41\x1c\n\x1a\x63ss.googleapis.com/Account\x12\x15\n\x08label_id\x18\x02 \x01(\x03H\x00\x88\x01\x01\x12\x16\n\tfull_name\x18\x03 \x01(\tH\x01\x88\x01\x01\x12\x16\n\tpage_size\x18\x04 \x01(\x05\x42\x03\xe0\x41\x01\x12\x17\n\npage_token\x18\x05 \x01(\tB\x03\xe0\x41\x01\x42\x0b\n\t_label_idB\x0c\n\n_full_name\"g\n\x19ListChildAccountsResponse\x12\x31\n\x08\x61\x63\x63ounts\x18\x01 \x03(\x0b\x32\x1f.google.shopping.css.v1.Account\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t\"\x89\x01\n\x11GetAccountRequest\x12\x30\n\x04name\x18\x01 \x01(\tB\"\xe0\x41\x02\xfa\x41\x1c\n\x1a\x63ss.googleapis.com/Account\x12\x37\n\x06parent\x18\x02 \x01(\tB\"\xe0\x41\x01\xfa\x41\x1c\n\x1a\x63ss.googleapis.com/AccountH\x00\x88\x01\x01\x42\t\n\x07_parent\"\xa5\x01\n\x1aUpdateAccountLabelsRequest\x12\x30\n\x04name\x18\x01 \x01(\tB\"\xe0\x41\x02\xfa\x41\x1c\n\x1a\x63ss.googleapis.com/Account\x12\x11\n\tlabel_ids\x18\x02 \x03(\x03\x12\x37\n\x06parent\x18\x03 \x01(\tB\"\xe0\x41\x01\xfa\x41\x1c\n\x1a\x63ss.googleapis.com/AccountH\x00\x88\x01\x01\x42\t\n\x07_parent\"\xbb\x04\n\x07\x41\x63\x63ount\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x19\n\tfull_name\x18\x02 \x01(\tB\x06\xe0\x41\x03\xe0\x41\x05\x12\x19\n\x0c\x64isplay_name\x18\x03 \x01(\tH\x00\x88\x01\x01\x12!\n\x0chomepage_uri\x18\x04 \x01(\tB\x06\xe0\x41\x03\xe0\x41\x05H\x01\x88\x01\x01\x12\x13\n\x06parent\x18\x05 \x01(\tH\x02\x88\x01\x01\x12\x11\n\tlabel_ids\x18\x06 \x03(\x03\x12\x1b\n\x13\x61utomatic_label_ids\x18\x07 \x03(\x03\x12\x46\n\x0c\x61\x63\x63ount_type\x18\x08 \x01(\x0e\x32+.google.shopping.css.v1.Account.AccountTypeB\x03\xe0\x41\x03\"\xc6\x01\n\x0b\x41\x63\x63ountType\x12\x1c\n\x18\x41\x43\x43OUNT_TYPE_UNSPECIFIED\x10\x00\x12\r\n\tCSS_GROUP\x10\x01\x12\x0e\n\nCSS_DOMAIN\x10\x02\x12\x16\n\x12MC_PRIMARY_CSS_MCA\x10\x03\x12\x0e\n\nMC_CSS_MCA\x10\x04\x12\x16\n\x12MC_MARKETPLACE_MCA\x10\x05\x12\x10\n\x0cMC_OTHER_MCA\x10\x06\x12\x11\n\rMC_STANDALONE\x10\x07\x12\x15\n\x11MC_MCA_SUBACCOUNT\x10\x08:F\xea\x41\x43\n\x1a\x63ss.googleapis.com/Account\x12\x12\x61\x63\x63ounts/{account}*\x08\x61\x63\x63ounts2\x07\x61\x63\x63ountB\x0f\n\r_display_nameB\x0f\n\r_homepage_uriB\t\n\x07_parent2\xa5\x04\n\x0f\x41\x63\x63ountsService\x12\xb4\x01\n\x11ListChildAccounts\x12\x30.google.shopping.css.v1.ListChildAccountsRequest\x1a\x31.google.shopping.css.v1.ListChildAccountsResponse\":\xda\x41\x06parent\x82\xd3\xe4\x93\x02+\x12)/v1/{parent=accounts/*}:listChildAccounts\x12~\n\nGetAccount\x12).google.shopping.css.v1.GetAccountRequest\x1a\x1f.google.shopping.css.v1.Account\"$\xda\x41\x04name\x82\xd3\xe4\x93\x02\x17\x12\x15/v1/{name=accounts/*}\x12\x99\x01\n\x0cUpdateLabels\x12\x32.google.shopping.css.v1.UpdateAccountLabelsRequest\x1a\x1f.google.shopping.css.v1.Account\"4\xda\x41\x04name\x82\xd3\xe4\x93\x02\'\"\"/v1/{name=accounts/*}:updateLabels:\x01*\x1a?\xca\x41\x12\x63ss.googleapis.com\xd2\x41\'https://www.googleapis.com/auth/contentB\xaf\x01\n\x1a\x63om.google.shopping.css.v1B\rAccountsProtoP\x01Z2cloud.google.com/go/shopping/css/apiv1/csspb;csspb\xaa\x02\x16Google.Shopping.Css.V1\xca\x02\x16Google\\Shopping\\Css\\V1\xea\x02\x19Google::Shopping::Css::V1b\x06proto3" + +pool = Google::Protobuf::DescriptorPool.generated_pool + +begin + pool.add_serialized_file(descriptor_data) +rescue TypeError + # Compatibility code: will be removed in the next major version. + require 'google/protobuf/descriptor_pb' + parsed = Google::Protobuf::FileDescriptorProto.decode(descriptor_data) + parsed.clear_dependency + serialized = parsed.class.encode(parsed) + file = pool.add_serialized_file(serialized) + warn "Warning: Protobuf detected an import path issue while loading generated file #{__FILE__}" + imports = [ + ] + imports.each do |type_name, expected_filename| + import_file = pool.lookup(type_name).file_descriptor + if import_file.name != expected_filename + warn "- #{file.name} imports #{expected_filename}, but that import was loaded as #{import_file.name}" + end + end + warn "Each proto file must use a consistent fully-qualified name." + warn "This will become an error in the next major version." +end + +module Google + module Shopping + module Css + module V1 + ListChildAccountsRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.css.v1.ListChildAccountsRequest").msgclass + ListChildAccountsResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.css.v1.ListChildAccountsResponse").msgclass + GetAccountRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.css.v1.GetAccountRequest").msgclass + UpdateAccountLabelsRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.css.v1.UpdateAccountLabelsRequest").msgclass + Account = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.css.v1.Account").msgclass + Account::AccountType = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.css.v1.Account.AccountType").enummodule + end + end + end +end diff --git a/google-shopping-css-v1/lib/google/shopping/css/v1/accounts_service.rb b/google-shopping-css-v1/lib/google/shopping/css/v1/accounts_service.rb new file mode 100644 index 000000000000..9b3307675e1d --- /dev/null +++ b/google-shopping-css-v1/lib/google/shopping/css/v1/accounts_service.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "gapic/common" +require "gapic/config" +require "gapic/config/method" + +require "google/shopping/css/v1/version" + +require "google/shopping/css/v1/accounts_service/credentials" +require "google/shopping/css/v1/accounts_service/paths" +require "google/shopping/css/v1/accounts_service/client" +require "google/shopping/css/v1/accounts_service/rest" + +module Google + module Shopping + module Css + module V1 + ## + # Service for managing CSS/MC account information. + # + # @example Load this service and instantiate a gRPC client + # + # require "google/shopping/css/v1/accounts_service" + # client = ::Google::Shopping::Css::V1::AccountsService::Client.new + # + # @example Load this service and instantiate a REST client + # + # require "google/shopping/css/v1/accounts_service/rest" + # client = ::Google::Shopping::Css::V1::AccountsService::Rest::Client.new + # + module AccountsService + end + end + end + end +end + +helper_path = ::File.join __dir__, "accounts_service", "helpers.rb" +require "google/shopping/css/v1/accounts_service/helpers" if ::File.file? helper_path diff --git a/google-shopping-css-v1/lib/google/shopping/css/v1/accounts_service/client.rb b/google-shopping-css-v1/lib/google/shopping/css/v1/accounts_service/client.rb new file mode 100644 index 000000000000..5b8fdd4d2e03 --- /dev/null +++ b/google-shopping-css-v1/lib/google/shopping/css/v1/accounts_service/client.rb @@ -0,0 +1,659 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/cloud/errors" +require "google/shopping/css/v1/accounts_pb" + +module Google + module Shopping + module Css + module V1 + module AccountsService + ## + # Client for the AccountsService service. + # + # Service for managing CSS/MC account information. + # + class Client + # @private + API_VERSION = "" + + # @private + DEFAULT_ENDPOINT_TEMPLATE = "css.$UNIVERSE_DOMAIN$" + + include Paths + + # @private + attr_reader :accounts_service_stub + + ## + # Configure the AccountsService Client class. + # + # See {::Google::Shopping::Css::V1::AccountsService::Client::Configuration} + # for a description of the configuration fields. + # + # @example + # + # # Modify the configuration for all AccountsService clients + # ::Google::Shopping::Css::V1::AccountsService::Client.configure do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def self.configure + @configure ||= begin + namespace = ["Google", "Shopping", "Css", "V1"] + parent_config = while namespace.any? + parent_name = namespace.join "::" + parent_const = const_get parent_name + break parent_const.configure if parent_const.respond_to? :configure + namespace.pop + end + default_config = Client::Configuration.new parent_config + + default_config.rpcs.list_child_accounts.timeout = 60.0 + default_config.rpcs.list_child_accounts.retry_policy = { + initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14] + } + + default_config.rpcs.get_account.timeout = 60.0 + default_config.rpcs.get_account.retry_policy = { + initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14] + } + + default_config.rpcs.update_labels.timeout = 60.0 + + default_config + end + yield @configure if block_given? + @configure + end + + ## + # Configure the AccountsService Client instance. + # + # The configuration is set to the derived mode, meaning that values can be changed, + # but structural changes (adding new fields, etc.) are not allowed. Structural changes + # should be made on {Client.configure}. + # + # See {::Google::Shopping::Css::V1::AccountsService::Client::Configuration} + # for a description of the configuration fields. + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def configure + yield @config if block_given? + @config + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @accounts_service_stub.universe_domain + end + + ## + # Create a new AccountsService client object. + # + # @example + # + # # Create a client using the default configuration + # client = ::Google::Shopping::Css::V1::AccountsService::Client.new + # + # # Create a client using a custom configuration + # client = ::Google::Shopping::Css::V1::AccountsService::Client.new do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the AccountsService client. + # @yieldparam config [Client::Configuration] + # + def initialize + # These require statements are intentionally placed here to initialize + # the gRPC module only when it's required. + # See https://github.com/googleapis/toolkit/issues/446 + require "gapic/grpc" + require "google/shopping/css/v1/accounts_services_pb" + + # Create the configuration object + @config = Configuration.new Client.configure + + # Yield the configuration if needed + yield @config if block_given? + + # Create credentials + credentials = @config.credentials + # Use self-signed JWT if the endpoint is unchanged from default, + # but only if the default endpoint does not have a region prefix. + enable_self_signed_jwt = @config.endpoint.nil? || + (@config.endpoint == Configuration::DEFAULT_ENDPOINT && + !@config.endpoint.split(".").first.include?("-")) + credentials ||= Credentials.default scope: @config.scope, + enable_self_signed_jwt: enable_self_signed_jwt + if credentials.is_a?(::String) || credentials.is_a?(::Hash) + credentials = Credentials.new credentials, scope: @config.scope + end + @quota_project_id = @config.quota_project + @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id + + @accounts_service_stub = ::Gapic::ServiceStub.new( + ::Google::Shopping::Css::V1::AccountsService::Stub, + credentials: credentials, + endpoint: @config.endpoint, + endpoint_template: DEFAULT_ENDPOINT_TEMPLATE, + universe_domain: @config.universe_domain, + channel_args: @config.channel_args, + interceptors: @config.interceptors, + channel_pool_config: @config.channel_pool + ) + end + + # Service calls + + ## + # Lists all the accounts under the specified CSS account ID, and + # optionally filters by label ID and account name. + # + # @overload list_child_accounts(request, options = nil) + # Pass arguments to `list_child_accounts` via a request object, either of type + # {::Google::Shopping::Css::V1::ListChildAccountsRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Css::V1::ListChildAccountsRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload list_child_accounts(parent: nil, label_id: nil, full_name: nil, page_size: nil, page_token: nil) + # Pass arguments to `list_child_accounts` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param parent [::String] + # Required. The parent account. Must be a CSS group or domain. + # Format: accounts/\\{account} + # @param label_id [::Integer] + # If set, only the MC accounts with the given label ID will be returned. + # @param full_name [::String] + # If set, only the MC accounts with the given name (case sensitive) will be + # returned. + # @param page_size [::Integer] + # Optional. The maximum number of accounts to return. The service may return + # fewer than this value. If unspecified, at most 50 accounts will be + # returned. The maximum value is 1000; values above 1000 will be coerced to + # 1000. + # @param page_token [::String] + # Optional. A page token, received from a previous `ListChildAccounts` call. + # Provide this to retrieve the subsequent page. + # + # When paginating, all other parameters provided to `ListChildAccounts` must + # match the call that provided the page token. + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Gapic::PagedEnumerable<::Google::Shopping::Css::V1::Account>] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Gapic::PagedEnumerable<::Google::Shopping::Css::V1::Account>] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/shopping/css/v1" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Css::V1::AccountsService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Css::V1::ListChildAccountsRequest.new + # + # # Call the list_child_accounts method. + # result = client.list_child_accounts request + # + # # The returned object is of type Gapic::PagedEnumerable. You can iterate + # # over elements, and API calls will be issued to fetch pages as needed. + # result.each do |item| + # # Each element is of type ::Google::Shopping::Css::V1::Account. + # p item + # end + # + def list_child_accounts request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Css::V1::ListChildAccountsRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + metadata = @config.rpcs.list_child_accounts.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Css::V1::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + header_params = {} + if request.parent + header_params["parent"] = request.parent + end + + request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") + metadata[:"x-goog-request-params"] ||= request_params_header + + options.apply_defaults timeout: @config.rpcs.list_child_accounts.timeout, + metadata: metadata, + retry_policy: @config.rpcs.list_child_accounts.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @accounts_service_stub.call_rpc :list_child_accounts, request, options: options do |response, operation| + response = ::Gapic::PagedEnumerable.new @accounts_service_stub, :list_child_accounts, request, response, operation, options + yield response, operation if block_given? + return response + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Retrieves a single CSS/MC account by ID. + # + # @overload get_account(request, options = nil) + # Pass arguments to `get_account` via a request object, either of type + # {::Google::Shopping::Css::V1::GetAccountRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Css::V1::GetAccountRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload get_account(name: nil, parent: nil) + # Pass arguments to `get_account` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param name [::String] + # Required. The name of the managed CSS/MC account. + # Format: accounts/\\{account} + # @param parent [::String] + # Optional. Only required when retrieving MC account information. + # The CSS domain that is the parent resource of the MC account. + # Format: accounts/\\{account} + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Google::Shopping::Css::V1::Account] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Google::Shopping::Css::V1::Account] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/shopping/css/v1" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Css::V1::AccountsService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Css::V1::GetAccountRequest.new + # + # # Call the get_account method. + # result = client.get_account request + # + # # The returned object is of type Google::Shopping::Css::V1::Account. + # p result + # + def get_account request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Css::V1::GetAccountRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + metadata = @config.rpcs.get_account.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Css::V1::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + header_params = {} + if request.name + header_params["name"] = request.name + end + + request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") + metadata[:"x-goog-request-params"] ||= request_params_header + + options.apply_defaults timeout: @config.rpcs.get_account.timeout, + metadata: metadata, + retry_policy: @config.rpcs.get_account.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @accounts_service_stub.call_rpc :get_account, request, options: options do |response, operation| + yield response, operation if block_given? + return response + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Updates labels assigned to CSS/MC accounts by a CSS domain. + # + # @overload update_labels(request, options = nil) + # Pass arguments to `update_labels` via a request object, either of type + # {::Google::Shopping::Css::V1::UpdateAccountLabelsRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Css::V1::UpdateAccountLabelsRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload update_labels(name: nil, label_ids: nil, parent: nil) + # Pass arguments to `update_labels` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param name [::String] + # Required. The label resource name. + # Format: accounts/\\{account} + # @param label_ids [::Array<::Integer>] + # The list of label IDs to overwrite the existing account label IDs. + # If the list is empty, all currently assigned label IDs will be deleted. + # @param parent [::String] + # Optional. Only required when updating MC account labels. + # The CSS domain that is the parent resource of the MC account. + # Format: accounts/\\{account} + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Google::Shopping::Css::V1::Account] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Google::Shopping::Css::V1::Account] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/shopping/css/v1" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Css::V1::AccountsService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Css::V1::UpdateAccountLabelsRequest.new + # + # # Call the update_labels method. + # result = client.update_labels request + # + # # The returned object is of type Google::Shopping::Css::V1::Account. + # p result + # + def update_labels request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Css::V1::UpdateAccountLabelsRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + metadata = @config.rpcs.update_labels.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Css::V1::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + header_params = {} + if request.name + header_params["name"] = request.name + end + + request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") + metadata[:"x-goog-request-params"] ||= request_params_header + + options.apply_defaults timeout: @config.rpcs.update_labels.timeout, + metadata: metadata, + retry_policy: @config.rpcs.update_labels.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @accounts_service_stub.call_rpc :update_labels, request, options: options do |response, operation| + yield response, operation if block_given? + return response + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Configuration class for the AccountsService API. + # + # This class represents the configuration for AccountsService, + # providing control over timeouts, retry behavior, logging, transport + # parameters, and other low-level controls. Certain parameters can also be + # applied individually to specific RPCs. See + # {::Google::Shopping::Css::V1::AccountsService::Client::Configuration::Rpcs} + # for a list of RPCs that can be configured independently. + # + # Configuration can be applied globally to all clients, or to a single client + # on construction. + # + # @example + # + # # Modify the global config, setting the timeout for + # # list_child_accounts to 20 seconds, + # # and all remaining timeouts to 10 seconds. + # ::Google::Shopping::Css::V1::AccountsService::Client.configure do |config| + # config.timeout = 10.0 + # config.rpcs.list_child_accounts.timeout = 20.0 + # end + # + # # Apply the above configuration only to a new client. + # client = ::Google::Shopping::Css::V1::AccountsService::Client.new do |config| + # config.timeout = 10.0 + # config.rpcs.list_child_accounts.timeout = 20.0 + # end + # + # @!attribute [rw] endpoint + # A custom service endpoint, as a hostname or hostname:port. The default is + # nil, indicating to use the default endpoint in the current universe domain. + # @return [::String,nil] + # @!attribute [rw] credentials + # Credentials to send with calls. You may provide any of the following types: + # * (`String`) The path to a service account key file in JSON format + # * (`Hash`) A service account key as a Hash + # * (`Google::Auth::Credentials`) A googleauth credentials object + # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials)) + # * (`Signet::OAuth2::Client`) A signet oauth2 client object + # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client)) + # * (`GRPC::Core::Channel`) a gRPC channel with included credentials + # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object + # * (`nil`) indicating no credentials + # @return [::Object] + # @!attribute [rw] scope + # The OAuth scopes + # @return [::Array<::String>] + # @!attribute [rw] lib_name + # The library name as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] lib_version + # The library version as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] channel_args + # Extra parameters passed to the gRPC channel. Note: this is ignored if a + # `GRPC::Core::Channel` object is provided as the credential. + # @return [::Hash] + # @!attribute [rw] interceptors + # An array of interceptors that are run before calls are executed. + # @return [::Array<::GRPC::ClientInterceptor>] + # @!attribute [rw] timeout + # The call timeout in seconds. + # @return [::Numeric] + # @!attribute [rw] metadata + # Additional gRPC headers to be sent with the call. + # @return [::Hash{::Symbol=>::String}] + # @!attribute [rw] retry_policy + # The retry policy. The value is a hash with the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # @return [::Hash] + # @!attribute [rw] quota_project + # A separate project against which to charge quota. + # @return [::String] + # @!attribute [rw] universe_domain + # The universe domain within which to make requests. This determines the + # default endpoint URL. The default value of nil uses the environment + # universe (usually the default "googleapis.com" universe). + # @return [::String,nil] + # + class Configuration + extend ::Gapic::Config + + # @private + # The endpoint specific to the default "googleapis.com" universe. Deprecated. + DEFAULT_ENDPOINT = "css.googleapis.com" + + config_attr :endpoint, nil, ::String, nil + config_attr :credentials, nil do |value| + allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil] + allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC + allowed.any? { |klass| klass === value } + end + config_attr :scope, nil, ::String, ::Array, nil + config_attr :lib_name, nil, ::String, nil + config_attr :lib_version, nil, ::String, nil + config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil) + config_attr :interceptors, nil, ::Array, nil + config_attr :timeout, nil, ::Numeric, nil + config_attr :metadata, nil, ::Hash, nil + config_attr :retry_policy, nil, ::Hash, ::Proc, nil + config_attr :quota_project, nil, ::String, nil + config_attr :universe_domain, nil, ::String, nil + + # @private + def initialize parent_config = nil + @parent_config = parent_config unless parent_config.nil? + + yield self if block_given? + end + + ## + # Configurations for individual RPCs + # @return [Rpcs] + # + def rpcs + @rpcs ||= begin + parent_rpcs = nil + parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs) + Rpcs.new parent_rpcs + end + end + + ## + # Configuration for the channel pool + # @return [::Gapic::ServiceStub::ChannelPool::Configuration] + # + def channel_pool + @channel_pool ||= ::Gapic::ServiceStub::ChannelPool::Configuration.new + end + + ## + # Configuration RPC class for the AccountsService API. + # + # Includes fields providing the configuration for each RPC in this service. + # Each configuration object is of type `Gapic::Config::Method` and includes + # the following configuration fields: + # + # * `timeout` (*type:* `Numeric`) - The call timeout in seconds + # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers + # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields + # include the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # + class Rpcs + ## + # RPC-specific configuration for `list_child_accounts` + # @return [::Gapic::Config::Method] + # + attr_reader :list_child_accounts + ## + # RPC-specific configuration for `get_account` + # @return [::Gapic::Config::Method] + # + attr_reader :get_account + ## + # RPC-specific configuration for `update_labels` + # @return [::Gapic::Config::Method] + # + attr_reader :update_labels + + # @private + def initialize parent_rpcs = nil + list_child_accounts_config = parent_rpcs.list_child_accounts if parent_rpcs.respond_to? :list_child_accounts + @list_child_accounts = ::Gapic::Config::Method.new list_child_accounts_config + get_account_config = parent_rpcs.get_account if parent_rpcs.respond_to? :get_account + @get_account = ::Gapic::Config::Method.new get_account_config + update_labels_config = parent_rpcs.update_labels if parent_rpcs.respond_to? :update_labels + @update_labels = ::Gapic::Config::Method.new update_labels_config + + yield self if block_given? + end + end + end + end + end + end + end + end +end diff --git a/google-shopping-css-v1/lib/google/shopping/css/v1/accounts_service/credentials.rb b/google-shopping-css-v1/lib/google/shopping/css/v1/accounts_service/credentials.rb new file mode 100644 index 000000000000..af0cbd74836d --- /dev/null +++ b/google-shopping-css-v1/lib/google/shopping/css/v1/accounts_service/credentials.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "googleauth" + +module Google + module Shopping + module Css + module V1 + module AccountsService + # Credentials for the AccountsService API. + class Credentials < ::Google::Auth::Credentials + self.scope = [ + "https://www.googleapis.com/auth/content" + ] + self.env_vars = [ + "GOOGLE_CLOUD_CREDENTIALS", + "GOOGLE_CLOUD_KEYFILE", + "GCLOUD_KEYFILE", + "GOOGLE_CLOUD_CREDENTIALS_JSON", + "GOOGLE_CLOUD_KEYFILE_JSON", + "GCLOUD_KEYFILE_JSON" + ] + self.paths = [ + "~/.config/google_cloud/application_default_credentials.json" + ] + end + end + end + end + end +end diff --git a/google-shopping-css-v1/lib/google/shopping/css/v1/accounts_service/paths.rb b/google-shopping-css-v1/lib/google/shopping/css/v1/accounts_service/paths.rb new file mode 100644 index 000000000000..ec0ec0c50ea2 --- /dev/null +++ b/google-shopping-css-v1/lib/google/shopping/css/v1/accounts_service/paths.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Shopping + module Css + module V1 + module AccountsService + # Path helper methods for the AccountsService API. + module Paths + ## + # Create a fully-qualified Account resource string. + # + # The resource will be in the following format: + # + # `accounts/{account}` + # + # @param account [String] + # + # @return [::String] + def account_path account: + "accounts/#{account}" + end + + extend self + end + end + end + end + end +end diff --git a/google-shopping-css-v1/lib/google/shopping/css/v1/accounts_service/rest.rb b/google-shopping-css-v1/lib/google/shopping/css/v1/accounts_service/rest.rb new file mode 100644 index 000000000000..54c93c31b314 --- /dev/null +++ b/google-shopping-css-v1/lib/google/shopping/css/v1/accounts_service/rest.rb @@ -0,0 +1,52 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "gapic/rest" +require "gapic/config" +require "gapic/config/method" + +require "google/shopping/css/v1/version" + +require "google/shopping/css/v1/accounts_service/credentials" +require "google/shopping/css/v1/accounts_service/paths" +require "google/shopping/css/v1/accounts_service/rest/client" + +module Google + module Shopping + module Css + module V1 + ## + # Service for managing CSS/MC account information. + # + # To load this service and instantiate a REST client: + # + # require "google/shopping/css/v1/accounts_service/rest" + # client = ::Google::Shopping::Css::V1::AccountsService::Rest::Client.new + # + module AccountsService + # Client for the REST transport + module Rest + end + end + end + end + end +end + +helper_path = ::File.join __dir__, "rest", "helpers.rb" +require "google/shopping/css/v1/accounts_service/rest/helpers" if ::File.file? helper_path diff --git a/google-shopping-css-v1/lib/google/shopping/css/v1/accounts_service/rest/client.rb b/google-shopping-css-v1/lib/google/shopping/css/v1/accounts_service/rest/client.rb new file mode 100644 index 000000000000..e367d6d9bf89 --- /dev/null +++ b/google-shopping-css-v1/lib/google/shopping/css/v1/accounts_service/rest/client.rb @@ -0,0 +1,612 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/cloud/errors" +require "google/shopping/css/v1/accounts_pb" +require "google/shopping/css/v1/accounts_service/rest/service_stub" + +module Google + module Shopping + module Css + module V1 + module AccountsService + module Rest + ## + # REST client for the AccountsService service. + # + # Service for managing CSS/MC account information. + # + class Client + # @private + API_VERSION = "" + + # @private + DEFAULT_ENDPOINT_TEMPLATE = "css.$UNIVERSE_DOMAIN$" + + include Paths + + # @private + attr_reader :accounts_service_stub + + ## + # Configure the AccountsService Client class. + # + # See {::Google::Shopping::Css::V1::AccountsService::Rest::Client::Configuration} + # for a description of the configuration fields. + # + # @example + # + # # Modify the configuration for all AccountsService clients + # ::Google::Shopping::Css::V1::AccountsService::Rest::Client.configure do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def self.configure + @configure ||= begin + namespace = ["Google", "Shopping", "Css", "V1"] + parent_config = while namespace.any? + parent_name = namespace.join "::" + parent_const = const_get parent_name + break parent_const.configure if parent_const.respond_to? :configure + namespace.pop + end + default_config = Client::Configuration.new parent_config + + default_config.rpcs.list_child_accounts.timeout = 60.0 + default_config.rpcs.list_child_accounts.retry_policy = { + initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14] + } + + default_config.rpcs.get_account.timeout = 60.0 + default_config.rpcs.get_account.retry_policy = { + initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14] + } + + default_config.rpcs.update_labels.timeout = 60.0 + + default_config + end + yield @configure if block_given? + @configure + end + + ## + # Configure the AccountsService Client instance. + # + # The configuration is set to the derived mode, meaning that values can be changed, + # but structural changes (adding new fields, etc.) are not allowed. Structural changes + # should be made on {Client.configure}. + # + # See {::Google::Shopping::Css::V1::AccountsService::Rest::Client::Configuration} + # for a description of the configuration fields. + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def configure + yield @config if block_given? + @config + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @accounts_service_stub.universe_domain + end + + ## + # Create a new AccountsService REST client object. + # + # @example + # + # # Create a client using the default configuration + # client = ::Google::Shopping::Css::V1::AccountsService::Rest::Client.new + # + # # Create a client using a custom configuration + # client = ::Google::Shopping::Css::V1::AccountsService::Rest::Client.new do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the AccountsService client. + # @yieldparam config [Client::Configuration] + # + def initialize + # Create the configuration object + @config = Configuration.new Client.configure + + # Yield the configuration if needed + yield @config if block_given? + + # Create credentials + credentials = @config.credentials + # Use self-signed JWT if the endpoint is unchanged from default, + # but only if the default endpoint does not have a region prefix. + enable_self_signed_jwt = @config.endpoint.nil? || + (@config.endpoint == Configuration::DEFAULT_ENDPOINT && + !@config.endpoint.split(".").first.include?("-")) + credentials ||= Credentials.default scope: @config.scope, + enable_self_signed_jwt: enable_self_signed_jwt + if credentials.is_a?(::String) || credentials.is_a?(::Hash) + credentials = Credentials.new credentials, scope: @config.scope + end + + @quota_project_id = @config.quota_project + @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id + + @accounts_service_stub = ::Google::Shopping::Css::V1::AccountsService::Rest::ServiceStub.new( + endpoint: @config.endpoint, + endpoint_template: DEFAULT_ENDPOINT_TEMPLATE, + universe_domain: @config.universe_domain, + credentials: credentials + ) + end + + # Service calls + + ## + # Lists all the accounts under the specified CSS account ID, and + # optionally filters by label ID and account name. + # + # @overload list_child_accounts(request, options = nil) + # Pass arguments to `list_child_accounts` via a request object, either of type + # {::Google::Shopping::Css::V1::ListChildAccountsRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Css::V1::ListChildAccountsRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload list_child_accounts(parent: nil, label_id: nil, full_name: nil, page_size: nil, page_token: nil) + # Pass arguments to `list_child_accounts` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param parent [::String] + # Required. The parent account. Must be a CSS group or domain. + # Format: accounts/\\{account} + # @param label_id [::Integer] + # If set, only the MC accounts with the given label ID will be returned. + # @param full_name [::String] + # If set, only the MC accounts with the given name (case sensitive) will be + # returned. + # @param page_size [::Integer] + # Optional. The maximum number of accounts to return. The service may return + # fewer than this value. If unspecified, at most 50 accounts will be + # returned. The maximum value is 1000; values above 1000 will be coerced to + # 1000. + # @param page_token [::String] + # Optional. A page token, received from a previous `ListChildAccounts` call. + # Provide this to retrieve the subsequent page. + # + # When paginating, all other parameters provided to `ListChildAccounts` must + # match the call that provided the page token. + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Shopping::Css::V1::Account>] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Gapic::Rest::PagedEnumerable<::Google::Shopping::Css::V1::Account>] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/shopping/css/v1" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Css::V1::AccountsService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Css::V1::ListChildAccountsRequest.new + # + # # Call the list_child_accounts method. + # result = client.list_child_accounts request + # + # # The returned object is of type Gapic::PagedEnumerable. You can iterate + # # over elements, and API calls will be issued to fetch pages as needed. + # result.each do |item| + # # Each element is of type ::Google::Shopping::Css::V1::Account. + # p item + # end + # + def list_child_accounts request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Css::V1::ListChildAccountsRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.list_child_accounts.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Css::V1::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.list_child_accounts.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.list_child_accounts.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @accounts_service_stub.list_child_accounts request, options do |result, operation| + result = ::Gapic::Rest::PagedEnumerable.new @accounts_service_stub, :list_child_accounts, "accounts", request, result, options + yield result, operation if block_given? + return result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Retrieves a single CSS/MC account by ID. + # + # @overload get_account(request, options = nil) + # Pass arguments to `get_account` via a request object, either of type + # {::Google::Shopping::Css::V1::GetAccountRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Css::V1::GetAccountRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload get_account(name: nil, parent: nil) + # Pass arguments to `get_account` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param name [::String] + # Required. The name of the managed CSS/MC account. + # Format: accounts/\\{account} + # @param parent [::String] + # Optional. Only required when retrieving MC account information. + # The CSS domain that is the parent resource of the MC account. + # Format: accounts/\\{account} + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Css::V1::Account] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Css::V1::Account] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/shopping/css/v1" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Css::V1::AccountsService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Css::V1::GetAccountRequest.new + # + # # Call the get_account method. + # result = client.get_account request + # + # # The returned object is of type Google::Shopping::Css::V1::Account. + # p result + # + def get_account request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Css::V1::GetAccountRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.get_account.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Css::V1::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.get_account.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.get_account.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @accounts_service_stub.get_account request, options do |result, operation| + yield result, operation if block_given? + return result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Updates labels assigned to CSS/MC accounts by a CSS domain. + # + # @overload update_labels(request, options = nil) + # Pass arguments to `update_labels` via a request object, either of type + # {::Google::Shopping::Css::V1::UpdateAccountLabelsRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Css::V1::UpdateAccountLabelsRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload update_labels(name: nil, label_ids: nil, parent: nil) + # Pass arguments to `update_labels` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param name [::String] + # Required. The label resource name. + # Format: accounts/\\{account} + # @param label_ids [::Array<::Integer>] + # The list of label IDs to overwrite the existing account label IDs. + # If the list is empty, all currently assigned label IDs will be deleted. + # @param parent [::String] + # Optional. Only required when updating MC account labels. + # The CSS domain that is the parent resource of the MC account. + # Format: accounts/\\{account} + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Css::V1::Account] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Css::V1::Account] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/shopping/css/v1" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Css::V1::AccountsService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Css::V1::UpdateAccountLabelsRequest.new + # + # # Call the update_labels method. + # result = client.update_labels request + # + # # The returned object is of type Google::Shopping::Css::V1::Account. + # p result + # + def update_labels request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Css::V1::UpdateAccountLabelsRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.update_labels.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Css::V1::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.update_labels.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.update_labels.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @accounts_service_stub.update_labels request, options do |result, operation| + yield result, operation if block_given? + return result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Configuration class for the AccountsService REST API. + # + # This class represents the configuration for AccountsService REST, + # providing control over timeouts, retry behavior, logging, transport + # parameters, and other low-level controls. Certain parameters can also be + # applied individually to specific RPCs. See + # {::Google::Shopping::Css::V1::AccountsService::Rest::Client::Configuration::Rpcs} + # for a list of RPCs that can be configured independently. + # + # Configuration can be applied globally to all clients, or to a single client + # on construction. + # + # @example + # + # # Modify the global config, setting the timeout for + # # list_child_accounts to 20 seconds, + # # and all remaining timeouts to 10 seconds. + # ::Google::Shopping::Css::V1::AccountsService::Rest::Client.configure do |config| + # config.timeout = 10.0 + # config.rpcs.list_child_accounts.timeout = 20.0 + # end + # + # # Apply the above configuration only to a new client. + # client = ::Google::Shopping::Css::V1::AccountsService::Rest::Client.new do |config| + # config.timeout = 10.0 + # config.rpcs.list_child_accounts.timeout = 20.0 + # end + # + # @!attribute [rw] endpoint + # A custom service endpoint, as a hostname or hostname:port. The default is + # nil, indicating to use the default endpoint in the current universe domain. + # @return [::String,nil] + # @!attribute [rw] credentials + # Credentials to send with calls. You may provide any of the following types: + # * (`String`) The path to a service account key file in JSON format + # * (`Hash`) A service account key as a Hash + # * (`Google::Auth::Credentials`) A googleauth credentials object + # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials)) + # * (`Signet::OAuth2::Client`) A signet oauth2 client object + # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client)) + # * (`nil`) indicating no credentials + # @return [::Object] + # @!attribute [rw] scope + # The OAuth scopes + # @return [::Array<::String>] + # @!attribute [rw] lib_name + # The library name as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] lib_version + # The library version as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] timeout + # The call timeout in seconds. + # @return [::Numeric] + # @!attribute [rw] metadata + # Additional headers to be sent with the call. + # @return [::Hash{::Symbol=>::String}] + # @!attribute [rw] retry_policy + # The retry policy. The value is a hash with the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # @return [::Hash] + # @!attribute [rw] quota_project + # A separate project against which to charge quota. + # @return [::String] + # @!attribute [rw] universe_domain + # The universe domain within which to make requests. This determines the + # default endpoint URL. The default value of nil uses the environment + # universe (usually the default "googleapis.com" universe). + # @return [::String,nil] + # + class Configuration + extend ::Gapic::Config + + # @private + # The endpoint specific to the default "googleapis.com" universe. Deprecated. + DEFAULT_ENDPOINT = "css.googleapis.com" + + config_attr :endpoint, nil, ::String, nil + config_attr :credentials, nil do |value| + allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil] + allowed.any? { |klass| klass === value } + end + config_attr :scope, nil, ::String, ::Array, nil + config_attr :lib_name, nil, ::String, nil + config_attr :lib_version, nil, ::String, nil + config_attr :timeout, nil, ::Numeric, nil + config_attr :metadata, nil, ::Hash, nil + config_attr :retry_policy, nil, ::Hash, ::Proc, nil + config_attr :quota_project, nil, ::String, nil + config_attr :universe_domain, nil, ::String, nil + + # @private + def initialize parent_config = nil + @parent_config = parent_config unless parent_config.nil? + + yield self if block_given? + end + + ## + # Configurations for individual RPCs + # @return [Rpcs] + # + def rpcs + @rpcs ||= begin + parent_rpcs = nil + parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs) + Rpcs.new parent_rpcs + end + end + + ## + # Configuration RPC class for the AccountsService API. + # + # Includes fields providing the configuration for each RPC in this service. + # Each configuration object is of type `Gapic::Config::Method` and includes + # the following configuration fields: + # + # * `timeout` (*type:* `Numeric`) - The call timeout in seconds + # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers + # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields + # include the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # + class Rpcs + ## + # RPC-specific configuration for `list_child_accounts` + # @return [::Gapic::Config::Method] + # + attr_reader :list_child_accounts + ## + # RPC-specific configuration for `get_account` + # @return [::Gapic::Config::Method] + # + attr_reader :get_account + ## + # RPC-specific configuration for `update_labels` + # @return [::Gapic::Config::Method] + # + attr_reader :update_labels + + # @private + def initialize parent_rpcs = nil + list_child_accounts_config = parent_rpcs.list_child_accounts if parent_rpcs.respond_to? :list_child_accounts + @list_child_accounts = ::Gapic::Config::Method.new list_child_accounts_config + get_account_config = parent_rpcs.get_account if parent_rpcs.respond_to? :get_account + @get_account = ::Gapic::Config::Method.new get_account_config + update_labels_config = parent_rpcs.update_labels if parent_rpcs.respond_to? :update_labels + @update_labels = ::Gapic::Config::Method.new update_labels_config + + yield self if block_given? + end + end + end + end + end + end + end + end + end +end diff --git a/google-shopping-css-v1/lib/google/shopping/css/v1/accounts_service/rest/service_stub.rb b/google-shopping-css-v1/lib/google/shopping/css/v1/accounts_service/rest/service_stub.rb new file mode 100644 index 000000000000..88f5b6f3eb8c --- /dev/null +++ b/google-shopping-css-v1/lib/google/shopping/css/v1/accounts_service/rest/service_stub.rb @@ -0,0 +1,247 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/shopping/css/v1/accounts_pb" + +module Google + module Shopping + module Css + module V1 + module AccountsService + module Rest + ## + # REST service stub for the AccountsService service. + # Service stub contains baseline method implementations + # including transcoding, making the REST call, and deserialing the response. + # + class ServiceStub + def initialize endpoint:, endpoint_template:, universe_domain:, credentials: + # These require statements are intentionally placed here to initialize + # the REST modules only when it's required. + require "gapic/rest" + + @client_stub = ::Gapic::Rest::ClientStub.new endpoint: endpoint, + endpoint_template: endpoint_template, + universe_domain: universe_domain, + credentials: credentials, + numeric_enums: true, + raise_faraday_errors: false + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @client_stub.universe_domain + end + + ## + # The effective endpoint + # + # @return [String] + # + def endpoint + @client_stub.endpoint + end + + ## + # Baseline implementation for the list_child_accounts REST call + # + # @param request_pb [::Google::Shopping::Css::V1::ListChildAccountsRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Css::V1::ListChildAccountsResponse] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Css::V1::ListChildAccountsResponse] + # A result object deserialized from the server's reply + def list_child_accounts request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_list_child_accounts_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Shopping::Css::V1::ListChildAccountsResponse.decode_json response.body, ignore_unknown_fields: true + + yield result, operation if block_given? + result + end + + ## + # Baseline implementation for the get_account REST call + # + # @param request_pb [::Google::Shopping::Css::V1::GetAccountRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Css::V1::Account] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Css::V1::Account] + # A result object deserialized from the server's reply + def get_account request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_get_account_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Shopping::Css::V1::Account.decode_json response.body, ignore_unknown_fields: true + + yield result, operation if block_given? + result + end + + ## + # Baseline implementation for the update_labels REST call + # + # @param request_pb [::Google::Shopping::Css::V1::UpdateAccountLabelsRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Css::V1::Account] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Css::V1::Account] + # A result object deserialized from the server's reply + def update_labels request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_update_labels_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Shopping::Css::V1::Account.decode_json response.body, ignore_unknown_fields: true + + yield result, operation if block_given? + result + end + + ## + # @private + # + # GRPC transcoding helper method for the list_child_accounts REST call + # + # @param request_pb [::Google::Shopping::Css::V1::ListChildAccountsRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_list_child_accounts_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :get, + uri_template: "/v1/{parent}:listChildAccounts", + matches: [ + ["parent", %r{^accounts/[^/]+/?$}, false] + ] + ) + transcoder.transcode request_pb + end + + ## + # @private + # + # GRPC transcoding helper method for the get_account REST call + # + # @param request_pb [::Google::Shopping::Css::V1::GetAccountRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_get_account_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :get, + uri_template: "/v1/{name}", + matches: [ + ["name", %r{^accounts/[^/]+/?$}, false] + ] + ) + transcoder.transcode request_pb + end + + ## + # @private + # + # GRPC transcoding helper method for the update_labels REST call + # + # @param request_pb [::Google::Shopping::Css::V1::UpdateAccountLabelsRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_update_labels_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :post, + uri_template: "/v1/{name}:updateLabels", + body: "*", + matches: [ + ["name", %r{^accounts/[^/]+/?$}, false] + ] + ) + transcoder.transcode request_pb + end + end + end + end + end + end + end +end diff --git a/google-shopping-css-v1/lib/google/shopping/css/v1/accounts_services_pb.rb b/google-shopping-css-v1/lib/google/shopping/css/v1/accounts_services_pb.rb new file mode 100644 index 000000000000..c682d7053b86 --- /dev/null +++ b/google-shopping-css-v1/lib/google/shopping/css/v1/accounts_services_pb.rb @@ -0,0 +1,50 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# Source: google/shopping/css/v1/accounts.proto for package 'Google.Shopping.Css.V1' +# Original file comments: +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +require 'grpc' +require 'google/shopping/css/v1/accounts_pb' + +module Google + module Shopping + module Css + module V1 + module AccountsService + # Service for managing CSS/MC account information. + class Service + + include ::GRPC::GenericService + + self.marshal_class_method = :encode + self.unmarshal_class_method = :decode + self.service_name = 'google.shopping.css.v1.AccountsService' + + # Lists all the accounts under the specified CSS account ID, and + # optionally filters by label ID and account name. + rpc :ListChildAccounts, ::Google::Shopping::Css::V1::ListChildAccountsRequest, ::Google::Shopping::Css::V1::ListChildAccountsResponse + # Retrieves a single CSS/MC account by ID. + rpc :GetAccount, ::Google::Shopping::Css::V1::GetAccountRequest, ::Google::Shopping::Css::V1::Account + # Updates labels assigned to CSS/MC accounts by a CSS domain. + rpc :UpdateLabels, ::Google::Shopping::Css::V1::UpdateAccountLabelsRequest, ::Google::Shopping::Css::V1::Account + end + + Stub = Service.rpc_stub_class + end + end + end + end +end diff --git a/google-shopping-css-v1/lib/google/shopping/css/v1/css_product_common_pb.rb b/google-shopping-css-v1/lib/google/shopping/css/v1/css_product_common_pb.rb new file mode 100644 index 000000000000..c62fac21ea3c --- /dev/null +++ b/google-shopping-css-v1/lib/google/shopping/css/v1/css_product_common_pb.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/shopping/css/v1/css_product_common.proto + +require 'google/protobuf' + +require 'google/api/field_behavior_pb' +require 'google/protobuf/timestamp_pb' +require 'google/shopping/type/types_pb' + + +descriptor_data = "\n/google/shopping/css/v1/css_product_common.proto\x12\x16google.shopping.css.v1\x1a\x1fgoogle/api/field_behavior.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a google/shopping/type/types.proto\"\xe9\x10\n\nAttributes\x12\x15\n\x08\x63pp_link\x18\x01 \x01(\tH\x00\x88\x01\x01\x12\x1c\n\x0f\x63pp_mobile_link\x18\x02 \x01(\tH\x01\x88\x01\x01\x12\x1d\n\x10\x63pp_ads_redirect\x18* \x01(\tH\x02\x88\x01\x01\x12.\n\tlow_price\x18\x03 \x01(\x0b\x32\x1b.google.shopping.type.Price\x12/\n\nhigh_price\x18\x04 \x01(\x0b\x32\x1b.google.shopping.type.Price\x12\x1d\n\x10number_of_offers\x18\x05 \x01(\x03H\x03\x88\x01\x01\x12%\n\x18headline_offer_condition\x18\x06 \x01(\tH\x04\x88\x01\x01\x12\x39\n\x14headline_offer_price\x18\x07 \x01(\x0b\x32\x1b.google.shopping.type.Price\x12 \n\x13headline_offer_link\x18\x08 \x01(\tH\x05\x88\x01\x01\x12\'\n\x1aheadline_offer_mobile_link\x18\t \x01(\tH\x06\x88\x01\x01\x12\x42\n\x1dheadline_offer_shipping_price\x18) \x01(\x0b\x32\x1b.google.shopping.type.Price\x12\x12\n\x05title\x18\n \x01(\tH\x07\x88\x01\x01\x12\x17\n\nimage_link\x18\x0b \x01(\tH\x08\x88\x01\x01\x12\x1e\n\x16\x61\x64\x64itional_image_links\x18\x0c \x03(\t\x12\x18\n\x0b\x64\x65scription\x18\r \x01(\tH\t\x88\x01\x01\x12\x12\n\x05\x62rand\x18\x0e \x01(\tH\n\x88\x01\x01\x12\x10\n\x03mpn\x18\x0f \x01(\tH\x0b\x88\x01\x01\x12\x11\n\x04gtin\x18\x10 \x01(\tH\x0c\x88\x01\x01\x12\x15\n\rproduct_types\x18$ \x03(\t\x12$\n\x17google_product_category\x18\x11 \x01(\tH\r\x88\x01\x01\x12\x12\n\x05\x61\x64ult\x18\x12 \x01(\x08H\x0e\x88\x01\x01\x12\x16\n\tmultipack\x18\x13 \x01(\x03H\x0f\x88\x01\x01\x12\x16\n\tis_bundle\x18\x14 \x01(\x08H\x10\x88\x01\x01\x12\x16\n\tage_group\x18\x15 \x01(\tH\x11\x88\x01\x01\x12\x12\n\x05\x63olor\x18\x16 \x01(\tH\x12\x88\x01\x01\x12\x13\n\x06gender\x18\x17 \x01(\tH\x13\x88\x01\x01\x12\x15\n\x08material\x18\x18 \x01(\tH\x14\x88\x01\x01\x12\x14\n\x07pattern\x18\x19 \x01(\tH\x15\x88\x01\x01\x12\x11\n\x04size\x18\x1a \x01(\tH\x16\x88\x01\x01\x12\x18\n\x0bsize_system\x18\x1b \x01(\tH\x17\x88\x01\x01\x12\x12\n\nsize_types\x18\x1c \x03(\t\x12\x1a\n\ritem_group_id\x18\x1d \x01(\tH\x18\x88\x01\x01\x12>\n\x0fproduct_details\x18\x1e \x03(\x0b\x32%.google.shopping.css.v1.ProductDetail\x12=\n\x0eproduct_weight\x18\x1f \x01(\x0b\x32%.google.shopping.css.v1.ProductWeight\x12@\n\x0eproduct_length\x18 \x01(\x0b\x32(.google.shopping.css.v1.ProductDimension\x12?\n\rproduct_width\x18! \x01(\x0b\x32(.google.shopping.css.v1.ProductDimension\x12@\n\x0eproduct_height\x18\" \x01(\x0b\x32(.google.shopping.css.v1.ProductDimension\x12\x1a\n\x12product_highlights\x18# \x03(\t\x12=\n\x0e\x63\x65rtifications\x18\' \x03(\x0b\x32%.google.shopping.css.v1.Certification\x12\x33\n\x0f\x65xpiration_date\x18( \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x1d\n\x15included_destinations\x18+ \x03(\t\x12\x1d\n\x15\x65xcluded_destinations\x18, \x03(\t\x12\x12\n\x05pause\x18- \x01(\tH\x19\x88\x01\x01\x12\x1b\n\x0e\x63ustom_label_0\x18. \x01(\tH\x1a\x88\x01\x01\x12\x1b\n\x0e\x63ustom_label_1\x18/ \x01(\tH\x1b\x88\x01\x01\x12\x1b\n\x0e\x63ustom_label_2\x18\x30 \x01(\tH\x1c\x88\x01\x01\x12\x1b\n\x0e\x63ustom_label_3\x18\x31 \x01(\tH\x1d\x88\x01\x01\x12\x1b\n\x0e\x63ustom_label_4\x18\x32 \x01(\tH\x1e\x88\x01\x01\x42\x0b\n\t_cpp_linkB\x12\n\x10_cpp_mobile_linkB\x13\n\x11_cpp_ads_redirectB\x13\n\x11_number_of_offersB\x1b\n\x19_headline_offer_conditionB\x16\n\x14_headline_offer_linkB\x1d\n\x1b_headline_offer_mobile_linkB\x08\n\x06_titleB\r\n\x0b_image_linkB\x0e\n\x0c_descriptionB\x08\n\x06_brandB\x06\n\x04_mpnB\x07\n\x05_gtinB\x1a\n\x18_google_product_categoryB\x08\n\x06_adultB\x0c\n\n_multipackB\x0c\n\n_is_bundleB\x0c\n\n_age_groupB\x08\n\x06_colorB\t\n\x07_genderB\x0b\n\t_materialB\n\n\x08_patternB\x07\n\x05_sizeB\x0e\n\x0c_size_systemB\x10\n\x0e_item_group_idB\x08\n\x06_pauseB\x11\n\x0f_custom_label_0B\x11\n\x0f_custom_label_1B\x11\n\x0f_custom_label_2B\x11\n\x0f_custom_label_3B\x11\n\x0f_custom_label_4\">\n\rCertification\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x11\n\tauthority\x18\x02 \x01(\t\x12\x0c\n\x04\x63ode\x18\x03 \x01(\t\"V\n\rProductDetail\x12\x14\n\x0csection_name\x18\x01 \x01(\t\x12\x16\n\x0e\x61ttribute_name\x18\x02 \x01(\t\x12\x17\n\x0f\x61ttribute_value\x18\x03 \x01(\t\"9\n\x10ProductDimension\x12\x12\n\x05value\x18\x01 \x01(\x01\x42\x03\xe0\x41\x02\x12\x11\n\x04unit\x18\x02 \x01(\tB\x03\xe0\x41\x02\"6\n\rProductWeight\x12\x12\n\x05value\x18\x01 \x01(\x01\x42\x03\xe0\x41\x02\x12\x11\n\x04unit\x18\x02 \x01(\tB\x03\xe0\x41\x02\"\xb1\x05\n\x10\x43ssProductStatus\x12X\n\x14\x64\x65stination_statuses\x18\x03 \x03(\x0b\x32:.google.shopping.css.v1.CssProductStatus.DestinationStatus\x12R\n\x11item_level_issues\x18\x04 \x03(\x0b\x32\x37.google.shopping.css.v1.CssProductStatus.ItemLevelIssue\x12\x31\n\rcreation_date\x18\x05 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x34\n\x10last_update_date\x18\x06 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12:\n\x16google_expiration_date\x18\x07 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x1a~\n\x11\x44\x65stinationStatus\x12\x13\n\x0b\x64\x65stination\x18\x01 \x01(\t\x12\x1a\n\x12\x61pproved_countries\x18\x02 \x03(\t\x12\x19\n\x11pending_countries\x18\x03 \x03(\t\x12\x1d\n\x15\x64isapproved_countries\x18\x04 \x03(\t\x1a\xc9\x01\n\x0eItemLevelIssue\x12\x0c\n\x04\x63ode\x18\x01 \x01(\t\x12\x13\n\x0bservability\x18\x02 \x01(\t\x12\x12\n\nresolution\x18\x03 \x01(\t\x12\x11\n\tattribute\x18\x04 \x01(\t\x12\x13\n\x0b\x64\x65stination\x18\x05 \x01(\t\x12\x13\n\x0b\x64\x65scription\x18\x06 \x01(\t\x12\x0e\n\x06\x64\x65tail\x18\x07 \x01(\t\x12\x15\n\rdocumentation\x18\x08 \x01(\t\x12\x1c\n\x14\x61pplicable_countries\x18\t \x03(\tB\xb7\x01\n\x1a\x63om.google.shopping.css.v1B\x15\x43ssProductCommonProtoP\x01Z2cloud.google.com/go/shopping/css/apiv1/csspb;csspb\xaa\x02\x16Google.Shopping.Css.V1\xca\x02\x16Google\\Shopping\\Css\\V1\xea\x02\x19Google::Shopping::Css::V1b\x06proto3" + +pool = Google::Protobuf::DescriptorPool.generated_pool + +begin + pool.add_serialized_file(descriptor_data) +rescue TypeError + # Compatibility code: will be removed in the next major version. + require 'google/protobuf/descriptor_pb' + parsed = Google::Protobuf::FileDescriptorProto.decode(descriptor_data) + parsed.clear_dependency + serialized = parsed.class.encode(parsed) + file = pool.add_serialized_file(serialized) + warn "Warning: Protobuf detected an import path issue while loading generated file #{__FILE__}" + imports = [ + ["google.shopping.type.Price", "google/shopping/type/types.proto"], + ["google.protobuf.Timestamp", "google/protobuf/timestamp.proto"], + ] + imports.each do |type_name, expected_filename| + import_file = pool.lookup(type_name).file_descriptor + if import_file.name != expected_filename + warn "- #{file.name} imports #{expected_filename}, but that import was loaded as #{import_file.name}" + end + end + warn "Each proto file must use a consistent fully-qualified name." + warn "This will become an error in the next major version." +end + +module Google + module Shopping + module Css + module V1 + Attributes = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.css.v1.Attributes").msgclass + Certification = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.css.v1.Certification").msgclass + ProductDetail = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.css.v1.ProductDetail").msgclass + ProductDimension = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.css.v1.ProductDimension").msgclass + ProductWeight = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.css.v1.ProductWeight").msgclass + CssProductStatus = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.css.v1.CssProductStatus").msgclass + CssProductStatus::DestinationStatus = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.css.v1.CssProductStatus.DestinationStatus").msgclass + CssProductStatus::ItemLevelIssue = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.css.v1.CssProductStatus.ItemLevelIssue").msgclass + end + end + end +end diff --git a/google-shopping-css-v1/lib/google/shopping/css/v1/css_product_inputs_pb.rb b/google-shopping-css-v1/lib/google/shopping/css/v1/css_product_inputs_pb.rb new file mode 100644 index 000000000000..7e66523c8f6e --- /dev/null +++ b/google-shopping-css-v1/lib/google/shopping/css/v1/css_product_inputs_pb.rb @@ -0,0 +1,56 @@ +# frozen_string_literal: true +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/shopping/css/v1/css_product_inputs.proto + +require 'google/protobuf' + +require 'google/api/annotations_pb' +require 'google/api/client_pb' +require 'google/api/field_behavior_pb' +require 'google/api/resource_pb' +require 'google/protobuf/empty_pb' +require 'google/protobuf/timestamp_pb' +require 'google/shopping/css/v1/css_product_common_pb' +require 'google/shopping/type/types_pb' + + +descriptor_data = "\n/google/shopping/css/v1/css_product_inputs.proto\x12\x16google.shopping.css.v1\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a/google/shopping/css/v1/css_product_common.proto\x1a google/shopping/type/types.proto\"\x9e\x03\n\x0f\x43ssProductInput\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x17\n\nfinal_name\x18\x02 \x01(\tB\x03\xe0\x41\x03\x12\x1c\n\x0fraw_provided_id\x18\x03 \x01(\tB\x03\xe0\x41\x02\x12\x1d\n\x10\x63ontent_language\x18\x04 \x01(\tB\x03\xe0\x41\x02\x12\x17\n\nfeed_label\x18\x05 \x01(\tB\x03\xe0\x41\x02\x12\x32\n\x0e\x66reshness_time\x18\x06 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x36\n\nattributes\x18\x07 \x01(\x0b\x32\".google.shopping.css.v1.Attributes\x12@\n\x11\x63ustom_attributes\x18\x08 \x03(\x0b\x32%.google.shopping.type.CustomAttribute:`\xea\x41]\n\"css.googleapis.com/CssProductInput\x12\x37\x61\x63\x63ounts/{account}/cssProductInputs/{css_product_input}\"\xb9\x01\n\x1cInsertCssProductInputRequest\x12:\n\x06parent\x18\x01 \x01(\tB*\xe0\x41\x02\xfa\x41$\x12\"css.googleapis.com/CssProductInput\x12G\n\x11\x63ss_product_input\x18\x02 \x01(\x0b\x32\'.google.shopping.css.v1.CssProductInputB\x03\xe0\x41\x02\x12\x14\n\x07\x66\x65\x65\x64_id\x18\x03 \x01(\x03\x42\x03\xe0\x41\x02\"\x94\x01\n\x1c\x44\x65leteCssProductInputRequest\x12\x38\n\x04name\x18\x01 \x01(\tB*\xe0\x41\x02\xfa\x41$\n\"css.googleapis.com/CssProductInput\x12!\n\x14supplemental_feed_id\x18\x02 \x01(\x03H\x00\x88\x01\x01\x42\x17\n\x15_supplemental_feed_id2\xc0\x03\n\x17\x43ssProductInputsService\x12\xc2\x01\n\x15InsertCssProductInput\x12\x34.google.shopping.css.v1.InsertCssProductInputRequest\x1a\'.google.shopping.css.v1.CssProductInput\"J\x82\xd3\xe4\x93\x02\x44\"//v1/{parent=accounts/*}/cssProductInputs:insert:\x11\x63ss_product_input\x12\x9e\x01\n\x15\x44\x65leteCssProductInput\x12\x34.google.shopping.css.v1.DeleteCssProductInputRequest\x1a\x16.google.protobuf.Empty\"7\xda\x41\x04name\x82\xd3\xe4\x93\x02**(/v1/{name=accounts/*/cssProductInputs/*}\x1a?\xca\x41\x12\x63ss.googleapis.com\xd2\x41\'https://www.googleapis.com/auth/contentB\xb7\x01\n\x1a\x63om.google.shopping.css.v1B\x15\x43ssProductInputsProtoP\x01Z2cloud.google.com/go/shopping/css/apiv1/csspb;csspb\xaa\x02\x16Google.Shopping.Css.V1\xca\x02\x16Google\\Shopping\\Css\\V1\xea\x02\x19Google::Shopping::Css::V1b\x06proto3" + +pool = Google::Protobuf::DescriptorPool.generated_pool + +begin + pool.add_serialized_file(descriptor_data) +rescue TypeError + # Compatibility code: will be removed in the next major version. + require 'google/protobuf/descriptor_pb' + parsed = Google::Protobuf::FileDescriptorProto.decode(descriptor_data) + parsed.clear_dependency + serialized = parsed.class.encode(parsed) + file = pool.add_serialized_file(serialized) + warn "Warning: Protobuf detected an import path issue while loading generated file #{__FILE__}" + imports = [ + ["google.protobuf.Timestamp", "google/protobuf/timestamp.proto"], + ["google.shopping.css.v1.Attributes", "google/shopping/css/v1/css_product_common.proto"], + ["google.shopping.type.CustomAttribute", "google/shopping/type/types.proto"], + ] + imports.each do |type_name, expected_filename| + import_file = pool.lookup(type_name).file_descriptor + if import_file.name != expected_filename + warn "- #{file.name} imports #{expected_filename}, but that import was loaded as #{import_file.name}" + end + end + warn "Each proto file must use a consistent fully-qualified name." + warn "This will become an error in the next major version." +end + +module Google + module Shopping + module Css + module V1 + CssProductInput = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.css.v1.CssProductInput").msgclass + InsertCssProductInputRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.css.v1.InsertCssProductInputRequest").msgclass + DeleteCssProductInputRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.css.v1.DeleteCssProductInputRequest").msgclass + end + end + end +end diff --git a/google-shopping-css-v1/lib/google/shopping/css/v1/css_product_inputs_service.rb b/google-shopping-css-v1/lib/google/shopping/css/v1/css_product_inputs_service.rb new file mode 100644 index 000000000000..11f8f806c9ce --- /dev/null +++ b/google-shopping-css-v1/lib/google/shopping/css/v1/css_product_inputs_service.rb @@ -0,0 +1,56 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "gapic/common" +require "gapic/config" +require "gapic/config/method" + +require "google/shopping/css/v1/version" + +require "google/shopping/css/v1/css_product_inputs_service/credentials" +require "google/shopping/css/v1/css_product_inputs_service/paths" +require "google/shopping/css/v1/css_product_inputs_service/client" +require "google/shopping/css/v1/css_product_inputs_service/rest" + +module Google + module Shopping + module Css + module V1 + ## + # Service to use CssProductInput resource. + # This service helps to insert/update/delete CSS Products. + # + # @example Load this service and instantiate a gRPC client + # + # require "google/shopping/css/v1/css_product_inputs_service" + # client = ::Google::Shopping::Css::V1::CssProductInputsService::Client.new + # + # @example Load this service and instantiate a REST client + # + # require "google/shopping/css/v1/css_product_inputs_service/rest" + # client = ::Google::Shopping::Css::V1::CssProductInputsService::Rest::Client.new + # + module CssProductInputsService + end + end + end + end +end + +helper_path = ::File.join __dir__, "css_product_inputs_service", "helpers.rb" +require "google/shopping/css/v1/css_product_inputs_service/helpers" if ::File.file? helper_path diff --git a/google-shopping-css-v1/lib/google/shopping/css/v1/css_product_inputs_service/client.rb b/google-shopping-css-v1/lib/google/shopping/css/v1/css_product_inputs_service/client.rb new file mode 100644 index 000000000000..76138041d2ea --- /dev/null +++ b/google-shopping-css-v1/lib/google/shopping/css/v1/css_product_inputs_service/client.rb @@ -0,0 +1,546 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/cloud/errors" +require "google/shopping/css/v1/css_product_inputs_pb" + +module Google + module Shopping + module Css + module V1 + module CssProductInputsService + ## + # Client for the CssProductInputsService service. + # + # Service to use CssProductInput resource. + # This service helps to insert/update/delete CSS Products. + # + class Client + # @private + API_VERSION = "" + + # @private + DEFAULT_ENDPOINT_TEMPLATE = "css.$UNIVERSE_DOMAIN$" + + include Paths + + # @private + attr_reader :css_product_inputs_service_stub + + ## + # Configure the CssProductInputsService Client class. + # + # See {::Google::Shopping::Css::V1::CssProductInputsService::Client::Configuration} + # for a description of the configuration fields. + # + # @example + # + # # Modify the configuration for all CssProductInputsService clients + # ::Google::Shopping::Css::V1::CssProductInputsService::Client.configure do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def self.configure + @configure ||= begin + namespace = ["Google", "Shopping", "Css", "V1"] + parent_config = while namespace.any? + parent_name = namespace.join "::" + parent_const = const_get parent_name + break parent_const.configure if parent_const.respond_to? :configure + namespace.pop + end + default_config = Client::Configuration.new parent_config + + default_config.rpcs.insert_css_product_input.timeout = 60.0 + + default_config.rpcs.delete_css_product_input.timeout = 60.0 + + default_config + end + yield @configure if block_given? + @configure + end + + ## + # Configure the CssProductInputsService Client instance. + # + # The configuration is set to the derived mode, meaning that values can be changed, + # but structural changes (adding new fields, etc.) are not allowed. Structural changes + # should be made on {Client.configure}. + # + # See {::Google::Shopping::Css::V1::CssProductInputsService::Client::Configuration} + # for a description of the configuration fields. + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def configure + yield @config if block_given? + @config + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @css_product_inputs_service_stub.universe_domain + end + + ## + # Create a new CssProductInputsService client object. + # + # @example + # + # # Create a client using the default configuration + # client = ::Google::Shopping::Css::V1::CssProductInputsService::Client.new + # + # # Create a client using a custom configuration + # client = ::Google::Shopping::Css::V1::CssProductInputsService::Client.new do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the CssProductInputsService client. + # @yieldparam config [Client::Configuration] + # + def initialize + # These require statements are intentionally placed here to initialize + # the gRPC module only when it's required. + # See https://github.com/googleapis/toolkit/issues/446 + require "gapic/grpc" + require "google/shopping/css/v1/css_product_inputs_services_pb" + + # Create the configuration object + @config = Configuration.new Client.configure + + # Yield the configuration if needed + yield @config if block_given? + + # Create credentials + credentials = @config.credentials + # Use self-signed JWT if the endpoint is unchanged from default, + # but only if the default endpoint does not have a region prefix. + enable_self_signed_jwt = @config.endpoint.nil? || + (@config.endpoint == Configuration::DEFAULT_ENDPOINT && + !@config.endpoint.split(".").first.include?("-")) + credentials ||= Credentials.default scope: @config.scope, + enable_self_signed_jwt: enable_self_signed_jwt + if credentials.is_a?(::String) || credentials.is_a?(::Hash) + credentials = Credentials.new credentials, scope: @config.scope + end + @quota_project_id = @config.quota_project + @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id + + @css_product_inputs_service_stub = ::Gapic::ServiceStub.new( + ::Google::Shopping::Css::V1::CssProductInputsService::Stub, + credentials: credentials, + endpoint: @config.endpoint, + endpoint_template: DEFAULT_ENDPOINT_TEMPLATE, + universe_domain: @config.universe_domain, + channel_args: @config.channel_args, + interceptors: @config.interceptors, + channel_pool_config: @config.channel_pool + ) + end + + # Service calls + + ## + # Uploads a CssProductInput to your CSS Center account. If an + # input with the same contentLanguage, identity, feedLabel and feedId already + # exists, this method replaces that entry. + # + # After inserting, updating, or deleting a CSS Product input, it may + # take several minutes before the processed CSS Product can be retrieved. + # + # @overload insert_css_product_input(request, options = nil) + # Pass arguments to `insert_css_product_input` via a request object, either of type + # {::Google::Shopping::Css::V1::InsertCssProductInputRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Css::V1::InsertCssProductInputRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload insert_css_product_input(parent: nil, css_product_input: nil, feed_id: nil) + # Pass arguments to `insert_css_product_input` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param parent [::String] + # Required. The account where this CSS Product will be inserted. + # Format: accounts/\\{account} + # @param css_product_input [::Google::Shopping::Css::V1::CssProductInput, ::Hash] + # Required. The CSS Product Input to insert. + # @param feed_id [::Integer] + # Required. The primary or supplemental feed id. If CSS Product already + # exists and feed id provided is different, then the CSS Product will be + # moved to a new feed. Note: For now, CSSs do not need to provide feed ids as + # we create feeds on the fly. We do not have supplemental feed support for + # CSS Products yet. + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Google::Shopping::Css::V1::CssProductInput] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Google::Shopping::Css::V1::CssProductInput] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/shopping/css/v1" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Css::V1::CssProductInputsService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Css::V1::InsertCssProductInputRequest.new + # + # # Call the insert_css_product_input method. + # result = client.insert_css_product_input request + # + # # The returned object is of type Google::Shopping::Css::V1::CssProductInput. + # p result + # + def insert_css_product_input request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Css::V1::InsertCssProductInputRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + metadata = @config.rpcs.insert_css_product_input.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Css::V1::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + header_params = {} + if request.parent + header_params["parent"] = request.parent + end + + request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") + metadata[:"x-goog-request-params"] ||= request_params_header + + options.apply_defaults timeout: @config.rpcs.insert_css_product_input.timeout, + metadata: metadata, + retry_policy: @config.rpcs.insert_css_product_input.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @css_product_inputs_service_stub.call_rpc :insert_css_product_input, request, options: options do |response, operation| + yield response, operation if block_given? + return response + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Deletes a CSS Product input from your CSS Center account. + # + # After a delete it may take several minutes until the input is no longer + # available. + # + # @overload delete_css_product_input(request, options = nil) + # Pass arguments to `delete_css_product_input` via a request object, either of type + # {::Google::Shopping::Css::V1::DeleteCssProductInputRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Css::V1::DeleteCssProductInputRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload delete_css_product_input(name: nil, supplemental_feed_id: nil) + # Pass arguments to `delete_css_product_input` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param name [::String] + # Required. The name of the CSS product input resource to delete. + # Format: accounts/\\{account}/cssProductInputs/\\{css_product_input} + # @param supplemental_feed_id [::Integer] + # The Content API Supplemental Feed ID. + # The field must not be set if the action applies to a primary feed. + # If the field is set, then product action applies to a supplemental feed + # instead of primary Content API feed. + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Google::Protobuf::Empty] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Google::Protobuf::Empty] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/shopping/css/v1" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Css::V1::CssProductInputsService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Css::V1::DeleteCssProductInputRequest.new + # + # # Call the delete_css_product_input method. + # result = client.delete_css_product_input request + # + # # The returned object is of type Google::Protobuf::Empty. + # p result + # + def delete_css_product_input request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Css::V1::DeleteCssProductInputRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + metadata = @config.rpcs.delete_css_product_input.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Css::V1::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + header_params = {} + if request.name + header_params["name"] = request.name + end + + request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") + metadata[:"x-goog-request-params"] ||= request_params_header + + options.apply_defaults timeout: @config.rpcs.delete_css_product_input.timeout, + metadata: metadata, + retry_policy: @config.rpcs.delete_css_product_input.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @css_product_inputs_service_stub.call_rpc :delete_css_product_input, request, options: options do |response, operation| + yield response, operation if block_given? + return response + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Configuration class for the CssProductInputsService API. + # + # This class represents the configuration for CssProductInputsService, + # providing control over timeouts, retry behavior, logging, transport + # parameters, and other low-level controls. Certain parameters can also be + # applied individually to specific RPCs. See + # {::Google::Shopping::Css::V1::CssProductInputsService::Client::Configuration::Rpcs} + # for a list of RPCs that can be configured independently. + # + # Configuration can be applied globally to all clients, or to a single client + # on construction. + # + # @example + # + # # Modify the global config, setting the timeout for + # # insert_css_product_input to 20 seconds, + # # and all remaining timeouts to 10 seconds. + # ::Google::Shopping::Css::V1::CssProductInputsService::Client.configure do |config| + # config.timeout = 10.0 + # config.rpcs.insert_css_product_input.timeout = 20.0 + # end + # + # # Apply the above configuration only to a new client. + # client = ::Google::Shopping::Css::V1::CssProductInputsService::Client.new do |config| + # config.timeout = 10.0 + # config.rpcs.insert_css_product_input.timeout = 20.0 + # end + # + # @!attribute [rw] endpoint + # A custom service endpoint, as a hostname or hostname:port. The default is + # nil, indicating to use the default endpoint in the current universe domain. + # @return [::String,nil] + # @!attribute [rw] credentials + # Credentials to send with calls. You may provide any of the following types: + # * (`String`) The path to a service account key file in JSON format + # * (`Hash`) A service account key as a Hash + # * (`Google::Auth::Credentials`) A googleauth credentials object + # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials)) + # * (`Signet::OAuth2::Client`) A signet oauth2 client object + # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client)) + # * (`GRPC::Core::Channel`) a gRPC channel with included credentials + # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object + # * (`nil`) indicating no credentials + # @return [::Object] + # @!attribute [rw] scope + # The OAuth scopes + # @return [::Array<::String>] + # @!attribute [rw] lib_name + # The library name as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] lib_version + # The library version as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] channel_args + # Extra parameters passed to the gRPC channel. Note: this is ignored if a + # `GRPC::Core::Channel` object is provided as the credential. + # @return [::Hash] + # @!attribute [rw] interceptors + # An array of interceptors that are run before calls are executed. + # @return [::Array<::GRPC::ClientInterceptor>] + # @!attribute [rw] timeout + # The call timeout in seconds. + # @return [::Numeric] + # @!attribute [rw] metadata + # Additional gRPC headers to be sent with the call. + # @return [::Hash{::Symbol=>::String}] + # @!attribute [rw] retry_policy + # The retry policy. The value is a hash with the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # @return [::Hash] + # @!attribute [rw] quota_project + # A separate project against which to charge quota. + # @return [::String] + # @!attribute [rw] universe_domain + # The universe domain within which to make requests. This determines the + # default endpoint URL. The default value of nil uses the environment + # universe (usually the default "googleapis.com" universe). + # @return [::String,nil] + # + class Configuration + extend ::Gapic::Config + + # @private + # The endpoint specific to the default "googleapis.com" universe. Deprecated. + DEFAULT_ENDPOINT = "css.googleapis.com" + + config_attr :endpoint, nil, ::String, nil + config_attr :credentials, nil do |value| + allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil] + allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC + allowed.any? { |klass| klass === value } + end + config_attr :scope, nil, ::String, ::Array, nil + config_attr :lib_name, nil, ::String, nil + config_attr :lib_version, nil, ::String, nil + config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil) + config_attr :interceptors, nil, ::Array, nil + config_attr :timeout, nil, ::Numeric, nil + config_attr :metadata, nil, ::Hash, nil + config_attr :retry_policy, nil, ::Hash, ::Proc, nil + config_attr :quota_project, nil, ::String, nil + config_attr :universe_domain, nil, ::String, nil + + # @private + def initialize parent_config = nil + @parent_config = parent_config unless parent_config.nil? + + yield self if block_given? + end + + ## + # Configurations for individual RPCs + # @return [Rpcs] + # + def rpcs + @rpcs ||= begin + parent_rpcs = nil + parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs) + Rpcs.new parent_rpcs + end + end + + ## + # Configuration for the channel pool + # @return [::Gapic::ServiceStub::ChannelPool::Configuration] + # + def channel_pool + @channel_pool ||= ::Gapic::ServiceStub::ChannelPool::Configuration.new + end + + ## + # Configuration RPC class for the CssProductInputsService API. + # + # Includes fields providing the configuration for each RPC in this service. + # Each configuration object is of type `Gapic::Config::Method` and includes + # the following configuration fields: + # + # * `timeout` (*type:* `Numeric`) - The call timeout in seconds + # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers + # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields + # include the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # + class Rpcs + ## + # RPC-specific configuration for `insert_css_product_input` + # @return [::Gapic::Config::Method] + # + attr_reader :insert_css_product_input + ## + # RPC-specific configuration for `delete_css_product_input` + # @return [::Gapic::Config::Method] + # + attr_reader :delete_css_product_input + + # @private + def initialize parent_rpcs = nil + insert_css_product_input_config = parent_rpcs.insert_css_product_input if parent_rpcs.respond_to? :insert_css_product_input + @insert_css_product_input = ::Gapic::Config::Method.new insert_css_product_input_config + delete_css_product_input_config = parent_rpcs.delete_css_product_input if parent_rpcs.respond_to? :delete_css_product_input + @delete_css_product_input = ::Gapic::Config::Method.new delete_css_product_input_config + + yield self if block_given? + end + end + end + end + end + end + end + end +end diff --git a/google-shopping-css-v1/lib/google/shopping/css/v1/css_product_inputs_service/credentials.rb b/google-shopping-css-v1/lib/google/shopping/css/v1/css_product_inputs_service/credentials.rb new file mode 100644 index 000000000000..09f1c65b86ae --- /dev/null +++ b/google-shopping-css-v1/lib/google/shopping/css/v1/css_product_inputs_service/credentials.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "googleauth" + +module Google + module Shopping + module Css + module V1 + module CssProductInputsService + # Credentials for the CssProductInputsService API. + class Credentials < ::Google::Auth::Credentials + self.scope = [ + "https://www.googleapis.com/auth/content" + ] + self.env_vars = [ + "GOOGLE_CLOUD_CREDENTIALS", + "GOOGLE_CLOUD_KEYFILE", + "GCLOUD_KEYFILE", + "GOOGLE_CLOUD_CREDENTIALS_JSON", + "GOOGLE_CLOUD_KEYFILE_JSON", + "GCLOUD_KEYFILE_JSON" + ] + self.paths = [ + "~/.config/google_cloud/application_default_credentials.json" + ] + end + end + end + end + end +end diff --git a/google-shopping-css-v1/lib/google/shopping/css/v1/css_product_inputs_service/paths.rb b/google-shopping-css-v1/lib/google/shopping/css/v1/css_product_inputs_service/paths.rb new file mode 100644 index 000000000000..d3affcac0d30 --- /dev/null +++ b/google-shopping-css-v1/lib/google/shopping/css/v1/css_product_inputs_service/paths.rb @@ -0,0 +1,64 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Shopping + module Css + module V1 + module CssProductInputsService + # Path helper methods for the CssProductInputsService API. + module Paths + ## + # Create a fully-qualified Account resource string. + # + # The resource will be in the following format: + # + # `accounts/{account}` + # + # @param account [String] + # + # @return [::String] + def account_path account: + "accounts/#{account}" + end + + ## + # Create a fully-qualified CssProductInput resource string. + # + # The resource will be in the following format: + # + # `accounts/{account}/cssProductInputs/{css_product_input}` + # + # @param account [String] + # @param css_product_input [String] + # + # @return [::String] + def css_product_input_path account:, css_product_input: + raise ::ArgumentError, "account cannot contain /" if account.to_s.include? "/" + + "accounts/#{account}/cssProductInputs/#{css_product_input}" + end + + extend self + end + end + end + end + end +end diff --git a/google-shopping-css-v1/lib/google/shopping/css/v1/css_product_inputs_service/rest.rb b/google-shopping-css-v1/lib/google/shopping/css/v1/css_product_inputs_service/rest.rb new file mode 100644 index 000000000000..976414ca6f87 --- /dev/null +++ b/google-shopping-css-v1/lib/google/shopping/css/v1/css_product_inputs_service/rest.rb @@ -0,0 +1,53 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "gapic/rest" +require "gapic/config" +require "gapic/config/method" + +require "google/shopping/css/v1/version" + +require "google/shopping/css/v1/css_product_inputs_service/credentials" +require "google/shopping/css/v1/css_product_inputs_service/paths" +require "google/shopping/css/v1/css_product_inputs_service/rest/client" + +module Google + module Shopping + module Css + module V1 + ## + # Service to use CssProductInput resource. + # This service helps to insert/update/delete CSS Products. + # + # To load this service and instantiate a REST client: + # + # require "google/shopping/css/v1/css_product_inputs_service/rest" + # client = ::Google::Shopping::Css::V1::CssProductInputsService::Rest::Client.new + # + module CssProductInputsService + # Client for the REST transport + module Rest + end + end + end + end + end +end + +helper_path = ::File.join __dir__, "rest", "helpers.rb" +require "google/shopping/css/v1/css_product_inputs_service/rest/helpers" if ::File.file? helper_path diff --git a/google-shopping-css-v1/lib/google/shopping/css/v1/css_product_inputs_service/rest/client.rb b/google-shopping-css-v1/lib/google/shopping/css/v1/css_product_inputs_service/rest/client.rb new file mode 100644 index 000000000000..dfc4665b3f5e --- /dev/null +++ b/google-shopping-css-v1/lib/google/shopping/css/v1/css_product_inputs_service/rest/client.rb @@ -0,0 +1,506 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/cloud/errors" +require "google/shopping/css/v1/css_product_inputs_pb" +require "google/shopping/css/v1/css_product_inputs_service/rest/service_stub" + +module Google + module Shopping + module Css + module V1 + module CssProductInputsService + module Rest + ## + # REST client for the CssProductInputsService service. + # + # Service to use CssProductInput resource. + # This service helps to insert/update/delete CSS Products. + # + class Client + # @private + API_VERSION = "" + + # @private + DEFAULT_ENDPOINT_TEMPLATE = "css.$UNIVERSE_DOMAIN$" + + include Paths + + # @private + attr_reader :css_product_inputs_service_stub + + ## + # Configure the CssProductInputsService Client class. + # + # See {::Google::Shopping::Css::V1::CssProductInputsService::Rest::Client::Configuration} + # for a description of the configuration fields. + # + # @example + # + # # Modify the configuration for all CssProductInputsService clients + # ::Google::Shopping::Css::V1::CssProductInputsService::Rest::Client.configure do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def self.configure + @configure ||= begin + namespace = ["Google", "Shopping", "Css", "V1"] + parent_config = while namespace.any? + parent_name = namespace.join "::" + parent_const = const_get parent_name + break parent_const.configure if parent_const.respond_to? :configure + namespace.pop + end + default_config = Client::Configuration.new parent_config + + default_config.rpcs.insert_css_product_input.timeout = 60.0 + + default_config.rpcs.delete_css_product_input.timeout = 60.0 + + default_config + end + yield @configure if block_given? + @configure + end + + ## + # Configure the CssProductInputsService Client instance. + # + # The configuration is set to the derived mode, meaning that values can be changed, + # but structural changes (adding new fields, etc.) are not allowed. Structural changes + # should be made on {Client.configure}. + # + # See {::Google::Shopping::Css::V1::CssProductInputsService::Rest::Client::Configuration} + # for a description of the configuration fields. + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def configure + yield @config if block_given? + @config + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @css_product_inputs_service_stub.universe_domain + end + + ## + # Create a new CssProductInputsService REST client object. + # + # @example + # + # # Create a client using the default configuration + # client = ::Google::Shopping::Css::V1::CssProductInputsService::Rest::Client.new + # + # # Create a client using a custom configuration + # client = ::Google::Shopping::Css::V1::CssProductInputsService::Rest::Client.new do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the CssProductInputsService client. + # @yieldparam config [Client::Configuration] + # + def initialize + # Create the configuration object + @config = Configuration.new Client.configure + + # Yield the configuration if needed + yield @config if block_given? + + # Create credentials + credentials = @config.credentials + # Use self-signed JWT if the endpoint is unchanged from default, + # but only if the default endpoint does not have a region prefix. + enable_self_signed_jwt = @config.endpoint.nil? || + (@config.endpoint == Configuration::DEFAULT_ENDPOINT && + !@config.endpoint.split(".").first.include?("-")) + credentials ||= Credentials.default scope: @config.scope, + enable_self_signed_jwt: enable_self_signed_jwt + if credentials.is_a?(::String) || credentials.is_a?(::Hash) + credentials = Credentials.new credentials, scope: @config.scope + end + + @quota_project_id = @config.quota_project + @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id + + @css_product_inputs_service_stub = ::Google::Shopping::Css::V1::CssProductInputsService::Rest::ServiceStub.new( + endpoint: @config.endpoint, + endpoint_template: DEFAULT_ENDPOINT_TEMPLATE, + universe_domain: @config.universe_domain, + credentials: credentials + ) + end + + # Service calls + + ## + # Uploads a CssProductInput to your CSS Center account. If an + # input with the same contentLanguage, identity, feedLabel and feedId already + # exists, this method replaces that entry. + # + # After inserting, updating, or deleting a CSS Product input, it may + # take several minutes before the processed CSS Product can be retrieved. + # + # @overload insert_css_product_input(request, options = nil) + # Pass arguments to `insert_css_product_input` via a request object, either of type + # {::Google::Shopping::Css::V1::InsertCssProductInputRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Css::V1::InsertCssProductInputRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload insert_css_product_input(parent: nil, css_product_input: nil, feed_id: nil) + # Pass arguments to `insert_css_product_input` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param parent [::String] + # Required. The account where this CSS Product will be inserted. + # Format: accounts/\\{account} + # @param css_product_input [::Google::Shopping::Css::V1::CssProductInput, ::Hash] + # Required. The CSS Product Input to insert. + # @param feed_id [::Integer] + # Required. The primary or supplemental feed id. If CSS Product already + # exists and feed id provided is different, then the CSS Product will be + # moved to a new feed. Note: For now, CSSs do not need to provide feed ids as + # we create feeds on the fly. We do not have supplemental feed support for + # CSS Products yet. + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Css::V1::CssProductInput] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Css::V1::CssProductInput] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/shopping/css/v1" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Css::V1::CssProductInputsService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Css::V1::InsertCssProductInputRequest.new + # + # # Call the insert_css_product_input method. + # result = client.insert_css_product_input request + # + # # The returned object is of type Google::Shopping::Css::V1::CssProductInput. + # p result + # + def insert_css_product_input request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Css::V1::InsertCssProductInputRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.insert_css_product_input.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Css::V1::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.insert_css_product_input.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.insert_css_product_input.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @css_product_inputs_service_stub.insert_css_product_input request, options do |result, operation| + yield result, operation if block_given? + return result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Deletes a CSS Product input from your CSS Center account. + # + # After a delete it may take several minutes until the input is no longer + # available. + # + # @overload delete_css_product_input(request, options = nil) + # Pass arguments to `delete_css_product_input` via a request object, either of type + # {::Google::Shopping::Css::V1::DeleteCssProductInputRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Css::V1::DeleteCssProductInputRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload delete_css_product_input(name: nil, supplemental_feed_id: nil) + # Pass arguments to `delete_css_product_input` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param name [::String] + # Required. The name of the CSS product input resource to delete. + # Format: accounts/\\{account}/cssProductInputs/\\{css_product_input} + # @param supplemental_feed_id [::Integer] + # The Content API Supplemental Feed ID. + # The field must not be set if the action applies to a primary feed. + # If the field is set, then product action applies to a supplemental feed + # instead of primary Content API feed. + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Protobuf::Empty] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Protobuf::Empty] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/shopping/css/v1" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Css::V1::CssProductInputsService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Css::V1::DeleteCssProductInputRequest.new + # + # # Call the delete_css_product_input method. + # result = client.delete_css_product_input request + # + # # The returned object is of type Google::Protobuf::Empty. + # p result + # + def delete_css_product_input request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Css::V1::DeleteCssProductInputRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.delete_css_product_input.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Css::V1::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.delete_css_product_input.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.delete_css_product_input.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @css_product_inputs_service_stub.delete_css_product_input request, options do |result, operation| + yield result, operation if block_given? + return result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Configuration class for the CssProductInputsService REST API. + # + # This class represents the configuration for CssProductInputsService REST, + # providing control over timeouts, retry behavior, logging, transport + # parameters, and other low-level controls. Certain parameters can also be + # applied individually to specific RPCs. See + # {::Google::Shopping::Css::V1::CssProductInputsService::Rest::Client::Configuration::Rpcs} + # for a list of RPCs that can be configured independently. + # + # Configuration can be applied globally to all clients, or to a single client + # on construction. + # + # @example + # + # # Modify the global config, setting the timeout for + # # insert_css_product_input to 20 seconds, + # # and all remaining timeouts to 10 seconds. + # ::Google::Shopping::Css::V1::CssProductInputsService::Rest::Client.configure do |config| + # config.timeout = 10.0 + # config.rpcs.insert_css_product_input.timeout = 20.0 + # end + # + # # Apply the above configuration only to a new client. + # client = ::Google::Shopping::Css::V1::CssProductInputsService::Rest::Client.new do |config| + # config.timeout = 10.0 + # config.rpcs.insert_css_product_input.timeout = 20.0 + # end + # + # @!attribute [rw] endpoint + # A custom service endpoint, as a hostname or hostname:port. The default is + # nil, indicating to use the default endpoint in the current universe domain. + # @return [::String,nil] + # @!attribute [rw] credentials + # Credentials to send with calls. You may provide any of the following types: + # * (`String`) The path to a service account key file in JSON format + # * (`Hash`) A service account key as a Hash + # * (`Google::Auth::Credentials`) A googleauth credentials object + # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials)) + # * (`Signet::OAuth2::Client`) A signet oauth2 client object + # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client)) + # * (`nil`) indicating no credentials + # @return [::Object] + # @!attribute [rw] scope + # The OAuth scopes + # @return [::Array<::String>] + # @!attribute [rw] lib_name + # The library name as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] lib_version + # The library version as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] timeout + # The call timeout in seconds. + # @return [::Numeric] + # @!attribute [rw] metadata + # Additional headers to be sent with the call. + # @return [::Hash{::Symbol=>::String}] + # @!attribute [rw] retry_policy + # The retry policy. The value is a hash with the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # @return [::Hash] + # @!attribute [rw] quota_project + # A separate project against which to charge quota. + # @return [::String] + # @!attribute [rw] universe_domain + # The universe domain within which to make requests. This determines the + # default endpoint URL. The default value of nil uses the environment + # universe (usually the default "googleapis.com" universe). + # @return [::String,nil] + # + class Configuration + extend ::Gapic::Config + + # @private + # The endpoint specific to the default "googleapis.com" universe. Deprecated. + DEFAULT_ENDPOINT = "css.googleapis.com" + + config_attr :endpoint, nil, ::String, nil + config_attr :credentials, nil do |value| + allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil] + allowed.any? { |klass| klass === value } + end + config_attr :scope, nil, ::String, ::Array, nil + config_attr :lib_name, nil, ::String, nil + config_attr :lib_version, nil, ::String, nil + config_attr :timeout, nil, ::Numeric, nil + config_attr :metadata, nil, ::Hash, nil + config_attr :retry_policy, nil, ::Hash, ::Proc, nil + config_attr :quota_project, nil, ::String, nil + config_attr :universe_domain, nil, ::String, nil + + # @private + def initialize parent_config = nil + @parent_config = parent_config unless parent_config.nil? + + yield self if block_given? + end + + ## + # Configurations for individual RPCs + # @return [Rpcs] + # + def rpcs + @rpcs ||= begin + parent_rpcs = nil + parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs) + Rpcs.new parent_rpcs + end + end + + ## + # Configuration RPC class for the CssProductInputsService API. + # + # Includes fields providing the configuration for each RPC in this service. + # Each configuration object is of type `Gapic::Config::Method` and includes + # the following configuration fields: + # + # * `timeout` (*type:* `Numeric`) - The call timeout in seconds + # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers + # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields + # include the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # + class Rpcs + ## + # RPC-specific configuration for `insert_css_product_input` + # @return [::Gapic::Config::Method] + # + attr_reader :insert_css_product_input + ## + # RPC-specific configuration for `delete_css_product_input` + # @return [::Gapic::Config::Method] + # + attr_reader :delete_css_product_input + + # @private + def initialize parent_rpcs = nil + insert_css_product_input_config = parent_rpcs.insert_css_product_input if parent_rpcs.respond_to? :insert_css_product_input + @insert_css_product_input = ::Gapic::Config::Method.new insert_css_product_input_config + delete_css_product_input_config = parent_rpcs.delete_css_product_input if parent_rpcs.respond_to? :delete_css_product_input + @delete_css_product_input = ::Gapic::Config::Method.new delete_css_product_input_config + + yield self if block_given? + end + end + end + end + end + end + end + end + end +end diff --git a/google-shopping-css-v1/lib/google/shopping/css/v1/css_product_inputs_service/rest/service_stub.rb b/google-shopping-css-v1/lib/google/shopping/css/v1/css_product_inputs_service/rest/service_stub.rb new file mode 100644 index 000000000000..1ed8aa6074ad --- /dev/null +++ b/google-shopping-css-v1/lib/google/shopping/css/v1/css_product_inputs_service/rest/service_stub.rb @@ -0,0 +1,188 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/shopping/css/v1/css_product_inputs_pb" + +module Google + module Shopping + module Css + module V1 + module CssProductInputsService + module Rest + ## + # REST service stub for the CssProductInputsService service. + # Service stub contains baseline method implementations + # including transcoding, making the REST call, and deserialing the response. + # + class ServiceStub + def initialize endpoint:, endpoint_template:, universe_domain:, credentials: + # These require statements are intentionally placed here to initialize + # the REST modules only when it's required. + require "gapic/rest" + + @client_stub = ::Gapic::Rest::ClientStub.new endpoint: endpoint, + endpoint_template: endpoint_template, + universe_domain: universe_domain, + credentials: credentials, + numeric_enums: true, + raise_faraday_errors: false + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @client_stub.universe_domain + end + + ## + # The effective endpoint + # + # @return [String] + # + def endpoint + @client_stub.endpoint + end + + ## + # Baseline implementation for the insert_css_product_input REST call + # + # @param request_pb [::Google::Shopping::Css::V1::InsertCssProductInputRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Css::V1::CssProductInput] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Css::V1::CssProductInput] + # A result object deserialized from the server's reply + def insert_css_product_input request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_insert_css_product_input_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Shopping::Css::V1::CssProductInput.decode_json response.body, ignore_unknown_fields: true + + yield result, operation if block_given? + result + end + + ## + # Baseline implementation for the delete_css_product_input REST call + # + # @param request_pb [::Google::Shopping::Css::V1::DeleteCssProductInputRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Protobuf::Empty] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Protobuf::Empty] + # A result object deserialized from the server's reply + def delete_css_product_input request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_delete_css_product_input_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Protobuf::Empty.decode_json response.body, ignore_unknown_fields: true + + yield result, operation if block_given? + result + end + + ## + # @private + # + # GRPC transcoding helper method for the insert_css_product_input REST call + # + # @param request_pb [::Google::Shopping::Css::V1::InsertCssProductInputRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_insert_css_product_input_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :post, + uri_template: "/v1/{parent}/cssProductInputs:insert", + body: "css_product_input", + matches: [ + ["parent", %r{^accounts/[^/]+/?$}, false] + ] + ) + transcoder.transcode request_pb + end + + ## + # @private + # + # GRPC transcoding helper method for the delete_css_product_input REST call + # + # @param request_pb [::Google::Shopping::Css::V1::DeleteCssProductInputRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_delete_css_product_input_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :delete, + uri_template: "/v1/{name}", + matches: [ + ["name", %r{^accounts/[^/]+/cssProductInputs/[^/]+/?$}, false] + ] + ) + transcoder.transcode request_pb + end + end + end + end + end + end + end +end diff --git a/google-shopping-css-v1/lib/google/shopping/css/v1/css_product_inputs_services_pb.rb b/google-shopping-css-v1/lib/google/shopping/css/v1/css_product_inputs_services_pb.rb new file mode 100644 index 000000000000..976633f2b6b9 --- /dev/null +++ b/google-shopping-css-v1/lib/google/shopping/css/v1/css_product_inputs_services_pb.rb @@ -0,0 +1,56 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# Source: google/shopping/css/v1/css_product_inputs.proto for package 'Google.Shopping.Css.V1' +# Original file comments: +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +require 'grpc' +require 'google/shopping/css/v1/css_product_inputs_pb' + +module Google + module Shopping + module Css + module V1 + module CssProductInputsService + # Service to use CssProductInput resource. + # This service helps to insert/update/delete CSS Products. + class Service + + include ::GRPC::GenericService + + self.marshal_class_method = :encode + self.unmarshal_class_method = :decode + self.service_name = 'google.shopping.css.v1.CssProductInputsService' + + # Uploads a CssProductInput to your CSS Center account. If an + # input with the same contentLanguage, identity, feedLabel and feedId already + # exists, this method replaces that entry. + # + # After inserting, updating, or deleting a CSS Product input, it may + # take several minutes before the processed CSS Product can be retrieved. + rpc :InsertCssProductInput, ::Google::Shopping::Css::V1::InsertCssProductInputRequest, ::Google::Shopping::Css::V1::CssProductInput + # Deletes a CSS Product input from your CSS Center account. + # + # After a delete it may take several minutes until the input is no longer + # available. + rpc :DeleteCssProductInput, ::Google::Shopping::Css::V1::DeleteCssProductInputRequest, ::Google::Protobuf::Empty + end + + Stub = Service.rpc_stub_class + end + end + end + end +end diff --git a/google-shopping-css-v1/lib/google/shopping/css/v1/css_products_pb.rb b/google-shopping-css-v1/lib/google/shopping/css/v1/css_products_pb.rb new file mode 100644 index 000000000000..310d3e54a76b --- /dev/null +++ b/google-shopping-css-v1/lib/google/shopping/css/v1/css_products_pb.rb @@ -0,0 +1,54 @@ +# frozen_string_literal: true +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/shopping/css/v1/css_products.proto + +require 'google/protobuf' + +require 'google/api/annotations_pb' +require 'google/api/client_pb' +require 'google/api/field_behavior_pb' +require 'google/api/resource_pb' +require 'google/shopping/css/v1/css_product_common_pb' +require 'google/shopping/type/types_pb' + + +descriptor_data = "\n)google/shopping/css/v1/css_products.proto\x12\x16google.shopping.css.v1\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a/google/shopping/css/v1/css_product_common.proto\x1a google/shopping/type/types.proto\"K\n\x14GetCssProductRequest\x12\x33\n\x04name\x18\x01 \x01(\tB%\xe0\x41\x02\xfa\x41\x1f\n\x1d\x63ss.googleapis.com/CssProduct\"\xaa\x03\n\nCssProduct\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x1c\n\x0fraw_provided_id\x18\x02 \x01(\tB\x03\xe0\x41\x03\x12\x1d\n\x10\x63ontent_language\x18\x03 \x01(\tB\x03\xe0\x41\x03\x12\x17\n\nfeed_label\x18\x04 \x01(\tB\x03\xe0\x41\x03\x12;\n\nattributes\x18\x05 \x01(\x0b\x32\".google.shopping.css.v1.AttributesB\x03\xe0\x41\x03\x12\x45\n\x11\x63ustom_attributes\x18\x06 \x03(\x0b\x32%.google.shopping.type.CustomAttributeB\x03\xe0\x41\x03\x12I\n\x12\x63ss_product_status\x18\x08 \x01(\x0b\x32(.google.shopping.css.v1.CssProductStatusB\x03\xe0\x41\x03:i\xea\x41\x66\n\x1d\x63ss.googleapis.com/CssProduct\x12,accounts/{account}/cssProducts/{css_product}*\x0b\x63ssProducts2\ncssProduct\"v\n\x16ListCssProductsRequest\x12\x35\n\x06parent\x18\x01 \x01(\tB%\xe0\x41\x02\xfa\x41\x1f\x12\x1d\x63ss.googleapis.com/CssProduct\x12\x11\n\tpage_size\x18\x02 \x01(\x05\x12\x12\n\npage_token\x18\x03 \x01(\t\"l\n\x17ListCssProductsResponse\x12\x38\n\x0c\x63ss_products\x18\x01 \x03(\x0b\x32\".google.shopping.css.v1.CssProduct\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t2\x98\x03\n\x12\x43ssProductsService\x12\x95\x01\n\rGetCssProduct\x12,.google.shopping.css.v1.GetCssProductRequest\x1a\".google.shopping.css.v1.CssProduct\"2\xda\x41\x04name\x82\xd3\xe4\x93\x02%\x12#/v1/{name=accounts/*/cssProducts/*}\x12\xa8\x01\n\x0fListCssProducts\x12..google.shopping.css.v1.ListCssProductsRequest\x1a/.google.shopping.css.v1.ListCssProductsResponse\"4\xda\x41\x06parent\x82\xd3\xe4\x93\x02%\x12#/v1/{parent=accounts/*}/cssProducts\x1a?\xca\x41\x12\x63ss.googleapis.com\xd2\x41\'https://www.googleapis.com/auth/contentB\xb2\x01\n\x1a\x63om.google.shopping.css.v1B\x10\x43ssProductsProtoP\x01Z2cloud.google.com/go/shopping/css/apiv1/csspb;csspb\xaa\x02\x16Google.Shopping.Css.V1\xca\x02\x16Google\\Shopping\\Css\\V1\xea\x02\x19Google::Shopping::Css::V1b\x06proto3" + +pool = Google::Protobuf::DescriptorPool.generated_pool + +begin + pool.add_serialized_file(descriptor_data) +rescue TypeError + # Compatibility code: will be removed in the next major version. + require 'google/protobuf/descriptor_pb' + parsed = Google::Protobuf::FileDescriptorProto.decode(descriptor_data) + parsed.clear_dependency + serialized = parsed.class.encode(parsed) + file = pool.add_serialized_file(serialized) + warn "Warning: Protobuf detected an import path issue while loading generated file #{__FILE__}" + imports = [ + ["google.shopping.css.v1.Attributes", "google/shopping/css/v1/css_product_common.proto"], + ["google.shopping.type.CustomAttribute", "google/shopping/type/types.proto"], + ] + imports.each do |type_name, expected_filename| + import_file = pool.lookup(type_name).file_descriptor + if import_file.name != expected_filename + warn "- #{file.name} imports #{expected_filename}, but that import was loaded as #{import_file.name}" + end + end + warn "Each proto file must use a consistent fully-qualified name." + warn "This will become an error in the next major version." +end + +module Google + module Shopping + module Css + module V1 + GetCssProductRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.css.v1.GetCssProductRequest").msgclass + CssProduct = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.css.v1.CssProduct").msgclass + ListCssProductsRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.css.v1.ListCssProductsRequest").msgclass + ListCssProductsResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.css.v1.ListCssProductsResponse").msgclass + end + end + end +end diff --git a/google-shopping-css-v1/lib/google/shopping/css/v1/css_products_service.rb b/google-shopping-css-v1/lib/google/shopping/css/v1/css_products_service.rb new file mode 100644 index 000000000000..9b03245690dd --- /dev/null +++ b/google-shopping-css-v1/lib/google/shopping/css/v1/css_products_service.rb @@ -0,0 +1,56 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "gapic/common" +require "gapic/config" +require "gapic/config/method" + +require "google/shopping/css/v1/version" + +require "google/shopping/css/v1/css_products_service/credentials" +require "google/shopping/css/v1/css_products_service/paths" +require "google/shopping/css/v1/css_products_service/client" +require "google/shopping/css/v1/css_products_service/rest" + +module Google + module Shopping + module Css + module V1 + ## + # Service for doing get and list on Css Products(a.k.a Aggregate Offers + # internally). + # + # @example Load this service and instantiate a gRPC client + # + # require "google/shopping/css/v1/css_products_service" + # client = ::Google::Shopping::Css::V1::CssProductsService::Client.new + # + # @example Load this service and instantiate a REST client + # + # require "google/shopping/css/v1/css_products_service/rest" + # client = ::Google::Shopping::Css::V1::CssProductsService::Rest::Client.new + # + module CssProductsService + end + end + end + end +end + +helper_path = ::File.join __dir__, "css_products_service", "helpers.rb" +require "google/shopping/css/v1/css_products_service/helpers" if ::File.file? helper_path diff --git a/google-shopping-css-v1/lib/google/shopping/css/v1/css_products_service/client.rb b/google-shopping-css-v1/lib/google/shopping/css/v1/css_products_service/client.rb new file mode 100644 index 000000000000..e89b9a42014a --- /dev/null +++ b/google-shopping-css-v1/lib/google/shopping/css/v1/css_products_service/client.rb @@ -0,0 +1,554 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/cloud/errors" +require "google/shopping/css/v1/css_products_pb" + +module Google + module Shopping + module Css + module V1 + module CssProductsService + ## + # Client for the CssProductsService service. + # + # Service for doing get and list on Css Products(a.k.a Aggregate Offers + # internally). + # + class Client + # @private + API_VERSION = "" + + # @private + DEFAULT_ENDPOINT_TEMPLATE = "css.$UNIVERSE_DOMAIN$" + + include Paths + + # @private + attr_reader :css_products_service_stub + + ## + # Configure the CssProductsService Client class. + # + # See {::Google::Shopping::Css::V1::CssProductsService::Client::Configuration} + # for a description of the configuration fields. + # + # @example + # + # # Modify the configuration for all CssProductsService clients + # ::Google::Shopping::Css::V1::CssProductsService::Client.configure do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def self.configure + @configure ||= begin + namespace = ["Google", "Shopping", "Css", "V1"] + parent_config = while namespace.any? + parent_name = namespace.join "::" + parent_const = const_get parent_name + break parent_const.configure if parent_const.respond_to? :configure + namespace.pop + end + default_config = Client::Configuration.new parent_config + + default_config.rpcs.get_css_product.timeout = 60.0 + default_config.rpcs.get_css_product.retry_policy = { + initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14] + } + + default_config.rpcs.list_css_products.timeout = 60.0 + default_config.rpcs.list_css_products.retry_policy = { + initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14] + } + + default_config + end + yield @configure if block_given? + @configure + end + + ## + # Configure the CssProductsService Client instance. + # + # The configuration is set to the derived mode, meaning that values can be changed, + # but structural changes (adding new fields, etc.) are not allowed. Structural changes + # should be made on {Client.configure}. + # + # See {::Google::Shopping::Css::V1::CssProductsService::Client::Configuration} + # for a description of the configuration fields. + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def configure + yield @config if block_given? + @config + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @css_products_service_stub.universe_domain + end + + ## + # Create a new CssProductsService client object. + # + # @example + # + # # Create a client using the default configuration + # client = ::Google::Shopping::Css::V1::CssProductsService::Client.new + # + # # Create a client using a custom configuration + # client = ::Google::Shopping::Css::V1::CssProductsService::Client.new do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the CssProductsService client. + # @yieldparam config [Client::Configuration] + # + def initialize + # These require statements are intentionally placed here to initialize + # the gRPC module only when it's required. + # See https://github.com/googleapis/toolkit/issues/446 + require "gapic/grpc" + require "google/shopping/css/v1/css_products_services_pb" + + # Create the configuration object + @config = Configuration.new Client.configure + + # Yield the configuration if needed + yield @config if block_given? + + # Create credentials + credentials = @config.credentials + # Use self-signed JWT if the endpoint is unchanged from default, + # but only if the default endpoint does not have a region prefix. + enable_self_signed_jwt = @config.endpoint.nil? || + (@config.endpoint == Configuration::DEFAULT_ENDPOINT && + !@config.endpoint.split(".").first.include?("-")) + credentials ||= Credentials.default scope: @config.scope, + enable_self_signed_jwt: enable_self_signed_jwt + if credentials.is_a?(::String) || credentials.is_a?(::Hash) + credentials = Credentials.new credentials, scope: @config.scope + end + @quota_project_id = @config.quota_project + @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id + + @css_products_service_stub = ::Gapic::ServiceStub.new( + ::Google::Shopping::Css::V1::CssProductsService::Stub, + credentials: credentials, + endpoint: @config.endpoint, + endpoint_template: DEFAULT_ENDPOINT_TEMPLATE, + universe_domain: @config.universe_domain, + channel_args: @config.channel_args, + interceptors: @config.interceptors, + channel_pool_config: @config.channel_pool + ) + end + + # Service calls + + ## + # Retrieves the processed CSS Product from your CSS Center account. After + # inserting, updating, or deleting a product input, it may take several + # minutes before the updated final product can be retrieved. + # + # @overload get_css_product(request, options = nil) + # Pass arguments to `get_css_product` via a request object, either of type + # {::Google::Shopping::Css::V1::GetCssProductRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Css::V1::GetCssProductRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload get_css_product(name: nil) + # Pass arguments to `get_css_product` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param name [::String] + # Required. The name of the CSS product to retrieve. + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Google::Shopping::Css::V1::CssProduct] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Google::Shopping::Css::V1::CssProduct] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/shopping/css/v1" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Css::V1::CssProductsService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Css::V1::GetCssProductRequest.new + # + # # Call the get_css_product method. + # result = client.get_css_product request + # + # # The returned object is of type Google::Shopping::Css::V1::CssProduct. + # p result + # + def get_css_product request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Css::V1::GetCssProductRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + metadata = @config.rpcs.get_css_product.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Css::V1::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + header_params = {} + if request.name + header_params["name"] = request.name + end + + request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") + metadata[:"x-goog-request-params"] ||= request_params_header + + options.apply_defaults timeout: @config.rpcs.get_css_product.timeout, + metadata: metadata, + retry_policy: @config.rpcs.get_css_product.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @css_products_service_stub.call_rpc :get_css_product, request, options: options do |response, operation| + yield response, operation if block_given? + return response + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Lists the processed CSS Products in your CSS Center account. The response + # might contain fewer items than specified by pageSize. Rely on pageToken to + # determine if there are more items to be requested. + # + # After inserting, updating, or deleting a CSS product input, it may + # take several minutes before the updated processed CSS product can be + # retrieved. + # + # @overload list_css_products(request, options = nil) + # Pass arguments to `list_css_products` via a request object, either of type + # {::Google::Shopping::Css::V1::ListCssProductsRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Css::V1::ListCssProductsRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload list_css_products(parent: nil, page_size: nil, page_token: nil) + # Pass arguments to `list_css_products` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param parent [::String] + # Required. The account/domain to list processed CSS Products for. + # Format: accounts/\\{account} + # @param page_size [::Integer] + # The maximum number of CSS Products to return. The service may return + # fewer than this value. + # The maximum value is 1000; values above 1000 will be coerced to 1000. If + # unspecified, the maximum number of CSS products will be returned. + # @param page_token [::String] + # A page token, received from a previous `ListCssProducts` call. + # Provide this to retrieve the subsequent page. + # + # When paginating, all other parameters provided to `ListCssProducts` + # must match the call that provided the page token. + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Gapic::PagedEnumerable<::Google::Shopping::Css::V1::CssProduct>] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Gapic::PagedEnumerable<::Google::Shopping::Css::V1::CssProduct>] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/shopping/css/v1" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Css::V1::CssProductsService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Css::V1::ListCssProductsRequest.new + # + # # Call the list_css_products method. + # result = client.list_css_products request + # + # # The returned object is of type Gapic::PagedEnumerable. You can iterate + # # over elements, and API calls will be issued to fetch pages as needed. + # result.each do |item| + # # Each element is of type ::Google::Shopping::Css::V1::CssProduct. + # p item + # end + # + def list_css_products request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Css::V1::ListCssProductsRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + metadata = @config.rpcs.list_css_products.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Css::V1::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + header_params = {} + if request.parent + header_params["parent"] = request.parent + end + + request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") + metadata[:"x-goog-request-params"] ||= request_params_header + + options.apply_defaults timeout: @config.rpcs.list_css_products.timeout, + metadata: metadata, + retry_policy: @config.rpcs.list_css_products.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @css_products_service_stub.call_rpc :list_css_products, request, options: options do |response, operation| + response = ::Gapic::PagedEnumerable.new @css_products_service_stub, :list_css_products, request, response, operation, options + yield response, operation if block_given? + return response + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Configuration class for the CssProductsService API. + # + # This class represents the configuration for CssProductsService, + # providing control over timeouts, retry behavior, logging, transport + # parameters, and other low-level controls. Certain parameters can also be + # applied individually to specific RPCs. See + # {::Google::Shopping::Css::V1::CssProductsService::Client::Configuration::Rpcs} + # for a list of RPCs that can be configured independently. + # + # Configuration can be applied globally to all clients, or to a single client + # on construction. + # + # @example + # + # # Modify the global config, setting the timeout for + # # get_css_product to 20 seconds, + # # and all remaining timeouts to 10 seconds. + # ::Google::Shopping::Css::V1::CssProductsService::Client.configure do |config| + # config.timeout = 10.0 + # config.rpcs.get_css_product.timeout = 20.0 + # end + # + # # Apply the above configuration only to a new client. + # client = ::Google::Shopping::Css::V1::CssProductsService::Client.new do |config| + # config.timeout = 10.0 + # config.rpcs.get_css_product.timeout = 20.0 + # end + # + # @!attribute [rw] endpoint + # A custom service endpoint, as a hostname or hostname:port. The default is + # nil, indicating to use the default endpoint in the current universe domain. + # @return [::String,nil] + # @!attribute [rw] credentials + # Credentials to send with calls. You may provide any of the following types: + # * (`String`) The path to a service account key file in JSON format + # * (`Hash`) A service account key as a Hash + # * (`Google::Auth::Credentials`) A googleauth credentials object + # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials)) + # * (`Signet::OAuth2::Client`) A signet oauth2 client object + # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client)) + # * (`GRPC::Core::Channel`) a gRPC channel with included credentials + # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object + # * (`nil`) indicating no credentials + # @return [::Object] + # @!attribute [rw] scope + # The OAuth scopes + # @return [::Array<::String>] + # @!attribute [rw] lib_name + # The library name as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] lib_version + # The library version as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] channel_args + # Extra parameters passed to the gRPC channel. Note: this is ignored if a + # `GRPC::Core::Channel` object is provided as the credential. + # @return [::Hash] + # @!attribute [rw] interceptors + # An array of interceptors that are run before calls are executed. + # @return [::Array<::GRPC::ClientInterceptor>] + # @!attribute [rw] timeout + # The call timeout in seconds. + # @return [::Numeric] + # @!attribute [rw] metadata + # Additional gRPC headers to be sent with the call. + # @return [::Hash{::Symbol=>::String}] + # @!attribute [rw] retry_policy + # The retry policy. The value is a hash with the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # @return [::Hash] + # @!attribute [rw] quota_project + # A separate project against which to charge quota. + # @return [::String] + # @!attribute [rw] universe_domain + # The universe domain within which to make requests. This determines the + # default endpoint URL. The default value of nil uses the environment + # universe (usually the default "googleapis.com" universe). + # @return [::String,nil] + # + class Configuration + extend ::Gapic::Config + + # @private + # The endpoint specific to the default "googleapis.com" universe. Deprecated. + DEFAULT_ENDPOINT = "css.googleapis.com" + + config_attr :endpoint, nil, ::String, nil + config_attr :credentials, nil do |value| + allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil] + allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC + allowed.any? { |klass| klass === value } + end + config_attr :scope, nil, ::String, ::Array, nil + config_attr :lib_name, nil, ::String, nil + config_attr :lib_version, nil, ::String, nil + config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil) + config_attr :interceptors, nil, ::Array, nil + config_attr :timeout, nil, ::Numeric, nil + config_attr :metadata, nil, ::Hash, nil + config_attr :retry_policy, nil, ::Hash, ::Proc, nil + config_attr :quota_project, nil, ::String, nil + config_attr :universe_domain, nil, ::String, nil + + # @private + def initialize parent_config = nil + @parent_config = parent_config unless parent_config.nil? + + yield self if block_given? + end + + ## + # Configurations for individual RPCs + # @return [Rpcs] + # + def rpcs + @rpcs ||= begin + parent_rpcs = nil + parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs) + Rpcs.new parent_rpcs + end + end + + ## + # Configuration for the channel pool + # @return [::Gapic::ServiceStub::ChannelPool::Configuration] + # + def channel_pool + @channel_pool ||= ::Gapic::ServiceStub::ChannelPool::Configuration.new + end + + ## + # Configuration RPC class for the CssProductsService API. + # + # Includes fields providing the configuration for each RPC in this service. + # Each configuration object is of type `Gapic::Config::Method` and includes + # the following configuration fields: + # + # * `timeout` (*type:* `Numeric`) - The call timeout in seconds + # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers + # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields + # include the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # + class Rpcs + ## + # RPC-specific configuration for `get_css_product` + # @return [::Gapic::Config::Method] + # + attr_reader :get_css_product + ## + # RPC-specific configuration for `list_css_products` + # @return [::Gapic::Config::Method] + # + attr_reader :list_css_products + + # @private + def initialize parent_rpcs = nil + get_css_product_config = parent_rpcs.get_css_product if parent_rpcs.respond_to? :get_css_product + @get_css_product = ::Gapic::Config::Method.new get_css_product_config + list_css_products_config = parent_rpcs.list_css_products if parent_rpcs.respond_to? :list_css_products + @list_css_products = ::Gapic::Config::Method.new list_css_products_config + + yield self if block_given? + end + end + end + end + end + end + end + end +end diff --git a/google-shopping-css-v1/lib/google/shopping/css/v1/css_products_service/credentials.rb b/google-shopping-css-v1/lib/google/shopping/css/v1/css_products_service/credentials.rb new file mode 100644 index 000000000000..cc7aca1c3bcd --- /dev/null +++ b/google-shopping-css-v1/lib/google/shopping/css/v1/css_products_service/credentials.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "googleauth" + +module Google + module Shopping + module Css + module V1 + module CssProductsService + # Credentials for the CssProductsService API. + class Credentials < ::Google::Auth::Credentials + self.scope = [ + "https://www.googleapis.com/auth/content" + ] + self.env_vars = [ + "GOOGLE_CLOUD_CREDENTIALS", + "GOOGLE_CLOUD_KEYFILE", + "GCLOUD_KEYFILE", + "GOOGLE_CLOUD_CREDENTIALS_JSON", + "GOOGLE_CLOUD_KEYFILE_JSON", + "GCLOUD_KEYFILE_JSON" + ] + self.paths = [ + "~/.config/google_cloud/application_default_credentials.json" + ] + end + end + end + end + end +end diff --git a/google-shopping-css-v1/lib/google/shopping/css/v1/css_products_service/paths.rb b/google-shopping-css-v1/lib/google/shopping/css/v1/css_products_service/paths.rb new file mode 100644 index 000000000000..cd2a35d4a2d8 --- /dev/null +++ b/google-shopping-css-v1/lib/google/shopping/css/v1/css_products_service/paths.rb @@ -0,0 +1,64 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Shopping + module Css + module V1 + module CssProductsService + # Path helper methods for the CssProductsService API. + module Paths + ## + # Create a fully-qualified Account resource string. + # + # The resource will be in the following format: + # + # `accounts/{account}` + # + # @param account [String] + # + # @return [::String] + def account_path account: + "accounts/#{account}" + end + + ## + # Create a fully-qualified CssProduct resource string. + # + # The resource will be in the following format: + # + # `accounts/{account}/cssProducts/{css_product}` + # + # @param account [String] + # @param css_product [String] + # + # @return [::String] + def css_product_path account:, css_product: + raise ::ArgumentError, "account cannot contain /" if account.to_s.include? "/" + + "accounts/#{account}/cssProducts/#{css_product}" + end + + extend self + end + end + end + end + end +end diff --git a/google-shopping-css-v1/lib/google/shopping/css/v1/css_products_service/rest.rb b/google-shopping-css-v1/lib/google/shopping/css/v1/css_products_service/rest.rb new file mode 100644 index 000000000000..6cdba6705170 --- /dev/null +++ b/google-shopping-css-v1/lib/google/shopping/css/v1/css_products_service/rest.rb @@ -0,0 +1,53 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "gapic/rest" +require "gapic/config" +require "gapic/config/method" + +require "google/shopping/css/v1/version" + +require "google/shopping/css/v1/css_products_service/credentials" +require "google/shopping/css/v1/css_products_service/paths" +require "google/shopping/css/v1/css_products_service/rest/client" + +module Google + module Shopping + module Css + module V1 + ## + # Service for doing get and list on Css Products(a.k.a Aggregate Offers + # internally). + # + # To load this service and instantiate a REST client: + # + # require "google/shopping/css/v1/css_products_service/rest" + # client = ::Google::Shopping::Css::V1::CssProductsService::Rest::Client.new + # + module CssProductsService + # Client for the REST transport + module Rest + end + end + end + end + end +end + +helper_path = ::File.join __dir__, "rest", "helpers.rb" +require "google/shopping/css/v1/css_products_service/rest/helpers" if ::File.file? helper_path diff --git a/google-shopping-css-v1/lib/google/shopping/css/v1/css_products_service/rest/client.rb b/google-shopping-css-v1/lib/google/shopping/css/v1/css_products_service/rest/client.rb new file mode 100644 index 000000000000..d413f7a38d3c --- /dev/null +++ b/google-shopping-css-v1/lib/google/shopping/css/v1/css_products_service/rest/client.rb @@ -0,0 +1,514 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/cloud/errors" +require "google/shopping/css/v1/css_products_pb" +require "google/shopping/css/v1/css_products_service/rest/service_stub" + +module Google + module Shopping + module Css + module V1 + module CssProductsService + module Rest + ## + # REST client for the CssProductsService service. + # + # Service for doing get and list on Css Products(a.k.a Aggregate Offers + # internally). + # + class Client + # @private + API_VERSION = "" + + # @private + DEFAULT_ENDPOINT_TEMPLATE = "css.$UNIVERSE_DOMAIN$" + + include Paths + + # @private + attr_reader :css_products_service_stub + + ## + # Configure the CssProductsService Client class. + # + # See {::Google::Shopping::Css::V1::CssProductsService::Rest::Client::Configuration} + # for a description of the configuration fields. + # + # @example + # + # # Modify the configuration for all CssProductsService clients + # ::Google::Shopping::Css::V1::CssProductsService::Rest::Client.configure do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def self.configure + @configure ||= begin + namespace = ["Google", "Shopping", "Css", "V1"] + parent_config = while namespace.any? + parent_name = namespace.join "::" + parent_const = const_get parent_name + break parent_const.configure if parent_const.respond_to? :configure + namespace.pop + end + default_config = Client::Configuration.new parent_config + + default_config.rpcs.get_css_product.timeout = 60.0 + default_config.rpcs.get_css_product.retry_policy = { + initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14] + } + + default_config.rpcs.list_css_products.timeout = 60.0 + default_config.rpcs.list_css_products.retry_policy = { + initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14] + } + + default_config + end + yield @configure if block_given? + @configure + end + + ## + # Configure the CssProductsService Client instance. + # + # The configuration is set to the derived mode, meaning that values can be changed, + # but structural changes (adding new fields, etc.) are not allowed. Structural changes + # should be made on {Client.configure}. + # + # See {::Google::Shopping::Css::V1::CssProductsService::Rest::Client::Configuration} + # for a description of the configuration fields. + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def configure + yield @config if block_given? + @config + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @css_products_service_stub.universe_domain + end + + ## + # Create a new CssProductsService REST client object. + # + # @example + # + # # Create a client using the default configuration + # client = ::Google::Shopping::Css::V1::CssProductsService::Rest::Client.new + # + # # Create a client using a custom configuration + # client = ::Google::Shopping::Css::V1::CssProductsService::Rest::Client.new do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the CssProductsService client. + # @yieldparam config [Client::Configuration] + # + def initialize + # Create the configuration object + @config = Configuration.new Client.configure + + # Yield the configuration if needed + yield @config if block_given? + + # Create credentials + credentials = @config.credentials + # Use self-signed JWT if the endpoint is unchanged from default, + # but only if the default endpoint does not have a region prefix. + enable_self_signed_jwt = @config.endpoint.nil? || + (@config.endpoint == Configuration::DEFAULT_ENDPOINT && + !@config.endpoint.split(".").first.include?("-")) + credentials ||= Credentials.default scope: @config.scope, + enable_self_signed_jwt: enable_self_signed_jwt + if credentials.is_a?(::String) || credentials.is_a?(::Hash) + credentials = Credentials.new credentials, scope: @config.scope + end + + @quota_project_id = @config.quota_project + @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id + + @css_products_service_stub = ::Google::Shopping::Css::V1::CssProductsService::Rest::ServiceStub.new( + endpoint: @config.endpoint, + endpoint_template: DEFAULT_ENDPOINT_TEMPLATE, + universe_domain: @config.universe_domain, + credentials: credentials + ) + end + + # Service calls + + ## + # Retrieves the processed CSS Product from your CSS Center account. After + # inserting, updating, or deleting a product input, it may take several + # minutes before the updated final product can be retrieved. + # + # @overload get_css_product(request, options = nil) + # Pass arguments to `get_css_product` via a request object, either of type + # {::Google::Shopping::Css::V1::GetCssProductRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Css::V1::GetCssProductRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload get_css_product(name: nil) + # Pass arguments to `get_css_product` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param name [::String] + # Required. The name of the CSS product to retrieve. + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Css::V1::CssProduct] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Css::V1::CssProduct] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/shopping/css/v1" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Css::V1::CssProductsService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Css::V1::GetCssProductRequest.new + # + # # Call the get_css_product method. + # result = client.get_css_product request + # + # # The returned object is of type Google::Shopping::Css::V1::CssProduct. + # p result + # + def get_css_product request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Css::V1::GetCssProductRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.get_css_product.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Css::V1::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.get_css_product.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.get_css_product.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @css_products_service_stub.get_css_product request, options do |result, operation| + yield result, operation if block_given? + return result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Lists the processed CSS Products in your CSS Center account. The response + # might contain fewer items than specified by pageSize. Rely on pageToken to + # determine if there are more items to be requested. + # + # After inserting, updating, or deleting a CSS product input, it may + # take several minutes before the updated processed CSS product can be + # retrieved. + # + # @overload list_css_products(request, options = nil) + # Pass arguments to `list_css_products` via a request object, either of type + # {::Google::Shopping::Css::V1::ListCssProductsRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Css::V1::ListCssProductsRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload list_css_products(parent: nil, page_size: nil, page_token: nil) + # Pass arguments to `list_css_products` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param parent [::String] + # Required. The account/domain to list processed CSS Products for. + # Format: accounts/\\{account} + # @param page_size [::Integer] + # The maximum number of CSS Products to return. The service may return + # fewer than this value. + # The maximum value is 1000; values above 1000 will be coerced to 1000. If + # unspecified, the maximum number of CSS products will be returned. + # @param page_token [::String] + # A page token, received from a previous `ListCssProducts` call. + # Provide this to retrieve the subsequent page. + # + # When paginating, all other parameters provided to `ListCssProducts` + # must match the call that provided the page token. + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Shopping::Css::V1::CssProduct>] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Gapic::Rest::PagedEnumerable<::Google::Shopping::Css::V1::CssProduct>] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/shopping/css/v1" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Css::V1::CssProductsService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Css::V1::ListCssProductsRequest.new + # + # # Call the list_css_products method. + # result = client.list_css_products request + # + # # The returned object is of type Gapic::PagedEnumerable. You can iterate + # # over elements, and API calls will be issued to fetch pages as needed. + # result.each do |item| + # # Each element is of type ::Google::Shopping::Css::V1::CssProduct. + # p item + # end + # + def list_css_products request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Css::V1::ListCssProductsRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.list_css_products.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Css::V1::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.list_css_products.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.list_css_products.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @css_products_service_stub.list_css_products request, options do |result, operation| + result = ::Gapic::Rest::PagedEnumerable.new @css_products_service_stub, :list_css_products, "css_products", request, result, options + yield result, operation if block_given? + return result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Configuration class for the CssProductsService REST API. + # + # This class represents the configuration for CssProductsService REST, + # providing control over timeouts, retry behavior, logging, transport + # parameters, and other low-level controls. Certain parameters can also be + # applied individually to specific RPCs. See + # {::Google::Shopping::Css::V1::CssProductsService::Rest::Client::Configuration::Rpcs} + # for a list of RPCs that can be configured independently. + # + # Configuration can be applied globally to all clients, or to a single client + # on construction. + # + # @example + # + # # Modify the global config, setting the timeout for + # # get_css_product to 20 seconds, + # # and all remaining timeouts to 10 seconds. + # ::Google::Shopping::Css::V1::CssProductsService::Rest::Client.configure do |config| + # config.timeout = 10.0 + # config.rpcs.get_css_product.timeout = 20.0 + # end + # + # # Apply the above configuration only to a new client. + # client = ::Google::Shopping::Css::V1::CssProductsService::Rest::Client.new do |config| + # config.timeout = 10.0 + # config.rpcs.get_css_product.timeout = 20.0 + # end + # + # @!attribute [rw] endpoint + # A custom service endpoint, as a hostname or hostname:port. The default is + # nil, indicating to use the default endpoint in the current universe domain. + # @return [::String,nil] + # @!attribute [rw] credentials + # Credentials to send with calls. You may provide any of the following types: + # * (`String`) The path to a service account key file in JSON format + # * (`Hash`) A service account key as a Hash + # * (`Google::Auth::Credentials`) A googleauth credentials object + # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials)) + # * (`Signet::OAuth2::Client`) A signet oauth2 client object + # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client)) + # * (`nil`) indicating no credentials + # @return [::Object] + # @!attribute [rw] scope + # The OAuth scopes + # @return [::Array<::String>] + # @!attribute [rw] lib_name + # The library name as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] lib_version + # The library version as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] timeout + # The call timeout in seconds. + # @return [::Numeric] + # @!attribute [rw] metadata + # Additional headers to be sent with the call. + # @return [::Hash{::Symbol=>::String}] + # @!attribute [rw] retry_policy + # The retry policy. The value is a hash with the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # @return [::Hash] + # @!attribute [rw] quota_project + # A separate project against which to charge quota. + # @return [::String] + # @!attribute [rw] universe_domain + # The universe domain within which to make requests. This determines the + # default endpoint URL. The default value of nil uses the environment + # universe (usually the default "googleapis.com" universe). + # @return [::String,nil] + # + class Configuration + extend ::Gapic::Config + + # @private + # The endpoint specific to the default "googleapis.com" universe. Deprecated. + DEFAULT_ENDPOINT = "css.googleapis.com" + + config_attr :endpoint, nil, ::String, nil + config_attr :credentials, nil do |value| + allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil] + allowed.any? { |klass| klass === value } + end + config_attr :scope, nil, ::String, ::Array, nil + config_attr :lib_name, nil, ::String, nil + config_attr :lib_version, nil, ::String, nil + config_attr :timeout, nil, ::Numeric, nil + config_attr :metadata, nil, ::Hash, nil + config_attr :retry_policy, nil, ::Hash, ::Proc, nil + config_attr :quota_project, nil, ::String, nil + config_attr :universe_domain, nil, ::String, nil + + # @private + def initialize parent_config = nil + @parent_config = parent_config unless parent_config.nil? + + yield self if block_given? + end + + ## + # Configurations for individual RPCs + # @return [Rpcs] + # + def rpcs + @rpcs ||= begin + parent_rpcs = nil + parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs) + Rpcs.new parent_rpcs + end + end + + ## + # Configuration RPC class for the CssProductsService API. + # + # Includes fields providing the configuration for each RPC in this service. + # Each configuration object is of type `Gapic::Config::Method` and includes + # the following configuration fields: + # + # * `timeout` (*type:* `Numeric`) - The call timeout in seconds + # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers + # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields + # include the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # + class Rpcs + ## + # RPC-specific configuration for `get_css_product` + # @return [::Gapic::Config::Method] + # + attr_reader :get_css_product + ## + # RPC-specific configuration for `list_css_products` + # @return [::Gapic::Config::Method] + # + attr_reader :list_css_products + + # @private + def initialize parent_rpcs = nil + get_css_product_config = parent_rpcs.get_css_product if parent_rpcs.respond_to? :get_css_product + @get_css_product = ::Gapic::Config::Method.new get_css_product_config + list_css_products_config = parent_rpcs.list_css_products if parent_rpcs.respond_to? :list_css_products + @list_css_products = ::Gapic::Config::Method.new list_css_products_config + + yield self if block_given? + end + end + end + end + end + end + end + end + end +end diff --git a/google-shopping-css-v1/lib/google/shopping/css/v1/css_products_service/rest/service_stub.rb b/google-shopping-css-v1/lib/google/shopping/css/v1/css_products_service/rest/service_stub.rb new file mode 100644 index 000000000000..52c1f414bc96 --- /dev/null +++ b/google-shopping-css-v1/lib/google/shopping/css/v1/css_products_service/rest/service_stub.rb @@ -0,0 +1,187 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/shopping/css/v1/css_products_pb" + +module Google + module Shopping + module Css + module V1 + module CssProductsService + module Rest + ## + # REST service stub for the CssProductsService service. + # Service stub contains baseline method implementations + # including transcoding, making the REST call, and deserialing the response. + # + class ServiceStub + def initialize endpoint:, endpoint_template:, universe_domain:, credentials: + # These require statements are intentionally placed here to initialize + # the REST modules only when it's required. + require "gapic/rest" + + @client_stub = ::Gapic::Rest::ClientStub.new endpoint: endpoint, + endpoint_template: endpoint_template, + universe_domain: universe_domain, + credentials: credentials, + numeric_enums: true, + raise_faraday_errors: false + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @client_stub.universe_domain + end + + ## + # The effective endpoint + # + # @return [String] + # + def endpoint + @client_stub.endpoint + end + + ## + # Baseline implementation for the get_css_product REST call + # + # @param request_pb [::Google::Shopping::Css::V1::GetCssProductRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Css::V1::CssProduct] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Css::V1::CssProduct] + # A result object deserialized from the server's reply + def get_css_product request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_get_css_product_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Shopping::Css::V1::CssProduct.decode_json response.body, ignore_unknown_fields: true + + yield result, operation if block_given? + result + end + + ## + # Baseline implementation for the list_css_products REST call + # + # @param request_pb [::Google::Shopping::Css::V1::ListCssProductsRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Css::V1::ListCssProductsResponse] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Css::V1::ListCssProductsResponse] + # A result object deserialized from the server's reply + def list_css_products request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_list_css_products_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Shopping::Css::V1::ListCssProductsResponse.decode_json response.body, ignore_unknown_fields: true + + yield result, operation if block_given? + result + end + + ## + # @private + # + # GRPC transcoding helper method for the get_css_product REST call + # + # @param request_pb [::Google::Shopping::Css::V1::GetCssProductRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_get_css_product_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :get, + uri_template: "/v1/{name}", + matches: [ + ["name", %r{^accounts/[^/]+/cssProducts/[^/]+/?$}, false] + ] + ) + transcoder.transcode request_pb + end + + ## + # @private + # + # GRPC transcoding helper method for the list_css_products REST call + # + # @param request_pb [::Google::Shopping::Css::V1::ListCssProductsRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_list_css_products_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :get, + uri_template: "/v1/{parent}/cssProducts", + matches: [ + ["parent", %r{^accounts/[^/]+/?$}, false] + ] + ) + transcoder.transcode request_pb + end + end + end + end + end + end + end +end diff --git a/google-shopping-css-v1/lib/google/shopping/css/v1/css_products_services_pb.rb b/google-shopping-css-v1/lib/google/shopping/css/v1/css_products_services_pb.rb new file mode 100644 index 000000000000..2ee9a4942917 --- /dev/null +++ b/google-shopping-css-v1/lib/google/shopping/css/v1/css_products_services_pb.rb @@ -0,0 +1,56 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# Source: google/shopping/css/v1/css_products.proto for package 'Google.Shopping.Css.V1' +# Original file comments: +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +require 'grpc' +require 'google/shopping/css/v1/css_products_pb' + +module Google + module Shopping + module Css + module V1 + module CssProductsService + # Service for doing get and list on Css Products(a.k.a Aggregate Offers + # internally). + class Service + + include ::GRPC::GenericService + + self.marshal_class_method = :encode + self.unmarshal_class_method = :decode + self.service_name = 'google.shopping.css.v1.CssProductsService' + + # Retrieves the processed CSS Product from your CSS Center account. After + # inserting, updating, or deleting a product input, it may take several + # minutes before the updated final product can be retrieved. + rpc :GetCssProduct, ::Google::Shopping::Css::V1::GetCssProductRequest, ::Google::Shopping::Css::V1::CssProduct + # Lists the processed CSS Products in your CSS Center account. The response + # might contain fewer items than specified by pageSize. Rely on pageToken to + # determine if there are more items to be requested. + # + # After inserting, updating, or deleting a CSS product input, it may + # take several minutes before the updated processed CSS product can be + # retrieved. + rpc :ListCssProducts, ::Google::Shopping::Css::V1::ListCssProductsRequest, ::Google::Shopping::Css::V1::ListCssProductsResponse + end + + Stub = Service.rpc_stub_class + end + end + end + end +end diff --git a/google-shopping-css-v1/lib/google/shopping/css/v1/rest.rb b/google-shopping-css-v1/lib/google/shopping/css/v1/rest.rb new file mode 100644 index 000000000000..0bdf57fabd38 --- /dev/null +++ b/google-shopping-css-v1/lib/google/shopping/css/v1/rest.rb @@ -0,0 +1,40 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/shopping/css/v1/accounts_service/rest" +require "google/shopping/css/v1/account_labels_service/rest" +require "google/shopping/css/v1/css_product_inputs_service/rest" +require "google/shopping/css/v1/css_products_service/rest" +require "google/shopping/css/v1/version" + +module Google + module Shopping + module Css + ## + # To load just the REST part of this package, including all its services, and instantiate a REST client: + # + # @example + # + # require "google/shopping/css/v1/rest" + # client = ::Google::Shopping::Css::V1::AccountsService::Rest::Client.new + # + module V1 + end + end + end +end diff --git a/google-shopping-css-v1/lib/google/shopping/css/v1/version.rb b/google-shopping-css-v1/lib/google/shopping/css/v1/version.rb new file mode 100644 index 000000000000..46a17dc8d0db --- /dev/null +++ b/google-shopping-css-v1/lib/google/shopping/css/v1/version.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Shopping + module Css + module V1 + VERSION = "0.0.1" + end + end + end +end diff --git a/google-shopping-css-v1/proto_docs/README.md b/google-shopping-css-v1/proto_docs/README.md new file mode 100644 index 000000000000..d5bb47472267 --- /dev/null +++ b/google-shopping-css-v1/proto_docs/README.md @@ -0,0 +1,4 @@ +# CSS V1 Protocol Buffer Documentation + +These files are for the YARD documentation of the generated protobuf files. +They are not intended to be required or loaded at runtime. diff --git a/google-shopping-css-v1/proto_docs/google/api/client.rb b/google-shopping-css-v1/proto_docs/google/api/client.rb new file mode 100644 index 000000000000..934c39849a6a --- /dev/null +++ b/google-shopping-css-v1/proto_docs/google/api/client.rb @@ -0,0 +1,399 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Api + # Required information for every language. + # @!attribute [rw] reference_docs_uri + # @deprecated This field is deprecated and may be removed in the next major version update. + # @return [::String] + # Link to automatically generated reference documentation. Example: + # https://cloud.google.com/nodejs/docs/reference/asset/latest + # @!attribute [rw] destinations + # @return [::Array<::Google::Api::ClientLibraryDestination>] + # The destination where API teams want this client library to be published. + class CommonLanguageSettings + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Details about how and where to publish client libraries. + # @!attribute [rw] version + # @return [::String] + # Version of the API to apply these settings to. This is the full protobuf + # package for the API, ending in the version element. + # Examples: "google.cloud.speech.v1" and "google.spanner.admin.database.v1". + # @!attribute [rw] launch_stage + # @return [::Google::Api::LaunchStage] + # Launch stage of this version of the API. + # @!attribute [rw] rest_numeric_enums + # @return [::Boolean] + # When using transport=rest, the client request will encode enums as + # numbers rather than strings. + # @!attribute [rw] java_settings + # @return [::Google::Api::JavaSettings] + # Settings for legacy Java features, supported in the Service YAML. + # @!attribute [rw] cpp_settings + # @return [::Google::Api::CppSettings] + # Settings for C++ client libraries. + # @!attribute [rw] php_settings + # @return [::Google::Api::PhpSettings] + # Settings for PHP client libraries. + # @!attribute [rw] python_settings + # @return [::Google::Api::PythonSettings] + # Settings for Python client libraries. + # @!attribute [rw] node_settings + # @return [::Google::Api::NodeSettings] + # Settings for Node client libraries. + # @!attribute [rw] dotnet_settings + # @return [::Google::Api::DotnetSettings] + # Settings for .NET client libraries. + # @!attribute [rw] ruby_settings + # @return [::Google::Api::RubySettings] + # Settings for Ruby client libraries. + # @!attribute [rw] go_settings + # @return [::Google::Api::GoSettings] + # Settings for Go client libraries. + class ClientLibrarySettings + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # This message configures the settings for publishing [Google Cloud Client + # libraries](https://cloud.google.com/apis/docs/cloud-client-libraries) + # generated from the service config. + # @!attribute [rw] method_settings + # @return [::Array<::Google::Api::MethodSettings>] + # A list of API method settings, e.g. the behavior for methods that use the + # long-running operation pattern. + # @!attribute [rw] new_issue_uri + # @return [::String] + # Link to a *public* URI where users can report issues. Example: + # https://issuetracker.google.com/issues/new?component=190865&template=1161103 + # @!attribute [rw] documentation_uri + # @return [::String] + # Link to product home page. Example: + # https://cloud.google.com/asset-inventory/docs/overview + # @!attribute [rw] api_short_name + # @return [::String] + # Used as a tracking tag when collecting data about the APIs developer + # relations artifacts like docs, packages delivered to package managers, + # etc. Example: "speech". + # @!attribute [rw] github_label + # @return [::String] + # GitHub label to apply to issues and pull requests opened for this API. + # @!attribute [rw] codeowner_github_teams + # @return [::Array<::String>] + # GitHub teams to be added to CODEOWNERS in the directory in GitHub + # containing source code for the client libraries for this API. + # @!attribute [rw] doc_tag_prefix + # @return [::String] + # A prefix used in sample code when demarking regions to be included in + # documentation. + # @!attribute [rw] organization + # @return [::Google::Api::ClientLibraryOrganization] + # For whom the client library is being published. + # @!attribute [rw] library_settings + # @return [::Array<::Google::Api::ClientLibrarySettings>] + # Client library settings. If the same version string appears multiple + # times in this list, then the last one wins. Settings from earlier + # settings with the same version string are discarded. + # @!attribute [rw] proto_reference_documentation_uri + # @return [::String] + # Optional link to proto reference documentation. Example: + # https://cloud.google.com/pubsub/lite/docs/reference/rpc + # @!attribute [rw] rest_reference_documentation_uri + # @return [::String] + # Optional link to REST reference documentation. Example: + # https://cloud.google.com/pubsub/lite/docs/reference/rest + class Publishing + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Settings for Java client libraries. + # @!attribute [rw] library_package + # @return [::String] + # The package name to use in Java. Clobbers the java_package option + # set in the protobuf. This should be used **only** by APIs + # who have already set the language_settings.java.package_name" field + # in gapic.yaml. API teams should use the protobuf java_package option + # where possible. + # + # Example of a YAML configuration:: + # + # publishing: + # java_settings: + # library_package: com.google.cloud.pubsub.v1 + # @!attribute [rw] service_class_names + # @return [::Google::Protobuf::Map{::String => ::String}] + # Configure the Java class name to use instead of the service's for its + # corresponding generated GAPIC client. Keys are fully-qualified + # service names as they appear in the protobuf (including the full + # the language_settings.java.interface_names" field in gapic.yaml. API + # teams should otherwise use the service name as it appears in the + # protobuf. + # + # Example of a YAML configuration:: + # + # publishing: + # java_settings: + # service_class_names: + # - google.pubsub.v1.Publisher: TopicAdmin + # - google.pubsub.v1.Subscriber: SubscriptionAdmin + # @!attribute [rw] common + # @return [::Google::Api::CommonLanguageSettings] + # Some settings. + class JavaSettings + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + + # @!attribute [rw] key + # @return [::String] + # @!attribute [rw] value + # @return [::String] + class ServiceClassNamesEntry + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + end + + # Settings for C++ client libraries. + # @!attribute [rw] common + # @return [::Google::Api::CommonLanguageSettings] + # Some settings. + class CppSettings + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Settings for Php client libraries. + # @!attribute [rw] common + # @return [::Google::Api::CommonLanguageSettings] + # Some settings. + class PhpSettings + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Settings for Python client libraries. + # @!attribute [rw] common + # @return [::Google::Api::CommonLanguageSettings] + # Some settings. + class PythonSettings + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Settings for Node client libraries. + # @!attribute [rw] common + # @return [::Google::Api::CommonLanguageSettings] + # Some settings. + class NodeSettings + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Settings for Dotnet client libraries. + # @!attribute [rw] common + # @return [::Google::Api::CommonLanguageSettings] + # Some settings. + # @!attribute [rw] renamed_services + # @return [::Google::Protobuf::Map{::String => ::String}] + # Map from original service names to renamed versions. + # This is used when the default generated types + # would cause a naming conflict. (Neither name is + # fully-qualified.) + # Example: Subscriber to SubscriberServiceApi. + # @!attribute [rw] renamed_resources + # @return [::Google::Protobuf::Map{::String => ::String}] + # Map from full resource types to the effective short name + # for the resource. This is used when otherwise resource + # named from different services would cause naming collisions. + # Example entry: + # "datalabeling.googleapis.com/Dataset": "DataLabelingDataset" + # @!attribute [rw] ignored_resources + # @return [::Array<::String>] + # List of full resource types to ignore during generation. + # This is typically used for API-specific Location resources, + # which should be handled by the generator as if they were actually + # the common Location resources. + # Example entry: "documentai.googleapis.com/Location" + # @!attribute [rw] forced_namespace_aliases + # @return [::Array<::String>] + # Namespaces which must be aliased in snippets due to + # a known (but non-generator-predictable) naming collision + # @!attribute [rw] handwritten_signatures + # @return [::Array<::String>] + # Method signatures (in the form "service.method(signature)") + # which are provided separately, so shouldn't be generated. + # Snippets *calling* these methods are still generated, however. + class DotnetSettings + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + + # @!attribute [rw] key + # @return [::String] + # @!attribute [rw] value + # @return [::String] + class RenamedServicesEntry + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # @!attribute [rw] key + # @return [::String] + # @!attribute [rw] value + # @return [::String] + class RenamedResourcesEntry + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + end + + # Settings for Ruby client libraries. + # @!attribute [rw] common + # @return [::Google::Api::CommonLanguageSettings] + # Some settings. + class RubySettings + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Settings for Go client libraries. + # @!attribute [rw] common + # @return [::Google::Api::CommonLanguageSettings] + # Some settings. + class GoSettings + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Describes the generator configuration for a method. + # @!attribute [rw] selector + # @return [::String] + # The fully qualified name of the method, for which the options below apply. + # This is used to find the method to apply the options. + # @!attribute [rw] long_running + # @return [::Google::Api::MethodSettings::LongRunning] + # Describes settings to use for long-running operations when generating + # API methods for RPCs. Complements RPCs that use the annotations in + # google/longrunning/operations.proto. + # + # Example of a YAML configuration:: + # + # publishing: + # method_settings: + # - selector: google.cloud.speech.v2.Speech.BatchRecognize + # long_running: + # initial_poll_delay: + # seconds: 60 # 1 minute + # poll_delay_multiplier: 1.5 + # max_poll_delay: + # seconds: 360 # 6 minutes + # total_poll_timeout: + # seconds: 54000 # 90 minutes + # @!attribute [rw] auto_populated_fields + # @return [::Array<::String>] + # List of top-level fields of the request message, that should be + # automatically populated by the client libraries based on their + # (google.api.field_info).format. Currently supported format: UUID4. + # + # Example of a YAML configuration: + # + # publishing: + # method_settings: + # - selector: google.example.v1.ExampleService.CreateExample + # auto_populated_fields: + # - request_id + class MethodSettings + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + + # Describes settings to use when generating API methods that use the + # long-running operation pattern. + # All default values below are from those used in the client library + # generators (e.g. + # [Java](https://github.com/googleapis/gapic-generator-java/blob/04c2faa191a9b5a10b92392fe8482279c4404803/src/main/java/com/google/api/generator/gapic/composer/common/RetrySettingsComposer.java)). + # @!attribute [rw] initial_poll_delay + # @return [::Google::Protobuf::Duration] + # Initial delay after which the first poll request will be made. + # Default value: 5 seconds. + # @!attribute [rw] poll_delay_multiplier + # @return [::Float] + # Multiplier to gradually increase delay between subsequent polls until it + # reaches max_poll_delay. + # Default value: 1.5. + # @!attribute [rw] max_poll_delay + # @return [::Google::Protobuf::Duration] + # Maximum time between two subsequent poll requests. + # Default value: 45 seconds. + # @!attribute [rw] total_poll_timeout + # @return [::Google::Protobuf::Duration] + # Total polling timeout. + # Default value: 5 minutes. + class LongRunning + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + end + + # The organization for which the client libraries are being published. + # Affects the url where generated docs are published, etc. + module ClientLibraryOrganization + # Not useful. + CLIENT_LIBRARY_ORGANIZATION_UNSPECIFIED = 0 + + # Google Cloud Platform Org. + CLOUD = 1 + + # Ads (Advertising) Org. + ADS = 2 + + # Photos Org. + PHOTOS = 3 + + # Street View Org. + STREET_VIEW = 4 + + # Shopping Org. + SHOPPING = 5 + + # Geo Org. + GEO = 6 + + # Generative AI - https://developers.generativeai.google + GENERATIVE_AI = 7 + end + + # To where should client libraries be published? + module ClientLibraryDestination + # Client libraries will neither be generated nor published to package + # managers. + CLIENT_LIBRARY_DESTINATION_UNSPECIFIED = 0 + + # Generate the client library in a repo under github.com/googleapis, + # but don't publish it to package managers. + GITHUB = 10 + + # Publish the library to package managers like nuget.org and npmjs.com. + PACKAGE_MANAGER = 20 + end + end +end diff --git a/google-shopping-css-v1/proto_docs/google/api/field_behavior.rb b/google-shopping-css-v1/proto_docs/google/api/field_behavior.rb new file mode 100644 index 000000000000..b03587481349 --- /dev/null +++ b/google-shopping-css-v1/proto_docs/google/api/field_behavior.rb @@ -0,0 +1,85 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Api + # An indicator of the behavior of a given field (for example, that a field + # is required in requests, or given as output but ignored as input). + # This **does not** change the behavior in protocol buffers itself; it only + # denotes the behavior and may affect how API tooling handles the field. + # + # Note: This enum **may** receive new values in the future. + module FieldBehavior + # Conventional default for enums. Do not use this. + FIELD_BEHAVIOR_UNSPECIFIED = 0 + + # Specifically denotes a field as optional. + # While all fields in protocol buffers are optional, this may be specified + # for emphasis if appropriate. + OPTIONAL = 1 + + # Denotes a field as required. + # This indicates that the field **must** be provided as part of the request, + # and failure to do so will cause an error (usually `INVALID_ARGUMENT`). + REQUIRED = 2 + + # Denotes a field as output only. + # This indicates that the field is provided in responses, but including the + # field in a request does nothing (the server *must* ignore it and + # *must not* throw an error as a result of the field's presence). + OUTPUT_ONLY = 3 + + # Denotes a field as input only. + # This indicates that the field is provided in requests, and the + # corresponding field is not included in output. + INPUT_ONLY = 4 + + # Denotes a field as immutable. + # This indicates that the field may be set once in a request to create a + # resource, but may not be changed thereafter. + IMMUTABLE = 5 + + # Denotes that a (repeated) field is an unordered list. + # This indicates that the service may provide the elements of the list + # in any arbitrary order, rather than the order the user originally + # provided. Additionally, the list's order may or may not be stable. + UNORDERED_LIST = 6 + + # Denotes that this field returns a non-empty default value if not set. + # This indicates that if the user provides the empty value in a request, + # a non-empty value will be returned. The user will not be aware of what + # non-empty value to expect. + NON_EMPTY_DEFAULT = 7 + + # Denotes that the field in a resource (a message annotated with + # google.api.resource) is used in the resource name to uniquely identify the + # resource. For AIP-compliant APIs, this should only be applied to the + # `name` field on the resource. + # + # This behavior should not be applied to references to other resources within + # the message. + # + # The identifier field of resources often have different field behavior + # depending on the request it is embedded in (e.g. for Create methods name + # is optional and unused, while for Update methods it is required). Instead + # of method-specific annotations, only `IDENTIFIER` is required. + IDENTIFIER = 8 + end + end +end diff --git a/google-shopping-css-v1/proto_docs/google/api/launch_stage.rb b/google-shopping-css-v1/proto_docs/google/api/launch_stage.rb new file mode 100644 index 000000000000..38b4b61e6061 --- /dev/null +++ b/google-shopping-css-v1/proto_docs/google/api/launch_stage.rb @@ -0,0 +1,71 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Api + # The launch stage as defined by [Google Cloud Platform + # Launch Stages](https://cloud.google.com/terms/launch-stages). + module LaunchStage + # Do not use this default value. + LAUNCH_STAGE_UNSPECIFIED = 0 + + # The feature is not yet implemented. Users can not use it. + UNIMPLEMENTED = 6 + + # Prelaunch features are hidden from users and are only visible internally. + PRELAUNCH = 7 + + # Early Access features are limited to a closed group of testers. To use + # these features, you must sign up in advance and sign a Trusted Tester + # agreement (which includes confidentiality provisions). These features may + # be unstable, changed in backward-incompatible ways, and are not + # guaranteed to be released. + EARLY_ACCESS = 1 + + # Alpha is a limited availability test for releases before they are cleared + # for widespread use. By Alpha, all significant design issues are resolved + # and we are in the process of verifying functionality. Alpha customers + # need to apply for access, agree to applicable terms, and have their + # projects allowlisted. Alpha releases don't have to be feature complete, + # no SLAs are provided, and there are no technical support obligations, but + # they will be far enough along that customers can actually use them in + # test environments or for limited-use tests -- just like they would in + # normal production cases. + ALPHA = 2 + + # Beta is the point at which we are ready to open a release for any + # customer to use. There are no SLA or technical support obligations in a + # Beta release. Products will be complete from a feature perspective, but + # may have some open outstanding issues. Beta releases are suitable for + # limited production use cases. + BETA = 3 + + # GA features are open to all developers and are considered stable and + # fully qualified for production use. + GA = 4 + + # Deprecated features are scheduled to be shut down and removed. For more + # information, see the "Deprecation Policy" section of our [Terms of + # Service](https://cloud.google.com/terms/) + # and the [Google Cloud Platform Subject to the Deprecation + # Policy](https://cloud.google.com/terms/deprecation) documentation. + DEPRECATED = 5 + end + end +end diff --git a/google-shopping-css-v1/proto_docs/google/api/resource.rb b/google-shopping-css-v1/proto_docs/google/api/resource.rb new file mode 100644 index 000000000000..6497ebc78dc1 --- /dev/null +++ b/google-shopping-css-v1/proto_docs/google/api/resource.rb @@ -0,0 +1,222 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Api + # A simple descriptor of a resource type. + # + # ResourceDescriptor annotates a resource message (either by means of a + # protobuf annotation or use in the service config), and associates the + # resource's schema, the resource type, and the pattern of the resource name. + # + # Example: + # + # message Topic { + # // Indicates this message defines a resource schema. + # // Declares the resource type in the format of {service}/{kind}. + # // For Kubernetes resources, the format is {api group}/{kind}. + # option (google.api.resource) = { + # type: "pubsub.googleapis.com/Topic" + # pattern: "projects/{project}/topics/{topic}" + # }; + # } + # + # The ResourceDescriptor Yaml config will look like: + # + # resources: + # - type: "pubsub.googleapis.com/Topic" + # pattern: "projects/{project}/topics/{topic}" + # + # Sometimes, resources have multiple patterns, typically because they can + # live under multiple parents. + # + # Example: + # + # message LogEntry { + # option (google.api.resource) = { + # type: "logging.googleapis.com/LogEntry" + # pattern: "projects/{project}/logs/{log}" + # pattern: "folders/{folder}/logs/{log}" + # pattern: "organizations/{organization}/logs/{log}" + # pattern: "billingAccounts/{billing_account}/logs/{log}" + # }; + # } + # + # The ResourceDescriptor Yaml config will look like: + # + # resources: + # - type: 'logging.googleapis.com/LogEntry' + # pattern: "projects/{project}/logs/{log}" + # pattern: "folders/{folder}/logs/{log}" + # pattern: "organizations/{organization}/logs/{log}" + # pattern: "billingAccounts/{billing_account}/logs/{log}" + # @!attribute [rw] type + # @return [::String] + # The resource type. It must be in the format of + # \\{service_name}/\\{resource_type_kind}. The `resource_type_kind` must be + # singular and must not include version numbers. + # + # Example: `storage.googleapis.com/Bucket` + # + # The value of the resource_type_kind must follow the regular expression + # /[A-Za-z][a-zA-Z0-9]+/. It should start with an upper case character and + # should use PascalCase (UpperCamelCase). The maximum number of + # characters allowed for the `resource_type_kind` is 100. + # @!attribute [rw] pattern + # @return [::Array<::String>] + # Optional. The relative resource name pattern associated with this resource + # type. The DNS prefix of the full resource name shouldn't be specified here. + # + # The path pattern must follow the syntax, which aligns with HTTP binding + # syntax: + # + # Template = Segment { "/" Segment } ; + # Segment = LITERAL | Variable ; + # Variable = "{" LITERAL "}" ; + # + # Examples: + # + # - "projects/\\{project}/topics/\\{topic}" + # - "projects/\\{project}/knowledgeBases/\\{knowledge_base}" + # + # The components in braces correspond to the IDs for each resource in the + # hierarchy. It is expected that, if multiple patterns are provided, + # the same component name (e.g. "project") refers to IDs of the same + # type of resource. + # @!attribute [rw] name_field + # @return [::String] + # Optional. The field on the resource that designates the resource name + # field. If omitted, this is assumed to be "name". + # @!attribute [rw] history + # @return [::Google::Api::ResourceDescriptor::History] + # Optional. The historical or future-looking state of the resource pattern. + # + # Example: + # + # // The InspectTemplate message originally only supported resource + # // names with organization, and project was added later. + # message InspectTemplate { + # option (google.api.resource) = { + # type: "dlp.googleapis.com/InspectTemplate" + # pattern: + # "organizations/{organization}/inspectTemplates/{inspect_template}" + # pattern: "projects/{project}/inspectTemplates/{inspect_template}" + # history: ORIGINALLY_SINGLE_PATTERN + # }; + # } + # @!attribute [rw] plural + # @return [::String] + # The plural name used in the resource name and permission names, such as + # 'projects' for the resource name of 'projects/\\{project}' and the permission + # name of 'cloudresourcemanager.googleapis.com/projects.get'. It is the same + # concept of the `plural` field in k8s CRD spec + # https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/ + # + # Note: The plural form is required even for singleton resources. See + # https://aip.dev/156 + # @!attribute [rw] singular + # @return [::String] + # The same concept of the `singular` field in k8s CRD spec + # https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/ + # Such as "project" for the `resourcemanager.googleapis.com/Project` type. + # @!attribute [rw] style + # @return [::Array<::Google::Api::ResourceDescriptor::Style>] + # Style flag(s) for this resource. + # These indicate that a resource is expected to conform to a given + # style. See the specific style flags for additional information. + class ResourceDescriptor + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + + # A description of the historical or future-looking state of the + # resource pattern. + module History + # The "unset" value. + HISTORY_UNSPECIFIED = 0 + + # The resource originally had one pattern and launched as such, and + # additional patterns were added later. + ORIGINALLY_SINGLE_PATTERN = 1 + + # The resource has one pattern, but the API owner expects to add more + # later. (This is the inverse of ORIGINALLY_SINGLE_PATTERN, and prevents + # that from being necessary once there are multiple patterns.) + FUTURE_MULTI_PATTERN = 2 + end + + # A flag representing a specific style that a resource claims to conform to. + module Style + # The unspecified value. Do not use. + STYLE_UNSPECIFIED = 0 + + # This resource is intended to be "declarative-friendly". + # + # Declarative-friendly resources must be more strictly consistent, and + # setting this to true communicates to tools that this resource should + # adhere to declarative-friendly expectations. + # + # Note: This is used by the API linter (linter.aip.dev) to enable + # additional checks. + DECLARATIVE_FRIENDLY = 1 + end + end + + # Defines a proto annotation that describes a string field that refers to + # an API resource. + # @!attribute [rw] type + # @return [::String] + # The resource type that the annotated field references. + # + # Example: + # + # message Subscription { + # string topic = 2 [(google.api.resource_reference) = { + # type: "pubsub.googleapis.com/Topic" + # }]; + # } + # + # Occasionally, a field may reference an arbitrary resource. In this case, + # APIs use the special value * in their resource reference. + # + # Example: + # + # message GetIamPolicyRequest { + # string resource = 2 [(google.api.resource_reference) = { + # type: "*" + # }]; + # } + # @!attribute [rw] child_type + # @return [::String] + # The resource type of a child collection that the annotated field + # references. This is useful for annotating the `parent` field that + # doesn't have a fixed resource type. + # + # Example: + # + # message ListLogEntriesRequest { + # string parent = 1 [(google.api.resource_reference) = { + # child_type: "logging.googleapis.com/LogEntry" + # }; + # } + class ResourceReference + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + end +end diff --git a/google-shopping-css-v1/proto_docs/google/protobuf/duration.rb b/google-shopping-css-v1/proto_docs/google/protobuf/duration.rb new file mode 100644 index 000000000000..b5731a824060 --- /dev/null +++ b/google-shopping-css-v1/proto_docs/google/protobuf/duration.rb @@ -0,0 +1,98 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Protobuf + # A Duration represents a signed, fixed-length span of time represented + # as a count of seconds and fractions of seconds at nanosecond + # resolution. It is independent of any calendar and concepts like "day" + # or "month". It is related to Timestamp in that the difference between + # two Timestamp values is a Duration and it can be added or subtracted + # from a Timestamp. Range is approximately +-10,000 years. + # + # # Examples + # + # Example 1: Compute Duration from two Timestamps in pseudo code. + # + # Timestamp start = ...; + # Timestamp end = ...; + # Duration duration = ...; + # + # duration.seconds = end.seconds - start.seconds; + # duration.nanos = end.nanos - start.nanos; + # + # if (duration.seconds < 0 && duration.nanos > 0) { + # duration.seconds += 1; + # duration.nanos -= 1000000000; + # } else if (duration.seconds > 0 && duration.nanos < 0) { + # duration.seconds -= 1; + # duration.nanos += 1000000000; + # } + # + # Example 2: Compute Timestamp from Timestamp + Duration in pseudo code. + # + # Timestamp start = ...; + # Duration duration = ...; + # Timestamp end = ...; + # + # end.seconds = start.seconds + duration.seconds; + # end.nanos = start.nanos + duration.nanos; + # + # if (end.nanos < 0) { + # end.seconds -= 1; + # end.nanos += 1000000000; + # } else if (end.nanos >= 1000000000) { + # end.seconds += 1; + # end.nanos -= 1000000000; + # } + # + # Example 3: Compute Duration from datetime.timedelta in Python. + # + # td = datetime.timedelta(days=3, minutes=10) + # duration = Duration() + # duration.FromTimedelta(td) + # + # # JSON Mapping + # + # In JSON format, the Duration type is encoded as a string rather than an + # object, where the string ends in the suffix "s" (indicating seconds) and + # is preceded by the number of seconds, with nanoseconds expressed as + # fractional seconds. For example, 3 seconds with 0 nanoseconds should be + # encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should + # be expressed in JSON format as "3.000000001s", and 3 seconds and 1 + # microsecond should be expressed in JSON format as "3.000001s". + # @!attribute [rw] seconds + # @return [::Integer] + # Signed seconds of the span of time. Must be from -315,576,000,000 + # to +315,576,000,000 inclusive. Note: these bounds are computed from: + # 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years + # @!attribute [rw] nanos + # @return [::Integer] + # Signed fractions of a second at nanosecond resolution of the span + # of time. Durations less than one second are represented with a 0 + # `seconds` field and a positive or negative `nanos` field. For durations + # of one second or more, a non-zero value for the `nanos` field must be + # of the same sign as the `seconds` field. Must be from -999,999,999 + # to +999,999,999 inclusive. + class Duration + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + end +end diff --git a/google-shopping-css-v1/proto_docs/google/protobuf/empty.rb b/google-shopping-css-v1/proto_docs/google/protobuf/empty.rb new file mode 100644 index 000000000000..8c6b19d52e3d --- /dev/null +++ b/google-shopping-css-v1/proto_docs/google/protobuf/empty.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Protobuf + # A generic empty message that you can re-use to avoid defining duplicated + # empty messages in your APIs. A typical example is to use it as the request + # or the response type of an API method. For instance: + # + # service Foo { + # rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); + # } + class Empty + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + end +end diff --git a/google-shopping-css-v1/proto_docs/google/protobuf/timestamp.rb b/google-shopping-css-v1/proto_docs/google/protobuf/timestamp.rb new file mode 100644 index 000000000000..4ac9c4801a3f --- /dev/null +++ b/google-shopping-css-v1/proto_docs/google/protobuf/timestamp.rb @@ -0,0 +1,127 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Protobuf + # A Timestamp represents a point in time independent of any time zone or local + # calendar, encoded as a count of seconds and fractions of seconds at + # nanosecond resolution. The count is relative to an epoch at UTC midnight on + # January 1, 1970, in the proleptic Gregorian calendar which extends the + # Gregorian calendar backwards to year one. + # + # All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap + # second table is needed for interpretation, using a [24-hour linear + # smear](https://developers.google.com/time/smear). + # + # The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By + # restricting to that range, we ensure that we can convert to and from [RFC + # 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings. + # + # # Examples + # + # Example 1: Compute Timestamp from POSIX `time()`. + # + # Timestamp timestamp; + # timestamp.set_seconds(time(NULL)); + # timestamp.set_nanos(0); + # + # Example 2: Compute Timestamp from POSIX `gettimeofday()`. + # + # struct timeval tv; + # gettimeofday(&tv, NULL); + # + # Timestamp timestamp; + # timestamp.set_seconds(tv.tv_sec); + # timestamp.set_nanos(tv.tv_usec * 1000); + # + # Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. + # + # FILETIME ft; + # GetSystemTimeAsFileTime(&ft); + # UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; + # + # // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z + # // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. + # Timestamp timestamp; + # timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); + # timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); + # + # Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. + # + # long millis = System.currentTimeMillis(); + # + # Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) + # .setNanos((int) ((millis % 1000) * 1000000)).build(); + # + # Example 5: Compute Timestamp from Java `Instant.now()`. + # + # Instant now = Instant.now(); + # + # Timestamp timestamp = + # Timestamp.newBuilder().setSeconds(now.getEpochSecond()) + # .setNanos(now.getNano()).build(); + # + # Example 6: Compute Timestamp from current time in Python. + # + # timestamp = Timestamp() + # timestamp.GetCurrentTime() + # + # # JSON Mapping + # + # In JSON format, the Timestamp type is encoded as a string in the + # [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the + # format is "\\{year}-\\{month}-\\{day}T\\{hour}:\\{min}:\\{sec}[.\\{frac_sec}]Z" + # where \\{year} is always expressed using four digits while \\{month}, \\{day}, + # \\{hour}, \\{min}, and \\{sec} are zero-padded to two digits each. The fractional + # seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), + # are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone + # is required. A proto3 JSON serializer should always use UTC (as indicated by + # "Z") when printing the Timestamp type and a proto3 JSON parser should be + # able to accept both UTC and other timezones (as indicated by an offset). + # + # For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past + # 01:30 UTC on January 15, 2017. + # + # In JavaScript, one can convert a Date object to this format using the + # standard + # [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString) + # method. In Python, a standard `datetime.datetime` object can be converted + # to this format using + # [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with + # the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use + # the Joda Time's [`ISODateTimeFormat.dateTime()`]( + # http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime() + # ) to obtain a formatter capable of generating timestamps in this format. + # @!attribute [rw] seconds + # @return [::Integer] + # Represents seconds of UTC time since Unix epoch + # 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to + # 9999-12-31T23:59:59Z inclusive. + # @!attribute [rw] nanos + # @return [::Integer] + # Non-negative fractions of a second at nanosecond resolution. Negative + # second values with fractions must still have non-negative nanos values + # that count forward in time. Must be from 0 to 999,999,999 + # inclusive. + class Timestamp + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + end +end diff --git a/google-shopping-css-v1/proto_docs/google/shopping/css/v1/accounts.rb b/google-shopping-css-v1/proto_docs/google/shopping/css/v1/accounts.rb new file mode 100644 index 000000000000..d1e84348438e --- /dev/null +++ b/google-shopping-css-v1/proto_docs/google/shopping/css/v1/accounts.rb @@ -0,0 +1,168 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Shopping + module Css + module V1 + # The request message for the `ListChildAccounts` method. + # @!attribute [rw] parent + # @return [::String] + # Required. The parent account. Must be a CSS group or domain. + # Format: accounts/\\{account} + # @!attribute [rw] label_id + # @return [::Integer] + # If set, only the MC accounts with the given label ID will be returned. + # @!attribute [rw] full_name + # @return [::String] + # If set, only the MC accounts with the given name (case sensitive) will be + # returned. + # @!attribute [rw] page_size + # @return [::Integer] + # Optional. The maximum number of accounts to return. The service may return + # fewer than this value. If unspecified, at most 50 accounts will be + # returned. The maximum value is 1000; values above 1000 will be coerced to + # 1000. + # @!attribute [rw] page_token + # @return [::String] + # Optional. A page token, received from a previous `ListChildAccounts` call. + # Provide this to retrieve the subsequent page. + # + # When paginating, all other parameters provided to `ListChildAccounts` must + # match the call that provided the page token. + class ListChildAccountsRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Response message for the `ListChildAccounts` method. + # @!attribute [rw] accounts + # @return [::Array<::Google::Shopping::Css::V1::Account>] + # The CSS/MC accounts returned for the specified CSS parent account. + # @!attribute [rw] next_page_token + # @return [::String] + # A token, which can be sent as `page_token` to retrieve the next page. + # If this field is omitted, there are no subsequent pages. + class ListChildAccountsResponse + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # The request message for the `GetAccount` method. + # @!attribute [rw] name + # @return [::String] + # Required. The name of the managed CSS/MC account. + # Format: accounts/\\{account} + # @!attribute [rw] parent + # @return [::String] + # Optional. Only required when retrieving MC account information. + # The CSS domain that is the parent resource of the MC account. + # Format: accounts/\\{account} + class GetAccountRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # The request message for the `UpdateLabels` method. + # @!attribute [rw] name + # @return [::String] + # Required. The label resource name. + # Format: accounts/\\{account} + # @!attribute [rw] label_ids + # @return [::Array<::Integer>] + # The list of label IDs to overwrite the existing account label IDs. + # If the list is empty, all currently assigned label IDs will be deleted. + # @!attribute [rw] parent + # @return [::String] + # Optional. Only required when updating MC account labels. + # The CSS domain that is the parent resource of the MC account. + # Format: accounts/\\{account} + class UpdateAccountLabelsRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Information about CSS/MC account. + # @!attribute [rw] name + # @return [::String] + # The label resource name. + # Format: accounts/\\{account} + # @!attribute [r] full_name + # @return [::String] + # Output only. Immutable. The CSS/MC account's full name. + # @!attribute [rw] display_name + # @return [::String] + # The CSS/MC account's short display name. + # @!attribute [r] homepage_uri + # @return [::String] + # Output only. Immutable. The CSS/MC account's homepage. + # @!attribute [rw] parent + # @return [::String] + # The CSS/MC account's parent resource. CSS group for CSS domains; CSS + # domain for MC accounts. Returned only if the user has access to the + # parent account. + # @!attribute [rw] label_ids + # @return [::Array<::Integer>] + # Manually created label IDs assigned to the CSS/MC account by a CSS parent + # account. + # @!attribute [rw] automatic_label_ids + # @return [::Array<::Integer>] + # Automatically created label IDs assigned to the MC account by + # CSS Center. + # @!attribute [r] account_type + # @return [::Google::Shopping::Css::V1::Account::AccountType] + # Output only. The type of this account. + class Account + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + + # The account type. + module AccountType + # Unknown account type. + ACCOUNT_TYPE_UNSPECIFIED = 0 + + # CSS group account. + CSS_GROUP = 1 + + # CSS domain account. + CSS_DOMAIN = 2 + + # MC Primary CSS MCA account. + MC_PRIMARY_CSS_MCA = 3 + + # MC CSS MCA account. + MC_CSS_MCA = 4 + + # MC Marketplace MCA account. + MC_MARKETPLACE_MCA = 5 + + # MC Other MCA account. + MC_OTHER_MCA = 6 + + # MC Standalone account. + MC_STANDALONE = 7 + + # MC MCA sub-account. + MC_MCA_SUBACCOUNT = 8 + end + end + end + end + end +end diff --git a/google-shopping-css-v1/proto_docs/google/shopping/css/v1/accounts_labels.rb b/google-shopping-css-v1/proto_docs/google/shopping/css/v1/accounts_labels.rb new file mode 100644 index 000000000000..cb6857a7d3f3 --- /dev/null +++ b/google-shopping-css-v1/proto_docs/google/shopping/css/v1/accounts_labels.rb @@ -0,0 +1,131 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Shopping + module Css + module V1 + # Label assigned by CSS domain or CSS group to one of its sub-accounts. + # @!attribute [rw] name + # @return [::String] + # The resource name of the label. + # Format: accounts/\\{account}/labels/\\{label} + # @!attribute [r] label_id + # @return [::Integer] + # Output only. The ID of the label. + # @!attribute [r] account_id + # @return [::Integer] + # Output only. The ID of account this label belongs to. + # @!attribute [rw] display_name + # @return [::String] + # The display name of this label. + # @!attribute [rw] description + # @return [::String] + # The description of this label. + # @!attribute [r] label_type + # @return [::Google::Shopping::Css::V1::AccountLabel::LabelType] + # Output only. The type of this label. + class AccountLabel + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + + # The label type. + module LabelType + # Unknown label type. + LABEL_TYPE_UNSPECIFIED = 0 + + # Indicates that the label was created manually. + MANUAL = 1 + + # Indicates that the label was created automatically by CSS Center. + AUTOMATIC = 2 + end + end + + # Request message for the `ListAccountLabels` method. + # @!attribute [rw] parent + # @return [::String] + # Required. The parent account. + # Format: accounts/\\{account} + # @!attribute [rw] page_size + # @return [::Integer] + # The maximum number of labels to return. The service may return fewer than + # this value. + # If unspecified, at most 50 labels will be returned. + # The maximum value is 1000; values above 1000 will be coerced to 1000. + # @!attribute [rw] page_token + # @return [::String] + # A page token, received from a previous `ListAccountLabels` call. + # Provide this to retrieve the subsequent page. + # + # When paginating, all other parameters provided to `ListAccountLabels` must + # match the call that provided the page token. + class ListAccountLabelsRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Response message for the `ListAccountLabels` method. + # @!attribute [rw] account_labels + # @return [::Array<::Google::Shopping::Css::V1::AccountLabel>] + # The labels from the specified account. + # @!attribute [rw] next_page_token + # @return [::String] + # A token, which can be sent as `page_token` to retrieve the next page. + # If this field is omitted, there are no subsequent pages. + class ListAccountLabelsResponse + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Request message for the 'CreateAccountLanel' method. + # @!attribute [rw] parent + # @return [::String] + # Required. The parent account. + # Format: accounts/\\{account} + # @!attribute [rw] account_label + # @return [::Google::Shopping::Css::V1::AccountLabel] + # Required. The label to create. + class CreateAccountLabelRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Request message for the `UpdateAccountLabel` method. + # @!attribute [rw] account_label + # @return [::Google::Shopping::Css::V1::AccountLabel] + # Required. The updated label. All fields must be provided. + class UpdateAccountLabelRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Request message for the 'DeleteAccountLabel' method. + # @!attribute [rw] name + # @return [::String] + # Required. The name of the label to delete. + # Format: accounts/\\{account}/labels/\\{label} + class DeleteAccountLabelRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + end + end + end +end diff --git a/google-shopping-css-v1/proto_docs/google/shopping/css/v1/css_product_common.rb b/google-shopping-css-v1/proto_docs/google/shopping/css/v1/css_product_common.rb new file mode 100644 index 000000000000..81a23659ed24 --- /dev/null +++ b/google-shopping-css-v1/proto_docs/google/shopping/css/v1/css_product_common.rb @@ -0,0 +1,352 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Shopping + module Css + module V1 + # Attributes for CSS Product. + # @!attribute [rw] cpp_link + # @return [::String] + # URL directly linking to your the Product Detail Page of the CSS. + # @!attribute [rw] cpp_mobile_link + # @return [::String] + # URL for the mobile-optimized version of the Product Detail Page of the CSS. + # @!attribute [rw] cpp_ads_redirect + # @return [::String] + # Allows advertisers to override the item URL when the product is shown + # within the context of Product Ads. + # @!attribute [rw] low_price + # @return [::Google::Shopping::Type::Price] + # Low Price of the aggregate offer. + # @!attribute [rw] high_price + # @return [::Google::Shopping::Type::Price] + # High Price of the aggregate offer. + # @!attribute [rw] number_of_offers + # @return [::Integer] + # The number of aggregate offers. + # @!attribute [rw] headline_offer_condition + # @return [::String] + # Condition of the headline offer. + # @!attribute [rw] headline_offer_price + # @return [::Google::Shopping::Type::Price] + # Headline Price of the aggregate offer. + # @!attribute [rw] headline_offer_link + # @return [::String] + # Link to the headline offer. + # @!attribute [rw] headline_offer_mobile_link + # @return [::String] + # Mobile Link to the headline offer. + # @!attribute [rw] headline_offer_shipping_price + # @return [::Google::Shopping::Type::Price] + # Headline Price of the aggregate offer. + # @!attribute [rw] title + # @return [::String] + # Title of the item. + # @!attribute [rw] image_link + # @return [::String] + # URL of an image of the item. + # @!attribute [rw] additional_image_links + # @return [::Array<::String>] + # Additional URL of images of the item. + # @!attribute [rw] description + # @return [::String] + # Description of the item. + # @!attribute [rw] brand + # @return [::String] + # Product Related Attributes.[14-36] + # Brand of the item. + # @!attribute [rw] mpn + # @return [::String] + # Manufacturer Part Number + # ([MPN](https://support.google.com/merchants/answer/188494#mpn)) of the + # item. + # @!attribute [rw] gtin + # @return [::String] + # Global Trade Item Number + # ([GTIN](https://support.google.com/merchants/answer/188494#gtin)) of the + # item. + # @!attribute [rw] product_types + # @return [::Array<::String>] + # Categories of the item (formatted as in [products data + # specification](https://support.google.com/merchants/answer/6324406)). + # @!attribute [rw] google_product_category + # @return [::String] + # Google's category of the item (see [Google product + # taxonomy](https://support.google.com/merchants/answer/1705911)). When + # querying products, this field will contain the user provided value. There + # is currently no way to get back the auto assigned google product + # categories through the API. + # @!attribute [rw] adult + # @return [::Boolean] + # Set to true if the item is targeted towards adults. + # @!attribute [rw] multipack + # @return [::Integer] + # The number of identical products in a merchant-defined multipack. + # @!attribute [rw] is_bundle + # @return [::Boolean] + # Whether the item is a merchant-defined bundle. A bundle is a custom + # grouping of different products sold by a merchant for a single price. + # @!attribute [rw] age_group + # @return [::String] + # Target age group of the item. + # @!attribute [rw] color + # @return [::String] + # Color of the item. + # @!attribute [rw] gender + # @return [::String] + # Target gender of the item. + # @!attribute [rw] material + # @return [::String] + # The material of which the item is made. + # @!attribute [rw] pattern + # @return [::String] + # The item's pattern (e.g. polka dots). + # @!attribute [rw] size + # @return [::String] + # Size of the item. Only one value is allowed. For variants with different + # sizes, insert a separate product for each size with the same + # `itemGroupId` value (see + # [https://support.google.com/merchants/answer/6324492](size definition)). + # @!attribute [rw] size_system + # @return [::String] + # System in which the size is specified. Recommended for apparel items. + # @!attribute [rw] size_types + # @return [::Array<::String>] + # The cut of the item. It can be used to represent combined size types for + # apparel items. Maximum two of size types can be provided (see + # [https://support.google.com/merchants/answer/6324497](size type)). + # @!attribute [rw] item_group_id + # @return [::String] + # Shared identifier for all variants of the same product. + # @!attribute [rw] product_details + # @return [::Array<::Google::Shopping::Css::V1::ProductDetail>] + # Technical specification or additional product details. + # @!attribute [rw] product_weight + # @return [::Google::Shopping::Css::V1::ProductWeight] + # The weight of the product in the units provided. The value must be + # between 0 (exclusive) and 2000 (inclusive). + # @!attribute [rw] product_length + # @return [::Google::Shopping::Css::V1::ProductDimension] + # The length of the product in the units provided. The value must be + # between 0 (exclusive) and 3000 (inclusive). + # @!attribute [rw] product_width + # @return [::Google::Shopping::Css::V1::ProductDimension] + # The width of the product in the units provided. The value must be between + # 0 (exclusive) and 3000 (inclusive). + # @!attribute [rw] product_height + # @return [::Google::Shopping::Css::V1::ProductDimension] + # The height of the product in the units provided. The value must be + # between + # 0 (exclusive) and 3000 (inclusive). + # @!attribute [rw] product_highlights + # @return [::Array<::String>] + # Bullet points describing the most relevant highlights of a product. + # @!attribute [rw] certifications + # @return [::Array<::Google::Shopping::Css::V1::Certification>] + # A list of certificates claimed by the CSS for the given product. + # @!attribute [rw] expiration_date + # @return [::Google::Protobuf::Timestamp] + # Date on which the item should expire, as specified upon insertion, in + # [ISO + # 8601](http://en.wikipedia.org/wiki/ISO_8601) format. The actual + # expiration date in Google Shopping is exposed in `productstatuses` as + # [googleExpirationDate](https://support.google.com/merchants/answer/6324499) + # and might be earlier if `expirationDate` is too far in the future. + # Note: It may take 2+ days from the expiration date for the item to + # actually get deleted. + # @!attribute [rw] included_destinations + # @return [::Array<::String>] + # The list of destinations to include for this target (corresponds to + # checked check boxes in Merchant Center). Default destinations are always + # included unless provided in `excludedDestinations`. + # @!attribute [rw] excluded_destinations + # @return [::Array<::String>] + # The list of destinations to exclude for this target (corresponds to + # unchecked check boxes in Merchant Center). + # @!attribute [rw] pause + # @return [::String] + # Publication of this item will be temporarily paused. + # @!attribute [rw] custom_label_0 + # @return [::String] + # Custom label 0 for custom grouping of items in a Shopping campaign. + # @!attribute [rw] custom_label_1 + # @return [::String] + # Custom label 1 for custom grouping of items in a Shopping campaign. + # @!attribute [rw] custom_label_2 + # @return [::String] + # Custom label 2 for custom grouping of items in a Shopping campaign. + # @!attribute [rw] custom_label_3 + # @return [::String] + # Custom label 3 for custom grouping of items in a Shopping campaign. + # @!attribute [rw] custom_label_4 + # @return [::String] + # Custom label 4 for custom grouping of items in a Shopping campaign. + class Attributes + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # The certification for the product. + # @!attribute [rw] name + # @return [::String] + # Name of the certification. + # @!attribute [rw] authority + # @return [::String] + # Name of the certification body. + # @!attribute [rw] code + # @return [::String] + # A unique code to identify the certification. + class Certification + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # The product details. + # @!attribute [rw] section_name + # @return [::String] + # The section header used to group a set of product details. + # @!attribute [rw] attribute_name + # @return [::String] + # The name of the product detail. + # @!attribute [rw] attribute_value + # @return [::String] + # The value of the product detail. + class ProductDetail + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # The dimension of the product. + # @!attribute [rw] value + # @return [::Float] + # Required. The dimension value represented as a number. The value can have a + # maximum precision of four decimal places. + # @!attribute [rw] unit + # @return [::String] + # Required. The dimension units. + # Acceptable values are: + # * "`in`" + # * "`cm`" + class ProductDimension + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # The weight of the product. + # @!attribute [rw] value + # @return [::Float] + # Required. The weight represented as a number. The weight can have a maximum + # precision of four decimal places. + # @!attribute [rw] unit + # @return [::String] + # Required. The weight unit. + # Acceptable values are: + # * "`g`" + # * "`kg`" + # * "`oz`" + # * "`lb`" + class ProductWeight + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # The status of the Css Product, data validation issues, that is, + # information about the Css Product computed asynchronously. + # @!attribute [rw] destination_statuses + # @return [::Array<::Google::Shopping::Css::V1::CssProductStatus::DestinationStatus>] + # The intended destinations for the product. + # @!attribute [rw] item_level_issues + # @return [::Array<::Google::Shopping::Css::V1::CssProductStatus::ItemLevelIssue>] + # A list of all issues associated with the product. + # @!attribute [rw] creation_date + # @return [::Google::Protobuf::Timestamp] + # Date on which the item has been created, in [ISO + # 8601](http://en.wikipedia.org/wiki/ISO_8601) format. + # @!attribute [rw] last_update_date + # @return [::Google::Protobuf::Timestamp] + # Date on which the item has been last updated, in [ISO + # 8601](http://en.wikipedia.org/wiki/ISO_8601) format. + # @!attribute [rw] google_expiration_date + # @return [::Google::Protobuf::Timestamp] + # Date on which the item expires in Google Shopping, in [ISO + # 8601](http://en.wikipedia.org/wiki/ISO_8601) format. + class CssProductStatus + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + + # The destination status of the product status. + # @!attribute [rw] destination + # @return [::String] + # The name of the destination + # @!attribute [rw] approved_countries + # @return [::Array<::String>] + # List of country codes (ISO 3166-1 alpha-2) where the aggregate offer is + # approved. + # @!attribute [rw] pending_countries + # @return [::Array<::String>] + # List of country codes (ISO 3166-1 alpha-2) where the aggregate offer is + # pending approval. + # @!attribute [rw] disapproved_countries + # @return [::Array<::String>] + # List of country codes (ISO 3166-1 alpha-2) where the aggregate offer is + # disapproved. + class DestinationStatus + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # The ItemLevelIssue of the product status. + # @!attribute [rw] code + # @return [::String] + # The error code of the issue. + # @!attribute [rw] servability + # @return [::String] + # How this issue affects serving of the aggregate offer. + # @!attribute [rw] resolution + # @return [::String] + # Whether the issue can be resolved by the merchant. + # @!attribute [rw] attribute + # @return [::String] + # The attribute's name, if the issue is caused by a single attribute. + # @!attribute [rw] destination + # @return [::String] + # The destination the issue applies to. + # @!attribute [rw] description + # @return [::String] + # A short issue description in English. + # @!attribute [rw] detail + # @return [::String] + # A detailed issue description in English. + # @!attribute [rw] documentation + # @return [::String] + # The URL of a web page to help with resolving this issue. + # @!attribute [rw] applicable_countries + # @return [::Array<::String>] + # List of country codes (ISO 3166-1 alpha-2) where issue applies to the + # aggregate offer. + class ItemLevelIssue + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + end + end + end + end +end diff --git a/google-shopping-css-v1/proto_docs/google/shopping/css/v1/css_product_inputs.rb b/google-shopping-css-v1/proto_docs/google/shopping/css/v1/css_product_inputs.rb new file mode 100644 index 000000000000..771d7760f071 --- /dev/null +++ b/google-shopping-css-v1/proto_docs/google/shopping/css/v1/css_product_inputs.rb @@ -0,0 +1,130 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Shopping + module Css + module V1 + # This resource represents input data you submit for a CSS Product, not + # the processed CSS Product that you see in CSS Center, in Shopping Ads, or + # across Google surfaces. + # @!attribute [rw] name + # @return [::String] + # The name of the CSS Product input. + # Format: + # `accounts/{account}/cssProductInputs/{css_product_input}` + # @!attribute [r] final_name + # @return [::String] + # Output only. The name of the processed CSS Product. + # Format: + # `accounts/{account}/cssProducts/{css_product}` + # " + # @!attribute [rw] raw_provided_id + # @return [::String] + # Required. Your unique identifier for the CSS Product. This is the same for + # the CSS Product input and processed CSS Product. We only allow ids with + # alphanumerics, underscores and dashes. See the [products feed + # specification](https://support.google.com/merchants/answer/188494#id) for + # details. + # @!attribute [rw] content_language + # @return [::String] + # Required. The two-letter [ISO + # 639-1](http://en.wikipedia.org/wiki/ISO_639-1) language code for the CSS + # Product. + # @!attribute [rw] feed_label + # @return [::String] + # Required. The [feed + # label](https://developers.google.com/shopping-content/guides/products/feed-labels) + # for the CSS Product. + # Feed Label is synonymous to "target country" and hence should always be a + # valid region code. For example: 'DE' for Germany, 'FR' for France. + # @!attribute [rw] freshness_time + # @return [::Google::Protobuf::Timestamp] + # Represents the existing version (freshness) of the CSS Product, which + # can be used to preserve the right order when multiple updates are done at + # the same time. + # + # This field must not be set to the future time. + # + # If set, the update is prevented if a newer version of the item already + # exists in our system (that is the last update time of the existing + # CSS products is later than the freshness time set in the update). If + # the update happens, the last update time is then set to this freshness + # time. + # + # If not set, the update will not be prevented and the last update time will + # default to when this request was received by the CSS API. + # + # If the operation is prevented, the aborted exception will be + # thrown. + # @!attribute [rw] attributes + # @return [::Google::Shopping::Css::V1::Attributes] + # A list of CSS Product attributes. + # @!attribute [rw] custom_attributes + # @return [::Array<::Google::Shopping::Type::CustomAttribute>] + # A list of custom (CSS-provided) attributes. It can also be used for + # submitting any attribute of the feed specification in its generic + # form (for example: + # `{ "name": "size type", "value": "regular" }`). + # This is useful for submitting attributes not explicitly exposed by the + # API, such as additional attributes used for Buy on Google. + class CssProductInput + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Request message for the InsertCssProductInput method. + # @!attribute [rw] parent + # @return [::String] + # Required. The account where this CSS Product will be inserted. + # Format: accounts/\\{account} + # @!attribute [rw] css_product_input + # @return [::Google::Shopping::Css::V1::CssProductInput] + # Required. The CSS Product Input to insert. + # @!attribute [rw] feed_id + # @return [::Integer] + # Required. The primary or supplemental feed id. If CSS Product already + # exists and feed id provided is different, then the CSS Product will be + # moved to a new feed. Note: For now, CSSs do not need to provide feed ids as + # we create feeds on the fly. We do not have supplemental feed support for + # CSS Products yet. + class InsertCssProductInputRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Request message for the DeleteCssProductInput method. + # @!attribute [rw] name + # @return [::String] + # Required. The name of the CSS product input resource to delete. + # Format: accounts/\\{account}/cssProductInputs/\\{css_product_input} + # @!attribute [rw] supplemental_feed_id + # @return [::Integer] + # The Content API Supplemental Feed ID. + # The field must not be set if the action applies to a primary feed. + # If the field is set, then product action applies to a supplemental feed + # instead of primary Content API feed. + class DeleteCssProductInputRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + end + end + end +end diff --git a/google-shopping-css-v1/proto_docs/google/shopping/css/v1/css_products.rb b/google-shopping-css-v1/proto_docs/google/shopping/css/v1/css_products.rb new file mode 100644 index 000000000000..db5fee473412 --- /dev/null +++ b/google-shopping-css-v1/proto_docs/google/shopping/css/v1/css_products.rb @@ -0,0 +1,109 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Shopping + module Css + module V1 + # The request message for the `GetCssProduct` method. + # @!attribute [rw] name + # @return [::String] + # Required. The name of the CSS product to retrieve. + class GetCssProductRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # The processed CSS Product(a.k.a Aggregate Offer internally). + # @!attribute [rw] name + # @return [::String] + # The name of the CSS Product. + # Format: + # `"accounts/{account}/cssProducts/{css_product}"` + # @!attribute [r] raw_provided_id + # @return [::String] + # Output only. Your unique raw identifier for the product. + # @!attribute [r] content_language + # @return [::String] + # Output only. The two-letter [ISO + # 639-1](http://en.wikipedia.org/wiki/ISO_639-1) language code for the + # product. + # @!attribute [r] feed_label + # @return [::String] + # Output only. The feed label for the product. + # @!attribute [r] attributes + # @return [::Google::Shopping::Css::V1::Attributes] + # Output only. A list of product attributes. + # @!attribute [r] custom_attributes + # @return [::Array<::Google::Shopping::Type::CustomAttribute>] + # Output only. A list of custom (CSS-provided) attributes. It can also be + # used to submit any attribute of the feed specification in its generic form + # (for example, + # `{ "name": "size type", "value": "regular" }`). + # This is useful for submitting attributes not explicitly exposed by the + # API, such as additional attributes used for Buy on Google. + # @!attribute [r] css_product_status + # @return [::Google::Shopping::Css::V1::CssProductStatus] + # Output only. The status of a product, data validation issues, that is, + # information about a product computed asynchronously. + class CssProduct + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Request message for the ListCssProducts method. + # @!attribute [rw] parent + # @return [::String] + # Required. The account/domain to list processed CSS Products for. + # Format: accounts/\\{account} + # @!attribute [rw] page_size + # @return [::Integer] + # The maximum number of CSS Products to return. The service may return + # fewer than this value. + # The maximum value is 1000; values above 1000 will be coerced to 1000. If + # unspecified, the maximum number of CSS products will be returned. + # @!attribute [rw] page_token + # @return [::String] + # A page token, received from a previous `ListCssProducts` call. + # Provide this to retrieve the subsequent page. + # + # When paginating, all other parameters provided to `ListCssProducts` + # must match the call that provided the page token. + class ListCssProductsRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Response message for the ListCssProducts method. + # @!attribute [rw] css_products + # @return [::Array<::Google::Shopping::Css::V1::CssProduct>] + # The processed CSS products from the specified account. These are your + # processed CSS products after applying rules and supplemental feeds. + # @!attribute [rw] next_page_token + # @return [::String] + # A token, which can be sent as `page_token` to retrieve the next page. + # If this field is omitted, there are no subsequent pages. + class ListCssProductsResponse + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + end + end + end +end diff --git a/google-shopping-css-v1/proto_docs/google/shopping/type/types.rb b/google-shopping-css-v1/proto_docs/google/shopping/type/types.rb new file mode 100644 index 000000000000..7c4fd780655b --- /dev/null +++ b/google-shopping-css-v1/proto_docs/google/shopping/type/types.rb @@ -0,0 +1,210 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Shopping + module Type + # The weight represented as the value in string and the unit. + # @!attribute [rw] amount_micros + # @return [::Integer] + # Required. The weight represented as a number in micros (1 million micros is + # an equivalent to one's currency standard unit, for example, 1 kg = 1000000 + # micros). + # This field can also be set as infinity by setting to -1. + # This field only support -1 and positive value. + # @!attribute [rw] unit + # @return [::Google::Shopping::Type::Weight::WeightUnit] + # Required. The weight unit. + # Acceptable values are: kg and lb + class Weight + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + + # The weight unit. + module WeightUnit + # unit unspecified + WEIGHT_UNIT_UNSPECIFIED = 0 + + # lb unit. + POUND = 1 + + # kg unit. + KILOGRAM = 2 + end + end + + # The price represented as a number and currency. + # @!attribute [rw] amount_micros + # @return [::Integer] + # The price represented as a number in micros (1 million micros is an + # equivalent to one's currency standard unit, for example, 1 USD = 1000000 + # micros). + # @!attribute [rw] currency_code + # @return [::String] + # The currency of the price using three-letter acronyms according to [ISO + # 4217](http://en.wikipedia.org/wiki/ISO_4217). + class Price + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # A message that represents custom attributes. Exactly one of `value` or + # `group_values` must not be empty. + # @!attribute [rw] name + # @return [::String] + # The name of the attribute. + # @!attribute [rw] value + # @return [::String] + # The value of the attribute. If `value` is not empty, `group_values` must be + # empty. + # @!attribute [rw] group_values + # @return [::Array<::Google::Shopping::Type::CustomAttribute>] + # Subattributes within this attribute group. If + # `group_values` is not empty, `value` must be empty. + class CustomAttribute + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Destinations available for a product. + # + # Destinations are used in Merchant Center to allow you to control where the + # products from your data feed should be displayed. + class Destination + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + + # Destination values. + module DestinationEnum + # Not specified. + DESTINATION_ENUM_UNSPECIFIED = 0 + + # [Shopping ads](https://support.google.com/google-ads/answer/2454022). + SHOPPING_ADS = 1 + + # [Display ads](https://support.google.com/merchants/answer/6069387). + DISPLAY_ADS = 2 + + # [Local inventory + # ads](https://support.google.com/merchants/answer/3057972). + LOCAL_INVENTORY_ADS = 3 + + # [Free listings](https://support.google.com/merchants/answer/9199328). + FREE_LISTINGS = 4 + + # [Free local product + # listings](https://support.google.com/merchants/answer/9825611). + FREE_LOCAL_LISTINGS = 5 + + # [YouTube Shopping](https://support.google.com/merchants/answer/12362804). + YOUTUBE_SHOPPING = 6 + end + end + + # Reporting contexts that your account and product issues apply to. + # + # Reporting contexts are groups of surfaces and formats for product results on + # Google. They can represent the entire destination (for example, [Shopping + # ads](https://support.google.com/merchants/answer/6149970)) or a subset of + # formats within a destination (for example, [Demand Gen + # ads](https://support.google.com/merchants/answer/13389785)). + class ReportingContext + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + + # Reporting context values. + module ReportingContextEnum + # Not specified. + REPORTING_CONTEXT_ENUM_UNSPECIFIED = 0 + + # [Shopping ads](https://support.google.com/merchants/answer/6149970). + SHOPPING_ADS = 1 + + # Deprecated: Use `DEMAND_GEN_ADS` instead. + # [Discovery and Demand Gen + # ads](https://support.google.com/merchants/answer/13389785). + DISCOVERY_ADS = 2 + + # [Demand Gen ads](https://support.google.com/merchants/answer/13389785). + DEMAND_GEN_ADS = 13 + + # [Demand Gen ads on Discover + # surface](https://support.google.com/merchants/answer/13389785). + DEMAND_GEN_ADS_DISCOVER_SURFACE = 14 + + # [Video ads](https://support.google.com/google-ads/answer/6340491). + VIDEO_ADS = 3 + + # [Display ads](https://support.google.com/merchants/answer/6069387). + DISPLAY_ADS = 4 + + # [Local inventory + # ads](https://support.google.com/merchants/answer/3271956). + LOCAL_INVENTORY_ADS = 5 + + # [Vehicle inventory + # ads](https://support.google.com/merchants/answer/11544533). + VEHICLE_INVENTORY_ADS = 6 + + # [Free product + # listings](https://support.google.com/merchants/answer/9199328). + FREE_LISTINGS = 7 + + # [Free local product + # listings](https://support.google.com/merchants/answer/9825611). + FREE_LOCAL_LISTINGS = 8 + + # [Free local vehicle + # listings](https://support.google.com/merchants/answer/11544533). + FREE_LOCAL_VEHICLE_LISTINGS = 9 + + # [YouTube + # Shopping](https://support.google.com/merchants/answer/13478370). + YOUTUBE_SHOPPING = 10 + + # [Cloud retail](https://cloud.google.com/solutions/retail). + CLOUD_RETAIL = 11 + + # [Local cloud retail](https://cloud.google.com/solutions/retail). + LOCAL_CLOUD_RETAIL = 12 + end + end + + # [Channel](https://support.google.com/merchants/answer/7361332) of a product. + # + # Channel is used to distinguish between online and local products. + class Channel + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + + # Channel values. + module ChannelEnum + # Not specified. + CHANNEL_ENUM_UNSPECIFIED = 0 + + # Online product. + ONLINE = 1 + + # Local product. + LOCAL = 2 + end + end + end + end +end diff --git a/google-shopping-css-v1/snippets/Gemfile b/google-shopping-css-v1/snippets/Gemfile new file mode 100644 index 000000000000..7cad76eb1aa7 --- /dev/null +++ b/google-shopping-css-v1/snippets/Gemfile @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +source "https://rubygems.org" + +if ENV["GOOGLE_CLOUD_SAMPLES_TEST"] == "master" + gem "google-shopping-css-v1", path: "../" +else + gem "google-shopping-css-v1" +end + +group :test do + gem "google-style", "~> 1.26.1" + gem "minitest", "~> 5.16" + gem "minitest-focus", "~> 1.1" + gem "minitest-hooks", "~> 1.5" +end diff --git a/google-shopping-css-v1/snippets/account_labels_service/create_account_label.rb b/google-shopping-css-v1/snippets/account_labels_service/create_account_label.rb new file mode 100644 index 000000000000..2640cdb1b8a1 --- /dev/null +++ b/google-shopping-css-v1/snippets/account_labels_service/create_account_label.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START css_v1_generated_AccountLabelsService_CreateAccountLabel_sync] +require "google/shopping/css/v1" + +## +# Snippet for the create_account_label call in the AccountLabelsService service +# +# This snippet 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 as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Shopping::Css::V1::AccountLabelsService::Client#create_account_label. +# +def create_account_label + # Create a client object. The client can be reused for multiple calls. + client = Google::Shopping::Css::V1::AccountLabelsService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Shopping::Css::V1::CreateAccountLabelRequest.new + + # Call the create_account_label method. + result = client.create_account_label request + + # The returned object is of type Google::Shopping::Css::V1::AccountLabel. + p result +end +# [END css_v1_generated_AccountLabelsService_CreateAccountLabel_sync] diff --git a/google-shopping-css-v1/snippets/account_labels_service/delete_account_label.rb b/google-shopping-css-v1/snippets/account_labels_service/delete_account_label.rb new file mode 100644 index 000000000000..63799fa17dfd --- /dev/null +++ b/google-shopping-css-v1/snippets/account_labels_service/delete_account_label.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START css_v1_generated_AccountLabelsService_DeleteAccountLabel_sync] +require "google/shopping/css/v1" + +## +# Snippet for the delete_account_label call in the AccountLabelsService service +# +# This snippet 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 as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Shopping::Css::V1::AccountLabelsService::Client#delete_account_label. +# +def delete_account_label + # Create a client object. The client can be reused for multiple calls. + client = Google::Shopping::Css::V1::AccountLabelsService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Shopping::Css::V1::DeleteAccountLabelRequest.new + + # Call the delete_account_label method. + result = client.delete_account_label request + + # The returned object is of type Google::Protobuf::Empty. + p result +end +# [END css_v1_generated_AccountLabelsService_DeleteAccountLabel_sync] diff --git a/google-shopping-css-v1/snippets/account_labels_service/list_account_labels.rb b/google-shopping-css-v1/snippets/account_labels_service/list_account_labels.rb new file mode 100644 index 000000000000..00ee171c02a0 --- /dev/null +++ b/google-shopping-css-v1/snippets/account_labels_service/list_account_labels.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START css_v1_generated_AccountLabelsService_ListAccountLabels_sync] +require "google/shopping/css/v1" + +## +# Snippet for the list_account_labels call in the AccountLabelsService service +# +# This snippet 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 as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Shopping::Css::V1::AccountLabelsService::Client#list_account_labels. +# +def list_account_labels + # Create a client object. The client can be reused for multiple calls. + client = Google::Shopping::Css::V1::AccountLabelsService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Shopping::Css::V1::ListAccountLabelsRequest.new + + # Call the list_account_labels method. + result = client.list_account_labels request + + # The returned object is of type Gapic::PagedEnumerable. You can iterate + # over elements, and API calls will be issued to fetch pages as needed. + result.each do |item| + # Each element is of type ::Google::Shopping::Css::V1::AccountLabel. + p item + end +end +# [END css_v1_generated_AccountLabelsService_ListAccountLabels_sync] diff --git a/google-shopping-css-v1/snippets/account_labels_service/update_account_label.rb b/google-shopping-css-v1/snippets/account_labels_service/update_account_label.rb new file mode 100644 index 000000000000..41031474cdde --- /dev/null +++ b/google-shopping-css-v1/snippets/account_labels_service/update_account_label.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START css_v1_generated_AccountLabelsService_UpdateAccountLabel_sync] +require "google/shopping/css/v1" + +## +# Snippet for the update_account_label call in the AccountLabelsService service +# +# This snippet 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 as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Shopping::Css::V1::AccountLabelsService::Client#update_account_label. +# +def update_account_label + # Create a client object. The client can be reused for multiple calls. + client = Google::Shopping::Css::V1::AccountLabelsService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Shopping::Css::V1::UpdateAccountLabelRequest.new + + # Call the update_account_label method. + result = client.update_account_label request + + # The returned object is of type Google::Shopping::Css::V1::AccountLabel. + p result +end +# [END css_v1_generated_AccountLabelsService_UpdateAccountLabel_sync] diff --git a/google-shopping-css-v1/snippets/accounts_service/get_account.rb b/google-shopping-css-v1/snippets/accounts_service/get_account.rb new file mode 100644 index 000000000000..4ae53f38710b --- /dev/null +++ b/google-shopping-css-v1/snippets/accounts_service/get_account.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START css_v1_generated_AccountsService_GetAccount_sync] +require "google/shopping/css/v1" + +## +# Snippet for the get_account call in the AccountsService service +# +# This snippet 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 as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Shopping::Css::V1::AccountsService::Client#get_account. +# +def get_account + # Create a client object. The client can be reused for multiple calls. + client = Google::Shopping::Css::V1::AccountsService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Shopping::Css::V1::GetAccountRequest.new + + # Call the get_account method. + result = client.get_account request + + # The returned object is of type Google::Shopping::Css::V1::Account. + p result +end +# [END css_v1_generated_AccountsService_GetAccount_sync] diff --git a/google-shopping-css-v1/snippets/accounts_service/list_child_accounts.rb b/google-shopping-css-v1/snippets/accounts_service/list_child_accounts.rb new file mode 100644 index 000000000000..536c79475d46 --- /dev/null +++ b/google-shopping-css-v1/snippets/accounts_service/list_child_accounts.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START css_v1_generated_AccountsService_ListChildAccounts_sync] +require "google/shopping/css/v1" + +## +# Snippet for the list_child_accounts call in the AccountsService service +# +# This snippet 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 as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Shopping::Css::V1::AccountsService::Client#list_child_accounts. +# +def list_child_accounts + # Create a client object. The client can be reused for multiple calls. + client = Google::Shopping::Css::V1::AccountsService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Shopping::Css::V1::ListChildAccountsRequest.new + + # Call the list_child_accounts method. + result = client.list_child_accounts request + + # The returned object is of type Gapic::PagedEnumerable. You can iterate + # over elements, and API calls will be issued to fetch pages as needed. + result.each do |item| + # Each element is of type ::Google::Shopping::Css::V1::Account. + p item + end +end +# [END css_v1_generated_AccountsService_ListChildAccounts_sync] diff --git a/google-shopping-css-v1/snippets/accounts_service/update_labels.rb b/google-shopping-css-v1/snippets/accounts_service/update_labels.rb new file mode 100644 index 000000000000..904f128be76c --- /dev/null +++ b/google-shopping-css-v1/snippets/accounts_service/update_labels.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START css_v1_generated_AccountsService_UpdateLabels_sync] +require "google/shopping/css/v1" + +## +# Snippet for the update_labels call in the AccountsService service +# +# This snippet 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 as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Shopping::Css::V1::AccountsService::Client#update_labels. +# +def update_labels + # Create a client object. The client can be reused for multiple calls. + client = Google::Shopping::Css::V1::AccountsService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Shopping::Css::V1::UpdateAccountLabelsRequest.new + + # Call the update_labels method. + result = client.update_labels request + + # The returned object is of type Google::Shopping::Css::V1::Account. + p result +end +# [END css_v1_generated_AccountsService_UpdateLabels_sync] diff --git a/google-shopping-css-v1/snippets/css_product_inputs_service/delete_css_product_input.rb b/google-shopping-css-v1/snippets/css_product_inputs_service/delete_css_product_input.rb new file mode 100644 index 000000000000..2c7cd36a0914 --- /dev/null +++ b/google-shopping-css-v1/snippets/css_product_inputs_service/delete_css_product_input.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START css_v1_generated_CssProductInputsService_DeleteCssProductInput_sync] +require "google/shopping/css/v1" + +## +# Snippet for the delete_css_product_input call in the CssProductInputsService service +# +# This snippet 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 as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Shopping::Css::V1::CssProductInputsService::Client#delete_css_product_input. +# +def delete_css_product_input + # Create a client object. The client can be reused for multiple calls. + client = Google::Shopping::Css::V1::CssProductInputsService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Shopping::Css::V1::DeleteCssProductInputRequest.new + + # Call the delete_css_product_input method. + result = client.delete_css_product_input request + + # The returned object is of type Google::Protobuf::Empty. + p result +end +# [END css_v1_generated_CssProductInputsService_DeleteCssProductInput_sync] diff --git a/google-shopping-css-v1/snippets/css_product_inputs_service/insert_css_product_input.rb b/google-shopping-css-v1/snippets/css_product_inputs_service/insert_css_product_input.rb new file mode 100644 index 000000000000..95aee279b384 --- /dev/null +++ b/google-shopping-css-v1/snippets/css_product_inputs_service/insert_css_product_input.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START css_v1_generated_CssProductInputsService_InsertCssProductInput_sync] +require "google/shopping/css/v1" + +## +# Snippet for the insert_css_product_input call in the CssProductInputsService service +# +# This snippet 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 as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Shopping::Css::V1::CssProductInputsService::Client#insert_css_product_input. +# +def insert_css_product_input + # Create a client object. The client can be reused for multiple calls. + client = Google::Shopping::Css::V1::CssProductInputsService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Shopping::Css::V1::InsertCssProductInputRequest.new + + # Call the insert_css_product_input method. + result = client.insert_css_product_input request + + # The returned object is of type Google::Shopping::Css::V1::CssProductInput. + p result +end +# [END css_v1_generated_CssProductInputsService_InsertCssProductInput_sync] diff --git a/google-shopping-css-v1/snippets/css_products_service/get_css_product.rb b/google-shopping-css-v1/snippets/css_products_service/get_css_product.rb new file mode 100644 index 000000000000..39dd2d347f1e --- /dev/null +++ b/google-shopping-css-v1/snippets/css_products_service/get_css_product.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START css_v1_generated_CssProductsService_GetCssProduct_sync] +require "google/shopping/css/v1" + +## +# Snippet for the get_css_product call in the CssProductsService service +# +# This snippet 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 as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Shopping::Css::V1::CssProductsService::Client#get_css_product. +# +def get_css_product + # Create a client object. The client can be reused for multiple calls. + client = Google::Shopping::Css::V1::CssProductsService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Shopping::Css::V1::GetCssProductRequest.new + + # Call the get_css_product method. + result = client.get_css_product request + + # The returned object is of type Google::Shopping::Css::V1::CssProduct. + p result +end +# [END css_v1_generated_CssProductsService_GetCssProduct_sync] diff --git a/google-shopping-css-v1/snippets/css_products_service/list_css_products.rb b/google-shopping-css-v1/snippets/css_products_service/list_css_products.rb new file mode 100644 index 000000000000..0a2468f7c9de --- /dev/null +++ b/google-shopping-css-v1/snippets/css_products_service/list_css_products.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START css_v1_generated_CssProductsService_ListCssProducts_sync] +require "google/shopping/css/v1" + +## +# Snippet for the list_css_products call in the CssProductsService service +# +# This snippet 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 as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Shopping::Css::V1::CssProductsService::Client#list_css_products. +# +def list_css_products + # Create a client object. The client can be reused for multiple calls. + client = Google::Shopping::Css::V1::CssProductsService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Shopping::Css::V1::ListCssProductsRequest.new + + # Call the list_css_products method. + result = client.list_css_products request + + # The returned object is of type Gapic::PagedEnumerable. You can iterate + # over elements, and API calls will be issued to fetch pages as needed. + result.each do |item| + # Each element is of type ::Google::Shopping::Css::V1::CssProduct. + p item + end +end +# [END css_v1_generated_CssProductsService_ListCssProducts_sync] diff --git a/google-shopping-css-v1/snippets/snippet_metadata_google.shopping.css.v1.json b/google-shopping-css-v1/snippets/snippet_metadata_google.shopping.css.v1.json new file mode 100644 index 000000000000..bd0b96d0946f --- /dev/null +++ b/google-shopping-css-v1/snippets/snippet_metadata_google.shopping.css.v1.json @@ -0,0 +1,455 @@ +{ + "client_library": { + "name": "google-shopping-css-v1", + "version": "", + "language": "RUBY", + "apis": [ + { + "id": "google.shopping.css.v1", + "version": "v1" + } + ] + }, + "snippets": [ + { + "region_tag": "css_v1_generated_AccountsService_ListChildAccounts_sync", + "title": "Snippet for the list_child_accounts call in the AccountsService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Shopping::Css::V1::AccountsService::Client#list_child_accounts.", + "file": "accounts_service/list_child_accounts.rb", + "language": "RUBY", + "client_method": { + "short_name": "list_child_accounts", + "full_name": "::Google::Shopping::Css::V1::AccountsService::Client#list_child_accounts", + "async": false, + "parameters": [ + { + "type": "::Google::Shopping::Css::V1::ListChildAccountsRequest", + "name": "request" + } + ], + "result_type": "::Google::Shopping::Css::V1::ListChildAccountsResponse", + "client": { + "short_name": "AccountsService::Client", + "full_name": "::Google::Shopping::Css::V1::AccountsService::Client" + }, + "method": { + "short_name": "ListChildAccounts", + "full_name": "google.shopping.css.v1.AccountsService.ListChildAccounts", + "service": { + "short_name": "AccountsService", + "full_name": "google.shopping.css.v1.AccountsService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 50, + "type": "FULL" + } + ] + }, + { + "region_tag": "css_v1_generated_AccountsService_GetAccount_sync", + "title": "Snippet for the get_account call in the AccountsService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Shopping::Css::V1::AccountsService::Client#get_account.", + "file": "accounts_service/get_account.rb", + "language": "RUBY", + "client_method": { + "short_name": "get_account", + "full_name": "::Google::Shopping::Css::V1::AccountsService::Client#get_account", + "async": false, + "parameters": [ + { + "type": "::Google::Shopping::Css::V1::GetAccountRequest", + "name": "request" + } + ], + "result_type": "::Google::Shopping::Css::V1::Account", + "client": { + "short_name": "AccountsService::Client", + "full_name": "::Google::Shopping::Css::V1::AccountsService::Client" + }, + "method": { + "short_name": "GetAccount", + "full_name": "google.shopping.css.v1.AccountsService.GetAccount", + "service": { + "short_name": "AccountsService", + "full_name": "google.shopping.css.v1.AccountsService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 46, + "type": "FULL" + } + ] + }, + { + "region_tag": "css_v1_generated_AccountsService_UpdateLabels_sync", + "title": "Snippet for the update_labels call in the AccountsService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Shopping::Css::V1::AccountsService::Client#update_labels.", + "file": "accounts_service/update_labels.rb", + "language": "RUBY", + "client_method": { + "short_name": "update_labels", + "full_name": "::Google::Shopping::Css::V1::AccountsService::Client#update_labels", + "async": false, + "parameters": [ + { + "type": "::Google::Shopping::Css::V1::UpdateAccountLabelsRequest", + "name": "request" + } + ], + "result_type": "::Google::Shopping::Css::V1::Account", + "client": { + "short_name": "AccountsService::Client", + "full_name": "::Google::Shopping::Css::V1::AccountsService::Client" + }, + "method": { + "short_name": "UpdateLabels", + "full_name": "google.shopping.css.v1.AccountsService.UpdateLabels", + "service": { + "short_name": "AccountsService", + "full_name": "google.shopping.css.v1.AccountsService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 46, + "type": "FULL" + } + ] + }, + { + "region_tag": "css_v1_generated_AccountLabelsService_ListAccountLabels_sync", + "title": "Snippet for the list_account_labels call in the AccountLabelsService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Shopping::Css::V1::AccountLabelsService::Client#list_account_labels.", + "file": "account_labels_service/list_account_labels.rb", + "language": "RUBY", + "client_method": { + "short_name": "list_account_labels", + "full_name": "::Google::Shopping::Css::V1::AccountLabelsService::Client#list_account_labels", + "async": false, + "parameters": [ + { + "type": "::Google::Shopping::Css::V1::ListAccountLabelsRequest", + "name": "request" + } + ], + "result_type": "::Google::Shopping::Css::V1::ListAccountLabelsResponse", + "client": { + "short_name": "AccountLabelsService::Client", + "full_name": "::Google::Shopping::Css::V1::AccountLabelsService::Client" + }, + "method": { + "short_name": "ListAccountLabels", + "full_name": "google.shopping.css.v1.AccountLabelsService.ListAccountLabels", + "service": { + "short_name": "AccountLabelsService", + "full_name": "google.shopping.css.v1.AccountLabelsService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 50, + "type": "FULL" + } + ] + }, + { + "region_tag": "css_v1_generated_AccountLabelsService_CreateAccountLabel_sync", + "title": "Snippet for the create_account_label call in the AccountLabelsService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Shopping::Css::V1::AccountLabelsService::Client#create_account_label.", + "file": "account_labels_service/create_account_label.rb", + "language": "RUBY", + "client_method": { + "short_name": "create_account_label", + "full_name": "::Google::Shopping::Css::V1::AccountLabelsService::Client#create_account_label", + "async": false, + "parameters": [ + { + "type": "::Google::Shopping::Css::V1::CreateAccountLabelRequest", + "name": "request" + } + ], + "result_type": "::Google::Shopping::Css::V1::AccountLabel", + "client": { + "short_name": "AccountLabelsService::Client", + "full_name": "::Google::Shopping::Css::V1::AccountLabelsService::Client" + }, + "method": { + "short_name": "CreateAccountLabel", + "full_name": "google.shopping.css.v1.AccountLabelsService.CreateAccountLabel", + "service": { + "short_name": "AccountLabelsService", + "full_name": "google.shopping.css.v1.AccountLabelsService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 46, + "type": "FULL" + } + ] + }, + { + "region_tag": "css_v1_generated_AccountLabelsService_UpdateAccountLabel_sync", + "title": "Snippet for the update_account_label call in the AccountLabelsService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Shopping::Css::V1::AccountLabelsService::Client#update_account_label.", + "file": "account_labels_service/update_account_label.rb", + "language": "RUBY", + "client_method": { + "short_name": "update_account_label", + "full_name": "::Google::Shopping::Css::V1::AccountLabelsService::Client#update_account_label", + "async": false, + "parameters": [ + { + "type": "::Google::Shopping::Css::V1::UpdateAccountLabelRequest", + "name": "request" + } + ], + "result_type": "::Google::Shopping::Css::V1::AccountLabel", + "client": { + "short_name": "AccountLabelsService::Client", + "full_name": "::Google::Shopping::Css::V1::AccountLabelsService::Client" + }, + "method": { + "short_name": "UpdateAccountLabel", + "full_name": "google.shopping.css.v1.AccountLabelsService.UpdateAccountLabel", + "service": { + "short_name": "AccountLabelsService", + "full_name": "google.shopping.css.v1.AccountLabelsService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 46, + "type": "FULL" + } + ] + }, + { + "region_tag": "css_v1_generated_AccountLabelsService_DeleteAccountLabel_sync", + "title": "Snippet for the delete_account_label call in the AccountLabelsService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Shopping::Css::V1::AccountLabelsService::Client#delete_account_label.", + "file": "account_labels_service/delete_account_label.rb", + "language": "RUBY", + "client_method": { + "short_name": "delete_account_label", + "full_name": "::Google::Shopping::Css::V1::AccountLabelsService::Client#delete_account_label", + "async": false, + "parameters": [ + { + "type": "::Google::Shopping::Css::V1::DeleteAccountLabelRequest", + "name": "request" + } + ], + "result_type": "::Google::Protobuf::Empty", + "client": { + "short_name": "AccountLabelsService::Client", + "full_name": "::Google::Shopping::Css::V1::AccountLabelsService::Client" + }, + "method": { + "short_name": "DeleteAccountLabel", + "full_name": "google.shopping.css.v1.AccountLabelsService.DeleteAccountLabel", + "service": { + "short_name": "AccountLabelsService", + "full_name": "google.shopping.css.v1.AccountLabelsService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 46, + "type": "FULL" + } + ] + }, + { + "region_tag": "css_v1_generated_CssProductInputsService_InsertCssProductInput_sync", + "title": "Snippet for the insert_css_product_input call in the CssProductInputsService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Shopping::Css::V1::CssProductInputsService::Client#insert_css_product_input.", + "file": "css_product_inputs_service/insert_css_product_input.rb", + "language": "RUBY", + "client_method": { + "short_name": "insert_css_product_input", + "full_name": "::Google::Shopping::Css::V1::CssProductInputsService::Client#insert_css_product_input", + "async": false, + "parameters": [ + { + "type": "::Google::Shopping::Css::V1::InsertCssProductInputRequest", + "name": "request" + } + ], + "result_type": "::Google::Shopping::Css::V1::CssProductInput", + "client": { + "short_name": "CssProductInputsService::Client", + "full_name": "::Google::Shopping::Css::V1::CssProductInputsService::Client" + }, + "method": { + "short_name": "InsertCssProductInput", + "full_name": "google.shopping.css.v1.CssProductInputsService.InsertCssProductInput", + "service": { + "short_name": "CssProductInputsService", + "full_name": "google.shopping.css.v1.CssProductInputsService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 46, + "type": "FULL" + } + ] + }, + { + "region_tag": "css_v1_generated_CssProductInputsService_DeleteCssProductInput_sync", + "title": "Snippet for the delete_css_product_input call in the CssProductInputsService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Shopping::Css::V1::CssProductInputsService::Client#delete_css_product_input.", + "file": "css_product_inputs_service/delete_css_product_input.rb", + "language": "RUBY", + "client_method": { + "short_name": "delete_css_product_input", + "full_name": "::Google::Shopping::Css::V1::CssProductInputsService::Client#delete_css_product_input", + "async": false, + "parameters": [ + { + "type": "::Google::Shopping::Css::V1::DeleteCssProductInputRequest", + "name": "request" + } + ], + "result_type": "::Google::Protobuf::Empty", + "client": { + "short_name": "CssProductInputsService::Client", + "full_name": "::Google::Shopping::Css::V1::CssProductInputsService::Client" + }, + "method": { + "short_name": "DeleteCssProductInput", + "full_name": "google.shopping.css.v1.CssProductInputsService.DeleteCssProductInput", + "service": { + "short_name": "CssProductInputsService", + "full_name": "google.shopping.css.v1.CssProductInputsService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 46, + "type": "FULL" + } + ] + }, + { + "region_tag": "css_v1_generated_CssProductsService_GetCssProduct_sync", + "title": "Snippet for the get_css_product call in the CssProductsService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Shopping::Css::V1::CssProductsService::Client#get_css_product.", + "file": "css_products_service/get_css_product.rb", + "language": "RUBY", + "client_method": { + "short_name": "get_css_product", + "full_name": "::Google::Shopping::Css::V1::CssProductsService::Client#get_css_product", + "async": false, + "parameters": [ + { + "type": "::Google::Shopping::Css::V1::GetCssProductRequest", + "name": "request" + } + ], + "result_type": "::Google::Shopping::Css::V1::CssProduct", + "client": { + "short_name": "CssProductsService::Client", + "full_name": "::Google::Shopping::Css::V1::CssProductsService::Client" + }, + "method": { + "short_name": "GetCssProduct", + "full_name": "google.shopping.css.v1.CssProductsService.GetCssProduct", + "service": { + "short_name": "CssProductsService", + "full_name": "google.shopping.css.v1.CssProductsService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 46, + "type": "FULL" + } + ] + }, + { + "region_tag": "css_v1_generated_CssProductsService_ListCssProducts_sync", + "title": "Snippet for the list_css_products call in the CssProductsService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Shopping::Css::V1::CssProductsService::Client#list_css_products.", + "file": "css_products_service/list_css_products.rb", + "language": "RUBY", + "client_method": { + "short_name": "list_css_products", + "full_name": "::Google::Shopping::Css::V1::CssProductsService::Client#list_css_products", + "async": false, + "parameters": [ + { + "type": "::Google::Shopping::Css::V1::ListCssProductsRequest", + "name": "request" + } + ], + "result_type": "::Google::Shopping::Css::V1::ListCssProductsResponse", + "client": { + "short_name": "CssProductsService::Client", + "full_name": "::Google::Shopping::Css::V1::CssProductsService::Client" + }, + "method": { + "short_name": "ListCssProducts", + "full_name": "google.shopping.css.v1.CssProductsService.ListCssProducts", + "service": { + "short_name": "CssProductsService", + "full_name": "google.shopping.css.v1.CssProductsService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 50, + "type": "FULL" + } + ] + } + ] +} \ No newline at end of file diff --git a/google-shopping-css-v1/test/google/shopping/css/v1/account_labels_service_paths_test.rb b/google-shopping-css-v1/test/google/shopping/css/v1/account_labels_service_paths_test.rb new file mode 100644 index 000000000000..5d703f3e99e0 --- /dev/null +++ b/google-shopping-css-v1/test/google/shopping/css/v1/account_labels_service_paths_test.rb @@ -0,0 +1,59 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" + +require "gapic/grpc/service_stub" + +require "google/shopping/css/v1/account_labels_service" + +class ::Google::Shopping::Css::V1::AccountLabelsService::ClientPathsTest < Minitest::Test + class DummyStub + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_account_path + grpc_channel = ::GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + ::Gapic::ServiceStub.stub :new, DummyStub.new do + client = ::Google::Shopping::Css::V1::AccountLabelsService::Client.new do |config| + config.credentials = grpc_channel + end + + path = client.account_path account: "value0" + assert_equal "accounts/value0", path + end + end + + def test_account_label_path + grpc_channel = ::GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + ::Gapic::ServiceStub.stub :new, DummyStub.new do + client = ::Google::Shopping::Css::V1::AccountLabelsService::Client.new do |config| + config.credentials = grpc_channel + end + + path = client.account_label_path account: "value0", label: "value1" + assert_equal "accounts/value0/labels/value1", path + end + end +end diff --git a/google-shopping-css-v1/test/google/shopping/css/v1/account_labels_service_rest_test.rb b/google-shopping-css-v1/test/google/shopping/css/v1/account_labels_service_rest_test.rb new file mode 100644 index 000000000000..32d686d2443b --- /dev/null +++ b/google-shopping-css-v1/test/google/shopping/css/v1/account_labels_service_rest_test.rb @@ -0,0 +1,310 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" +require "gapic/rest" +require "google/shopping/css/v1/accounts_labels_pb" +require "google/shopping/css/v1/account_labels_service/rest" + + +class ::Google::Shopping::Css::V1::AccountLabelsService::Rest::ClientTest < Minitest::Test + class ClientStub + attr_accessor :call_count, :requests + + def initialize response, &block + @response = response + @block = block + @call_count = 0 + @requests = [] + end + + def make_get_request uri:, params: {}, options: {} + make_http_request :get, uri: uri, body: nil, params: params, options: options + end + + def make_delete_request uri:, params: {}, options: {} + make_http_request :delete, uri: uri, body: nil, params: params, options: options + end + + def make_post_request uri:, body: nil, params: {}, options: {} + make_http_request :post, uri: uri, body: body, params: params, options: options + end + + def make_patch_request uri:, body:, params: {}, options: {} + make_http_request :patch, uri: uri, body: body, params: params, options: options + end + + def make_put_request uri:, body:, params: {}, options: {} + make_http_request :put, uri: uri, body: body, params: params, options: options + end + + def make_http_request *args, **kwargs + @call_count += 1 + + @requests << @block&.call(*args, **kwargs) + + @response + end + + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_list_account_labels + # Create test objects. + client_result = ::Google::Shopping::Css::V1::ListAccountLabelsResponse.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + parent = "hello world" + page_size = 42 + page_token = "hello world" + + list_account_labels_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Shopping::Css::V1::AccountLabelsService::Rest::ServiceStub.stub :transcode_list_account_labels_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, list_account_labels_client_stub do + # Create client + client = ::Google::Shopping::Css::V1::AccountLabelsService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.list_account_labels({ parent: parent, page_size: page_size, page_token: page_token }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.list_account_labels parent: parent, page_size: page_size, page_token: page_token do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.list_account_labels ::Google::Shopping::Css::V1::ListAccountLabelsRequest.new(parent: parent, page_size: page_size, page_token: page_token) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.list_account_labels({ parent: parent, page_size: page_size, page_token: page_token }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.list_account_labels(::Google::Shopping::Css::V1::ListAccountLabelsRequest.new(parent: parent, page_size: page_size, page_token: page_token), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, list_account_labels_client_stub.call_count + end + end + end + + def test_create_account_label + # Create test objects. + client_result = ::Google::Shopping::Css::V1::AccountLabel.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + parent = "hello world" + account_label = {} + + create_account_label_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Shopping::Css::V1::AccountLabelsService::Rest::ServiceStub.stub :transcode_create_account_label_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, create_account_label_client_stub do + # Create client + client = ::Google::Shopping::Css::V1::AccountLabelsService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.create_account_label({ parent: parent, account_label: account_label }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.create_account_label parent: parent, account_label: account_label do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.create_account_label ::Google::Shopping::Css::V1::CreateAccountLabelRequest.new(parent: parent, account_label: account_label) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.create_account_label({ parent: parent, account_label: account_label }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.create_account_label(::Google::Shopping::Css::V1::CreateAccountLabelRequest.new(parent: parent, account_label: account_label), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, create_account_label_client_stub.call_count + end + end + end + + def test_update_account_label + # Create test objects. + client_result = ::Google::Shopping::Css::V1::AccountLabel.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + account_label = {} + + update_account_label_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Shopping::Css::V1::AccountLabelsService::Rest::ServiceStub.stub :transcode_update_account_label_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, update_account_label_client_stub do + # Create client + client = ::Google::Shopping::Css::V1::AccountLabelsService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.update_account_label({ account_label: account_label }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.update_account_label account_label: account_label do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.update_account_label ::Google::Shopping::Css::V1::UpdateAccountLabelRequest.new(account_label: account_label) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.update_account_label({ account_label: account_label }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.update_account_label(::Google::Shopping::Css::V1::UpdateAccountLabelRequest.new(account_label: account_label), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, update_account_label_client_stub.call_count + end + end + end + + def test_delete_account_label + # Create test objects. + client_result = ::Google::Protobuf::Empty.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + name = "hello world" + + delete_account_label_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Shopping::Css::V1::AccountLabelsService::Rest::ServiceStub.stub :transcode_delete_account_label_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, delete_account_label_client_stub do + # Create client + client = ::Google::Shopping::Css::V1::AccountLabelsService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.delete_account_label({ name: name }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.delete_account_label name: name do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.delete_account_label ::Google::Shopping::Css::V1::DeleteAccountLabelRequest.new(name: name) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.delete_account_label({ name: name }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.delete_account_label(::Google::Shopping::Css::V1::DeleteAccountLabelRequest.new(name: name), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, delete_account_label_client_stub.call_count + end + end + end + + def test_configure + credentials_token = :dummy_value + + client = block_config = config = nil + dummy_stub = ClientStub.new nil + Gapic::Rest::ClientStub.stub :new, dummy_stub do + client = ::Google::Shopping::Css::V1::AccountLabelsService::Rest::Client.new do |config| + config.credentials = credentials_token + end + end + + config = client.configure do |c| + block_config = c + end + + assert_same block_config, config + assert_kind_of ::Google::Shopping::Css::V1::AccountLabelsService::Rest::Client::Configuration, config + end +end diff --git a/google-shopping-css-v1/test/google/shopping/css/v1/account_labels_service_test.rb b/google-shopping-css-v1/test/google/shopping/css/v1/account_labels_service_test.rb new file mode 100644 index 000000000000..4e6f2a5f7bc6 --- /dev/null +++ b/google-shopping-css-v1/test/google/shopping/css/v1/account_labels_service_test.rb @@ -0,0 +1,319 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" + +require "gapic/grpc/service_stub" + +require "google/shopping/css/v1/accounts_labels_pb" +require "google/shopping/css/v1/accounts_labels_services_pb" +require "google/shopping/css/v1/account_labels_service" + +class ::Google::Shopping::Css::V1::AccountLabelsService::ClientTest < Minitest::Test + class ClientStub + attr_accessor :call_rpc_count, :requests + + def initialize response, operation, &block + @response = response + @operation = operation + @block = block + @call_rpc_count = 0 + @requests = [] + end + + def call_rpc *args, **kwargs + @call_rpc_count += 1 + + @requests << @block&.call(*args, **kwargs) + + yield @response, @operation if block_given? + + @response + end + + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_list_account_labels + # Create GRPC objects. + grpc_response = ::Google::Shopping::Css::V1::ListAccountLabelsResponse.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + parent = "hello world" + page_size = 42 + page_token = "hello world" + + list_account_labels_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :list_account_labels, name + assert_kind_of ::Google::Shopping::Css::V1::ListAccountLabelsRequest, request + assert_equal "hello world", request["parent"] + assert_equal 42, request["page_size"] + assert_equal "hello world", request["page_token"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, list_account_labels_client_stub do + # Create client + client = ::Google::Shopping::Css::V1::AccountLabelsService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.list_account_labels({ parent: parent, page_size: page_size, page_token: page_token }) do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.list_account_labels parent: parent, page_size: page_size, page_token: page_token do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.list_account_labels ::Google::Shopping::Css::V1::ListAccountLabelsRequest.new(parent: parent, page_size: page_size, page_token: page_token) do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.list_account_labels({ parent: parent, page_size: page_size, page_token: page_token }, grpc_options) do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.list_account_labels(::Google::Shopping::Css::V1::ListAccountLabelsRequest.new(parent: parent, page_size: page_size, page_token: page_token), grpc_options) do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, list_account_labels_client_stub.call_rpc_count + end + end + + def test_create_account_label + # Create GRPC objects. + grpc_response = ::Google::Shopping::Css::V1::AccountLabel.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + parent = "hello world" + account_label = {} + + create_account_label_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :create_account_label, name + assert_kind_of ::Google::Shopping::Css::V1::CreateAccountLabelRequest, request + assert_equal "hello world", request["parent"] + assert_equal Gapic::Protobuf.coerce({}, to: ::Google::Shopping::Css::V1::AccountLabel), request["account_label"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, create_account_label_client_stub do + # Create client + client = ::Google::Shopping::Css::V1::AccountLabelsService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.create_account_label({ parent: parent, account_label: account_label }) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.create_account_label parent: parent, account_label: account_label do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.create_account_label ::Google::Shopping::Css::V1::CreateAccountLabelRequest.new(parent: parent, account_label: account_label) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.create_account_label({ parent: parent, account_label: account_label }, grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.create_account_label(::Google::Shopping::Css::V1::CreateAccountLabelRequest.new(parent: parent, account_label: account_label), grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, create_account_label_client_stub.call_rpc_count + end + end + + def test_update_account_label + # Create GRPC objects. + grpc_response = ::Google::Shopping::Css::V1::AccountLabel.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + account_label = {} + + update_account_label_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :update_account_label, name + assert_kind_of ::Google::Shopping::Css::V1::UpdateAccountLabelRequest, request + assert_equal Gapic::Protobuf.coerce({}, to: ::Google::Shopping::Css::V1::AccountLabel), request["account_label"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, update_account_label_client_stub do + # Create client + client = ::Google::Shopping::Css::V1::AccountLabelsService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.update_account_label({ account_label: account_label }) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.update_account_label account_label: account_label do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.update_account_label ::Google::Shopping::Css::V1::UpdateAccountLabelRequest.new(account_label: account_label) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.update_account_label({ account_label: account_label }, grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.update_account_label(::Google::Shopping::Css::V1::UpdateAccountLabelRequest.new(account_label: account_label), grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, update_account_label_client_stub.call_rpc_count + end + end + + def test_delete_account_label + # Create GRPC objects. + grpc_response = ::Google::Protobuf::Empty.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + name = "hello world" + + delete_account_label_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :delete_account_label, name + assert_kind_of ::Google::Shopping::Css::V1::DeleteAccountLabelRequest, request + assert_equal "hello world", request["name"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, delete_account_label_client_stub do + # Create client + client = ::Google::Shopping::Css::V1::AccountLabelsService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.delete_account_label({ name: name }) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.delete_account_label name: name do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.delete_account_label ::Google::Shopping::Css::V1::DeleteAccountLabelRequest.new(name: name) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.delete_account_label({ name: name }, grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.delete_account_label(::Google::Shopping::Css::V1::DeleteAccountLabelRequest.new(name: name), grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, delete_account_label_client_stub.call_rpc_count + end + end + + def test_configure + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + + client = block_config = config = nil + dummy_stub = ClientStub.new nil, nil + Gapic::ServiceStub.stub :new, dummy_stub do + client = ::Google::Shopping::Css::V1::AccountLabelsService::Client.new do |config| + config.credentials = grpc_channel + end + end + + config = client.configure do |c| + block_config = c + end + + assert_same block_config, config + assert_kind_of ::Google::Shopping::Css::V1::AccountLabelsService::Client::Configuration, config + end +end diff --git a/google-shopping-css-v1/test/google/shopping/css/v1/accounts_service_paths_test.rb b/google-shopping-css-v1/test/google/shopping/css/v1/accounts_service_paths_test.rb new file mode 100644 index 000000000000..0e7ddee80ffd --- /dev/null +++ b/google-shopping-css-v1/test/google/shopping/css/v1/accounts_service_paths_test.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" + +require "gapic/grpc/service_stub" + +require "google/shopping/css/v1/accounts_service" + +class ::Google::Shopping::Css::V1::AccountsService::ClientPathsTest < Minitest::Test + class DummyStub + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_account_path + grpc_channel = ::GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + ::Gapic::ServiceStub.stub :new, DummyStub.new do + client = ::Google::Shopping::Css::V1::AccountsService::Client.new do |config| + config.credentials = grpc_channel + end + + path = client.account_path account: "value0" + assert_equal "accounts/value0", path + end + end +end diff --git a/google-shopping-css-v1/test/google/shopping/css/v1/accounts_service_rest_test.rb b/google-shopping-css-v1/test/google/shopping/css/v1/accounts_service_rest_test.rb new file mode 100644 index 000000000000..4f87dcd8ac77 --- /dev/null +++ b/google-shopping-css-v1/test/google/shopping/css/v1/accounts_service_rest_test.rb @@ -0,0 +1,260 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" +require "gapic/rest" +require "google/shopping/css/v1/accounts_pb" +require "google/shopping/css/v1/accounts_service/rest" + + +class ::Google::Shopping::Css::V1::AccountsService::Rest::ClientTest < Minitest::Test + class ClientStub + attr_accessor :call_count, :requests + + def initialize response, &block + @response = response + @block = block + @call_count = 0 + @requests = [] + end + + def make_get_request uri:, params: {}, options: {} + make_http_request :get, uri: uri, body: nil, params: params, options: options + end + + def make_delete_request uri:, params: {}, options: {} + make_http_request :delete, uri: uri, body: nil, params: params, options: options + end + + def make_post_request uri:, body: nil, params: {}, options: {} + make_http_request :post, uri: uri, body: body, params: params, options: options + end + + def make_patch_request uri:, body:, params: {}, options: {} + make_http_request :patch, uri: uri, body: body, params: params, options: options + end + + def make_put_request uri:, body:, params: {}, options: {} + make_http_request :put, uri: uri, body: body, params: params, options: options + end + + def make_http_request *args, **kwargs + @call_count += 1 + + @requests << @block&.call(*args, **kwargs) + + @response + end + + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_list_child_accounts + # Create test objects. + client_result = ::Google::Shopping::Css::V1::ListChildAccountsResponse.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + parent = "hello world" + label_id = 42 + full_name = "hello world" + page_size = 42 + page_token = "hello world" + + list_child_accounts_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Shopping::Css::V1::AccountsService::Rest::ServiceStub.stub :transcode_list_child_accounts_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, list_child_accounts_client_stub do + # Create client + client = ::Google::Shopping::Css::V1::AccountsService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.list_child_accounts({ parent: parent, label_id: label_id, full_name: full_name, page_size: page_size, page_token: page_token }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.list_child_accounts parent: parent, label_id: label_id, full_name: full_name, page_size: page_size, page_token: page_token do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.list_child_accounts ::Google::Shopping::Css::V1::ListChildAccountsRequest.new(parent: parent, label_id: label_id, full_name: full_name, page_size: page_size, page_token: page_token) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.list_child_accounts({ parent: parent, label_id: label_id, full_name: full_name, page_size: page_size, page_token: page_token }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.list_child_accounts(::Google::Shopping::Css::V1::ListChildAccountsRequest.new(parent: parent, label_id: label_id, full_name: full_name, page_size: page_size, page_token: page_token), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, list_child_accounts_client_stub.call_count + end + end + end + + def test_get_account + # Create test objects. + client_result = ::Google::Shopping::Css::V1::Account.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + name = "hello world" + parent = "hello world" + + get_account_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Shopping::Css::V1::AccountsService::Rest::ServiceStub.stub :transcode_get_account_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, get_account_client_stub do + # Create client + client = ::Google::Shopping::Css::V1::AccountsService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.get_account({ name: name, parent: parent }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.get_account name: name, parent: parent do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.get_account ::Google::Shopping::Css::V1::GetAccountRequest.new(name: name, parent: parent) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.get_account({ name: name, parent: parent }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.get_account(::Google::Shopping::Css::V1::GetAccountRequest.new(name: name, parent: parent), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, get_account_client_stub.call_count + end + end + end + + def test_update_labels + # Create test objects. + client_result = ::Google::Shopping::Css::V1::Account.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + name = "hello world" + label_ids = [42] + parent = "hello world" + + update_labels_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Shopping::Css::V1::AccountsService::Rest::ServiceStub.stub :transcode_update_labels_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, update_labels_client_stub do + # Create client + client = ::Google::Shopping::Css::V1::AccountsService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.update_labels({ name: name, label_ids: label_ids, parent: parent }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.update_labels name: name, label_ids: label_ids, parent: parent do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.update_labels ::Google::Shopping::Css::V1::UpdateAccountLabelsRequest.new(name: name, label_ids: label_ids, parent: parent) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.update_labels({ name: name, label_ids: label_ids, parent: parent }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.update_labels(::Google::Shopping::Css::V1::UpdateAccountLabelsRequest.new(name: name, label_ids: label_ids, parent: parent), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, update_labels_client_stub.call_count + end + end + end + + def test_configure + credentials_token = :dummy_value + + client = block_config = config = nil + dummy_stub = ClientStub.new nil + Gapic::Rest::ClientStub.stub :new, dummy_stub do + client = ::Google::Shopping::Css::V1::AccountsService::Rest::Client.new do |config| + config.credentials = credentials_token + end + end + + config = client.configure do |c| + block_config = c + end + + assert_same block_config, config + assert_kind_of ::Google::Shopping::Css::V1::AccountsService::Rest::Client::Configuration, config + end +end diff --git a/google-shopping-css-v1/test/google/shopping/css/v1/accounts_service_test.rb b/google-shopping-css-v1/test/google/shopping/css/v1/accounts_service_test.rb new file mode 100644 index 000000000000..0097f02e5b51 --- /dev/null +++ b/google-shopping-css-v1/test/google/shopping/css/v1/accounts_service_test.rb @@ -0,0 +1,273 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" + +require "gapic/grpc/service_stub" + +require "google/shopping/css/v1/accounts_pb" +require "google/shopping/css/v1/accounts_services_pb" +require "google/shopping/css/v1/accounts_service" + +class ::Google::Shopping::Css::V1::AccountsService::ClientTest < Minitest::Test + class ClientStub + attr_accessor :call_rpc_count, :requests + + def initialize response, operation, &block + @response = response + @operation = operation + @block = block + @call_rpc_count = 0 + @requests = [] + end + + def call_rpc *args, **kwargs + @call_rpc_count += 1 + + @requests << @block&.call(*args, **kwargs) + + yield @response, @operation if block_given? + + @response + end + + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_list_child_accounts + # Create GRPC objects. + grpc_response = ::Google::Shopping::Css::V1::ListChildAccountsResponse.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + parent = "hello world" + label_id = 42 + full_name = "hello world" + page_size = 42 + page_token = "hello world" + + list_child_accounts_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :list_child_accounts, name + assert_kind_of ::Google::Shopping::Css::V1::ListChildAccountsRequest, request + assert_equal "hello world", request["parent"] + assert_equal 42, request["label_id"] + assert request.has_label_id? + assert_equal "hello world", request["full_name"] + assert request.has_full_name? + assert_equal 42, request["page_size"] + assert_equal "hello world", request["page_token"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, list_child_accounts_client_stub do + # Create client + client = ::Google::Shopping::Css::V1::AccountsService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.list_child_accounts({ parent: parent, label_id: label_id, full_name: full_name, page_size: page_size, page_token: page_token }) do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.list_child_accounts parent: parent, label_id: label_id, full_name: full_name, page_size: page_size, page_token: page_token do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.list_child_accounts ::Google::Shopping::Css::V1::ListChildAccountsRequest.new(parent: parent, label_id: label_id, full_name: full_name, page_size: page_size, page_token: page_token) do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.list_child_accounts({ parent: parent, label_id: label_id, full_name: full_name, page_size: page_size, page_token: page_token }, grpc_options) do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.list_child_accounts(::Google::Shopping::Css::V1::ListChildAccountsRequest.new(parent: parent, label_id: label_id, full_name: full_name, page_size: page_size, page_token: page_token), grpc_options) do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, list_child_accounts_client_stub.call_rpc_count + end + end + + def test_get_account + # Create GRPC objects. + grpc_response = ::Google::Shopping::Css::V1::Account.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + name = "hello world" + parent = "hello world" + + get_account_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :get_account, name + assert_kind_of ::Google::Shopping::Css::V1::GetAccountRequest, request + assert_equal "hello world", request["name"] + assert_equal "hello world", request["parent"] + assert request.has_parent? + refute_nil options + end + + Gapic::ServiceStub.stub :new, get_account_client_stub do + # Create client + client = ::Google::Shopping::Css::V1::AccountsService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.get_account({ name: name, parent: parent }) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.get_account name: name, parent: parent do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.get_account ::Google::Shopping::Css::V1::GetAccountRequest.new(name: name, parent: parent) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.get_account({ name: name, parent: parent }, grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.get_account(::Google::Shopping::Css::V1::GetAccountRequest.new(name: name, parent: parent), grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, get_account_client_stub.call_rpc_count + end + end + + def test_update_labels + # Create GRPC objects. + grpc_response = ::Google::Shopping::Css::V1::Account.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + name = "hello world" + label_ids = [42] + parent = "hello world" + + update_labels_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :update_labels, name + assert_kind_of ::Google::Shopping::Css::V1::UpdateAccountLabelsRequest, request + assert_equal "hello world", request["name"] + assert_equal [42], request["label_ids"] + assert_equal "hello world", request["parent"] + assert request.has_parent? + refute_nil options + end + + Gapic::ServiceStub.stub :new, update_labels_client_stub do + # Create client + client = ::Google::Shopping::Css::V1::AccountsService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.update_labels({ name: name, label_ids: label_ids, parent: parent }) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.update_labels name: name, label_ids: label_ids, parent: parent do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.update_labels ::Google::Shopping::Css::V1::UpdateAccountLabelsRequest.new(name: name, label_ids: label_ids, parent: parent) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.update_labels({ name: name, label_ids: label_ids, parent: parent }, grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.update_labels(::Google::Shopping::Css::V1::UpdateAccountLabelsRequest.new(name: name, label_ids: label_ids, parent: parent), grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, update_labels_client_stub.call_rpc_count + end + end + + def test_configure + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + + client = block_config = config = nil + dummy_stub = ClientStub.new nil, nil + Gapic::ServiceStub.stub :new, dummy_stub do + client = ::Google::Shopping::Css::V1::AccountsService::Client.new do |config| + config.credentials = grpc_channel + end + end + + config = client.configure do |c| + block_config = c + end + + assert_same block_config, config + assert_kind_of ::Google::Shopping::Css::V1::AccountsService::Client::Configuration, config + end +end diff --git a/google-shopping-css-v1/test/google/shopping/css/v1/css_product_inputs_service_paths_test.rb b/google-shopping-css-v1/test/google/shopping/css/v1/css_product_inputs_service_paths_test.rb new file mode 100644 index 000000000000..be1cb5ad0f8b --- /dev/null +++ b/google-shopping-css-v1/test/google/shopping/css/v1/css_product_inputs_service_paths_test.rb @@ -0,0 +1,59 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" + +require "gapic/grpc/service_stub" + +require "google/shopping/css/v1/css_product_inputs_service" + +class ::Google::Shopping::Css::V1::CssProductInputsService::ClientPathsTest < Minitest::Test + class DummyStub + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_account_path + grpc_channel = ::GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + ::Gapic::ServiceStub.stub :new, DummyStub.new do + client = ::Google::Shopping::Css::V1::CssProductInputsService::Client.new do |config| + config.credentials = grpc_channel + end + + path = client.account_path account: "value0" + assert_equal "accounts/value0", path + end + end + + def test_css_product_input_path + grpc_channel = ::GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + ::Gapic::ServiceStub.stub :new, DummyStub.new do + client = ::Google::Shopping::Css::V1::CssProductInputsService::Client.new do |config| + config.credentials = grpc_channel + end + + path = client.css_product_input_path account: "value0", css_product_input: "value1" + assert_equal "accounts/value0/cssProductInputs/value1", path + end + end +end diff --git a/google-shopping-css-v1/test/google/shopping/css/v1/css_product_inputs_service_rest_test.rb b/google-shopping-css-v1/test/google/shopping/css/v1/css_product_inputs_service_rest_test.rb new file mode 100644 index 000000000000..6d71a918344c --- /dev/null +++ b/google-shopping-css-v1/test/google/shopping/css/v1/css_product_inputs_service_rest_test.rb @@ -0,0 +1,202 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" +require "gapic/rest" +require "google/shopping/css/v1/css_product_inputs_pb" +require "google/shopping/css/v1/css_product_inputs_service/rest" + + +class ::Google::Shopping::Css::V1::CssProductInputsService::Rest::ClientTest < Minitest::Test + class ClientStub + attr_accessor :call_count, :requests + + def initialize response, &block + @response = response + @block = block + @call_count = 0 + @requests = [] + end + + def make_get_request uri:, params: {}, options: {} + make_http_request :get, uri: uri, body: nil, params: params, options: options + end + + def make_delete_request uri:, params: {}, options: {} + make_http_request :delete, uri: uri, body: nil, params: params, options: options + end + + def make_post_request uri:, body: nil, params: {}, options: {} + make_http_request :post, uri: uri, body: body, params: params, options: options + end + + def make_patch_request uri:, body:, params: {}, options: {} + make_http_request :patch, uri: uri, body: body, params: params, options: options + end + + def make_put_request uri:, body:, params: {}, options: {} + make_http_request :put, uri: uri, body: body, params: params, options: options + end + + def make_http_request *args, **kwargs + @call_count += 1 + + @requests << @block&.call(*args, **kwargs) + + @response + end + + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_insert_css_product_input + # Create test objects. + client_result = ::Google::Shopping::Css::V1::CssProductInput.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + parent = "hello world" + css_product_input = {} + feed_id = 42 + + insert_css_product_input_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Shopping::Css::V1::CssProductInputsService::Rest::ServiceStub.stub :transcode_insert_css_product_input_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, insert_css_product_input_client_stub do + # Create client + client = ::Google::Shopping::Css::V1::CssProductInputsService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.insert_css_product_input({ parent: parent, css_product_input: css_product_input, feed_id: feed_id }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.insert_css_product_input parent: parent, css_product_input: css_product_input, feed_id: feed_id do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.insert_css_product_input ::Google::Shopping::Css::V1::InsertCssProductInputRequest.new(parent: parent, css_product_input: css_product_input, feed_id: feed_id) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.insert_css_product_input({ parent: parent, css_product_input: css_product_input, feed_id: feed_id }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.insert_css_product_input(::Google::Shopping::Css::V1::InsertCssProductInputRequest.new(parent: parent, css_product_input: css_product_input, feed_id: feed_id), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, insert_css_product_input_client_stub.call_count + end + end + end + + def test_delete_css_product_input + # Create test objects. + client_result = ::Google::Protobuf::Empty.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + name = "hello world" + supplemental_feed_id = 42 + + delete_css_product_input_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Shopping::Css::V1::CssProductInputsService::Rest::ServiceStub.stub :transcode_delete_css_product_input_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, delete_css_product_input_client_stub do + # Create client + client = ::Google::Shopping::Css::V1::CssProductInputsService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.delete_css_product_input({ name: name, supplemental_feed_id: supplemental_feed_id }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.delete_css_product_input name: name, supplemental_feed_id: supplemental_feed_id do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.delete_css_product_input ::Google::Shopping::Css::V1::DeleteCssProductInputRequest.new(name: name, supplemental_feed_id: supplemental_feed_id) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.delete_css_product_input({ name: name, supplemental_feed_id: supplemental_feed_id }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.delete_css_product_input(::Google::Shopping::Css::V1::DeleteCssProductInputRequest.new(name: name, supplemental_feed_id: supplemental_feed_id), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, delete_css_product_input_client_stub.call_count + end + end + end + + def test_configure + credentials_token = :dummy_value + + client = block_config = config = nil + dummy_stub = ClientStub.new nil + Gapic::Rest::ClientStub.stub :new, dummy_stub do + client = ::Google::Shopping::Css::V1::CssProductInputsService::Rest::Client.new do |config| + config.credentials = credentials_token + end + end + + config = client.configure do |c| + block_config = c + end + + assert_same block_config, config + assert_kind_of ::Google::Shopping::Css::V1::CssProductInputsService::Rest::Client::Configuration, config + end +end diff --git a/google-shopping-css-v1/test/google/shopping/css/v1/css_product_inputs_service_test.rb b/google-shopping-css-v1/test/google/shopping/css/v1/css_product_inputs_service_test.rb new file mode 100644 index 000000000000..2d0038d87919 --- /dev/null +++ b/google-shopping-css-v1/test/google/shopping/css/v1/css_product_inputs_service_test.rb @@ -0,0 +1,199 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" + +require "gapic/grpc/service_stub" + +require "google/shopping/css/v1/css_product_inputs_pb" +require "google/shopping/css/v1/css_product_inputs_services_pb" +require "google/shopping/css/v1/css_product_inputs_service" + +class ::Google::Shopping::Css::V1::CssProductInputsService::ClientTest < Minitest::Test + class ClientStub + attr_accessor :call_rpc_count, :requests + + def initialize response, operation, &block + @response = response + @operation = operation + @block = block + @call_rpc_count = 0 + @requests = [] + end + + def call_rpc *args, **kwargs + @call_rpc_count += 1 + + @requests << @block&.call(*args, **kwargs) + + yield @response, @operation if block_given? + + @response + end + + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_insert_css_product_input + # Create GRPC objects. + grpc_response = ::Google::Shopping::Css::V1::CssProductInput.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + parent = "hello world" + css_product_input = {} + feed_id = 42 + + insert_css_product_input_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :insert_css_product_input, name + assert_kind_of ::Google::Shopping::Css::V1::InsertCssProductInputRequest, request + assert_equal "hello world", request["parent"] + assert_equal Gapic::Protobuf.coerce({}, to: ::Google::Shopping::Css::V1::CssProductInput), request["css_product_input"] + assert_equal 42, request["feed_id"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, insert_css_product_input_client_stub do + # Create client + client = ::Google::Shopping::Css::V1::CssProductInputsService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.insert_css_product_input({ parent: parent, css_product_input: css_product_input, feed_id: feed_id }) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.insert_css_product_input parent: parent, css_product_input: css_product_input, feed_id: feed_id do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.insert_css_product_input ::Google::Shopping::Css::V1::InsertCssProductInputRequest.new(parent: parent, css_product_input: css_product_input, feed_id: feed_id) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.insert_css_product_input({ parent: parent, css_product_input: css_product_input, feed_id: feed_id }, grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.insert_css_product_input(::Google::Shopping::Css::V1::InsertCssProductInputRequest.new(parent: parent, css_product_input: css_product_input, feed_id: feed_id), grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, insert_css_product_input_client_stub.call_rpc_count + end + end + + def test_delete_css_product_input + # Create GRPC objects. + grpc_response = ::Google::Protobuf::Empty.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + name = "hello world" + supplemental_feed_id = 42 + + delete_css_product_input_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :delete_css_product_input, name + assert_kind_of ::Google::Shopping::Css::V1::DeleteCssProductInputRequest, request + assert_equal "hello world", request["name"] + assert_equal 42, request["supplemental_feed_id"] + assert request.has_supplemental_feed_id? + refute_nil options + end + + Gapic::ServiceStub.stub :new, delete_css_product_input_client_stub do + # Create client + client = ::Google::Shopping::Css::V1::CssProductInputsService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.delete_css_product_input({ name: name, supplemental_feed_id: supplemental_feed_id }) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.delete_css_product_input name: name, supplemental_feed_id: supplemental_feed_id do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.delete_css_product_input ::Google::Shopping::Css::V1::DeleteCssProductInputRequest.new(name: name, supplemental_feed_id: supplemental_feed_id) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.delete_css_product_input({ name: name, supplemental_feed_id: supplemental_feed_id }, grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.delete_css_product_input(::Google::Shopping::Css::V1::DeleteCssProductInputRequest.new(name: name, supplemental_feed_id: supplemental_feed_id), grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, delete_css_product_input_client_stub.call_rpc_count + end + end + + def test_configure + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + + client = block_config = config = nil + dummy_stub = ClientStub.new nil, nil + Gapic::ServiceStub.stub :new, dummy_stub do + client = ::Google::Shopping::Css::V1::CssProductInputsService::Client.new do |config| + config.credentials = grpc_channel + end + end + + config = client.configure do |c| + block_config = c + end + + assert_same block_config, config + assert_kind_of ::Google::Shopping::Css::V1::CssProductInputsService::Client::Configuration, config + end +end diff --git a/google-shopping-css-v1/test/google/shopping/css/v1/css_products_service_paths_test.rb b/google-shopping-css-v1/test/google/shopping/css/v1/css_products_service_paths_test.rb new file mode 100644 index 000000000000..1deea6708de4 --- /dev/null +++ b/google-shopping-css-v1/test/google/shopping/css/v1/css_products_service_paths_test.rb @@ -0,0 +1,59 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" + +require "gapic/grpc/service_stub" + +require "google/shopping/css/v1/css_products_service" + +class ::Google::Shopping::Css::V1::CssProductsService::ClientPathsTest < Minitest::Test + class DummyStub + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_account_path + grpc_channel = ::GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + ::Gapic::ServiceStub.stub :new, DummyStub.new do + client = ::Google::Shopping::Css::V1::CssProductsService::Client.new do |config| + config.credentials = grpc_channel + end + + path = client.account_path account: "value0" + assert_equal "accounts/value0", path + end + end + + def test_css_product_path + grpc_channel = ::GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + ::Gapic::ServiceStub.stub :new, DummyStub.new do + client = ::Google::Shopping::Css::V1::CssProductsService::Client.new do |config| + config.credentials = grpc_channel + end + + path = client.css_product_path account: "value0", css_product: "value1" + assert_equal "accounts/value0/cssProducts/value1", path + end + end +end diff --git a/google-shopping-css-v1/test/google/shopping/css/v1/css_products_service_rest_test.rb b/google-shopping-css-v1/test/google/shopping/css/v1/css_products_service_rest_test.rb new file mode 100644 index 000000000000..99d353c20827 --- /dev/null +++ b/google-shopping-css-v1/test/google/shopping/css/v1/css_products_service_rest_test.rb @@ -0,0 +1,201 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" +require "gapic/rest" +require "google/shopping/css/v1/css_products_pb" +require "google/shopping/css/v1/css_products_service/rest" + + +class ::Google::Shopping::Css::V1::CssProductsService::Rest::ClientTest < Minitest::Test + class ClientStub + attr_accessor :call_count, :requests + + def initialize response, &block + @response = response + @block = block + @call_count = 0 + @requests = [] + end + + def make_get_request uri:, params: {}, options: {} + make_http_request :get, uri: uri, body: nil, params: params, options: options + end + + def make_delete_request uri:, params: {}, options: {} + make_http_request :delete, uri: uri, body: nil, params: params, options: options + end + + def make_post_request uri:, body: nil, params: {}, options: {} + make_http_request :post, uri: uri, body: body, params: params, options: options + end + + def make_patch_request uri:, body:, params: {}, options: {} + make_http_request :patch, uri: uri, body: body, params: params, options: options + end + + def make_put_request uri:, body:, params: {}, options: {} + make_http_request :put, uri: uri, body: body, params: params, options: options + end + + def make_http_request *args, **kwargs + @call_count += 1 + + @requests << @block&.call(*args, **kwargs) + + @response + end + + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_get_css_product + # Create test objects. + client_result = ::Google::Shopping::Css::V1::CssProduct.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + name = "hello world" + + get_css_product_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Shopping::Css::V1::CssProductsService::Rest::ServiceStub.stub :transcode_get_css_product_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, get_css_product_client_stub do + # Create client + client = ::Google::Shopping::Css::V1::CssProductsService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.get_css_product({ name: name }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.get_css_product name: name do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.get_css_product ::Google::Shopping::Css::V1::GetCssProductRequest.new(name: name) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.get_css_product({ name: name }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.get_css_product(::Google::Shopping::Css::V1::GetCssProductRequest.new(name: name), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, get_css_product_client_stub.call_count + end + end + end + + def test_list_css_products + # Create test objects. + client_result = ::Google::Shopping::Css::V1::ListCssProductsResponse.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + parent = "hello world" + page_size = 42 + page_token = "hello world" + + list_css_products_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Shopping::Css::V1::CssProductsService::Rest::ServiceStub.stub :transcode_list_css_products_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, list_css_products_client_stub do + # Create client + client = ::Google::Shopping::Css::V1::CssProductsService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.list_css_products({ parent: parent, page_size: page_size, page_token: page_token }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.list_css_products parent: parent, page_size: page_size, page_token: page_token do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.list_css_products ::Google::Shopping::Css::V1::ListCssProductsRequest.new(parent: parent, page_size: page_size, page_token: page_token) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.list_css_products({ parent: parent, page_size: page_size, page_token: page_token }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.list_css_products(::Google::Shopping::Css::V1::ListCssProductsRequest.new(parent: parent, page_size: page_size, page_token: page_token), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, list_css_products_client_stub.call_count + end + end + end + + def test_configure + credentials_token = :dummy_value + + client = block_config = config = nil + dummy_stub = ClientStub.new nil + Gapic::Rest::ClientStub.stub :new, dummy_stub do + client = ::Google::Shopping::Css::V1::CssProductsService::Rest::Client.new do |config| + config.credentials = credentials_token + end + end + + config = client.configure do |c| + block_config = c + end + + assert_same block_config, config + assert_kind_of ::Google::Shopping::Css::V1::CssProductsService::Rest::Client::Configuration, config + end +end diff --git a/google-shopping-css-v1/test/google/shopping/css/v1/css_products_service_test.rb b/google-shopping-css-v1/test/google/shopping/css/v1/css_products_service_test.rb new file mode 100644 index 000000000000..703f768df154 --- /dev/null +++ b/google-shopping-css-v1/test/google/shopping/css/v1/css_products_service_test.rb @@ -0,0 +1,201 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" + +require "gapic/grpc/service_stub" + +require "google/shopping/css/v1/css_products_pb" +require "google/shopping/css/v1/css_products_services_pb" +require "google/shopping/css/v1/css_products_service" + +class ::Google::Shopping::Css::V1::CssProductsService::ClientTest < Minitest::Test + class ClientStub + attr_accessor :call_rpc_count, :requests + + def initialize response, operation, &block + @response = response + @operation = operation + @block = block + @call_rpc_count = 0 + @requests = [] + end + + def call_rpc *args, **kwargs + @call_rpc_count += 1 + + @requests << @block&.call(*args, **kwargs) + + yield @response, @operation if block_given? + + @response + end + + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_get_css_product + # Create GRPC objects. + grpc_response = ::Google::Shopping::Css::V1::CssProduct.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + name = "hello world" + + get_css_product_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :get_css_product, name + assert_kind_of ::Google::Shopping::Css::V1::GetCssProductRequest, request + assert_equal "hello world", request["name"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, get_css_product_client_stub do + # Create client + client = ::Google::Shopping::Css::V1::CssProductsService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.get_css_product({ name: name }) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.get_css_product name: name do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.get_css_product ::Google::Shopping::Css::V1::GetCssProductRequest.new(name: name) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.get_css_product({ name: name }, grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.get_css_product(::Google::Shopping::Css::V1::GetCssProductRequest.new(name: name), grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, get_css_product_client_stub.call_rpc_count + end + end + + def test_list_css_products + # Create GRPC objects. + grpc_response = ::Google::Shopping::Css::V1::ListCssProductsResponse.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + parent = "hello world" + page_size = 42 + page_token = "hello world" + + list_css_products_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :list_css_products, name + assert_kind_of ::Google::Shopping::Css::V1::ListCssProductsRequest, request + assert_equal "hello world", request["parent"] + assert_equal 42, request["page_size"] + assert_equal "hello world", request["page_token"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, list_css_products_client_stub do + # Create client + client = ::Google::Shopping::Css::V1::CssProductsService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.list_css_products({ parent: parent, page_size: page_size, page_token: page_token }) do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.list_css_products parent: parent, page_size: page_size, page_token: page_token do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.list_css_products ::Google::Shopping::Css::V1::ListCssProductsRequest.new(parent: parent, page_size: page_size, page_token: page_token) do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.list_css_products({ parent: parent, page_size: page_size, page_token: page_token }, grpc_options) do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.list_css_products(::Google::Shopping::Css::V1::ListCssProductsRequest.new(parent: parent, page_size: page_size, page_token: page_token), grpc_options) do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, list_css_products_client_stub.call_rpc_count + end + end + + def test_configure + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + + client = block_config = config = nil + dummy_stub = ClientStub.new nil, nil + Gapic::ServiceStub.stub :new, dummy_stub do + client = ::Google::Shopping::Css::V1::CssProductsService::Client.new do |config| + config.credentials = grpc_channel + end + end + + config = client.configure do |c| + block_config = c + end + + assert_same block_config, config + assert_kind_of ::Google::Shopping::Css::V1::CssProductsService::Client::Configuration, config + end +end diff --git a/google-shopping-css-v1/test/helper.rb b/google-shopping-css-v1/test/helper.rb new file mode 100644 index 000000000000..48407bca7edb --- /dev/null +++ b/google-shopping-css-v1/test/helper.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://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. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "minitest/autorun" +require "minitest/focus" +require "minitest/rg" + +require "grpc" + +require "ostruct" diff --git a/release-please-config.json b/release-please-config.json index e4b2cec3516b..05bb305eaa10 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -1647,6 +1647,10 @@ "component": "google-maps-fleet_engine-v1", "version_file": "lib/google/maps/fleet_engine/v1/version.rb" }, + "google-shopping-css-v1": { + "component": "google-shopping-css-v1", + "version_file": "lib/google/shopping/css/v1/version.rb" + }, "google-shopping-merchant-accounts": { "component": "google-shopping-merchant-accounts", "version_file": "lib/google/shopping/merchant/accounts/version.rb"