openstack_sdk

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§

Structs§

  • 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.
  • A structure for form parameters.
  • A query modifier that paginates an endpoint.
  • A structure for query parameters.

Enums§

Traits§

  • A trait representing an asynchronous client which can communicate with OpenStack cloud.
  • A trait representing a client which can communicate with a OpenStack cloud APIs.
  • Trait for findable resources that combines GET and LIST endpoint
  • A trait to indicate that an endpoint is pageable.
  • A trait representing a parameter value.
  • 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.
  • 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.
  • 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.
  • 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.
  • A trait representing a client which can communicate with a OpenStack service API via REST API.
  • A trait for providing the necessary information for a single REST API endpoint.

Functions§

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