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()
, method, which is configured from environment variables, - or you can create a factory explicitly by providing the
platform
,tenant
and APIpassword
yourself 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 struct
s 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,
}
- All types are
pub
. - All fields are
pub
. - All types have derived implementations of the
Clone
,Debug
,Deserialize
,PartialEq
andSerialize
traits. - Some selected types also have an implementation of the
Display
trait.
§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§
- Access
Rights - Indicates access rights
- DshApi
Error - 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§
- DshApi
Result - Generic result type