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 secret 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(
  "greenbox".to_string(),
  "2067:2067".to_string(),
  DshPlatform::NpLz
);
let secret = "...".to_string();
let client_factory = DshApiClientFactory::create(tenant, secret)?;
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);
}

Modules§

Enums§

  • Enumeration that denotes an injection of a resource
  • Enumeration that denotes where a resource has been used

Constants§

Statics§

Functions§

Type Aliases§