Crate dsh_api

Source
Expand description

§DSH resource management API

This crate contains functions and definitions that provide support for using the functions of the DSH resource management API. The crate was originally developed as part of the dsh command line tool, but has now been promoted to a separate library.

§DshApiClient

The crate consists basically of the struct DshApiClient, which has many associated methods. In order to use these methods, you first need to acquire an instance of the struct. This is a two-step process.

You can now call the client’s methods to interact with the DSH resource management API.

§types

For their parameters and return values the methods and functions in the crate make use of rust structs that where generated from the DSH resource management API Openapi specification (version 1.9.0).

The generated types are defined as follows:

#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct Secret {
  pub name: String,
  pub value: String,
}

§Examples

§Minimal example

The first minimal example will print a list of all the applications that are deployed in a tenant environment. This example requires that the tenant’s name, platform and API password are configured via environment variables.

use dsh_api::dsh_api_client_factory::DshApiClientFactory;

let client = DshApiClientFactory::default().client().await?;
for (application_id, application) in client.list_applications()? {
  println!("{} -> {}", application_id, application);
}

§More elaborate example

In the next, more elaborate example, these tenant parameters are given explicitly. This example will list all the applications in the tenant environment that have been configured to require a token in order to access the Kafka broker. This is accomplished via the find_applications() methods, that returns a list of all applications for which the provided predicate evaluates to true.

let tenant = DshApiTenant::new(
  "my-tenant".to_string(),
  DshPlatform::try_from("np-aws-lz-dsh")?
);
let password = "...".to_string();
let client_factory = DshApiClientFactory::create(tenant, password)?;
let client = client_factory.client().await?;
let predicate = |application: &Application| application.needs_token;
let applications = client.find_applications(&predicate).await?;
for (_, application) in applications {
  println!("{}", application);
}

§Features

By enabling/disabling the features described below you have control over what’s included in your library and what’s not. All features are disabled by default.

The following features are defined:

  • generic - Enables the generic methods.
  • manage - Enables the manage methods.
  • robot - Enables the robot operation.

Modules§

app
Additional methods and functions to manage apps in the app catalog
app_manifest
Additional methods to manage the app catalog manifests
application
Additional methods and functions to manage applications
bucket
Additional methods to manage buckets
certificate
Additional methods to manage certificates
display
Display implementations for selected types
dsh_api_client
DSH API client
dsh_api_client_factory
DSH API client factory
dsh_api_tenant
Client tenant
generic
Generic API function calls
platform
Defines DSH platforms and their properties
query_processor
Enums, traits and structs used by the various find methods
secret
Additional methods and functions to manage secrets
stream
Additional methods and functions to manage streams
tenant
Additional methods and functions to manage tenant
token_fetcher
Management API token fetching for DSH
topic
Additional method to manage Kafka topics
types
Types generated from openapi file
vhost
Additional method to manage vhosts
volume
Additional methods to manage volumes

Enums§

AccessRights
Indicates access rights
DshApiError
Describes an API error
Injection
Describes an injection of a resource
UsedBy
Describes where a resource has been used

Statics§

DEFAULT_PLATFORMS
Specification of default platforms
OPENAPI_SPEC
Openapi specification version 1.9.0

Functions§

crate_version
Returns the version of the lib crate
openapi_version
Returns the version of the openapi spec

Type Aliases§

DshApiResult
Generic result type