pub struct Session { /* private fields */ }
Expand description
An OpenStack API session.
The session object serves as a wrapper around an HTTP(s) client, handling authentication, accessing the service catalog and token refresh.
The session object also owns the endpoint interface to use.
Implementations
sourceimpl Session
impl Session
sourcepub fn new<Auth: AuthMethod + 'static>(auth_method: Auth) -> Session
pub fn new<Auth: AuthMethod + 'static>(auth_method: Auth) -> Session
Create a new session with a given authentication plugin.
The resulting session will use the default endpoint interface (usually, public).
sourcepub fn set_endpoint_interface<S>(&mut self, endpoint_interface: S)where
S: Into<String>,
pub fn set_endpoint_interface<S>(&mut self, endpoint_interface: S)where
S: Into<String>,
Set endpoint interface to use.
This call clears the cached service information.
sourcepub fn with_endpoint_interface<S>(self, endpoint_interface: S) -> Sessionwhere
S: Into<String>,
pub fn with_endpoint_interface<S>(self, endpoint_interface: S) -> Sessionwhere
S: Into<String>,
Convert this session into one using the given endpoint interface.
sourcepub fn auth_method(&self) -> &dyn AuthMethod
pub fn auth_method(&self) -> &dyn AuthMethod
Get a reference to the authentication method in use.
sourcepub fn auth_method_mut(&mut self) -> &mut dyn AuthMethod
pub fn auth_method_mut(&mut self) -> &mut dyn AuthMethod
Get a mutable reference to the authentication method in use.
sourcepub fn get_endpoint<Srv: ServiceType>(&self, path: &[&str]) -> Result<Url>
pub fn get_endpoint<Srv: ServiceType>(&self, path: &[&str]) -> Result<Url>
Construct and endpoint for the given service from the path.
sourcepub fn get_major_version<Srv: ServiceType>(&self) -> Result<ApiVersion>
pub fn get_major_version<Srv: ServiceType>(&self) -> Result<ApiVersion>
Get the currently used major version from the given service.
sourcepub fn get_api_versions<Srv: ServiceType>(
&self
) -> Result<Option<(ApiVersion, ApiVersion)>>
pub fn get_api_versions<Srv: ServiceType>(
&self
) -> Result<Option<(ApiVersion, ApiVersion)>>
Get minimum/maximum API (micro)version information.
Returns None
if the range cannot be determined, which usually means
that microversioning is not supported.
sourcepub fn request<Srv: ServiceType>(
&self,
method: Method,
path: &[&str],
api_version: Option<ApiVersion>
) -> Result<RequestBuilder>
pub fn request<Srv: ServiceType>(
&self,
method: Method,
path: &[&str],
api_version: Option<ApiVersion>
) -> Result<RequestBuilder>
Make an HTTP request to the given service.
sourcepub fn get<Srv: ServiceType>(
&self,
path: &[&str],
api_version: Option<ApiVersion>
) -> Result<RequestBuilder>
pub fn get<Srv: ServiceType>(
&self,
path: &[&str],
api_version: Option<ApiVersion>
) -> Result<RequestBuilder>
Start a GET request.
sourcepub fn post<Srv: ServiceType>(
&self,
path: &[&str],
api_version: Option<ApiVersion>
) -> Result<RequestBuilder>
pub fn post<Srv: ServiceType>(
&self,
path: &[&str],
api_version: Option<ApiVersion>
) -> Result<RequestBuilder>
Start a POST request.
sourcepub fn put<Srv: ServiceType>(
&self,
path: &[&str],
api_version: Option<ApiVersion>
) -> Result<RequestBuilder>
pub fn put<Srv: ServiceType>(
&self,
path: &[&str],
api_version: Option<ApiVersion>
) -> Result<RequestBuilder>
Start a PUT request.
sourcepub fn delete<Srv: ServiceType>(
&self,
path: &[&str],
api_version: Option<ApiVersion>
) -> Result<RequestBuilder>
pub fn delete<Srv: ServiceType>(
&self,
path: &[&str],
api_version: Option<ApiVersion>
) -> Result<RequestBuilder>
Start a DELETE request.