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/annotations.proto"; 20import "google/api/client.proto"; 21import "google/api/field_behavior.proto"; 22import "google/api/resource.proto"; 23import "google/cloud/retail/v2/model.proto"; 24import "google/longrunning/operations.proto"; 25import "google/protobuf/empty.proto"; 26import "google/protobuf/field_mask.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 = "ModelServiceProto"; 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// Service for performing CRUD operations on models. 38// Recommendation models contain all the metadata necessary to generate a set of 39// models for the `Predict()` API. A model is queried 40// indirectly via a ServingConfig, which associates a model with a 41// given Placement (e.g. Frequently Bought Together on Home Page). 42// 43// This service allows you to do the following: 44// 45// * Initiate training of a model. 46// * Pause training of an existing model. 47// * List all the available models along with their metadata. 48// * Control their tuning schedule. 49service ModelService { 50 option (google.api.default_host) = "retail.googleapis.com"; 51 option (google.api.oauth_scopes) = 52 "https://www.googleapis.com/auth/cloud-platform"; 53 54 // Creates a new model. 55 rpc CreateModel(CreateModelRequest) returns (google.longrunning.Operation) { 56 option (google.api.http) = { 57 post: "/v2/{parent=projects/*/locations/*/catalogs/*}/models" 58 body: "model" 59 }; 60 option (google.api.method_signature) = "parent,model"; 61 option (google.longrunning.operation_info) = { 62 response_type: "google.cloud.retail.v2.Model" 63 metadata_type: "google.cloud.retail.v2.CreateModelMetadata" 64 }; 65 } 66 67 // Gets a model. 68 rpc GetModel(GetModelRequest) returns (Model) { 69 option (google.api.http) = { 70 get: "/v2/{name=projects/*/locations/*/catalogs/*/models/*}" 71 }; 72 option (google.api.method_signature) = "name"; 73 } 74 75 // Pauses the training of an existing model. 76 rpc PauseModel(PauseModelRequest) returns (Model) { 77 option (google.api.http) = { 78 post: "/v2/{name=projects/*/locations/*/catalogs/*/models/*}:pause" 79 body: "*" 80 }; 81 option (google.api.method_signature) = "name"; 82 } 83 84 // Resumes the training of an existing model. 85 rpc ResumeModel(ResumeModelRequest) returns (Model) { 86 option (google.api.http) = { 87 post: "/v2/{name=projects/*/locations/*/catalogs/*/models/*}:resume" 88 body: "*" 89 }; 90 option (google.api.method_signature) = "name"; 91 } 92 93 // Deletes an existing model. 94 rpc DeleteModel(DeleteModelRequest) returns (google.protobuf.Empty) { 95 option (google.api.http) = { 96 delete: "/v2/{name=projects/*/locations/*/catalogs/*/models/*}" 97 }; 98 option (google.api.method_signature) = "name"; 99 } 100 101 // Lists all the models linked to this event store. 102 rpc ListModels(ListModelsRequest) returns (ListModelsResponse) { 103 option (google.api.http) = { 104 get: "/v2/{parent=projects/*/locations/*/catalogs/*}/models" 105 }; 106 option (google.api.method_signature) = "parent"; 107 } 108 109 // Update of model metadata. Only fields that 110 // currently can be updated are: `filtering_option` and 111 // `periodic_tuning_state`. 112 // If other values are provided, this API method ignores them. 113 rpc UpdateModel(UpdateModelRequest) returns (Model) { 114 option (google.api.http) = { 115 patch: "/v2/{model.name=projects/*/locations/*/catalogs/*/models/*}" 116 body: "model" 117 }; 118 option (google.api.method_signature) = "model,update_mask"; 119 } 120 121 // Tunes an existing model. 122 rpc TuneModel(TuneModelRequest) returns (google.longrunning.Operation) { 123 option (google.api.http) = { 124 post: "/v2/{name=projects/*/locations/*/catalogs/*/models/*}:tune" 125 body: "*" 126 }; 127 option (google.api.method_signature) = "name"; 128 option (google.longrunning.operation_info) = { 129 response_type: "google.cloud.retail.v2.TuneModelResponse" 130 metadata_type: "google.cloud.retail.v2.TuneModelMetadata" 131 }; 132 } 133} 134 135// Request for creating a model. 136message CreateModelRequest { 137 // Required. The parent resource under which to create the model. Format: 138 // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` 139 string parent = 1 [ 140 (google.api.field_behavior) = REQUIRED, 141 (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } 142 ]; 143 144 // Required. The payload of the [Model][google.cloud.retail.v2.Model] to 145 // create. 146 Model model = 2 [(google.api.field_behavior) = REQUIRED]; 147 148 // Optional. Whether to run a dry run to validate the request (without 149 // actually creating the model). 150 bool dry_run = 3 [(google.api.field_behavior) = OPTIONAL]; 151} 152 153// Request for updating an existing model. 154message UpdateModelRequest { 155 // Required. The body of the updated [Model][google.cloud.retail.v2.Model]. 156 Model model = 1 [(google.api.field_behavior) = REQUIRED]; 157 158 // Optional. Indicates which fields in the provided 'model' to 159 // update. If not set, by default updates all fields. 160 google.protobuf.FieldMask update_mask = 2 161 [(google.api.field_behavior) = OPTIONAL]; 162} 163 164// Request for getting a model. 165message GetModelRequest { 166 // Required. The resource name of the [Model][google.cloud.retail.v2.Model] to 167 // get. Format: 168 // `projects/{project_number}/locations/{location_id}/catalogs/{catalog}/models/{model_id}` 169 string name = 1 [ 170 (google.api.field_behavior) = REQUIRED, 171 (google.api.resource_reference) = { type: "retail.googleapis.com/Model" } 172 ]; 173} 174 175// Request for pausing training of a model. 176message PauseModelRequest { 177 // Required. The name of the model to pause. 178 // Format: 179 // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` 180 string name = 1 [ 181 (google.api.field_behavior) = REQUIRED, 182 (google.api.resource_reference) = { type: "retail.googleapis.com/Model" } 183 ]; 184} 185 186// Request for resuming training of a model. 187message ResumeModelRequest { 188 // Required. The name of the model to resume. 189 // Format: 190 // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` 191 string name = 1 [(google.api.field_behavior) = REQUIRED]; 192} 193 194// Request for listing models associated with a resource. 195message ListModelsRequest { 196 // Required. The parent for which to list models. 197 // Format: 198 // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` 199 string parent = 1 [ 200 (google.api.field_behavior) = REQUIRED, 201 (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } 202 ]; 203 204 // Optional. Maximum number of results to return. If unspecified, defaults 205 // to 50. Max allowed value is 1000. 206 int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; 207 208 // Optional. A page token, received from a previous `ListModels` 209 // call. Provide this to retrieve the subsequent page. 210 string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; 211} 212 213// Request for deleting a model. 214message DeleteModelRequest { 215 // Required. The resource name of the [Model][google.cloud.retail.v2.Model] to 216 // delete. Format: 217 // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` 218 string name = 1 [ 219 (google.api.field_behavior) = REQUIRED, 220 (google.api.resource_reference) = { type: "retail.googleapis.com/Model" } 221 ]; 222} 223 224// Response to a ListModelRequest. 225message ListModelsResponse { 226 // List of Models. 227 repeated Model models = 1; 228 229 // Pagination token, if not returned indicates the last page. 230 string next_page_token = 2; 231} 232 233// Request to manually start a tuning process now (instead of waiting for 234// the periodically scheduled tuning to happen). 235message TuneModelRequest { 236 // Required. The resource name of the model to tune. 237 // Format: 238 // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` 239 string name = 1 [ 240 (google.api.field_behavior) = REQUIRED, 241 (google.api.resource_reference) = { type: "retail.googleapis.com/Model" } 242 ]; 243} 244 245// Metadata associated with a create operation. 246message CreateModelMetadata { 247 // The resource name of the model that this create applies to. 248 // Format: 249 // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` 250 string model = 1; 251} 252 253// Metadata associated with a tune operation. 254message TuneModelMetadata { 255 // The resource name of the model that this tune applies to. 256 // Format: 257 // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` 258 string model = 1; 259} 260 261// Response associated with a tune operation. 262message TuneModelResponse {} 263