From 3d20b3985eac6bdebafe27f7c11c9a6a48b1296b Mon Sep 17 00:00:00 2001 From: Google APIs Date: Fri, 19 Jan 2024 17:15:01 -0800 Subject: [PATCH] feat: add analytics service PiperOrigin-RevId: 599976565 --- google/cloud/retail/v2beta/BUILD.bazel | 3 + .../retail/v2beta/analytics_service.proto | 57 +++++++ .../cloud/retail/v2beta/export_config.proto | 82 ++++++++++ .../v2beta/retail_grpc_service_config.json | 144 +++++++++--------- google/cloud/retail/v2beta/retail_v2beta.yaml | 6 + 5 files changed, 219 insertions(+), 73 deletions(-) create mode 100644 google/cloud/retail/v2beta/analytics_service.proto diff --git a/google/cloud/retail/v2beta/BUILD.bazel b/google/cloud/retail/v2beta/BUILD.bazel index 860fce5a37342..b5245eeacc1fb 100644 --- a/google/cloud/retail/v2beta/BUILD.bazel +++ b/google/cloud/retail/v2beta/BUILD.bazel @@ -21,6 +21,7 @@ load("@com_google_googleapis_imports//:imports.bzl", "proto_library_with_info") proto_library( name = "retail_proto", srcs = [ + "analytics_service.proto", "catalog.proto", "catalog_service.proto", "common.proto", @@ -111,6 +112,8 @@ java_gapic_library( java_gapic_test( name = "retail_java_gapic_test_suite", test_classes = [ + "com.google.cloud.retail.v2beta.AnalyticsServiceClientHttpJsonTest", + "com.google.cloud.retail.v2beta.AnalyticsServiceClientTest", "com.google.cloud.retail.v2beta.CatalogServiceClientHttpJsonTest", "com.google.cloud.retail.v2beta.CatalogServiceClientTest", "com.google.cloud.retail.v2beta.CompletionServiceClientHttpJsonTest", diff --git a/google/cloud/retail/v2beta/analytics_service.proto b/google/cloud/retail/v2beta/analytics_service.proto new file mode 100644 index 0000000000000..6782baf836c0f --- /dev/null +++ b/google/cloud/retail/v2beta/analytics_service.proto @@ -0,0 +1,57 @@ +// Copyright 2021 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. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2beta/export_config.proto"; +import "google/longrunning/operations.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "cloud.google.com/go/retail/apiv2beta/retailpb;retailpb"; +option java_multiple_files = true; +option java_outer_classname = "AnalyticsServiceProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; + +// Service for managing & accessing retail search business metric. +// Retail recommendation business metric is currently not available. +service AnalyticsService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Exports analytics metrics. + // + // `Operation.response` is of type `ExportAnalyticsMetricsResponse`. + // `Operation.metadata` is of type `ExportMetadata`. + rpc ExportAnalyticsMetrics(ExportAnalyticsMetricsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2beta/{catalog=projects/*/locations/*/catalogs/*}:exportAnalyticsMetrics" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2beta.ExportAnalyticsMetricsResponse" + metadata_type: "google.cloud.retail.v2beta.ExportMetadata" + }; + } +} diff --git a/google/cloud/retail/v2beta/export_config.proto b/google/cloud/retail/v2beta/export_config.proto index 9efc0d195a629..303712b21624a 100644 --- a/google/cloud/retail/v2beta/export_config.proto +++ b/google/cloud/retail/v2beta/export_config.proto @@ -30,6 +30,45 @@ option objc_class_prefix = "RETAIL"; option php_namespace = "Google\\Cloud\\Retail\\V2beta"; option ruby_package = "Google::Cloud::Retail::V2beta"; +// The output configuration setting. +message OutputConfig { + // The Google Cloud Storage output destination configuration. + message GcsDestination { + // Required. The output uri prefix for saving output data to json files. + // Some mapping examples are as follows: + // output_uri_prefix sample output(assuming the object is foo.json) + // ======================== ============================================= + // gs://bucket/ gs://bucket/foo.json + // gs://bucket/folder/ gs://bucket/folder/foo.json + // gs://bucket/folder/item_ gs://bucket/folder/item_foo.json + string output_uri_prefix = 1 [(google.api.field_behavior) = REQUIRED]; + } + + // The BigQuery output destination configuration. + message BigQueryDestination { + // Required. The ID of a BigQuery Dataset. + string dataset_id = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The prefix of exported BigQuery tables. + string table_id_prefix = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. Describes the table type. The following values are supported: + // + // * `table`: A BigQuery native table. + // * `view`: A virtual table defined by a SQL query. + string table_type = 3 [(google.api.field_behavior) = REQUIRED]; + } + + // The configuration of destination for holding output data. + oneof destination { + // The Google Cloud Storage location where the output is to be written to. + GcsDestination gcs_destination = 1; + + // The BigQuery location where the output is to be written to. + BigQueryDestination bigquery_destination = 2; + } +} + // Configuration of destination for Export related errors. message ExportErrorsConfig { // Required. Errors destination. @@ -42,6 +81,35 @@ message ExportErrorsConfig { } } +// Request message for the `ExportAnalyticsMetrics` method. +message ExportAnalyticsMetricsRequest { + // Required. Full resource name of the parent catalog. + // Expected format: `projects/*/locations/*/catalogs/*` + string catalog = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The output location of the data. + OutputConfig output_config = 2 [(google.api.field_behavior) = REQUIRED]; + + // A filtering expression to specify restrictions on returned metrics. + // The expression is a sequence of terms. Each term applies a restriction to + // the returned metrics. Use this expression to restrict results to a + // specific time range. + // + // Currently we expect only one types of fields: + // + // * `timestamp`: This can be specified twice, once with a + // less than operator and once with a greater than operator. The + // `timestamp` restriction should result in one, contiguous, valid, + // `timestamp` range. + // + // Some examples of valid filters expressions: + // + // * Example 1: `timestamp > "2012-04-23T18:25:43.511Z" + // timestamp < "2012-04-23T18:30:43.511Z"` + // * Example 2: `timestamp > "2012-04-23T18:25:43.511Z"` + string filter = 3; +} + // Metadata related to the progress of the Export operation. This is // returned by the google.longrunning.Operation.metadata field. message ExportMetadata { @@ -81,6 +149,20 @@ message ExportUserEventsResponse { OutputResult output_result = 3; } +// Response of the ExportAnalyticsMetricsRequest. If the long running +// operation was successful, then this message is returned by the +// google.longrunning.Operations.response field if the operation was successful. +message ExportAnalyticsMetricsResponse { + // A sample of errors encountered while processing the request. + repeated google.rpc.Status error_samples = 1; + + // This field is never set. + ExportErrorsConfig errors_config = 2; + + // Output result indicating where the data were exported to. + OutputResult output_result = 3; +} + // Output result that stores the information about where the exported data is // stored. message OutputResult { diff --git a/google/cloud/retail/v2beta/retail_grpc_service_config.json b/google/cloud/retail/v2beta/retail_grpc_service_config.json index 8e587919da735..9f3b7320c695e 100644 --- a/google/cloud/retail/v2beta/retail_grpc_service_config.json +++ b/google/cloud/retail/v2beta/retail_grpc_service_config.json @@ -1,43 +1,44 @@ { - "methodConfig": [{ - "name": [ - { "service": "google.cloud.retail.v2beta.CatalogService" }, - { "service": "google.cloud.retail.v2beta.CompletionService" }, - { "service": "google.cloud.retail.v2beta.UserEventService" }, - { "service": "google.cloud.retail.v2beta.PredictionService" }, - { "service": "google.cloud.retail.v2beta.SearchService" } - ], - "timeout": "5s", - "retryPolicy": { - "initialBackoff": "0.100s", - "maxBackoff": "5s", - "backoffMultiplier": 1.3, - "retryableStatusCodes": [ - "UNAVAILABLE", - "DEADLINE_EXCEEDED" - ] - } - }, { - "name": [ - { "service": "google.cloud.retail.v2beta.ProductService" }, - { - "service": "google.cloud.retail.v2beta.UserEventService", - "method": "PurgeUserEvents" + "methodConfig": [ + { + "name": [ + { "service": "google.cloud.retail.v2beta.CatalogService" }, + { "service": "google.cloud.retail.v2beta.CompletionService" }, + { "service": "google.cloud.retail.v2beta.UserEventService" }, + { "service": "google.cloud.retail.v2beta.PredictionService" }, + { "service": "google.cloud.retail.v2beta.SearchService" } + ], + "timeout": "5s", + "retryPolicy": { + "initialBackoff": "0.100s", + "maxBackoff": "5s", + "backoffMultiplier": 1.3, + "retryableStatusCodes": ["UNAVAILABLE", "DEADLINE_EXCEEDED"] } - ], - "timeout": "30s", - "retryPolicy": { - "initialBackoff": "0.100s", - "maxBackoff": "30s", - "backoffMultiplier": 1.3, - "retryableStatusCodes": [ - "UNAVAILABLE", - "DEADLINE_EXCEEDED" - ] - } - }, { + }, + { + "name": [ + { "service": "google.cloud.retail.v2beta.ProductService" }, + { + "service": "google.cloud.retail.v2beta.UserEventService", + "method": "PurgeUserEvents" + } + ], + "timeout": "30s", + "retryPolicy": { + "initialBackoff": "0.100s", + "maxBackoff": "30s", + "backoffMultiplier": 1.3, + "retryableStatusCodes": ["UNAVAILABLE", "DEADLINE_EXCEEDED"] + } + }, + { "name": [ - { "service": "google.cloud.retail.v2alpha.ModelService" } + { + "service": "google.cloud.retail.v2beta.AnalyticsService", + "method": "ExportAnalyticsMetrics" + }, + { "service": "google.cloud.retail.v2beta.ModelService" } ], "timeout": "60s", "retryPolicy": { @@ -46,43 +47,40 @@ "backoffMultiplier": 1.3, "retryableStatusCodes": ["UNAVAILABLE", "DEADLINE_EXCEEDED"] } - }, { - "name": [ - { - "service": "google.longrunning.Operations", - "method": "ListOperations" - }, - { - "service": "google.cloud.retail.v2beta.ProductService", - "method": "ImportProducts" + }, + { + "name": [ + { + "service": "google.longrunning.Operations", + "method": "ListOperations" + }, + { + "service": "google.cloud.retail.v2beta.ProductService", + "method": "ImportProducts" + } + ], + "timeout": "300s", + "retryPolicy": { + "initialBackoff": "0.100s", + "maxBackoff": "300s", + "backoffMultiplier": 1.3, + "retryableStatusCodes": ["UNAVAILABLE", "DEADLINE_EXCEEDED"] } - ], - "timeout": "300s", - "retryPolicy": { - "initialBackoff": "0.100s", - "maxBackoff": "300s", - "backoffMultiplier": 1.3, - "retryableStatusCodes": [ - "UNAVAILABLE", - "DEADLINE_EXCEEDED" - ] - } - }, { - "name": [ - { - "service": "google.cloud.retail.v2beta.UserEventService", - "method": "ImportUserEvents" + }, + { + "name": [ + { + "service": "google.cloud.retail.v2beta.UserEventService", + "method": "ImportUserEvents" + } + ], + "timeout": "600s", + "retryPolicy": { + "initialBackoff": "0.100s", + "maxBackoff": "300s", + "backoffMultiplier": 1.3, + "retryableStatusCodes": ["UNAVAILABLE", "DEADLINE_EXCEEDED"] } - ], - "timeout": "600s", - "retryPolicy": { - "initialBackoff": "0.100s", - "maxBackoff": "300s", - "backoffMultiplier": 1.3, - "retryableStatusCodes": [ - "UNAVAILABLE", - "DEADLINE_EXCEEDED" - ] } - }] + ] } diff --git a/google/cloud/retail/v2beta/retail_v2beta.yaml b/google/cloud/retail/v2beta/retail_v2beta.yaml index f0ed2b85ef432..6725a2cc028c4 100644 --- a/google/cloud/retail/v2beta/retail_v2beta.yaml +++ b/google/cloud/retail/v2beta/retail_v2beta.yaml @@ -5,6 +5,7 @@ title: Retail API apis: - name: google.cloud.location.Locations +- name: google.cloud.retail.v2beta.AnalyticsService - name: google.cloud.retail.v2beta.CatalogService - name: google.cloud.retail.v2beta.CompletionService - name: google.cloud.retail.v2beta.ControlService @@ -23,6 +24,7 @@ types: - name: google.cloud.retail.v2beta.AddLocalInventoriesMetadata - name: google.cloud.retail.v2beta.AddLocalInventoriesResponse - name: google.cloud.retail.v2beta.CreateModelMetadata +- name: google.cloud.retail.v2beta.ExportAnalyticsMetricsResponse - name: google.cloud.retail.v2beta.ExportErrorsConfig - name: google.cloud.retail.v2beta.ExportMetadata - name: google.cloud.retail.v2beta.ExportProductsResponse @@ -103,6 +105,10 @@ authentication: oauth: canonical_scopes: |- https://www.googleapis.com/auth/cloud-platform + - selector: google.cloud.retail.v2beta.AnalyticsService.ExportAnalyticsMetrics + oauth: + canonical_scopes: |- + https://www.googleapis.com/auth/cloud-platform - selector: 'google.cloud.retail.v2beta.CatalogService.*' oauth: canonical_scopes: |-