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.v2alpha; 18 19import "google/api/field_behavior.proto"; 20import "google/api/resource.proto"; 21import "google/cloud/retail/v2alpha/product.proto"; 22import "google/cloud/retail/v2alpha/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.V2Alpha"; 29option go_package = "cloud.google.com/go/retail/apiv2alpha/retailpb;retailpb"; 30option java_multiple_files = true; 31option java_outer_classname = "ImportConfigProto"; 32option java_package = "com.google.cloud.retail.v2alpha"; 33option objc_class_prefix = "RETAIL"; 34option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; 35option ruby_package = "Google::Cloud::Retail::V2alpha"; 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 54 // [Product][google.cloud.retail.v2alpha.Product] per line. Each product must 55 // have a valid [Product.id][google.cloud.retail.v2alpha.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.v2alpha.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 69 // [Control][google.cloud.retail.v2alpha.Control] per line. 70 // 71 // Supported values for catalog attribute imports: 72 // 73 // * `catalog_attribute` (default): One CSV 74 // [CatalogAttribute][google.cloud.retail.v2alpha.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.v2alpha.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 113 // [Product][google.cloud.retail.v2alpha.Product] per line. Each product must 114 // have a valid [Product.id][google.cloud.retail.v2alpha.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.v2alpha.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.v2alpha.Product.id]. Recommended max 141 // of 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.v2alpha.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.v2alpha.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 // If true, this performs the FULL import even if it would delete a large 221 // proportion of the products in the default branch, which could potentially 222 // cause outages if you have live predict/search traffic. 223 // 224 // Only supported when 225 // [ImportProductsRequest.reconciliation_mode][google.cloud.retail.v2alpha.ImportProductsRequest.reconciliation_mode] 226 // is set to `FULL`. 227 bool skip_default_branch_protection = 8; 228} 229 230// Request message for the ImportUserEvents request. 231message ImportUserEventsRequest { 232 // Required. `projects/1234/locations/global/catalogs/default_catalog` 233 string parent = 1 [ 234 (google.api.field_behavior) = REQUIRED, 235 (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } 236 ]; 237 238 // Required. The desired input location of the data. 239 UserEventInputConfig input_config = 2 240 [(google.api.field_behavior) = REQUIRED]; 241 242 // The desired location of errors incurred during the Import. Cannot be set 243 // for inline user event imports. 244 ImportErrorsConfig errors_config = 3; 245} 246 247// Request message for ImportCompletionData methods. 248message ImportCompletionDataRequest { 249 // Required. The catalog which the suggestions dataset belongs to. 250 // 251 // Format: `projects/1234/locations/global/catalogs/default_catalog`. 252 string parent = 1 [ 253 (google.api.field_behavior) = REQUIRED, 254 (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } 255 ]; 256 257 // Required. The desired input location of the data. 258 CompletionDataInputConfig input_config = 2 259 [(google.api.field_behavior) = REQUIRED]; 260 261 // Pub/Sub topic for receiving notification. If this field is set, 262 // when the import is finished, a notification is sent to 263 // specified Pub/Sub topic. The message data is JSON string of a 264 // [Operation][google.longrunning.Operation]. 265 // Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. 266 string notification_pubsub_topic = 3; 267} 268 269// The input config source for products. 270message ProductInputConfig { 271 // Required. The source of the input. 272 oneof source { 273 // The Inline source for the input content for products. 274 ProductInlineSource product_inline_source = 1; 275 276 // Google Cloud Storage location for the input content. 277 GcsSource gcs_source = 2; 278 279 // BigQuery input source. 280 BigQuerySource big_query_source = 3; 281 } 282} 283 284// The input config source for user events. 285message UserEventInputConfig { 286 // The source of the input. 287 oneof source { 288 // Required. The Inline source for the input content for UserEvents. 289 UserEventInlineSource user_event_inline_source = 1 290 [(google.api.field_behavior) = REQUIRED]; 291 292 // Required. Google Cloud Storage location for the input content. 293 GcsSource gcs_source = 2 [(google.api.field_behavior) = REQUIRED]; 294 295 // Required. BigQuery input source. 296 BigQuerySource big_query_source = 3 297 [(google.api.field_behavior) = REQUIRED]; 298 } 299} 300 301// The input config source for completion data. 302message CompletionDataInputConfig { 303 // The source of the input. 304 // 305 // Supported 306 // [BigQuerySource.data_schema][google.cloud.retail.v2alpha.BigQuerySource.data_schema] 307 // values for suggestions imports: 308 // 309 // * `suggestions` (default): One JSON completion suggestion per line. 310 // * `denylist`: One JSON deny suggestion per line. 311 // * `allowlist`: One JSON allow suggestion per line. 312 oneof source { 313 // Required. BigQuery input source. 314 // 315 // Add the IAM permission "BigQuery Data Viewer" for 316 // cloud-retail-customer-data-access@system.gserviceaccount.com before 317 // using this feature otherwise an error is thrown. 318 BigQuerySource big_query_source = 1 319 [(google.api.field_behavior) = REQUIRED]; 320 } 321} 322 323// Metadata related to the progress of the Import operation. This is 324// returned by the google.longrunning.Operation.metadata field. 325message ImportMetadata { 326 // Operation create time. 327 google.protobuf.Timestamp create_time = 1; 328 329 // Operation last update time. If the operation is done, this is also the 330 // finish time. 331 google.protobuf.Timestamp update_time = 2; 332 333 // Count of entries that were processed successfully. 334 int64 success_count = 3; 335 336 // Count of entries that encountered errors while processing. 337 int64 failure_count = 4; 338 339 // Deprecated. This field is never set. 340 string request_id = 5 [deprecated = true]; 341 342 // Pub/Sub topic for receiving notification. If this field is set, 343 // when the import is finished, a notification is sent to 344 // specified Pub/Sub topic. The message data is JSON string of a 345 // [Operation][google.longrunning.Operation]. 346 // Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. 347 string notification_pubsub_topic = 6; 348 349 // Metadata related to transform user events. 350 TransformedUserEventsMetadata transformed_user_events_metadata = 7; 351} 352 353// Metadata related to transform user events operation. 354message TransformedUserEventsMetadata { 355 // Count of entries in the source user events BigQuery table. 356 int64 source_events_count = 1; 357 358 // Count of entries in the transformed user events BigQuery table, which could 359 // be different from the actually imported number of user events. 360 int64 transformed_events_count = 2; 361} 362 363// Response of the 364// [ImportProductsRequest][google.cloud.retail.v2alpha.ImportProductsRequest]. 365// If the long running operation is done, then this message is returned by the 366// google.longrunning.Operations.response field if the operation was successful. 367message ImportProductsResponse { 368 // A sample of errors encountered while processing the request. 369 repeated google.rpc.Status error_samples = 1; 370 371 // Echoes the destination for the complete errors in the request if set. 372 ImportErrorsConfig errors_config = 2; 373} 374 375// Response of the ImportUserEventsRequest. If the long running 376// operation was successful, then this message is returned by the 377// google.longrunning.Operations.response field if the operation was successful. 378message ImportUserEventsResponse { 379 // A sample of errors encountered while processing the request. 380 repeated google.rpc.Status error_samples = 1; 381 382 // Echoes the destination for the complete errors if this field was set in 383 // the request. 384 ImportErrorsConfig errors_config = 2; 385 386 // Aggregated statistics of user event import status. 387 UserEventImportSummary import_summary = 3; 388} 389 390// A summary of import result. The UserEventImportSummary summarizes 391// the import status for user events. 392message UserEventImportSummary { 393 // Count of user events imported with complete existing catalog information. 394 int64 joined_events_count = 1; 395 396 // Count of user events imported, but with catalog information not found 397 // in the imported catalog. 398 int64 unjoined_events_count = 2; 399} 400 401// Response of the 402// [ImportCompletionDataRequest][google.cloud.retail.v2alpha.ImportCompletionDataRequest]. 403// If the long running operation is done, this message is returned by the 404// google.longrunning.Operations.response field if the operation is successful. 405message ImportCompletionDataResponse { 406 // A sample of errors encountered while processing the request. 407 repeated google.rpc.Status error_samples = 1; 408} 409