The Rust client libraries automatically configure the endpoint for each service. Some applications may need to override the default endpoint either because their network has specific requirements, or because they need to use regional versions of the service. This guide shows you how to override the default.
Prerequisites
This guide uses the Secret Manager API. To enable this API, follow the service quickstart.
For complete setup instructions for the Rust client libraries, see Getting started with Rust.
Dependencies
You must declare the dependencies in your Cargo.toml file:
cargo add google-cloud-secretmanager-v1 google-cloud-gax
The default endpoint
First, review how to use the client libraries with the default endpoint. Start by writing some use declarations to simplify the rest of the example:
Write the example in a function that receives the project ID as a parameter:
Add some use declarations simplify the example code:
Initialize the client using the defaults:
And use this client as usual:
Override the default endpoint
In this example we configure the client library to use secret manager's regional endpoints. The same override can be used to configure the endpoint with one of the private access options, or for locational endpoints in the services that support them.
As before, write an example that receives the project ID and region as parameters:
Add some use declarations to simplify the code:
Initialize the client using the target endpoint:
And use this client as usual: