Sample code for 30+ languages & platforms
DataFlex

Amazon Voice ID - Describe Domain

See more Amazon Voice ID Examples

Describes the specified domain.

Chilkat DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Handle hoRest
    Variant vAuthAws
    Handle hoAuthAws
    Boolean iBTls
    Integer iPort
    Boolean iBAutoReconnect
    Handle hoJson
    Variant vSbRequestBody
    Handle hoSbRequestBody
    Variant vSbResponseBody
    Handle hoSbResponseBody
    Integer iRespStatusCode
    Handle hoJsonResponse
    String sDomainArn
    Integer iDomainCreatedAt
    String sDomainDescription
    String sDomainDomainId
    String sDomainDomainStatus
    String sDomainName
    String sDomainServerSideEncryptionConfigurationKmsKeyId
    Integer iDomainUpdatedAt
    String sTemp1
    Integer iTemp1

    Move False To iSuccess

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

    Get Create (RefClass(cComChilkatRest)) To hoRest
    If (Not(IsComObjectCreated(hoRest))) Begin
        Send CreateComObject of hoRest
    End

    Get Create (RefClass(cComChilkatAuthAws)) To hoAuthAws
    If (Not(IsComObjectCreated(hoAuthAws))) Begin
        Send CreateComObject of hoAuthAws
    End
    Set ComAccessKey Of hoAuthAws To "AWS_ACCESS_KEY"
    Set ComSecretKey Of hoAuthAws To "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.)
    Set ComRegion Of hoAuthAws To "us-west-2"
    Set ComServiceName Of hoAuthAws To "voiceid"
    // SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
    Get pvComObject of hoAuthAws to vAuthAws
    Get ComSetAuthAws Of hoRest vAuthAws To iSuccess

    // URL: https://voiceid.us-west-2.amazonaws.com/
    Move True To iBTls
    Move 443 To iPort
    Move True To iBAutoReconnect
    // Use the same region as specified above.
    Get ComConnect Of hoRest "voiceid.us-west-2.amazonaws.com" iPort iBTls iBAutoReconnect To iSuccess
    If (iSuccess <> True) Begin
        Get ComConnectFailReason Of hoRest To iTemp1
        Showln "ConnectFailReason: " iTemp1
        Get ComLastErrorText Of hoRest To sTemp1
        Showln sTemp1
        Procedure_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>"
    // }
    // 

    Get Create (RefClass(cComChilkatJsonObject)) To hoJson
    If (Not(IsComObjectCreated(hoJson))) Begin
        Send CreateComObject of hoJson
    End
    Get ComUpdateString Of hoJson "DomainId" "<domainId>" To iSuccess

    Get ComAddHeader Of hoRest "Content-Type" "application/x-amz-json-1.0" To iSuccess
    Get ComAddHeader Of hoRest "X-Amz-Target" "VoiceID.DescribeDomain" To iSuccess
    Get ComAddHeader Of hoRest "Accept-Encoding" "identity" To iSuccess

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbRequestBody
    If (Not(IsComObjectCreated(hoSbRequestBody))) Begin
        Send CreateComObject of hoSbRequestBody
    End
    Get pvComObject of hoSbRequestBody to vSbRequestBody
    Get ComEmitSb Of hoJson vSbRequestBody To iSuccess
    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
    If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
        Send CreateComObject of hoSbResponseBody
    End
    Get pvComObject of hoSbRequestBody to vSbRequestBody
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComFullRequestSb Of hoRest "POST" "/" vSbRequestBody vSbResponseBody To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoRest To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get ComResponseStatusCode Of hoRest To iRespStatusCode
    Showln "response status code = " iRespStatusCode
    If (iRespStatusCode <> 200) Begin
        Showln "Response Status Code = " iRespStatusCode
        Showln "Response Header:"
        Get ComResponseHeader Of hoRest To sTemp1
        Showln sTemp1
        Showln "Response Body:"
        Get ComGetAsString Of hoSbResponseBody To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatJsonObject)) To hoJsonResponse
    If (Not(IsComObjectCreated(hoJsonResponse))) Begin
        Send CreateComObject of hoJsonResponse
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComLoadSb Of hoJsonResponse vSbResponseBody To iSuccess

    Set ComEmitCompact Of hoJsonResponse To False
    Get ComEmit Of hoJsonResponse To sTemp1
    Showln sTemp1

    // 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
    //    }
    // }

    Get ComStringOf Of hoJsonResponse "Domain.Arn" To sDomainArn
    Get ComIntOf Of hoJsonResponse "Domain.CreatedAt" To iDomainCreatedAt
    Get ComStringOf Of hoJsonResponse "Domain.Description" To sDomainDescription
    Get ComStringOf Of hoJsonResponse "Domain.DomainId" To sDomainDomainId
    Get ComStringOf Of hoJsonResponse "Domain.DomainStatus" To sDomainDomainStatus
    Get ComStringOf Of hoJsonResponse "Domain.Name" To sDomainName
    Get ComStringOf Of hoJsonResponse "Domain.ServerSideEncryptionConfiguration.KmsKeyId" To sDomainServerSideEncryptionConfigurationKmsKeyId
    Get ComIntOf Of hoJsonResponse "Domain.UpdatedAt" To iDomainUpdatedAt


End_Procedure