Skip to main content

Profile

Struct Profile 

Source
pub struct Profile {
Show 14 fields pub access_key: Option<String>, pub secret_key: Option<String>, pub x509_client_cert: Option<String>, pub x509_client_key: Option<String>, pub x509_client_cert_b64: Option<String>, pub x509_client_key_b64: Option<String>, pub tls_skip_verify: bool, pub login: Option<String>, pub password: Option<String>, pub protocol: String, pub region: String, pub endpoints: Endpoint, pub backoff_params: BackoffParams, pub limiter_params: LimiterParams,
}

Fields§

§access_key: Option<String>§secret_key: Option<String>§x509_client_cert: Option<String>§x509_client_key: Option<String>§x509_client_cert_b64: Option<String>§x509_client_key_b64: Option<String>§tls_skip_verify: bool§login: Option<String>§password: Option<String>§protocol: String§region: String§endpoints: Endpoint§backoff_params: BackoffParams§limiter_params: LimiterParams

Implementations§

Source§

impl Profile

Source

pub fn builder() -> ProfileBuilder

Source

pub fn default() -> Result<Profile>

Examples found in repository?
examples/keypair.rs (line 9)
8fn main() {
9    let config = Profile::default().and_then(|p| p.try_into()).unwrap();
10
11    // Example reading all keypairs
12    print!("Reading all keypairs... ");
13    let request = ReadKeypairsRequest::new();
14    let response = match read_keypairs(&config, Some(request)) {
15        Err(error) => {
16            println!("Error: {:?}", error);
17            return;
18        }
19        Ok(resp) => resp,
20    };
21    if let Some(keypairs) = response.keypairs {
22        println!("OK -> there are {} keypairs", keypairs.len());
23    }
24
25    // Example creating a keypair
26    print!("Creating new keypair... ");
27    let mut rng = rand::rng();
28    let keypair_name = format!("osc-sdk-rust-test-{}", rng.random::<u64>());
29    let request = CreateKeypairRequest::new(keypair_name.clone());
30    match create_keypair(&config, Some(request)) {
31        Err(error) => {
32            println!("Error: {:?}", error);
33            return;
34        }
35        Ok(resp) => resp,
36    };
37    println!("OK -> created keypair {}", keypair_name);
38
39    // Filtering on newly created keypair
40    print!("Filtering on {}... ", keypair_name);
41    let mut filters = FiltersKeypair::new();
42    filters.keypair_names = Some(vec![keypair_name.clone()]);
43    let mut request = ReadKeypairsRequest::new();
44    request.filters = Some(Box::new(filters));
45    if let Err(error) = read_keypairs(&config, Some(request)) {
46        eprintln!("Error: {:?}", error);
47        std::process::exit(1);
48    }
49    println!("OK");
50
51    // Deleting a keypair
52    print!("Deleting keypair {}... ", keypair_name);
53    let mut request = DeleteKeypairRequest::new();
54    request.keypair_name = Some(keypair_name.clone());
55    if let Err(error) = delete_keypair(&config, Some(request)) {
56        eprintln!("Error: {:?}", error);
57        std::process::exit(1);
58    }
59    println!("OK");
60}
More examples
Hide additional examples
examples/volume.rs (line 8)
7fn main() {
8    let config = Profile::default().and_then(|p| p.try_into()).unwrap();
9
10    // Example reading all volumes
11    print!("Reading all volumes... ");
12    let request = ReadVolumesRequest::new();
13    let response = match read_volumes(&config, Some(request)) {
14        Err(error) => {
15            eprintln!("Error: {:?}", error);
16            std::process::exit(1);
17        }
18        Ok(resp) => resp,
19    };
20    if let Some(volumes) = response.volumes {
21        println!("OK -> there are {} volumes", volumes.len());
22    }
23
24    // Example creating a volume
25    print!("Creating new volume... ");
26    let mut request = CreateVolumeRequest::new("eu-west-2a".to_string());
27    request.volume_type = Some("gp2".to_string());
28    request.size = Some(10);
29    let response = match create_volume(&config, Some(request)) {
30        Err(error) => {
31            eprintln!("Error: {:?}", error);
32            std::process::exit(1);
33        }
34        Ok(resp) => resp,
35    };
36    let volume_id = response.volume.unwrap().volume_id.unwrap();
37    println!("OK -> created volume id {}", volume_id);
38
39    // Filtering on newly created volume
40    print!("Filtering on {}... ", volume_id);
41    let mut filters = FiltersVolume::new();
42    filters.volume_ids = Some(vec![volume_id.clone()]);
43    let mut request = ReadVolumesRequest::new();
44    request.filters = Some(Box::new(filters));
45    if let Err(error) = read_volumes(&config, Some(request)) {
46        eprintln!("Error: {:?}", error);
47        std::process::exit(1);
48    }
49    println!("OK");
50
51    // Deleting a volume
52    print!("Deleting volume {}... ", volume_id);
53    let request = DeleteVolumeRequest::new(volume_id.clone());
54    if let Err(error) = delete_volume(&config, Some(request)) {
55        eprintln!("Error: {:?}", error);
56        std::process::exit(1);
57    }
58    println!("OK");
59}

Trait Implementations§

Source§

impl TryFrom<Profile> for Configuration

Source§

type Error = ConfigurationFileError

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

fn try_from(value: Profile) -> Result<Self, Self::Error>

Performs the conversion.

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> 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<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: 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: 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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