Struct openstack_sdk::OpenStack
source · 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".to_string()).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
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
sourcepub fn rest_with_auth(
&self,
request: Builder,
body: Vec<u8>,
auth: &Auth
) -> Result<HttpResponse<Bytes>, ApiError<<Self as RestClient>::Error>>
pub fn rest_with_auth( &self, request: Builder, body: Vec<u8>, auth: &Auth ) -> Result<HttpResponse<Bytes>, ApiError<<Self as RestClient>::Error>>
Perform a REST query with a given auth.
Trait Implementations§
source§impl RestClient for OpenStack
impl RestClient for OpenStack
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 current token project information
Auto Trait Implementations§
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