Module api

Source
Expand description

OpenStack API bindings

This module provides implementation for the individual APIs as well as the necessary logic

§Query/QueryAsync trait

API requests that return data should be invoked using Query or QueryAsync style.

   use openstack_sdk::api::QueryAsync;
   let data_raw: serde_json::Value = ep.query_async(&client).await?;

§RawQuery/RawQueryAsync trait

It may be sometimes desired to get the raw API response for example to access headers. It is possible using RawQuery/RawQueryAsync trait on such endpoints.

   use openstack_sdk::api::RawQueryAsync;
   let rsp: Response<Bytes> = ep.raw_query_async(&client).await?;

§Find combinator

Finding resource by name or id is possible using find combinator. First a API request to get resource directly by the identified (i.e. flavors/<VALUE>) is done. When it returns positive data it is used as a find response. Otherwise list API call is invoked (passing name filter parameter when available). Single operation return entry is used as find result otherwise an error is returned. Only endpoints implementing Findable trait support that.

   use openstack_sdk::api::QueryAsync;
   use openstack_sdk::api::find;
   let data_raw: serde_json::Value = find(ep).query_async(&client).await?;

When identifier is clearly known to be name find is more useful and is saving unnecessary API roundtrip for attempting to query resource by the identifier and immediately triggers listing operation.

   use openstack_sdk::api::QueryAsync;
   use openstack_sdk::api::find_by_name;
   let data_raw: serde_json::Value = find_by_name(ep).query_async(&client).await?;

§Pagination combinator

Support for querying paginated resources is covered using paged combinator. The endpoint must implement Pageable trait to support this combinator.

   use openstack_sdk::api::{QueryAsync, Pagination};
   use openstack_sdk::api::paged;
   let data: Vec<serde_json::Value> = paged(ep, Pagination::Limit(100))
       .query_async(&client)
       .await?;

§Ignoring response combinator

Some APIs natively do not return any response. Trying to use Query/QueryAsync trait on them result in an error while casing the data. When API do not return any response or it is explicitly uninteresting a ignore combinator can be used. When API returned an error it is properly thrown.

   use openstack_sdk::api::{ignore, QueryAsync};
   ignore(ep).query_async(&client).await?;

Modules§

block_storage
Block Storage (Cinder) API bindings
compute
Compute service (Nova) bindings
container_infrastructure_management
Container Infrastructure Management service (Magnum) bindings
dns
DNS service (Designate) bindings
identity
Identity API (Keystone) bindings
image
Image API (Glance) bindings
load_balancer
Load Balancing API (Octavia) bindings
network
Network API (Neutron) bindings
object_store
Object-Store API (Swift) bindings
placement
Placement bindings
rest_endpoint_prelude
Endpoint prelude

Structs§

Ignore
A query modifier that ignores the data returned from an endpoint. For error responses it tries to extract error information from body. It can be used for example for HEAD requests.
JsonBodyParams
A structure for form parameters.
Paged
A query modifier that paginates an endpoint.
QueryParams
A structure for query parameters.

Enums§

ApiError
Errors which may occur when using API endpoints.
BodyError
Errors which may occur when creating form data.
Pagination
Pagination options
PaginationError
Errors which may occur with pagination.

Traits§

AsyncClient
A trait representing an asynchronous client which can communicate with OpenStack cloud.
Client
A trait representing a client which can communicate with a OpenStack cloud APIs.
Findable
Trait for findable resources that combines GET and LIST endpoint
Pageable
A trait to indicate that an endpoint is pageable.
ParamValue
A trait representing a parameter value.
Query
A trait which represents a query which may be made to a OpenStack service API client trat returns deserializable data. It does know nothing about required authorization, which is handled by the client.
QueryAsync
A trait which represents an asynchronous query which may be made to a OpenStack service API client that returns deserializable data. It does know nothing about required authorization, which is handled by the client.
RawQuery
A trait which represents a synchronous query which may be made to a OpenStack service API client and return http response. It does know nothing about required authorization, which is handled by the client. It can be used for special cases where headers must be captured, response is not json, etc.
RawQueryAsync
A trait which represents an asynchronous query which may be made to a OpenStack service API client and return http response. It does know nothing about required authorization, which is handled by the client.
RestClient
A trait representing a client which can communicate with a OpenStack service API via REST API.
RestEndpoint
A trait for providing the necessary information for a single REST API endpoint.

Functions§

check_response_error
Check for possible error in the response
find
Function wrapper for findable resources to locate resource by name or id
find_by_name
Function wrapper for findable resources to locate by name
ignore
Ignore the resulting data from an endpoint.
paged
Collect data from a paged endpoint.