pub struct ModelService { /* private fields */ }Expand description
Implements a client for the Vertex AI Search for commerce API.
§Example
use google_cloud_gax::paginator::ItemPaginator as _;
let client = ModelService::builder().build().await?;
let parent = "parent_value";
let mut list = client.list_models()
.set_parent(parent)
.by_item();
while let Some(item) = list.next().await.transpose()? {
println!("{:?}", item);
}§Service Description
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.
§Configuration
To configure ModelService use the with_* methods in the type returned
by builder(). The default configuration should
work for most applications. Common configuration changes include
- with_endpoint(): by default this client uses the global default endpoint
(
https://retail.googleapis.com). Applications using regional endpoints or running in restricted networks (e.g. a network configured override this default. - with_credentials(): by default this client uses Application Default Credentials. Applications using custom authentication may need to override this default.
§Pooling and Cloning
ModelService holds a connection pool internally, it is advised to
create one and reuse it. You do not need to wrap ModelService in
an Rc or Arc to reuse it, because it
already uses an Arc internally.
Implementations§
Source§impl ModelService
impl ModelService
Sourcepub fn builder() -> ClientBuilder
pub fn builder() -> ClientBuilder
Returns a builder for ModelService.
let client = ModelService::builder().build().await?;Sourcepub fn from_stub<T>(stub: T) -> Selfwhere
T: ModelService + 'static,
pub fn from_stub<T>(stub: T) -> Selfwhere
T: ModelService + 'static,
Creates a new client from the provided stub.
The most common case for calling this function is in tests mocking the client’s behavior.
Sourcepub fn create_model(&self) -> CreateModel
pub fn create_model(&self) -> CreateModel
Creates a new model.
§Long running operations
This method is used to start, and/or poll a long-running Operation. The Working with long-running operations chapter in the user guide covers these operations in detail.
§Example
use google_cloud_lro::Poller;
use google_cloud_retail_v2::model::Model;
use google_cloud_retail_v2::Result;
async fn sample(
client: &ModelService, parent: &str
) -> Result<()> {
let response = client.create_model()
.set_parent(parent)
.set_model(
Model::new()/* set fields */
)
.poller().until_done().await?;
println!("response {:?}", response);
Ok(())
}Sourcepub fn get_model(&self) -> GetModel
pub fn get_model(&self) -> GetModel
Gets a model.
§Example
use google_cloud_retail_v2::Result;
async fn sample(
client: &ModelService, name: &str
) -> Result<()> {
let response = client.get_model()
.set_name(name)
.send().await?;
println!("response {:?}", response);
Ok(())
}Sourcepub fn pause_model(&self) -> PauseModel
pub fn pause_model(&self) -> PauseModel
Pauses the training of an existing model.
§Example
use google_cloud_retail_v2::Result;
async fn sample(
client: &ModelService
) -> Result<()> {
let response = client.pause_model()
/* set fields */
.send().await?;
println!("response {:?}", response);
Ok(())
}Sourcepub fn resume_model(&self) -> ResumeModel
pub fn resume_model(&self) -> ResumeModel
Resumes the training of an existing model.
§Example
use google_cloud_retail_v2::Result;
async fn sample(
client: &ModelService
) -> Result<()> {
let response = client.resume_model()
/* set fields */
.send().await?;
println!("response {:?}", response);
Ok(())
}Sourcepub fn delete_model(&self) -> DeleteModel
pub fn delete_model(&self) -> DeleteModel
Deletes an existing model.
§Example
use google_cloud_retail_v2::Result;
async fn sample(
client: &ModelService, name: &str
) -> Result<()> {
client.delete_model()
.set_name(name)
.send().await?;
Ok(())
}Sourcepub fn list_models(&self) -> ListModels
pub fn list_models(&self) -> ListModels
Lists all the models linked to this event store.
§Example
use google_cloud_gax::paginator::ItemPaginator as _;
use google_cloud_retail_v2::Result;
async fn sample(
client: &ModelService, parent: &str
) -> Result<()> {
let mut list = client.list_models()
.set_parent(parent)
.by_item();
while let Some(item) = list.next().await.transpose()? {
println!("{:?}", item);
}
Ok(())
}Sourcepub fn update_model(&self) -> UpdateModel
pub fn update_model(&self) -> UpdateModel
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.
§Example
use google_cloud_wkt::FieldMask;
use google_cloud_retail_v2::model::Model;
use google_cloud_retail_v2::Result;
async fn sample(
client: &ModelService, name: &str
) -> Result<()> {
let response = client.update_model()
.set_model(
Model::new().set_name(name)/* set fields */
)
.set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
.send().await?;
println!("response {:?}", response);
Ok(())
}Sourcepub fn tune_model(&self) -> TuneModel
pub fn tune_model(&self) -> TuneModel
Tunes an existing model.
§Long running operations
This method is used to start, and/or poll a long-running Operation. The Working with long-running operations chapter in the user guide covers these operations in detail.
§Example
use google_cloud_lro::Poller;
use google_cloud_retail_v2::Result;
async fn sample(
client: &ModelService
) -> Result<()> {
let response = client.tune_model()
/* set fields */
.poller().until_done().await?;
println!("response {:?}", response);
Ok(())
}Sourcepub fn list_operations(&self) -> ListOperations
pub fn list_operations(&self) -> ListOperations
Provides the Operations service functionality in this service.
§Example
use google_cloud_gax::paginator::ItemPaginator as _;
use google_cloud_retail_v2::Result;
async fn sample(
client: &ModelService
) -> Result<()> {
let mut list = client.list_operations()
/* set fields */
.by_item();
while let Some(item) = list.next().await.transpose()? {
println!("{:?}", item);
}
Ok(())
}Sourcepub fn get_operation(&self) -> GetOperation
pub fn get_operation(&self) -> GetOperation
Provides the Operations service functionality in this service.
§Example
use google_cloud_retail_v2::Result;
async fn sample(
client: &ModelService
) -> Result<()> {
let response = client.get_operation()
/* set fields */
.send().await?;
println!("response {:?}", response);
Ok(())
}Trait Implementations§
Source§impl Clone for ModelService
impl Clone for ModelService
Source§fn clone(&self) -> ModelService
fn clone(&self) -> ModelService
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more