pub struct OpenStack { /* private fields */ }
Expand description
Synchronous client for the OpenStack API for a single user.
Separate Identity (not the scope) should use separate instances of this.
use openstack_sdk::api::{paged, Pagination, Query};
use openstack_sdk::{OpenStack, config::ConfigFile, OpenStackError};
use openstack_sdk::types::ServiceType;
use openstack_sdk::api::compute::v2::flavor::list;
fn list_flavors() -> Result<(), OpenStackError> {
// Get the builder for the listing Flavors Endpoint
let mut ep_builder = list::Request::builder();
// Set the `min_disk` query param
ep_builder.min_disk("15");
let ep = ep_builder.build().unwrap();
let cfg = ConfigFile::new().unwrap();
// Get connection config from clouds.yaml/secure.yaml
let profile = cfg.get_cloud_config("devstack").unwrap().unwrap();
// Establish connection
let mut session = OpenStack::new(&profile)?;
// Invoke service discovery when desired.
session.discover_service_endpoint(&ServiceType::Compute)?;
// Execute the call with pagination limiting maximum amount of entries to 1000
let data: Vec<serde_json::Value> = paged(ep, Pagination::Limit(1000))
.query(&session)
.unwrap();
println!("Data = {:?}", data);
Ok(())
}
Implementations§
Source§impl OpenStack
impl OpenStack
Sourcepub fn new(config: &CloudConfig) -> Result<Self, OpenStackError>
pub fn new(config: &CloudConfig) -> Result<Self, OpenStackError>
Create a new OpenStack API session from CloudConfig
Authorize against the cloud using provided credentials and get the session token
Authorize against the cloud using provided credentials and get the session token
pub fn discover_service_endpoint( &mut self, service_type: &ServiceType, ) -> Result<(), OpenStackError>
Sourcepub fn get_auth_token(&self) -> Option<String>
pub fn get_auth_token(&self) -> Option<String>
Return current authentication token
Trait Implementations§
Source§impl RestClient for OpenStack
impl RestClient for OpenStack
Source§fn get_service_endpoint(
&self,
service_type: &ServiceType,
version: Option<&ApiVersion>,
) -> Result<&ServiceEndpoint, ApiError<Self::Error>>
fn get_service_endpoint( &self, service_type: &ServiceType, version: Option<&ApiVersion>, ) -> Result<&ServiceEndpoint, ApiError<Self::Error>>
Get service endpoint from the catalog
Source§fn get_current_project(&self) -> Option<Project>
fn get_current_project(&self) -> Option<Project>
Get current token project information
Auto Trait Implementations§
impl Freeze for OpenStack
impl !RefUnwindSafe for OpenStack
impl Send for OpenStack
impl Sync for OpenStack
impl Unpin for OpenStack
impl !UnwindSafe for OpenStack
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 more