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.v2beta; 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/v2beta/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.V2Beta"; 29option go_package = "cloud.google.com/go/retail/apiv2beta/retailpb;retailpb"; 30option java_multiple_files = true; 31option java_outer_classname = "ModelServiceProto"; 32option java_package = "com.google.cloud.retail.v2beta"; 33option objc_class_prefix = "RETAIL"; 34option php_namespace = "Google\\Cloud\\Retail\\V2beta"; 35option ruby_package = "Google::Cloud::Retail::V2beta"; 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: "/v2beta/{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.v2beta.Model" 63 metadata_type: "google.cloud.retail.v2beta.CreateModelMetadata" 64 }; 65 } 66 67 // Gets a model. 68 rpc GetModel(GetModelRequest) returns (Model) { 69 option (google.api.http) = { 70 get: "/v2beta/{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: "/v2beta/{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: "/v2beta/{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: "/v2beta/{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: "/v2beta/{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: "/v2beta/{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: "/v2beta/{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.v2beta.TuneModelResponse" 130 metadata_type: "google.cloud.retail.v2beta.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.v2beta.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 156 // [Model][google.cloud.retail.v2beta.Model]. 157 Model model = 1 [(google.api.field_behavior) = REQUIRED]; 158 159 // Optional. Indicates which fields in the provided 'model' to 160 // update. If not set, by default updates all fields. 161 google.protobuf.FieldMask update_mask = 2 162 [(google.api.field_behavior) = OPTIONAL]; 163} 164 165// Request for getting a model. 166message GetModelRequest { 167 // Required. The resource name of the 168 // [Model][google.cloud.retail.v2beta.Model] to get. Format: 169 // `projects/{project_number}/locations/{location_id}/catalogs/{catalog}/models/{model_id}` 170 string name = 1 [ 171 (google.api.field_behavior) = REQUIRED, 172 (google.api.resource_reference) = { type: "retail.googleapis.com/Model" } 173 ]; 174} 175 176// Request for pausing training of a model. 177message PauseModelRequest { 178 // Required. The name of the model to pause. 179 // Format: 180 // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` 181 string name = 1 [ 182 (google.api.field_behavior) = REQUIRED, 183 (google.api.resource_reference) = { type: "retail.googleapis.com/Model" } 184 ]; 185} 186 187// Request for resuming training of a model. 188message ResumeModelRequest { 189 // Required. The name of the model to resume. 190 // Format: 191 // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` 192 string name = 1 [(google.api.field_behavior) = REQUIRED]; 193} 194 195// Request for listing models associated with a resource. 196message ListModelsRequest { 197 // Required. The parent for which to list models. 198 // Format: 199 // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` 200 string parent = 1 [ 201 (google.api.field_behavior) = REQUIRED, 202 (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } 203 ]; 204 205 // Optional. Maximum number of results to return. If unspecified, defaults 206 // to 50. Max allowed value is 1000. 207 int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; 208 209 // Optional. A page token, received from a previous `ListModels` 210 // call. Provide this to retrieve the subsequent page. 211 string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; 212} 213 214// Request for deleting a model. 215message DeleteModelRequest { 216 // Required. The resource name of the 217 // [Model][google.cloud.retail.v2beta.Model] to delete. Format: 218 // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` 219 string name = 1 [ 220 (google.api.field_behavior) = REQUIRED, 221 (google.api.resource_reference) = { type: "retail.googleapis.com/Model" } 222 ]; 223} 224 225// Response to a ListModelRequest. 226message ListModelsResponse { 227 // List of Models. 228 repeated Model models = 1; 229 230 // Pagination token, if not returned indicates the last page. 231 string next_page_token = 2; 232} 233 234// Request to manually start a tuning process now (instead of waiting for 235// the periodically scheduled tuning to happen). 236message TuneModelRequest { 237 // Required. The resource name of the model to tune. 238 // Format: 239 // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` 240 string name = 1 [ 241 (google.api.field_behavior) = REQUIRED, 242 (google.api.resource_reference) = { type: "retail.googleapis.com/Model" } 243 ]; 244} 245 246// Metadata associated with a create operation. 247message CreateModelMetadata { 248 // The resource name of the model that this create applies to. 249 // Format: 250 // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` 251 string model = 1; 252} 253 254// Metadata associated with a tune operation. 255message TuneModelMetadata { 256 // The resource name of the model that this tune applies to. 257 // Format: 258 // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` 259 string model = 1; 260} 261 262// Response associated with a tune operation. 263message TuneModelResponse {} 264