Unicode C
Unicode C
Amazon Voice ID - Describe Domain
See more Amazon Voice ID Examples
Describes the specified domain.Chilkat Unicode C Downloads
#include <C_CkRestW.h>
#include <C_CkAuthAwsW.h>
#include <C_CkJsonObjectW.h>
#include <C_CkStringBuilderW.h>
void ChilkatSample(void)
{
BOOL success;
HCkRestW rest;
HCkAuthAwsW authAws;
BOOL bTls;
int port;
BOOL bAutoReconnect;
HCkJsonObjectW json;
HCkStringBuilderW sbRequestBody;
HCkStringBuilderW sbResponseBody;
int respStatusCode;
HCkJsonObjectW jsonResponse;
const wchar_t *DomainArn;
int DomainCreatedAt;
const wchar_t *DomainDescription;
const wchar_t *DomainDomainId;
const wchar_t *DomainDomainStatus;
const wchar_t *DomainName;
const wchar_t *DomainServerSideEncryptionConfigurationKmsKeyId;
int DomainUpdatedAt;
success = FALSE;
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
rest = CkRestW_Create();
authAws = CkAuthAwsW_Create();
CkAuthAwsW_putAccessKey(authAws,L"AWS_ACCESS_KEY");
CkAuthAwsW_putSecretKey(authAws,L"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.)
CkAuthAwsW_putRegion(authAws,L"us-west-2");
CkAuthAwsW_putServiceName(authAws,L"voiceid");
// SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
CkRestW_SetAuthAws(rest,authAws);
// URL: https://voiceid.us-west-2.amazonaws.com/
bTls = TRUE;
port = 443;
bAutoReconnect = TRUE;
// Use the same region as specified above.
success = CkRestW_Connect(rest,L"voiceid.us-west-2.amazonaws.com",port,bTls,bAutoReconnect);
if (success != TRUE) {
wprintf(L"ConnectFailReason: %d\n",CkRestW_getConnectFailReason(rest));
wprintf(L"%s\n",CkRestW_lastErrorText(rest));
CkRestW_Dispose(rest);
CkAuthAwsW_Dispose(authAws);
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>"
// }
//
json = CkJsonObjectW_Create();
CkJsonObjectW_UpdateString(json,L"DomainId",L"<domainId>");
CkRestW_AddHeader(rest,L"Content-Type",L"application/x-amz-json-1.0");
CkRestW_AddHeader(rest,L"X-Amz-Target",L"VoiceID.DescribeDomain");
CkRestW_AddHeader(rest,L"Accept-Encoding",L"identity");
sbRequestBody = CkStringBuilderW_Create();
CkJsonObjectW_EmitSb(json,sbRequestBody);
sbResponseBody = CkStringBuilderW_Create();
success = CkRestW_FullRequestSb(rest,L"POST",L"/",sbRequestBody,sbResponseBody);
if (success != TRUE) {
wprintf(L"%s\n",CkRestW_lastErrorText(rest));
CkRestW_Dispose(rest);
CkAuthAwsW_Dispose(authAws);
CkJsonObjectW_Dispose(json);
CkStringBuilderW_Dispose(sbRequestBody);
CkStringBuilderW_Dispose(sbResponseBody);
return;
}
respStatusCode = CkRestW_getResponseStatusCode(rest);
wprintf(L"response status code = %d\n",respStatusCode);
if (respStatusCode != 200) {
wprintf(L"Response Status Code = %d\n",respStatusCode);
wprintf(L"Response Header:\n");
wprintf(L"%s\n",CkRestW_responseHeader(rest));
wprintf(L"Response Body:\n");
wprintf(L"%s\n",CkStringBuilderW_getAsString(sbResponseBody));
CkRestW_Dispose(rest);
CkAuthAwsW_Dispose(authAws);
CkJsonObjectW_Dispose(json);
CkStringBuilderW_Dispose(sbRequestBody);
CkStringBuilderW_Dispose(sbResponseBody);
return;
}
jsonResponse = CkJsonObjectW_Create();
CkJsonObjectW_LoadSb(jsonResponse,sbResponseBody);
CkJsonObjectW_putEmitCompact(jsonResponse,FALSE);
wprintf(L"%s\n",CkJsonObjectW_emit(jsonResponse));
// 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
// }
// }
DomainArn = CkJsonObjectW_stringOf(jsonResponse,L"Domain.Arn");
DomainCreatedAt = CkJsonObjectW_IntOf(jsonResponse,L"Domain.CreatedAt");
DomainDescription = CkJsonObjectW_stringOf(jsonResponse,L"Domain.Description");
DomainDomainId = CkJsonObjectW_stringOf(jsonResponse,L"Domain.DomainId");
DomainDomainStatus = CkJsonObjectW_stringOf(jsonResponse,L"Domain.DomainStatus");
DomainName = CkJsonObjectW_stringOf(jsonResponse,L"Domain.Name");
DomainServerSideEncryptionConfigurationKmsKeyId = CkJsonObjectW_stringOf(jsonResponse,L"Domain.ServerSideEncryptionConfiguration.KmsKeyId");
DomainUpdatedAt = CkJsonObjectW_IntOf(jsonResponse,L"Domain.UpdatedAt");
CkRestW_Dispose(rest);
CkAuthAwsW_Dispose(authAws);
CkJsonObjectW_Dispose(json);
CkStringBuilderW_Dispose(sbRequestBody);
CkStringBuilderW_Dispose(sbResponseBody);
CkJsonObjectW_Dispose(jsonResponse);
}