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 dcli tool, but has now been promoted to a separate library.

§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, group id, user id, platform and API password are configured via environment variables.

use dsh_api::dsh_api_client_factory::DEFAULT_DSH_API_CLIENT_FACTORY;

let client = &DEFAULT_DSH_API_CLIENT_FACTORY.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.

use dsh_api::dsh_api_client_factory::DshApiClientFactory;
use dsh_api::dsh_api_tenant::DshApiTenant;
use dsh_api::platform::DshPlatform;
use dsh_api::types::Application;

let tenant = DshApiTenant::new(
  "my-tenant".to_string(),
  1234,
  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

The following features are defined:

  • actual - When this feature is enabled the library will include all the “actual” method versions of the REST API. By default, these methods will not be included.
  • generic - When this feature is enabled the library will also include the generic methods. This feature is disabled by default.

Modules§

app
Manage apps in the App Catalog
app_configuration
Manage the App Catalog
app_manifest
View the App Catalog manifests
application
Manage applications
bucket
Manage buckets
certificate
Manage certificates
display
Display implementations for selected types
dsh_api_client
Client for accessing the DSH api
dsh_api_client_factory
Factory for DSH API client
dsh_api_tenant
Client tenant
generic
Generic API function calls
platform
Defines DSH platforms and their properties
proxy
Manage proxies
query_processor
Enums, traits and structs used by the various find methods.
secret
Manage secrets
topic
Manage Kafka topics
types
Types generated from openapi file
vhost
Manage vhosts
volume
Manage volumes

Enums§

DshApiError
Enumeration of the recognized api errors
Injection
Enumeration that denotes an injection of a resource
UsedBy
Enumeration that denotes where a resource has been used

Constants§

ENV_VAR_PLATFORM
Environment variable used to define the target platform
ENV_VAR_PLATFORMS_FILE_NAME
Environment variable used to specify the name of a file with an alternative list of platforms
ENV_VAR_TENANT
Environment variable used to define the client tenant

Statics§

DEFAULT_PLATFORMS
Specification of default platforms
OPENAPI_SPEC
Openapi specification version 1.9.0

Functions§

api_version
Returns the version of the openapi spec
crate_version
Returns the version of the lib crate
guid_environment_variable
Create client tenant guid environment variable
password_environment_variable
Create client password environment variable
password_file_environment_variable
Create client password file environment variable

Type Aliases§

DshApiResult
Generic result type