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.
- First you need to get an instance of
DshApiClientFactoryorDshApiPlatformClientFactory. - Once you have the client factory instance, you can call its
client()method to create theDshApiClient.
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,
}- All types are
pub. - All fields are
pub. - All types have derived implementations of the
Clone,Debug,Deserialize,PartialEqandSerializetraits. - Some selected types also have an implementation of the
Defaulttrait. - Some selected types also have an implementation of the
Displaytrait. - Some selected types also have a
newfunction.
§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", DshPlatform::try_from("np-aws-lz-dsh")?);
let password = "...";
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 thegenericmodule, which allows calling all api operations by name.manage- Enables the manage modulesstreamandtenant, which support creating managed streams and tenants. This feature is only useful when you have the proper authorizations for these capabilities.robot- Enables thepost_robot_generate_secret()operation, which will generate a new robot password, invalidating the old password.
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
- Module that contains methods and functions to manage certificates.
- database
- Additional methods to manage buckets
- default
Defaultimplementations for selected types- display
Displayimplementations 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
- proxy
- Additional methods to manage proxies
- 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§
- Dependant
App - Describes an app dependency
- Dependant
Application - Describes an application dependency
- Dependant
Proxy - Describes a proxy dependency
Enums§
- Access
Rights - Indicates access rights
- Dependant
- Describes a app or application dependency
- DshApi
Error - 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§
- DshApi
Result - Generic result type