Reference documentation and code samples for the Retail V2 API class Google::Cloud::Retail::V2::ModelService::Client.
Client for the ModelService service.
Service for performing CRUD operations on models.
Recommendation models contain all the metadata necessary to generate a set of
models for the Predict()
API. A model is queried
indirectly via a ServingConfig, which associates a model with a
given Placement (e.g. Frequently Bought Together on Home Page).
This service allows you to do the following:
- Initiate training of a model.
- Pause training of an existing model.
- List all the available models along with their metadata.
- Control their tuning schedule.
Inherits
- Object
Methods
.configure
def self.configure() { |config| ... } -> Client::Configuration
Configure the ModelService Client class.
See Configuration for a description of the configuration fields.
- (config) — Configure the Client client.
- config (Client::Configuration)
# Modify the configuration for all ModelService clients ::Google::Cloud::Retail::V2::ModelService::Client.configure do |config| config.timeout = 10.0 end
#configure
def configure() { |config| ... } -> Client::Configuration
Configure the ModelService Client instance.
The configuration is set to the derived mode, meaning that values can be changed, but structural changes (adding new fields, etc.) are not allowed. Structural changes should be made on Client.configure.
See Configuration for a description of the configuration fields.
- (config) — Configure the Client client.
- config (Client::Configuration)
#create_model
def create_model(request, options = nil) -> ::Gapic::Operation
def create_model(parent: nil, model: nil, dry_run: nil) -> ::Gapic::Operation
Creates a new model.
def create_model(request, options = nil) -> ::Gapic::Operation
create_model
via a request object, either of type
CreateModelRequest or an equivalent Hash.
- request (::Google::Cloud::Retail::V2::CreateModelRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def create_model(parent: nil, model: nil, dry_run: nil) -> ::Gapic::Operation
create_model
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
-
parent (::String) — Required. The parent resource under which to create the model. Format:
projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}
- model (::Google::Cloud::Retail::V2::Model, ::Hash) — Required. The payload of the Model to create.
- dry_run (::Boolean) — Optional. Whether to run a dry run to validate the request (without actually creating the model).
- (response, operation) — Access the result along with the RPC operation
- response (::Gapic::Operation)
- operation (::GRPC::ActiveCall::Operation)
- (::Gapic::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/retail/v2" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Retail::V2::ModelService::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::Retail::V2::CreateModelRequest.new # Call the create_model method. result = client.create_model request # The returned object is of type Gapic::Operation. You can use it to # check the status of an operation, cancel it, or wait for results. # Here is how to wait for a response. result.wait_until_done! timeout: 60 if result.response? p result.response else puts "No response received." end
#delete_model
def delete_model(request, options = nil) -> ::Google::Protobuf::Empty
def delete_model(name: nil) -> ::Google::Protobuf::Empty
Deletes an existing model.
def delete_model(request, options = nil) -> ::Google::Protobuf::Empty
delete_model
via a request object, either of type
DeleteModelRequest or an equivalent Hash.
- request (::Google::Cloud::Retail::V2::DeleteModelRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def delete_model(name: nil) -> ::Google::Protobuf::Empty
delete_model
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
-
name (::String) — Required. The resource name of the Model to
delete. Format:
projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Protobuf::Empty)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/retail/v2" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Retail::V2::ModelService::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::Retail::V2::DeleteModelRequest.new # Call the delete_model method. result = client.delete_model request # The returned object is of type Google::Protobuf::Empty. p result
#get_model
def get_model(request, options = nil) -> ::Google::Cloud::Retail::V2::Model
def get_model(name: nil) -> ::Google::Cloud::Retail::V2::Model
Gets a model.
def get_model(request, options = nil) -> ::Google::Cloud::Retail::V2::Model
get_model
via a request object, either of type
GetModelRequest or an equivalent Hash.
- request (::Google::Cloud::Retail::V2::GetModelRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def get_model(name: nil) -> ::Google::Cloud::Retail::V2::Model
get_model
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
-
name (::String) — Required. The resource name of the Model to
get. Format:
projects/{project_number}/locations/{location_id}/catalogs/{catalog}/models/{model_id}
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Cloud::Retail::V2::Model)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/retail/v2" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Retail::V2::ModelService::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::Retail::V2::GetModelRequest.new # Call the get_model method. result = client.get_model request # The returned object is of type Google::Cloud::Retail::V2::Model. p result
#initialize
def initialize() { |config| ... } -> Client
Create a new ModelService client object.
- (config) — Configure the ModelService client.
- config (Client::Configuration)
- (Client) — a new instance of Client
# Create a client using the default configuration client = ::Google::Cloud::Retail::V2::ModelService::Client.new # Create a client using a custom configuration client = ::Google::Cloud::Retail::V2::ModelService::Client.new do |config| config.timeout = 10.0 end
#list_models
def list_models(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Retail::V2::Model>
def list_models(parent: nil, page_size: nil, page_token: nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Retail::V2::Model>
Lists all the models linked to this event store.
def list_models(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Retail::V2::Model>
list_models
via a request object, either of type
ListModelsRequest or an equivalent Hash.
- request (::Google::Cloud::Retail::V2::ListModelsRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def list_models(parent: nil, page_size: nil, page_token: nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Retail::V2::Model>
list_models
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
-
parent (::String) — Required. The parent for which to list models.
Format:
projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}
- page_size (::Integer) — Optional. Maximum number of results to return. If unspecified, defaults to 50. Max allowed value is 1000.
-
page_token (::String) — Optional. A page token, received from a previous
ListModels
call. Provide this to retrieve the subsequent page.
- (response, operation) — Access the result along with the RPC operation
- response (::Gapic::PagedEnumerable<::Google::Cloud::Retail::V2::Model>)
- operation (::GRPC::ActiveCall::Operation)
- (::Gapic::PagedEnumerable<::Google::Cloud::Retail::V2::Model>)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/retail/v2" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Retail::V2::ModelService::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::Retail::V2::ListModelsRequest.new # Call the list_models method. result = client.list_models request # The returned object is of type Gapic::PagedEnumerable. You can iterate # over elements, and API calls will be issued to fetch pages as needed. result.each do |item| # Each element is of type ::Google::Cloud::Retail::V2::Model. p item end
#location_client
def location_client() -> Google::Cloud::Location::Locations::Client
Get the associated client for mix-in of the Locations.
- (Google::Cloud::Location::Locations::Client)
#operations_client
def operations_client() -> ::Google::Cloud::Retail::V2::ModelService::Operations
Get the associated client for long-running operations.
#pause_model
def pause_model(request, options = nil) -> ::Google::Cloud::Retail::V2::Model
def pause_model(name: nil) -> ::Google::Cloud::Retail::V2::Model
Pauses the training of an existing model.
def pause_model(request, options = nil) -> ::Google::Cloud::Retail::V2::Model
pause_model
via a request object, either of type
PauseModelRequest or an equivalent Hash.
- request (::Google::Cloud::Retail::V2::PauseModelRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def pause_model(name: nil) -> ::Google::Cloud::Retail::V2::Model
pause_model
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
-
name (::String) — Required. The name of the model to pause.
Format:
projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Cloud::Retail::V2::Model)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/retail/v2" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Retail::V2::ModelService::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::Retail::V2::PauseModelRequest.new # Call the pause_model method. result = client.pause_model request # The returned object is of type Google::Cloud::Retail::V2::Model. p result
#resume_model
def resume_model(request, options = nil) -> ::Google::Cloud::Retail::V2::Model
def resume_model(name: nil) -> ::Google::Cloud::Retail::V2::Model
Resumes the training of an existing model.
def resume_model(request, options = nil) -> ::Google::Cloud::Retail::V2::Model
resume_model
via a request object, either of type
ResumeModelRequest or an equivalent Hash.
- request (::Google::Cloud::Retail::V2::ResumeModelRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def resume_model(name: nil) -> ::Google::Cloud::Retail::V2::Model
resume_model
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
-
name (::String) — Required. The name of the model to resume.
Format:
projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Cloud::Retail::V2::Model)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/retail/v2" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Retail::V2::ModelService::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::Retail::V2::ResumeModelRequest.new # Call the resume_model method. result = client.resume_model request # The returned object is of type Google::Cloud::Retail::V2::Model. p result
#tune_model
def tune_model(request, options = nil) -> ::Gapic::Operation
def tune_model(name: nil) -> ::Gapic::Operation
Tunes an existing model.
def tune_model(request, options = nil) -> ::Gapic::Operation
tune_model
via a request object, either of type
TuneModelRequest or an equivalent Hash.
- request (::Google::Cloud::Retail::V2::TuneModelRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def tune_model(name: nil) -> ::Gapic::Operation
tune_model
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
-
name (::String) — Required. The resource name of the model to tune.
Format:
projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}
- (response, operation) — Access the result along with the RPC operation
- response (::Gapic::Operation)
- operation (::GRPC::ActiveCall::Operation)
- (::Gapic::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/retail/v2" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Retail::V2::ModelService::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::Retail::V2::TuneModelRequest.new # Call the tune_model method. result = client.tune_model request # The returned object is of type Gapic::Operation. You can use it to # check the status of an operation, cancel it, or wait for results. # Here is how to wait for a response. result.wait_until_done! timeout: 60 if result.response? p result.response else puts "No response received." end
#update_model
def update_model(request, options = nil) -> ::Google::Cloud::Retail::V2::Model
def update_model(model: nil, update_mask: nil) -> ::Google::Cloud::Retail::V2::Model
Update of model metadata. Only fields that
currently can be updated are: filtering_option
and
periodic_tuning_state
.
If other values are provided, this API method ignores them.
def update_model(request, options = nil) -> ::Google::Cloud::Retail::V2::Model
update_model
via a request object, either of type
UpdateModelRequest or an equivalent Hash.
- request (::Google::Cloud::Retail::V2::UpdateModelRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def update_model(model: nil, update_mask: nil) -> ::Google::Cloud::Retail::V2::Model
update_model
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
- model (::Google::Cloud::Retail::V2::Model, ::Hash) — Required. The body of the updated Model.
- update_mask (::Google::Protobuf::FieldMask, ::Hash) — Optional. Indicates which fields in the provided 'model' to update. If not set, by default updates all fields.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Cloud::Retail::V2::Model)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/retail/v2" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Retail::V2::ModelService::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::Retail::V2::UpdateModelRequest.new # Call the update_model method. result = client.update_model request # The returned object is of type Google::Cloud::Retail::V2::Model. p result