Crate dsh_api

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.10.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 to manage apps in the app catalog
application
Additional methods to manage applications
application_types
bucket
Additional methods to manage buckets
certificate
Additional methods to manage certificates
database
Additional methods to manage buckets
default
Default implementations for selected types
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
dsh_jwt
Models DSH tokens
generic
Generic API function calls
manifest
Additional methods to manage manifest
new
New functions for selected types
parse
Parsers for formatted strings
platform
Defines DSH platforms and their properties
query_processor
Enums, traits and structs used by the various find methods
secret
Additional methods to manage secrets
stream
Additional methods to manage streams
tenant
Additional methods to manage tenants
token_fetcher
Management API token fetching for DSH
topic
Additional methods to manage topics
types
Types generated from openapi file
version
Models semantic versions
vhost
Additional methods to manage vhosts
volume
Additional methods to manage volumes

Structs§

DependantApp
Describes an app dependency
DependantApplication
Describes an application dependency

Enums§

AccessRights
Indicates access rights
Dependant
Describes a app or application dependency
DshApiError
Describes an API error

Statics§

DEFAULT_PLATFORMS
Specification of default platforms
OPENAPI_SPEC
Openapi specification version 1.10.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