Lua
Lua
Amazon Voice ID - Describe Domain
See more Amazon Voice ID Examples
Describes the specified domain.Chilkat Lua Downloads
local chilkat = require("chilkat")
-- This example requires the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
local rest = chilkat.Rest.new()
local authAws = chilkat.AuthAws.new()
authAws.access_key = "AWS_ACCESS_KEY"
authAws.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.)
authAws.region = "us-west-2"
authAws.service_name = "voiceid"
-- SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
rest:set_auth_aws(authAws)
-- URL: https://voiceid.us-west-2.amazonaws.com/
local bTls = true
local port = 443
local bAutoReconnect = true
-- Use the same region as specified above.
local success = rest:connect("voiceid.us-west-2.amazonaws.com", port, bTls, bAutoReconnect)
if not success then
print("ConnectFailReason: " .. rest.connect_fail_reason)
print(rest.last_error_text)
return
end
-- 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>"
-- }
--
local json = chilkat.JsonObject.new()
json:update_string("DomainId", "<domainId>")
rest:add_header("Content-Type", "application/x-amz-json-1.0")
rest:add_header("X-Amz-Target", "VoiceID.DescribeDomain")
rest:add_header("Accept-Encoding", "identity")
local sbRequestBody = chilkat.StringBuilder.new()
json:emit_sb(sbRequestBody)
local sbResponseBody = chilkat.StringBuilder.new()
success = rest:full_request_sb("POST", "/", sbRequestBody, sbResponseBody)
if not success then
print(rest.last_error_text)
return
end
local respStatusCode = rest.response_status_code
print("response status code = " .. respStatusCode)
if respStatusCode ~= 200 then
print("Response Status Code = " .. respStatusCode)
print("Response Header:")
print(rest.response_header)
print("Response Body:")
print(sbResponseBody:get_as_string())
return
end
local jsonResponse = chilkat.JsonObject.new()
jsonResponse:load_sb(sbResponseBody)
jsonResponse.emit_compact = 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
-- }
-- }
local DomainArn = jsonResponse:string_of("Domain.Arn")
local DomainCreatedAt = jsonResponse:int_of("Domain.CreatedAt")
local DomainDescription = jsonResponse:string_of("Domain.Description")
local DomainDomainId = jsonResponse:string_of("Domain.DomainId")
local DomainDomainStatus = jsonResponse:string_of("Domain.DomainStatus")
local DomainName = jsonResponse:string_of("Domain.Name")
local DomainServerSideEncryptionConfigurationKmsKeyId = jsonResponse:string_of("Domain.ServerSideEncryptionConfiguration.KmsKeyId")
local DomainUpdatedAt = jsonResponse:int_of("Domain.UpdatedAt")