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 a
DshApiClientFactory:- Either use the
DshApiClientFactory::default()function, which returns a client factory configured from environment variables, - or you can create a factory explicitly by providing the
platform,tenantand APIpasswordyourself and feeding them to theDshApiClientFactory::create()function.
- Either use the
- Once you have the
DshApiClientFactory, you can call itsclient()method.
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".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
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
- 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
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