Skip to main content

GoogleCloudStorageBuilder

Struct GoogleCloudStorageBuilder 

Source
pub struct GoogleCloudStorageBuilder { /* private fields */ }
Available on crate feature gcp-base only.
Expand description

Configure a connection to Google Cloud Storage.

If no credentials are explicitly provided, they will be sourced from the environment as documented here.

§Example

let gcs = GoogleCloudStorageBuilder::from_env().with_bucket_name(BUCKET_NAME).build();

Implementations§

Source§

impl GoogleCloudStorageBuilder

Source

pub fn new() -> Self

Create a new GoogleCloudStorageBuilder with default values.

Source

pub fn from_env() -> Self

Create an instance of GoogleCloudStorageBuilder with values pre-populated from environment variables.

Variables extracted from environment:

  • GOOGLE_SERVICE_ACCOUNT: location of service account file
  • GOOGLE_SERVICE_ACCOUNT_PATH: (alias) location of service account file
  • SERVICE_ACCOUNT: (alias) location of service account file
  • GOOGLE_SERVICE_ACCOUNT_KEY: JSON serialized service account key
  • GOOGLE_BUCKET: bucket name
  • GOOGLE_BUCKET_NAME: (alias) bucket name
§Example
use object_store::gcp::GoogleCloudStorageBuilder;

let gcs = GoogleCloudStorageBuilder::from_env()
    .with_bucket_name("foo")
    .build();
Source

pub fn with_url(self, url: impl Into<String>) -> Self

Parse available connection info form a well-known storage URL.

The supported url schemes are:

  • gs://<bucket>/<path>

Note: Settings derived from the URL will override any others set on this builder

§Example
use object_store::gcp::GoogleCloudStorageBuilder;

let gcs = GoogleCloudStorageBuilder::from_env()
    .with_url("gs://bucket/path")
    .build();
Source

pub fn with_config(self, key: GoogleConfigKey, value: impl Into<String>) -> Self

Set an option on the builder via a key - value pair.

Source

pub fn get_config_value(&self, key: &GoogleConfigKey) -> Option<String>

Get config value via a GoogleConfigKey.

§Example
use object_store::gcp::{GoogleCloudStorageBuilder, GoogleConfigKey};

let builder = GoogleCloudStorageBuilder::from_env()
    .with_service_account_key("foo");
let service_account_key = builder.get_config_value(&GoogleConfigKey::ServiceAccountKey).unwrap_or_default();
assert_eq!("foo", &service_account_key);
Source

pub fn with_bucket_name(self, bucket_name: impl Into<String>) -> Self

Set the bucket name (required)

Source

pub fn with_base_url(self, base_url: &str) -> Self

Sets the base URL for communicating with GCS.

If not explicitly set, it will be:

  1. Derived from the service account credentials, if provided
  2. Otherwise, uses the default GCS endpoint
§Example
use object_store::gcp::GoogleCloudStorageBuilder;

let gcs = GoogleCloudStorageBuilder::from_env()
    .with_base_url("https://localhost:4443")
    .build();
Source

pub fn with_service_account_path( self, service_account_path: impl Into<String>, ) -> Self

Set the path to the service account file.

This or GoogleCloudStorageBuilder::with_service_account_key must be set.

Example "/tmp/gcs.json".

Example contents of gcs.json:

{
   "gcs_base_url": "https://localhost:4443",
   "disable_oauth": true,
   "client_email": "",
   "private_key": ""
}
Source

pub fn with_service_account_key( self, service_account: impl Into<String>, ) -> Self

Set the service account key. The service account must be in the JSON format.

This or GoogleCloudStorageBuilder::with_service_account_path must be set.

Source

pub fn with_application_credentials( self, application_credentials_path: impl Into<String>, ) -> Self

Set the path to the application credentials file.

https://cloud.google.com/docs/authentication/provide-credentials-adc

Source

pub fn with_bearer_token(self, bearer_token: impl Into<String>) -> Self

Set an explicit OAuth bearer token.

This is treated as a static token and will not be refreshed automatically.

Source

pub fn with_skip_signature(self, skip_signature: bool) -> Self

If enabled, GoogleCloudStorage will not fetch credentials and will not sign requests.

This can be useful when interacting with public GCS buckets that deny authorized requests.

Source

pub fn with_credentials(self, credentials: GcpCredentialProvider) -> Self

Set the credential provider overriding any other options

Source

pub fn with_signing_credentials( self, credentials: GcpSigningCredentialProvider, ) -> Self

Set the signing credential provider overriding any other options

Source

pub fn with_crypto_provider(self, provider: Arc<dyn CryptoProvider>) -> Self

The CryptoProvider to use

Source

pub fn with_retry(self, retry_config: RetryConfig) -> Self

Set the retry configuration

Source

pub fn with_proxy_url(self, proxy_url: impl Into<String>) -> Self

Set the proxy_url to be used by the underlying client

Source

pub fn with_proxy_ca_certificate( self, proxy_ca_certificate: impl Into<String>, ) -> Self

Set a trusted proxy CA certificate

Source

pub fn with_proxy_excludes(self, proxy_excludes: impl Into<String>) -> Self

Set a list of hosts to exclude from proxy connections

Source

pub fn with_client_options(self, options: ClientOptions) -> Self

Sets the client options, overriding any already set

Source

pub fn with_http_connector<C: HttpConnector>(self, connector: C) -> Self

The HttpConnector to use

On non-WASM32 platforms uses reqwest by default, on WASM32 platforms must be provided

Source

pub fn build(self) -> Result<GoogleCloudStorage>

Configure a connection to Google Cloud Storage, returning a new GoogleCloudStorage and consuming self

Trait Implementations§

Source§

impl Clone for GoogleCloudStorageBuilder

Source§

fn clone(&self) -> GoogleCloudStorageBuilder

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for GoogleCloudStorageBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for GoogleCloudStorageBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more