Sample code for 30+ languages & platforms
Rust

Amazon Voice ID - Describe Domain

See more Amazon Voice ID Examples

Describes the specified domain.

Chilkat Rust Downloads

Rust

// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

let rest = chilkat::Rest::new();

let auth_aws = chilkat::AuthAws::new();
auth_aws.set_access_key("AWS_ACCESS_KEY");
auth_aws.set_secret_key("AWS_SECRET_KEY");

// Don't forget to change the region to your particular region. (Also make the same change in the call to Connect below.)
auth_aws.set_region("us-west-2");
auth_aws.set_service_name("voiceid");
// SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
let _ = rest.set_auth_aws(&auth_aws);

// URL: https://voiceid.us-west-2.amazonaws.com/
let b_tls = true;
let port = 443;
let b_auto_reconnect = true;
// Use the same region as specified above.
if rest.connect("voiceid.us-west-2.amazonaws.com", port, b_tls, b_auto_reconnect).is_err() {
    println!("ConnectFailReason: {}", rest.connect_fail_reason());
    println!("{}", rest.last_error_text());
    return;
}

// Use this online tool to generate code from sample JSON:
// Generate Code to Create JSON

// The following JSON is sent in the request body.

// {
//     "DomainId": "<domainId>"
// }
// 

let json = chilkat::JsonObject::new();
let _ = json.update_string("DomainId", "<domainId>");

let _ = rest.add_header("Content-Type", "application/x-amz-json-1.0");
let _ = rest.add_header("X-Amz-Target", "VoiceID.DescribeDomain");
let _ = rest.add_header("Accept-Encoding", "identity");

let sb_request_body = chilkat::StringBuilder::new();
let _ = json.emit_sb(&sb_request_body);
let sb_response_body = chilkat::StringBuilder::new();
if rest.full_request_sb("POST", "/", &sb_request_body, &sb_response_body).is_err() {
    println!("{}", rest.last_error_text());
    return;
}

let resp_status_code = rest.response_status_code();
println!("response status code = {}", resp_status_code);
if resp_status_code != 200 {
    println!("Response Status Code = {}", resp_status_code);
    println!("Response Header:");
    println!("{}", rest.response_header());
    println!("Response Body:");
    println!("{}", sb_response_body.get_as_string().unwrap_or_default());
    return;
}

let json_response = chilkat::JsonObject::new();
let _ = json_response.load_sb(&sb_response_body);

json_response.set_emit_compact(false);
println!("{}", json_response.emit().unwrap_or_default());

// If successful, the response status code is 200, and the response syntax:

// {
//    "Domain": { 
//       "Arn": "string",
//       "CreatedAt": number,
//       "Description": "string",
//       "DomainId": "string",
//       "DomainStatus": "string",
//       "Name": "string",
//       "ServerSideEncryptionConfiguration": { 
//          "KmsKeyId": "string"
//       },
//       "UpdatedAt": number
//    }
// }

let domain_arn = json_response.string_of("Domain.Arn").unwrap_or_default();
let domain_created_at = json_response.int_of("Domain.CreatedAt");
let domain_description = json_response.string_of("Domain.Description").unwrap_or_default();
let domain_domain_id = json_response.string_of("Domain.DomainId").unwrap_or_default();
let domain_domain_status = json_response.string_of("Domain.DomainStatus").unwrap_or_default();
let domain_name = json_response.string_of("Domain.Name").unwrap_or_default();
let domain_server_side_encryption_configuration_kms_key_id = json_response.string_of("Domain.ServerSideEncryptionConfiguration.KmsKeyId").unwrap_or_default();
let domain_updated_at = json_response.int_of("Domain.UpdatedAt");