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: LimiterParamsImplementations§
Source§impl Profile
impl Profile
pub fn builder() -> ProfileBuilder
Sourcepub fn default() -> Result<Profile>
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
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§
Auto Trait Implementations§
impl Freeze for Profile
impl RefUnwindSafe for Profile
impl Send for Profile
impl Sync for Profile
impl Unpin for Profile
impl UnsafeUnpin for Profile
impl UnwindSafe for Profile
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreCreates a shared type from an unshared type.