Dart
Dart
Amazon Voice ID - Describe Domain
See more Amazon Voice ID Examples
Describes the specified domain.Chilkat Dart Downloads
import 'package:chilkat/chilkat.dart';
void main() {
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
final rest = CkRest();
final authAws = CkAuthAws();
authAws.accessKey = 'AWS_ACCESS_KEY';
authAws.secretKey = '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.)
authAws.region = 'us-west-2';
authAws.serviceName = 'voiceid';
// SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
rest.setAuthAws(authAws);
// URL: https://voiceid.us-west-2.amazonaws.com/
final bTls = true;
final port = 443;
final bAutoReconnect = true;
// Use the same region as specified above.
try {
rest.connect('voiceid.us-west-2.amazonaws.com', port, bTls, bAutoReconnect);
} on ChilkatException catch (e) {
print('ConnectFailReason: ${rest.connectFailReason}');
print(e.lastErrorText);
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>"
// }
//
final json = CkJsonObject();
json.updateString('DomainId', '<domainId>');
rest.addHeader('Content-Type', 'application/x-amz-json-1.0');
rest.addHeader('X-Amz-Target', 'VoiceID.DescribeDomain');
rest.addHeader('Accept-Encoding', 'identity');
final sbRequestBody = CkStringBuilder();
json.emitSb(sbRequestBody);
final sbResponseBody = CkStringBuilder();
try {
rest.fullRequestSb('POST', '/', sbRequestBody, sbResponseBody);
} on ChilkatException catch (e) {
print(e.lastErrorText);
return;
}
final respStatusCode = rest.responseStatusCode;
print('response status code = $respStatusCode');
if (respStatusCode != 200) {
print('Response Status Code = $respStatusCode');
print('Response Header:');
print(rest.responseHeader);
print('Response Body:');
print(sbResponseBody.getAsString());
return;
}
final jsonResponse = CkJsonObject();
jsonResponse.loadSb(sbResponseBody);
jsonResponse.emitCompact = false;
print(jsonResponse.emit());
// 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
// }
// }
final domainArn = jsonResponse.stringOf('Domain.Arn');
final domainCreatedAt = jsonResponse.intOf('Domain.CreatedAt');
final domainDescription = jsonResponse.stringOf('Domain.Description');
final domainDomainId = jsonResponse.stringOf('Domain.DomainId');
final domainDomainStatus = jsonResponse.stringOf('Domain.DomainStatus');
final domainName = jsonResponse.stringOf('Domain.Name');
final domainServerSideEncryptionConfigurationKmsKeyId = jsonResponse.stringOf('Domain.ServerSideEncryptionConfiguration.KmsKeyId');
final domainUpdatedAt = jsonResponse.intOf('Domain.UpdatedAt');
}