Skip to content

Commit 12fdc70

Browse files
Google APIscopybara-github
authored andcommitted
feat: add analytics service
PiperOrigin-RevId: 605291363
1 parent 549960c commit 12fdc70

5 files changed

Lines changed: 233 additions & 0 deletions

File tree

google/cloud/retail/v2/BUILD.bazel

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@ load("@com_google_googleapis_imports//:imports.bzl", "proto_library_with_info")
2121
proto_library(
2222
name = "retail_proto",
2323
srcs = [
24+
"analytics_service.proto",
2425
"catalog.proto",
2526
"catalog_service.proto",
2627
"common.proto",
2728
"completion_service.proto",
2829
"control.proto",
2930
"control_service.proto",
31+
"export_config.proto",
3032
"import_config.proto",
3133
"model.proto",
3234
"model_service.proto",
@@ -110,6 +112,8 @@ java_gapic_library(
110112
java_gapic_test(
111113
name = "retail_java_gapic_test_suite",
112114
test_classes = [
115+
"com.google.cloud.retail.v2.AnalyticsServiceClientHttpJsonTest",
116+
"com.google.cloud.retail.v2.AnalyticsServiceClientTest",
113117
"com.google.cloud.retail.v2.CatalogServiceClientHttpJsonTest",
114118
"com.google.cloud.retail.v2.CatalogServiceClientTest",
115119
"com.google.cloud.retail.v2.CompletionServiceClientHttpJsonTest",
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// Copyright 2021 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
syntax = "proto3";
16+
17+
package google.cloud.retail.v2;
18+
19+
import "google/api/annotations.proto";
20+
import "google/api/client.proto";
21+
import "google/api/field_behavior.proto";
22+
import "google/api/resource.proto";
23+
import "google/cloud/retail/v2/export_config.proto";
24+
import "google/longrunning/operations.proto";
25+
26+
option csharp_namespace = "Google.Cloud.Retail.V2";
27+
option go_package = "cloud.google.com/go/retail/apiv2/retailpb;retailpb";
28+
option java_multiple_files = true;
29+
option java_outer_classname = "AnalyticsServiceProto";
30+
option java_package = "com.google.cloud.retail.v2";
31+
option objc_class_prefix = "RETAIL";
32+
option php_namespace = "Google\\Cloud\\Retail\\V2";
33+
option ruby_package = "Google::Cloud::Retail::V2";
34+
35+
// Service for managing & accessing retail search business metric.
36+
// Retail recommendation business metric is currently not available.
37+
service AnalyticsService {
38+
option (google.api.default_host) = "retail.googleapis.com";
39+
option (google.api.oauth_scopes) =
40+
"https://www.googleapis.com/auth/cloud-platform";
41+
42+
// Exports analytics metrics.
43+
//
44+
// `Operation.response` is of type `ExportAnalyticsMetricsResponse`.
45+
// `Operation.metadata` is of type `ExportMetadata`.
46+
rpc ExportAnalyticsMetrics(ExportAnalyticsMetricsRequest)
47+
returns (google.longrunning.Operation) {
48+
option (google.api.http) = {
49+
post: "/v2/{catalog=projects/*/locations/*/catalogs/*}:exportAnalyticsMetrics"
50+
body: "*"
51+
};
52+
option (google.longrunning.operation_info) = {
53+
response_type: "google.cloud.retail.v2.ExportAnalyticsMetricsResponse"
54+
metadata_type: "google.cloud.retail.v2.ExportMetadata"
55+
};
56+
}
57+
}
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
// Copyright 2021 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
syntax = "proto3";
16+
17+
package google.cloud.retail.v2;
18+
19+
import "google/api/field_behavior.proto";
20+
import "google/api/resource.proto";
21+
import "google/protobuf/timestamp.proto";
22+
import "google/rpc/status.proto";
23+
24+
option csharp_namespace = "Google.Cloud.Retail.V2";
25+
option go_package = "cloud.google.com/go/retail/apiv2/retailpb;retailpb";
26+
option java_multiple_files = true;
27+
option java_outer_classname = "ExportConfigProto";
28+
option java_package = "com.google.cloud.retail.v2";
29+
option objc_class_prefix = "RETAIL";
30+
option php_namespace = "Google\\Cloud\\Retail\\V2";
31+
option ruby_package = "Google::Cloud::Retail::V2";
32+
33+
// The output configuration setting.
34+
message OutputConfig {
35+
// The Google Cloud Storage output destination configuration.
36+
message GcsDestination {
37+
// Required. The output uri prefix for saving output data to json files.
38+
// Some mapping examples are as follows:
39+
// output_uri_prefix sample output(assuming the object is foo.json)
40+
// ======================== =============================================
41+
// gs://bucket/ gs://bucket/foo.json
42+
// gs://bucket/folder/ gs://bucket/folder/foo.json
43+
// gs://bucket/folder/item_ gs://bucket/folder/item_foo.json
44+
string output_uri_prefix = 1 [(google.api.field_behavior) = REQUIRED];
45+
}
46+
47+
// The BigQuery output destination configuration.
48+
message BigQueryDestination {
49+
// Required. The ID of a BigQuery Dataset.
50+
string dataset_id = 1 [(google.api.field_behavior) = REQUIRED];
51+
52+
// Required. The prefix of exported BigQuery tables.
53+
string table_id_prefix = 2 [(google.api.field_behavior) = REQUIRED];
54+
55+
// Required. Describes the table type. The following values are supported:
56+
//
57+
// * `table`: A BigQuery native table.
58+
// * `view`: A virtual table defined by a SQL query.
59+
string table_type = 3 [(google.api.field_behavior) = REQUIRED];
60+
}
61+
62+
// The configuration of destination for holding output data.
63+
oneof destination {
64+
// The Google Cloud Storage location where the output is to be written to.
65+
GcsDestination gcs_destination = 1;
66+
67+
// The BigQuery location where the output is to be written to.
68+
BigQueryDestination bigquery_destination = 2;
69+
}
70+
}
71+
72+
// Configuration of destination for Export related errors.
73+
message ExportErrorsConfig {
74+
// Required. Errors destination.
75+
oneof destination {
76+
// Google Cloud Storage path for import errors. This must be an empty,
77+
// existing Cloud Storage bucket. Export errors will be written to a file in
78+
// this bucket, one per line, as a JSON-encoded
79+
// `google.rpc.Status` message.
80+
string gcs_prefix = 1;
81+
}
82+
}
83+
84+
// Request message for the `ExportAnalyticsMetrics` method.
85+
message ExportAnalyticsMetricsRequest {
86+
// Required. Full resource name of the parent catalog.
87+
// Expected format: `projects/*/locations/*/catalogs/*`
88+
string catalog = 1 [(google.api.field_behavior) = REQUIRED];
89+
90+
// Required. The output location of the data.
91+
OutputConfig output_config = 2 [(google.api.field_behavior) = REQUIRED];
92+
93+
// A filtering expression to specify restrictions on returned metrics.
94+
// The expression is a sequence of terms. Each term applies a restriction to
95+
// the returned metrics. Use this expression to restrict results to a
96+
// specific time range.
97+
//
98+
// Currently we expect only one types of fields:
99+
//
100+
// * `timestamp`: This can be specified twice, once with a
101+
// less than operator and once with a greater than operator. The
102+
// `timestamp` restriction should result in one, contiguous, valid,
103+
// `timestamp` range.
104+
//
105+
// Some examples of valid filters expressions:
106+
//
107+
// * Example 1: `timestamp > "2012-04-23T18:25:43.511Z"
108+
// timestamp < "2012-04-23T18:30:43.511Z"`
109+
// * Example 2: `timestamp > "2012-04-23T18:25:43.511Z"`
110+
string filter = 3;
111+
}
112+
113+
// Metadata related to the progress of the Export operation. This is
114+
// returned by the google.longrunning.Operation.metadata field.
115+
message ExportMetadata {
116+
// Operation create time.
117+
google.protobuf.Timestamp create_time = 1;
118+
119+
// Operation last update time. If the operation is done, this is also the
120+
// finish time.
121+
google.protobuf.Timestamp update_time = 2;
122+
}
123+
124+
// Response of the ExportAnalyticsMetricsRequest. If the long running
125+
// operation was successful, then this message is returned by the
126+
// google.longrunning.Operations.response field if the operation was successful.
127+
message ExportAnalyticsMetricsResponse {
128+
// A sample of errors encountered while processing the request.
129+
repeated google.rpc.Status error_samples = 1;
130+
131+
// This field is never set.
132+
ExportErrorsConfig errors_config = 2;
133+
134+
// Output result indicating where the data were exported to.
135+
OutputResult output_result = 3;
136+
}
137+
138+
// Output result that stores the information about where the exported data is
139+
// stored.
140+
message OutputResult {
141+
// The BigQuery location where the result is stored.
142+
repeated BigQueryOutputResult bigquery_result = 1;
143+
144+
// The Google Cloud Storage location where the result is stored.
145+
repeated GcsOutputResult gcs_result = 2;
146+
}
147+
148+
// A BigQuery output result.
149+
message BigQueryOutputResult {
150+
// The ID of a BigQuery Dataset.
151+
string dataset_id = 1;
152+
153+
// The ID of a BigQuery Table.
154+
string table_id = 2;
155+
}
156+
157+
// A Gcs output result.
158+
message GcsOutputResult {
159+
// The uri of Gcs output
160+
string output_uri = 1;
161+
}

google/cloud/retail/v2/retail_grpc_service_config.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434
},
3535
{
3636
"name": [
37+
{
38+
"service": "google.cloud.retail.v2.AnalyticsService",
39+
"method": "ExportAnalyticsMetrics"
40+
},
3741
{ "service": "google.cloud.retail.v2.ModelService" }
3842
],
3943
"timeout": "60s",

google/cloud/retail/v2/retail_v2.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ title: Retail API
55

66
apis:
77
- name: google.cloud.location.Locations
8+
- name: google.cloud.retail.v2.AnalyticsService
89
- name: google.cloud.retail.v2.CatalogService
910
- name: google.cloud.retail.v2.CompletionService
1011
- name: google.cloud.retail.v2.ControlService
@@ -23,6 +24,8 @@ types:
2324
- name: google.cloud.retail.v2.AddLocalInventoriesMetadata
2425
- name: google.cloud.retail.v2.AddLocalInventoriesResponse
2526
- name: google.cloud.retail.v2.CreateModelMetadata
27+
- name: google.cloud.retail.v2.ExportAnalyticsMetricsResponse
28+
- name: google.cloud.retail.v2.ExportMetadata
2629
- name: google.cloud.retail.v2.ImportCompletionDataResponse
2730
- name: google.cloud.retail.v2.ImportErrorsConfig
2831
- name: google.cloud.retail.v2.ImportMetadata
@@ -99,6 +102,10 @@ authentication:
99102
oauth:
100103
canonical_scopes: |-
101104
https://www.googleapis.com/auth/cloud-platform
105+
- selector: google.cloud.retail.v2.AnalyticsService.ExportAnalyticsMetrics
106+
oauth:
107+
canonical_scopes: |-
108+
https://www.googleapis.com/auth/cloud-platform
102109
- selector: 'google.cloud.retail.v2.CatalogService.*'
103110
oauth:
104111
canonical_scopes: |-

0 commit comments

Comments
 (0)