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
15syntax = "proto3";
16
17package google.cloud.retail.v2;
18
19import "google/api/field_behavior.proto";
20import "google/api/resource.proto";
21import "google/cloud/retail/v2/product.proto";
22import "google/cloud/retail/v2/user_event.proto";
23import "google/protobuf/field_mask.proto";
24import "google/protobuf/timestamp.proto";
25import "google/rpc/status.proto";
26import "google/type/date.proto";
27
28option csharp_namespace = "Google.Cloud.Retail.V2";
29option go_package = "cloud.google.com/go/retail/apiv2/retailpb;retailpb";
30option java_multiple_files = true;
31option java_outer_classname = "ImportConfigProto";
32option java_package = "com.google.cloud.retail.v2";
33option objc_class_prefix = "RETAIL";
34option php_namespace = "Google\\Cloud\\Retail\\V2";
35option ruby_package = "Google::Cloud::Retail::V2";
36
37// Google Cloud Storage location for input content.
38message GcsSource {
39  // Required. Google Cloud Storage URIs to input files. URI can be up to
40  // 2000 characters long. URIs can match the full object path (for example,
41  // `gs://bucket/directory/object.json`) or a pattern matching one or more
42  // files, such as `gs://bucket/directory/*.json`. A request can
43  // contain at most 100 files, and each file can be up to 2 GB. See
44  // [Importing product
45  // information](https://cloud.google.com/retail/recommendations-ai/docs/upload-catalog)
46  // for the expected file format and setup instructions.
47  repeated string input_uris = 1 [(google.api.field_behavior) = REQUIRED];
48
49  // The schema to use when parsing the data from the source.
50  //
51  // Supported values for product imports:
52  //
53  // * `product` (default): One JSON [Product][google.cloud.retail.v2.Product]
54  // per line. Each product must
55  //   have a valid [Product.id][google.cloud.retail.v2.Product.id].
56  // * `product_merchant_center`: See [Importing catalog data from Merchant
57  //   Center](https://cloud.google.com/retail/recommendations-ai/docs/upload-catalog#mc).
58  //
59  // Supported values for user events imports:
60  //
61  // * `user_event` (default): One JSON
62  // [UserEvent][google.cloud.retail.v2.UserEvent] per line.
63  // * `user_event_ga360`: Using
64  //   https://support.google.com/analytics/answer/3437719.
65  //
66  // Supported values for control imports:
67  //
68  // * `control` (default): One JSON [Control][google.cloud.retail.v2.Control]
69  // per line.
70  //
71  // Supported values for catalog attribute imports:
72  //
73  // * `catalog_attribute` (default): One CSV
74  // [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] per line.
75  string data_schema = 2;
76}
77
78// BigQuery source import data from.
79message BigQuerySource {
80  // BigQuery table partition info. Leave this empty if the BigQuery table
81  // is not partitioned.
82  oneof partition {
83    // BigQuery time partitioned table's _PARTITIONDATE in YYYY-MM-DD format.
84    //
85    // Only supported in
86    // [ImportProductsRequest][google.cloud.retail.v2.ImportProductsRequest].
87    google.type.Date partition_date = 6;
88  }
89
90  // The project ID (can be project # or ID) that the BigQuery source is in with
91  // a length limit of 128 characters. If not specified, inherits the project
92  // ID from the parent request.
93  string project_id = 5;
94
95  // Required. The BigQuery data set to copy the data from with a length limit
96  // of 1,024 characters.
97  string dataset_id = 1 [(google.api.field_behavior) = REQUIRED];
98
99  // Required. The BigQuery table to copy the data from with a length limit of
100  // 1,024 characters.
101  string table_id = 2 [(google.api.field_behavior) = REQUIRED];
102
103  // Intermediate Cloud Storage directory used for the import with a length
104  // limit of 2,000 characters. Can be specified if one wants to have the
105  // BigQuery export to a specific Cloud Storage directory.
106  string gcs_staging_dir = 3;
107
108  // The schema to use when parsing the data from the source.
109  //
110  // Supported values for product imports:
111  //
112  // * `product` (default): One JSON [Product][google.cloud.retail.v2.Product]
113  // per line. Each product must
114  //   have a valid [Product.id][google.cloud.retail.v2.Product.id].
115  // * `product_merchant_center`: See [Importing catalog data from Merchant
116  //   Center](https://cloud.google.com/retail/recommendations-ai/docs/upload-catalog#mc).
117  //
118  // Supported values for user events imports:
119  //
120  // * `user_event` (default): One JSON
121  // [UserEvent][google.cloud.retail.v2.UserEvent] per line.
122  // * `user_event_ga360`:
123  //   The schema is available here:
124  //   https://support.google.com/analytics/answer/3437719.
125  // * `user_event_ga4`:
126  //   The schema is available here:
127  //   https://support.google.com/analytics/answer/7029846.
128  //
129  // Supported values for autocomplete imports:
130  //
131  // * `suggestions` (default): One JSON completion suggestion per line.
132  // * `denylist`:  One JSON deny suggestion per line.
133  // * `allowlist`:  One JSON allow suggestion per line.
134  string data_schema = 4;
135}
136
137// The inline source for the input config for ImportProducts method.
138message ProductInlineSource {
139  // Required. A list of products to update/create. Each product must have a
140  // valid [Product.id][google.cloud.retail.v2.Product.id]. Recommended max of
141  // 100 items.
142  repeated Product products = 1 [(google.api.field_behavior) = REQUIRED];
143}
144
145// The inline source for the input config for ImportUserEvents method.
146message UserEventInlineSource {
147  // Required. A list of user events to import. Recommended max of 10k items.
148  repeated UserEvent user_events = 1 [(google.api.field_behavior) = REQUIRED];
149}
150
151// Configuration of destination for Import related errors.
152message ImportErrorsConfig {
153  // Required. Errors destination.
154  oneof destination {
155    // Google Cloud Storage prefix for import errors. This must be an empty,
156    // existing Cloud Storage directory. Import errors are written to
157    // sharded files in this directory, one per line, as a JSON-encoded
158    // `google.rpc.Status` message.
159    string gcs_prefix = 1;
160  }
161}
162
163// Request message for Import methods.
164message ImportProductsRequest {
165  // Indicates how imported products are reconciled with the existing products
166  // created or imported before.
167  enum ReconciliationMode {
168    // Defaults to INCREMENTAL.
169    RECONCILIATION_MODE_UNSPECIFIED = 0;
170
171    // Inserts new products or updates existing products.
172    INCREMENTAL = 1;
173
174    // Calculates diff and replaces the entire product dataset. Existing
175    // products may be deleted if they are not present in the source location.
176    FULL = 2;
177  }
178
179  // Required.
180  // `projects/1234/locations/global/catalogs/default_catalog/branches/default_branch`
181  //
182  // If no updateMask is specified, requires products.create permission.
183  // If updateMask is specified, requires products.update permission.
184  string parent = 1 [
185    (google.api.field_behavior) = REQUIRED,
186    (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" }
187  ];
188
189  // Deprecated. This field has no effect.
190  string request_id = 6 [deprecated = true];
191
192  // Required. The desired input location of the data.
193  ProductInputConfig input_config = 2 [(google.api.field_behavior) = REQUIRED];
194
195  // The desired location of errors incurred during the Import.
196  ImportErrorsConfig errors_config = 3;
197
198  // Indicates which fields in the provided imported `products` to update. If
199  // not set, all fields are updated.
200  google.protobuf.FieldMask update_mask = 4;
201
202  // The mode of reconciliation between existing products and the products to be
203  // imported. Defaults to
204  // [ReconciliationMode.INCREMENTAL][google.cloud.retail.v2.ImportProductsRequest.ReconciliationMode.INCREMENTAL].
205  ReconciliationMode reconciliation_mode = 5;
206
207  // Full Pub/Sub topic name for receiving notification. If this field is set,
208  // when the import is finished, a notification is sent to
209  // specified Pub/Sub topic. The message data is JSON string of a
210  // [Operation][google.longrunning.Operation].
211  //
212  // Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. It has
213  // to be within the same project as
214  // [ImportProductsRequest.parent][google.cloud.retail.v2.ImportProductsRequest.parent].
215  // Make sure that `service-<project
216  // number>@gcp-sa-retail.iam.gserviceaccount.com` has the
217  // `pubsub.topics.publish` IAM permission on the topic.
218  string notification_pubsub_topic = 7;
219}
220
221// Request message for the ImportUserEvents request.
222message ImportUserEventsRequest {
223  // Required. `projects/1234/locations/global/catalogs/default_catalog`
224  string parent = 1 [
225    (google.api.field_behavior) = REQUIRED,
226    (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" }
227  ];
228
229  // Required. The desired input location of the data.
230  UserEventInputConfig input_config = 2
231      [(google.api.field_behavior) = REQUIRED];
232
233  // The desired location of errors incurred during the Import. Cannot be set
234  // for inline user event imports.
235  ImportErrorsConfig errors_config = 3;
236}
237
238// Request message for ImportCompletionData methods.
239message ImportCompletionDataRequest {
240  // Required. The catalog which the suggestions dataset belongs to.
241  //
242  // Format: `projects/1234/locations/global/catalogs/default_catalog`.
243  string parent = 1 [
244    (google.api.field_behavior) = REQUIRED,
245    (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" }
246  ];
247
248  // Required. The desired input location of the data.
249  CompletionDataInputConfig input_config = 2
250      [(google.api.field_behavior) = REQUIRED];
251
252  // Pub/Sub topic for receiving notification. If this field is set,
253  // when the import is finished, a notification is sent to
254  // specified Pub/Sub topic. The message data is JSON string of a
255  // [Operation][google.longrunning.Operation].
256  // Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`.
257  string notification_pubsub_topic = 3;
258}
259
260// The input config source for products.
261message ProductInputConfig {
262  // Required. The source of the input.
263  oneof source {
264    // The Inline source for the input content for products.
265    ProductInlineSource product_inline_source = 1;
266
267    // Google Cloud Storage location for the input content.
268    GcsSource gcs_source = 2;
269
270    // BigQuery input source.
271    BigQuerySource big_query_source = 3;
272  }
273}
274
275// The input config source for user events.
276message UserEventInputConfig {
277  // The source of the input.
278  oneof source {
279    // Required. The Inline source for the input content for UserEvents.
280    UserEventInlineSource user_event_inline_source = 1
281        [(google.api.field_behavior) = REQUIRED];
282
283    // Required. Google Cloud Storage location for the input content.
284    GcsSource gcs_source = 2 [(google.api.field_behavior) = REQUIRED];
285
286    // Required. BigQuery input source.
287    BigQuerySource big_query_source = 3
288        [(google.api.field_behavior) = REQUIRED];
289  }
290}
291
292// The input config source for completion data.
293message CompletionDataInputConfig {
294  // The source of the input.
295  //
296  // Supported
297  // [BigQuerySource.data_schema][google.cloud.retail.v2.BigQuerySource.data_schema]
298  // values for suggestions imports:
299  //
300  // * `suggestions` (default): One JSON completion suggestion per line.
301  // * `denylist`:  One JSON deny suggestion per line.
302  // * `allowlist`:  One JSON allow suggestion per line.
303  oneof source {
304    // Required. BigQuery input source.
305    //
306    // Add the IAM permission "BigQuery Data Viewer" for
307    // [email protected] before
308    // using this feature otherwise an error is thrown.
309    BigQuerySource big_query_source = 1
310        [(google.api.field_behavior) = REQUIRED];
311  }
312}
313
314// Metadata related to the progress of the Import operation. This is
315// returned by the google.longrunning.Operation.metadata field.
316message ImportMetadata {
317  // Operation create time.
318  google.protobuf.Timestamp create_time = 1;
319
320  // Operation last update time. If the operation is done, this is also the
321  // finish time.
322  google.protobuf.Timestamp update_time = 2;
323
324  // Count of entries that were processed successfully.
325  int64 success_count = 3;
326
327  // Count of entries that encountered errors while processing.
328  int64 failure_count = 4;
329
330  // Deprecated. This field is never set.
331  string request_id = 5 [deprecated = true];
332
333  // Pub/Sub topic for receiving notification. If this field is set,
334  // when the import is finished, a notification is sent to
335  // specified Pub/Sub topic. The message data is JSON string of a
336  // [Operation][google.longrunning.Operation].
337  // Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`.
338  string notification_pubsub_topic = 6;
339}
340
341// Response of the
342// [ImportProductsRequest][google.cloud.retail.v2.ImportProductsRequest]. If the
343// long running operation is done, then this message is returned by the
344// google.longrunning.Operations.response field if the operation was successful.
345message ImportProductsResponse {
346  // A sample of errors encountered while processing the request.
347  repeated google.rpc.Status error_samples = 1;
348
349  // Echoes the destination for the complete errors in the request if set.
350  ImportErrorsConfig errors_config = 2;
351}
352
353// Response of the ImportUserEventsRequest. If the long running
354// operation was successful, then this message is returned by the
355// google.longrunning.Operations.response field if the operation was successful.
356message ImportUserEventsResponse {
357  // A sample of errors encountered while processing the request.
358  repeated google.rpc.Status error_samples = 1;
359
360  // Echoes the destination for the complete errors if this field was set in
361  // the request.
362  ImportErrorsConfig errors_config = 2;
363
364  // Aggregated statistics of user event import status.
365  UserEventImportSummary import_summary = 3;
366}
367
368// A summary of import result. The UserEventImportSummary summarizes
369// the import status for user events.
370message UserEventImportSummary {
371  // Count of user events imported with complete existing catalog information.
372  int64 joined_events_count = 1;
373
374  // Count of user events imported, but with catalog information not found
375  // in the imported catalog.
376  int64 unjoined_events_count = 2;
377}
378
379// Response of the
380// [ImportCompletionDataRequest][google.cloud.retail.v2.ImportCompletionDataRequest].
381// If the long running operation is done, this message is returned by the
382// google.longrunning.Operations.response field if the operation is successful.
383message ImportCompletionDataResponse {
384  // A sample of errors encountered while processing the request.
385  repeated google.rpc.Status error_samples = 1;
386}
387