Struct openstack_sdk::AsyncOpenStack
source · 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".to_string()).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_interactive(
config: &CloudConfig,
renew_auth: bool
) -> Result<Self, OpenStackError>
pub async fn new_interactive( config: &CloudConfig, renew_auth: bool ) -> Result<Self, OpenStackError>
Create a new OpenStack API session from CloudConfig
Authorize against the cloud using provided credentials and get the session token
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_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
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl Debug for AsyncOpenStack
impl Debug for AsyncOpenStack
source§impl RestClient for AsyncOpenStack
impl RestClient for AsyncOpenStack
source§fn rest_endpoint(
&self,
service_type: &ServiceType,
endpoint: &str
) -> Result<Url, ApiError<Self::Error>>
fn rest_endpoint( &self, service_type: &ServiceType, endpoint: &str ) -> Result<Url, ApiError<Self::Error>>
Construct final URL for the resource given the service type and RestEndpoint
source§fn get_service_endpoint(
&self,
service_type: &ServiceType
) -> Result<ServiceEndpoint, ApiError<Self::Error>>
fn get_service_endpoint( &self, service_type: &ServiceType ) -> 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 !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
Mutably borrows from an owned value. Read more