GetDistributionConfiguration DataFlex Example
Use ChilkatAx-9.5.0-win32.pkg
Procedure Test
Handle hoRest
Boolean iSuccess
Variant vAuthAws
Handle hoAuthAws
Variant vSbResponseBody
Handle hoSbResponseBody
Integer iRespStatusCode
Handle hoJResp
String sAmiTagsString
String sAmiDistributionConfigurationDescription
String sKmsKeyId
String sAmiDistributionConfigurationName
String sContainerDistributionConfigurationDescription
String sRepositoryName
String sService
String sRegion
String sDiskImageFormat
String sRoleName
String sS3Bucket
String sS3Prefix
Integer j
Integer iCount_j
String sStrVal
String sAccountId
Integer iEnabled
String sLaunchTemplateId
String sLaunchTemplateName
String sLaunchTemplateVersion
Integer iMaxParallelLaunches
Integer iTargetResourceCount
String sLaunchTemplateId
Integer iSetDefaultVersion
String sArn
String sDateCreated
String sDateUpdated
String sDescription
String sName
String sV_String
Integer iTimeoutMinutes
String sRequestId
Integer i
Integer iCount_i
String sTemp1
Integer iTemp1
// 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 "imagebuilder"
// 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://imagebuilder.us-west-2.amazonaws.com/
// Use the same region as specified above.
Get ComConnect Of hoRest "imagebuilder.us-west-2.amazonaws.com" 443 True True 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
Get ComAddHeader Of hoRest "Content-Type" "application/x-amz-json-1.1" To iSuccess
Get ComAddHeader Of hoRest "X-Amz-Target" "GetDistributionConfiguration" To iSuccess
Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
Send CreateComObject of hoSbResponseBody
End
Get pvComObject of hoSbResponseBody to vSbResponseBody
Get ComFullRequestNoBodySb Of hoRest "GET" "/GetDistributionConfiguration" 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 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 hoJResp
If (Not(IsComObjectCreated(hoJResp))) Begin
Send CreateComObject of hoJResp
End
Get pvComObject of hoSbResponseBody to vSbResponseBody
Get ComLoadSb Of hoJResp vSbResponseBody To iSuccess
// The following code parses the JSON response.
// A sample JSON response is shown below the sample code.
// Use this online tool to generate parsing code from sample JSON:
// Generate Parsing Code from JSON
Get ComStringOf Of hoJResp "distributionConfiguration.arn" To sArn
Get ComStringOf Of hoJResp "distributionConfiguration.dateCreated" To sDateCreated
Get ComStringOf Of hoJResp "distributionConfiguration.dateUpdated" To sDateUpdated
Get ComStringOf Of hoJResp "distributionConfiguration.description" To sDescription
Get ComStringOf Of hoJResp "distributionConfiguration.name" To sName
Get ComStringOf Of hoJResp "distributionConfiguration.tags.string" To sV_String
Get ComIntOf Of hoJResp "distributionConfiguration.timeoutMinutes" To iTimeoutMinutes
Get ComStringOf Of hoJResp "requestId" To sRequestId
Move 0 To i
Get ComSizeOfArray Of hoJResp "distributionConfiguration.distributions" To iCount_i
While (i < iCount_i)
Set ComI Of hoJResp To i
Get ComStringOf Of hoJResp "distributionConfiguration.distributions[i].amiDistributionConfiguration.amiTags.string" To sAmiTagsString
Get ComStringOf Of hoJResp "distributionConfiguration.distributions[i].amiDistributionConfiguration.description" To sAmiDistributionConfigurationDescription
Get ComStringOf Of hoJResp "distributionConfiguration.distributions[i].amiDistributionConfiguration.kmsKeyId" To sKmsKeyId
Get ComStringOf Of hoJResp "distributionConfiguration.distributions[i].amiDistributionConfiguration.name" To sAmiDistributionConfigurationName
Get ComStringOf Of hoJResp "distributionConfiguration.distributions[i].containerDistributionConfiguration.description" To sContainerDistributionConfigurationDescription
Get ComStringOf Of hoJResp "distributionConfiguration.distributions[i].containerDistributionConfiguration.targetRepository.repositoryName" To sRepositoryName
Get ComStringOf Of hoJResp "distributionConfiguration.distributions[i].containerDistributionConfiguration.targetRepository.service" To sService
Get ComStringOf Of hoJResp "distributionConfiguration.distributions[i].region" To sRegion
Get ComStringOf Of hoJResp "distributionConfiguration.distributions[i].s3ExportConfiguration.diskImageFormat" To sDiskImageFormat
Get ComStringOf Of hoJResp "distributionConfiguration.distributions[i].s3ExportConfiguration.roleName" To sRoleName
Get ComStringOf Of hoJResp "distributionConfiguration.distributions[i].s3ExportConfiguration.s3Bucket" To sS3Bucket
Get ComStringOf Of hoJResp "distributionConfiguration.distributions[i].s3ExportConfiguration.s3Prefix" To sS3Prefix
Move 0 To j
Get ComSizeOfArray Of hoJResp "distributionConfiguration.distributions[i].amiDistributionConfiguration.launchPermission.organizationalUnitArns" To iCount_j
While (j < iCount_j)
Set ComJ Of hoJResp To j
Get ComStringOf Of hoJResp "distributionConfiguration.distributions[i].amiDistributionConfiguration.launchPermission.organizationalUnitArns[j]" To sStrVal
Move (j + 1) To j
Loop
Move 0 To j
Get ComSizeOfArray Of hoJResp "distributionConfiguration.distributions[i].amiDistributionConfiguration.launchPermission.organizationArns" To iCount_j
While (j < iCount_j)
Set ComJ Of hoJResp To j
Get ComStringOf Of hoJResp "distributionConfiguration.distributions[i].amiDistributionConfiguration.launchPermission.organizationArns[j]" To sStrVal
Move (j + 1) To j
Loop
Move 0 To j
Get ComSizeOfArray Of hoJResp "distributionConfiguration.distributions[i].amiDistributionConfiguration.launchPermission.userGroups" To iCount_j
While (j < iCount_j)
Set ComJ Of hoJResp To j
Get ComStringOf Of hoJResp "distributionConfiguration.distributions[i].amiDistributionConfiguration.launchPermission.userGroups[j]" To sStrVal
Move (j + 1) To j
Loop
Move 0 To j
Get ComSizeOfArray Of hoJResp "distributionConfiguration.distributions[i].amiDistributionConfiguration.launchPermission.userIds" To iCount_j
While (j < iCount_j)
Set ComJ Of hoJResp To j
Get ComStringOf Of hoJResp "distributionConfiguration.distributions[i].amiDistributionConfiguration.launchPermission.userIds[j]" To sStrVal
Move (j + 1) To j
Loop
Move 0 To j
Get ComSizeOfArray Of hoJResp "distributionConfiguration.distributions[i].amiDistributionConfiguration.targetAccountIds" To iCount_j
While (j < iCount_j)
Set ComJ Of hoJResp To j
Get ComStringOf Of hoJResp "distributionConfiguration.distributions[i].amiDistributionConfiguration.targetAccountIds[j]" To sStrVal
Move (j + 1) To j
Loop
Move 0 To j
Get ComSizeOfArray Of hoJResp "distributionConfiguration.distributions[i].containerDistributionConfiguration.containerTags" To iCount_j
While (j < iCount_j)
Set ComJ Of hoJResp To j
Get ComStringOf Of hoJResp "distributionConfiguration.distributions[i].containerDistributionConfiguration.containerTags[j]" To sStrVal
Move (j + 1) To j
Loop
Move 0 To j
Get ComSizeOfArray Of hoJResp "distributionConfiguration.distributions[i].fastLaunchConfigurations" To iCount_j
While (j < iCount_j)
Set ComJ Of hoJResp To j
Get ComStringOf Of hoJResp "distributionConfiguration.distributions[i].fastLaunchConfigurations[j].accountId" To sAccountId
Get ComIntOf Of hoJResp "distributionConfiguration.distributions[i].fastLaunchConfigurations[j].enabled" To iEnabled
Get ComStringOf Of hoJResp "distributionConfiguration.distributions[i].fastLaunchConfigurations[j].launchTemplate.launchTemplateId" To sLaunchTemplateId
Get ComStringOf Of hoJResp "distributionConfiguration.distributions[i].fastLaunchConfigurations[j].launchTemplate.launchTemplateName" To sLaunchTemplateName
Get ComStringOf Of hoJResp "distributionConfiguration.distributions[i].fastLaunchConfigurations[j].launchTemplate.launchTemplateVersion" To sLaunchTemplateVersion
Get ComIntOf Of hoJResp "distributionConfiguration.distributions[i].fastLaunchConfigurations[j].maxParallelLaunches" To iMaxParallelLaunches
Get ComIntOf Of hoJResp "distributionConfiguration.distributions[i].fastLaunchConfigurations[j].snapshotConfiguration.targetResourceCount" To iTargetResourceCount
Move (j + 1) To j
Loop
Move 0 To j
Get ComSizeOfArray Of hoJResp "distributionConfiguration.distributions[i].launchTemplateConfigurations" To iCount_j
While (j < iCount_j)
Set ComJ Of hoJResp To j
Get ComStringOf Of hoJResp "distributionConfiguration.distributions[i].launchTemplateConfigurations[j].accountId" To sAccountId
Get ComStringOf Of hoJResp "distributionConfiguration.distributions[i].launchTemplateConfigurations[j].launchTemplateId" To sLaunchTemplateId
Get ComIntOf Of hoJResp "distributionConfiguration.distributions[i].launchTemplateConfigurations[j].setDefaultVersion" To iSetDefaultVersion
Move (j + 1) To j
Loop
Move 0 To j
Get ComSizeOfArray Of hoJResp "distributionConfiguration.distributions[i].licenseConfigurationArns" To iCount_j
While (j < iCount_j)
Set ComJ Of hoJResp To j
Get ComStringOf Of hoJResp "distributionConfiguration.distributions[i].licenseConfigurationArns[j]" To sStrVal
Move (j + 1) To j
Loop
Move (i + 1) To i
Loop
// A sample JSON response body parsed by the above code:
// {
// "distributionConfiguration": {
// "arn": "string",
// "dateCreated": "string",
// "dateUpdated": "string",
// "description": "string",
// "distributions": [
// {
// "amiDistributionConfiguration": {
// "amiTags": {
// "string": "string"
// },
// "description": "string",
// "kmsKeyId": "string",
// "launchPermission": {
// "organizationalUnitArns": [
// "string"
// ],
// "organizationArns": [
// "string"
// ],
// "userGroups": [
// "string"
// ],
// "userIds": [
// "string"
// ]
// },
// "name": "string",
// "targetAccountIds": [
// "string"
// ]
// },
// "containerDistributionConfiguration": {
// "containerTags": [
// "string"
// ],
// "description": "string",
// "targetRepository": {
// "repositoryName": "string",
// "service": "string"
// }
// },
// "fastLaunchConfigurations": [
// {
// "accountId": "string",
// "enabled": boolean,
// "launchTemplate": {
// "launchTemplateId": "string",
// "launchTemplateName": "string",
// "launchTemplateVersion": "string"
// },
// "maxParallelLaunches": number,
// "snapshotConfiguration": {
// "targetResourceCount": number
// }
// }
// ],
// "launchTemplateConfigurations": [
// {
// "accountId": "string",
// "launchTemplateId": "string",
// "setDefaultVersion": boolean
// }
// ],
// "licenseConfigurationArns": [
// "string"
// ],
// "region": "string",
// "s3ExportConfiguration": {
// "diskImageFormat": "string",
// "roleName": "string",
// "s3Bucket": "string",
// "s3Prefix": "string"
// }
// }
// ],
// "name": "string",
// "tags": {
// "string": "string"
// },
// "timeoutMinutes": number
// },
// "requestId": "string"
// }
End_Procedure