Skip to main content

Crate origincloud_core

Crate origincloud_core 

Source
Expand description

What every service crate of the Origin Cloud SDK shares: credentials, endpoints, retries, errors, long-running operations and read-your-writes.

A program creates one Client and hands it to the clients of the services it uses:

let client = origincloud_core::Client::new()?;
// let volumes = origincloud_pvs::v1beta1::VolumeClient::new(&client);

§Credentials

Unless ClientBuilder::credentials names them, Client::new takes the first of:

  1. ORIGINCLOUD_ACCESS_TOKEN: an access token, sent as it is.
  2. ORIGINCLOUD_CLIENT_ID and ORIGINCLOUD_CLIENT_SECRET: a service account’s credential, exchanged for access tokens as they expire.
  3. The session the origin CLI stored at its last login (origin id login).

§Endpoints

Every service answers at {service}.origincloudapis.eu, which serves every resource wherever it lives. ClientBuilder::region, or ORIGINCLOUD_REGION, picks a region’s front door instead, {service}.{region}.origincloudapis.eu, for the services that have regional ones.

§Retries

A call the API answers as retryable is sent again, after the delay the answer asks for or a growing one, as long as sending it again is safe: a read, or a mutation with a request id. The client fills in a mutation’s request id when it is empty, so that a retry can’t apply it twice.

§Read-your-writes

The API answers reads from replicas that can be a moment behind a write that just succeeded. The client keeps the consistency token each mutation and each finished operation answers with, and sends it with every later call, so that a read through the same client shows the client’s own writes. The token answered last replaces the one held: for writes made one after another, it covers them all; of writes made concurrently, it covers the one answered last (see Client::set_consistency_token).

§Errors

A call the API refuses returns an Error::Api: branch on Error::reason, the platform’s error code.

§Runtime

The clients are async and send their calls with reqwest, on Tokio.

Re-exports§

pub use credentials::AccessToken;
pub use credentials::CliSession;
pub use credentials::Credentials;
pub use credentials::ServiceAccount;
pub use credentials::default_credentials;

Modules§

credentials
Credentials: where the access token each call is sent with comes from.
longrunning
Long-running operations: what a service’s creates, updates and deletes answer with, until their resource settles.
protobuf
The well-known types (google.protobuf), with their proto3 JSON mapping: FieldMask, Timestamp, Duration, Empty and the others.
rpc
google.rpc.Status and google.protobuf.Any in their JSON form: what a failed operation carries, and the details of an error.

Structs§

ApiError
A call the API refused, or an operation that failed.
Client
What the clients of every service share: credentials, endpoints, an HTTP client and the consistency token. Cloning it is cheap, and the clones share all of it.
ClientBuilder
Configures a Client.
FieldViolation
One request field the API refused.
Method
The HTTP method of a Request. The Request Method (VERB)
Operation
A mutation the API accepted and carries out after answering. Its result, a T, is the resource it acted on, or Empty for a delete.
Pages
Everything a list method lists, page by page: a Stream that fetches the next page as it is reached. A page that fails ends it with its error.
Request
One call of a service’s method, as its HTTP binding sends it. The generated clients build it.
Service
The endpoint of one service, which its generated clients send calls to.

Enums§

Error
What a call, or waiting on an operation, failed with.

Constants§

CONSISTENCY_TOKEN_HEADER
The header carrying the consistency token, in responses and in requests.
VERSION
This SDK’s version, sent in the User-Agent header.

Functions§

json_body
message as a JSON body. The generated clients call it.
new_request_id
A new random request id, a UUID, for a mutation whose caller left its request id empty. The generated clients call it.
path_value
value as the path segments of a request, checking it has the form pattern, such as projects/*/zones/*/volumes/*, gives it. field names it in the error. The generated clients call it.
query
The fields of message as query parameters, by their JSON paths, leaving out the fields skip names and fields at their default value. A nested field is sent by its dotted path, a repeated one as one parameter per element. The generated clients send the fields their method’s path and body don’t carry this way.

Type Aliases§

Query
Query parameters, by their JSON paths.