pub struct AsyncOpenStack { /* private fields */ }Expand description
Asynchronous 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, QueryAsync};
use openstack_sdk::{AsyncOpenStack, config::ConfigFile, OpenStackError};
use openstack_sdk::types::ServiceType;
use openstack_sdk::api::compute::v2::flavor::list;
async 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 = AsyncOpenStack::new(&profile).await?;
// Invoke service discovery when desired.
session.discover_service_endpoint(&ServiceType::Compute).await?;
// Execute the call with pagination limiting maximum amount of entries to 1000
let data: Vec<serde_json::Value> = paged(ep, Pagination::Limit(1000))
.query_async(&session)
.await.unwrap();
println!("Data = {:?}", data);
Ok(())
}Implementations§
Source§impl AsyncOpenStack
impl AsyncOpenStack
Sourcepub async fn new(config: &CloudConfig) -> Result<Self, OpenStackError>
pub async fn new(config: &CloudConfig) -> Result<Self, OpenStackError>
Create a new OpenStack API session from CloudConfig
Sourcepub async fn new_with_authentication_helper(
config: &CloudConfig,
auth_helper: &mut impl AuthHelper,
renew_auth: bool,
) -> Result<Self, OpenStackError>
pub async fn new_with_authentication_helper( config: &CloudConfig, auth_helper: &mut impl AuthHelper, renew_auth: bool, ) -> Result<Self, OpenStackError>
Create a new OpenStack API session from CloudConfig
Sourcepub async fn new_interactive(
config: &CloudConfig,
renew_auth: bool,
) -> Result<Self, OpenStackError>
👎Deprecated since 0.22.0: please use new_with_authentication_helper instead
pub async fn new_interactive( config: &CloudConfig, renew_auth: bool, ) -> Result<Self, OpenStackError>
new_with_authentication_helper insteadCreate 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 with the auth helper that may be invoked to interactively ask for the credentials.
Sourcepub async fn discover_service_endpoint(
&mut self,
service_type: &ServiceType,
) -> Result<(), OpenStackError>
pub async fn discover_service_endpoint( &mut self, service_type: &ServiceType, ) -> Result<(), OpenStackError>
Perform version discovery of a service
Sourcepub fn get_token_catalog(&self) -> Option<Vec<ServiceEndpoints>>
pub fn get_token_catalog(&self) -> Option<Vec<ServiceEndpoints>>
Return catalog information given in the token
Sourcepub fn get_auth_info(&self) -> Option<AuthResponse>
pub fn get_auth_info(&self) -> Option<AuthResponse>
Return current authentication information
Sourcepub fn get_auth_state(&self, offset: Option<TimeDelta>) -> Option<AuthState>
pub fn get_auth_state(&self, offset: Option<TimeDelta>) -> Option<AuthState>
Return current authentication status
Offset can be used to calculate imminent expiration.
Sourcepub fn get_auth_token(&self) -> Option<String>
pub fn get_auth_token(&self) -> Option<String>
Return current authentication token
Sourcepub async fn fetch_token_info<S: AsRef<str>>(
&self,
token: S,
) -> Result<AuthResponse, OpenStackError>
pub async fn fetch_token_info<S: AsRef<str>>( &self, token: S, ) -> Result<AuthResponse, OpenStackError>
Perform token introspection call
Trait Implementations§
Source§impl AsyncClient for AsyncOpenStack
impl AsyncClient for AsyncOpenStack
Source§fn rest_read_body_async<'life0, 'async_trait>(
&'life0 self,
request: Builder,
body: BoxedAsyncRead,
) -> Pin<Box<dyn Future<Output = Result<HttpResponse<Bytes>, ApiError<<Self as RestClient>::Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn rest_read_body_async<'life0, 'async_trait>(
&'life0 self,
request: Builder,
body: BoxedAsyncRead,
) -> Pin<Box<dyn Future<Output = Result<HttpResponse<Bytes>, ApiError<<Self as RestClient>::Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Perform REST request with the body read from AsyncRead
Source§fn download_async<'life0, 'async_trait>(
&'life0 self,
request: Builder,
body: Vec<u8>,
) -> Pin<Box<dyn Future<Output = Result<(HeaderMap, BoxedAsyncRead), ApiError<<Self as RestClient>::Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn download_async<'life0, 'async_trait>(
&'life0 self,
request: Builder,
body: Vec<u8>,
) -> Pin<Box<dyn Future<Output = Result<(HeaderMap, BoxedAsyncRead), ApiError<<Self as RestClient>::Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Download result of HTTP operation.
Source§impl Clone for AsyncOpenStack
impl Clone for AsyncOpenStack
Source§fn clone(&self) -> AsyncOpenStack
fn clone(&self) -> AsyncOpenStack
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AsyncOpenStack
impl Debug for AsyncOpenStack
Source§impl RestClient for AsyncOpenStack
impl RestClient for AsyncOpenStack
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 project id from the current scope
Auto Trait Implementations§
impl Freeze for AsyncOpenStack
impl !RefUnwindSafe for AsyncOpenStack
impl Send for AsyncOpenStack
impl Sync for AsyncOpenStack
impl Unpin for AsyncOpenStack
impl !UnwindSafe for AsyncOpenStack
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
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>
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>
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