DescribeLayers DataFlex Example
Use ChilkatAx-9.5.0-win32.pkg
Procedure Test
Handle hoRest
Boolean iSuccess
Variant vAuthAws
Handle hoAuthAws
Handle hoJson
Variant vSbRequestBody
Handle hoSbRequestBody
Variant vSbResponseBody
Handle hoSbResponseBody
Integer iRespStatusCode
Handle hoJResp
String sArn
String sV_String
Integer iAutoAssignElasticIps
Integer iAutoAssignPublicIps
Integer iEnabled
String sCreatedAt
String sCustomInstanceProfileArn
String sCustomJson
Integer iEnableAutoHealing
Integer iInstallUpdatesOnBoot
String sLayerId
Integer iDelayUntilElbConnectionsDrained
Integer iExecutionTimeout
String sName
String sShortname
String sStackId
String sV_Type
Integer iUseEbsOptimizedInstances
Integer j
Integer iCount_j
Integer iBatchCount
Integer iBatchSize
Integer iBufferDuration
String sDatetimeFormat
String sEncoding
String sFile
String sFileFingerprintLines
String sInitialPosition
String sLogGroupName
String sMultiLineStartPattern
String sTimeZone
String sStrVal
Integer iEncrypted
Integer iIops
String sMountPoint
Integer iNumberOfDisks
Integer iRaidLevel
Integer iSize
String sVolumeType
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 "opsworks"
// 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://opsworks.us-west-2.amazonaws.com/
// Use the same region as specified above.
Get ComConnect Of hoRest "opsworks.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
// The following code creates the JSON request body.
// The JSON created by this code is shown below.
// Use this online tool to generate code from sample JSON:
// Generate Code to Create JSON
Get Create (RefClass(cComChilkatJsonObject)) To hoJson
If (Not(IsComObjectCreated(hoJson))) Begin
Send CreateComObject of hoJson
End
Get ComUpdateString Of hoJson "LayerIds[0]" "string" To iSuccess
Get ComUpdateString Of hoJson "StackId" "string" To iSuccess
// The JSON request body created by the above code:
// {
// "LayerIds": [
// "string"
// ],
// "StackId": "string"
// }
Get ComAddHeader Of hoRest "Content-Type" "application/x-amz-json-1.1" To iSuccess
Get ComAddHeader Of hoRest "X-Amz-Target" "OpsWorks_20130218.DescribeLayers" 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 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
Move 0 To i
Get ComSizeOfArray Of hoJResp "Layers" To iCount_i
While (i < iCount_i)
Set ComI Of hoJResp To i
Get ComStringOf Of hoJResp "Layers[i].Arn" To sArn
Get ComStringOf Of hoJResp "Layers[i].Attributes.string" To sV_String
Get ComIntOf Of hoJResp "Layers[i].AutoAssignElasticIps" To iAutoAssignElasticIps
Get ComIntOf Of hoJResp "Layers[i].AutoAssignPublicIps" To iAutoAssignPublicIps
Get ComIntOf Of hoJResp "Layers[i].CloudWatchLogsConfiguration.Enabled" To iEnabled
Get ComStringOf Of hoJResp "Layers[i].CreatedAt" To sCreatedAt
Get ComStringOf Of hoJResp "Layers[i].CustomInstanceProfileArn" To sCustomInstanceProfileArn
Get ComStringOf Of hoJResp "Layers[i].CustomJson" To sCustomJson
Get ComIntOf Of hoJResp "Layers[i].EnableAutoHealing" To iEnableAutoHealing
Get ComIntOf Of hoJResp "Layers[i].InstallUpdatesOnBoot" To iInstallUpdatesOnBoot
Get ComStringOf Of hoJResp "Layers[i].LayerId" To sLayerId
Get ComIntOf Of hoJResp "Layers[i].LifecycleEventConfiguration.Shutdown.DelayUntilElbConnectionsDrained" To iDelayUntilElbConnectionsDrained
Get ComIntOf Of hoJResp "Layers[i].LifecycleEventConfiguration.Shutdown.ExecutionTimeout" To iExecutionTimeout
Get ComStringOf Of hoJResp "Layers[i].Name" To sName
Get ComStringOf Of hoJResp "Layers[i].Shortname" To sShortname
Get ComStringOf Of hoJResp "Layers[i].StackId" To sStackId
Get ComStringOf Of hoJResp "Layers[i].Type" To sV_Type
Get ComIntOf Of hoJResp "Layers[i].UseEbsOptimizedInstances" To iUseEbsOptimizedInstances
Move 0 To j
Get ComSizeOfArray Of hoJResp "Layers[i].CloudWatchLogsConfiguration.LogStreams" To iCount_j
While (j < iCount_j)
Set ComJ Of hoJResp To j
Get ComIntOf Of hoJResp "Layers[i].CloudWatchLogsConfiguration.LogStreams[j].BatchCount" To iBatchCount
Get ComIntOf Of hoJResp "Layers[i].CloudWatchLogsConfiguration.LogStreams[j].BatchSize" To iBatchSize
Get ComIntOf Of hoJResp "Layers[i].CloudWatchLogsConfiguration.LogStreams[j].BufferDuration" To iBufferDuration
Get ComStringOf Of hoJResp "Layers[i].CloudWatchLogsConfiguration.LogStreams[j].DatetimeFormat" To sDatetimeFormat
Get ComStringOf Of hoJResp "Layers[i].CloudWatchLogsConfiguration.LogStreams[j].Encoding" To sEncoding
Get ComStringOf Of hoJResp "Layers[i].CloudWatchLogsConfiguration.LogStreams[j].File" To sFile
Get ComStringOf Of hoJResp "Layers[i].CloudWatchLogsConfiguration.LogStreams[j].FileFingerprintLines" To sFileFingerprintLines
Get ComStringOf Of hoJResp "Layers[i].CloudWatchLogsConfiguration.LogStreams[j].InitialPosition" To sInitialPosition
Get ComStringOf Of hoJResp "Layers[i].CloudWatchLogsConfiguration.LogStreams[j].LogGroupName" To sLogGroupName
Get ComStringOf Of hoJResp "Layers[i].CloudWatchLogsConfiguration.LogStreams[j].MultiLineStartPattern" To sMultiLineStartPattern
Get ComStringOf Of hoJResp "Layers[i].CloudWatchLogsConfiguration.LogStreams[j].TimeZone" To sTimeZone
Move (j + 1) To j
Loop
Move 0 To j
Get ComSizeOfArray Of hoJResp "Layers[i].CustomRecipes.Configure" To iCount_j
While (j < iCount_j)
Set ComJ Of hoJResp To j
Get ComStringOf Of hoJResp "Layers[i].CustomRecipes.Configure[j]" To sStrVal
Move (j + 1) To j
Loop
Move 0 To j
Get ComSizeOfArray Of hoJResp "Layers[i].CustomRecipes.Deploy" To iCount_j
While (j < iCount_j)
Set ComJ Of hoJResp To j
Get ComStringOf Of hoJResp "Layers[i].CustomRecipes.Deploy[j]" To sStrVal
Move (j + 1) To j
Loop
Move 0 To j
Get ComSizeOfArray Of hoJResp "Layers[i].CustomRecipes.Setup" To iCount_j
While (j < iCount_j)
Set ComJ Of hoJResp To j
Get ComStringOf Of hoJResp "Layers[i].CustomRecipes.Setup[j]" To sStrVal
Move (j + 1) To j
Loop
Move 0 To j
Get ComSizeOfArray Of hoJResp "Layers[i].CustomRecipes.Shutdown" To iCount_j
While (j < iCount_j)
Set ComJ Of hoJResp To j
Get ComStringOf Of hoJResp "Layers[i].CustomRecipes.Shutdown[j]" To sStrVal
Move (j + 1) To j
Loop
Move 0 To j
Get ComSizeOfArray Of hoJResp "Layers[i].CustomRecipes.Undeploy" To iCount_j
While (j < iCount_j)
Set ComJ Of hoJResp To j
Get ComStringOf Of hoJResp "Layers[i].CustomRecipes.Undeploy[j]" To sStrVal
Move (j + 1) To j
Loop
Move 0 To j
Get ComSizeOfArray Of hoJResp "Layers[i].CustomSecurityGroupIds" To iCount_j
While (j < iCount_j)
Set ComJ Of hoJResp To j
Get ComStringOf Of hoJResp "Layers[i].CustomSecurityGroupIds[j]" To sStrVal
Move (j + 1) To j
Loop
Move 0 To j
Get ComSizeOfArray Of hoJResp "Layers[i].DefaultRecipes.Configure" To iCount_j
While (j < iCount_j)
Set ComJ Of hoJResp To j
Get ComStringOf Of hoJResp "Layers[i].DefaultRecipes.Configure[j]" To sStrVal
Move (j + 1) To j
Loop
Move 0 To j
Get ComSizeOfArray Of hoJResp "Layers[i].DefaultRecipes.Deploy" To iCount_j
While (j < iCount_j)
Set ComJ Of hoJResp To j
Get ComStringOf Of hoJResp "Layers[i].DefaultRecipes.Deploy[j]" To sStrVal
Move (j + 1) To j
Loop
Move 0 To j
Get ComSizeOfArray Of hoJResp "Layers[i].DefaultRecipes.Setup" To iCount_j
While (j < iCount_j)
Set ComJ Of hoJResp To j
Get ComStringOf Of hoJResp "Layers[i].DefaultRecipes.Setup[j]" To sStrVal
Move (j + 1) To j
Loop
Move 0 To j
Get ComSizeOfArray Of hoJResp "Layers[i].DefaultRecipes.Shutdown" To iCount_j
While (j < iCount_j)
Set ComJ Of hoJResp To j
Get ComStringOf Of hoJResp "Layers[i].DefaultRecipes.Shutdown[j]" To sStrVal
Move (j + 1) To j
Loop
Move 0 To j
Get ComSizeOfArray Of hoJResp "Layers[i].DefaultRecipes.Undeploy" To iCount_j
While (j < iCount_j)
Set ComJ Of hoJResp To j
Get ComStringOf Of hoJResp "Layers[i].DefaultRecipes.Undeploy[j]" To sStrVal
Move (j + 1) To j
Loop
Move 0 To j
Get ComSizeOfArray Of hoJResp "Layers[i].DefaultSecurityGroupNames" To iCount_j
While (j < iCount_j)
Set ComJ Of hoJResp To j
Get ComStringOf Of hoJResp "Layers[i].DefaultSecurityGroupNames[j]" To sStrVal
Move (j + 1) To j
Loop
Move 0 To j
Get ComSizeOfArray Of hoJResp "Layers[i].Packages" To iCount_j
While (j < iCount_j)
Set ComJ Of hoJResp To j
Get ComStringOf Of hoJResp "Layers[i].Packages[j]" To sStrVal
Move (j + 1) To j
Loop
Move 0 To j
Get ComSizeOfArray Of hoJResp "Layers[i].VolumeConfigurations" To iCount_j
While (j < iCount_j)
Set ComJ Of hoJResp To j
Get ComIntOf Of hoJResp "Layers[i].VolumeConfigurations[j].Encrypted" To iEncrypted
Get ComIntOf Of hoJResp "Layers[i].VolumeConfigurations[j].Iops" To iIops
Get ComStringOf Of hoJResp "Layers[i].VolumeConfigurations[j].MountPoint" To sMountPoint
Get ComIntOf Of hoJResp "Layers[i].VolumeConfigurations[j].NumberOfDisks" To iNumberOfDisks
Get ComIntOf Of hoJResp "Layers[i].VolumeConfigurations[j].RaidLevel" To iRaidLevel
Get ComIntOf Of hoJResp "Layers[i].VolumeConfigurations[j].Size" To iSize
Get ComStringOf Of hoJResp "Layers[i].VolumeConfigurations[j].VolumeType" To sVolumeType
Move (j + 1) To j
Loop
Move (i + 1) To i
Loop
// A sample JSON response body parsed by the above code:
// {
// "Layers": [
// {
// "Arn": "string",
// "Attributes": {
// "string": "string"
// },
// "AutoAssignElasticIps": boolean,
// "AutoAssignPublicIps": boolean,
// "CloudWatchLogsConfiguration": {
// "Enabled": boolean,
// "LogStreams": [
// {
// "BatchCount": number,
// "BatchSize": number,
// "BufferDuration": number,
// "DatetimeFormat": "string",
// "Encoding": "string",
// "File": "string",
// "FileFingerprintLines": "string",
// "InitialPosition": "string",
// "LogGroupName": "string",
// "MultiLineStartPattern": "string",
// "TimeZone": "string"
// }
// ]
// },
// "CreatedAt": "string",
// "CustomInstanceProfileArn": "string",
// "CustomJson": "string",
// "CustomRecipes": {
// "Configure": [
// "string"
// ],
// "Deploy": [
// "string"
// ],
// "Setup": [
// "string"
// ],
// "Shutdown": [
// "string"
// ],
// "Undeploy": [
// "string"
// ]
// },
// "CustomSecurityGroupIds": [
// "string"
// ],
// "DefaultRecipes": {
// "Configure": [
// "string"
// ],
// "Deploy": [
// "string"
// ],
// "Setup": [
// "string"
// ],
// "Shutdown": [
// "string"
// ],
// "Undeploy": [
// "string"
// ]
// },
// "DefaultSecurityGroupNames": [
// "string"
// ],
// "EnableAutoHealing": boolean,
// "InstallUpdatesOnBoot": boolean,
// "LayerId": "string",
// "LifecycleEventConfiguration": {
// "Shutdown": {
// "DelayUntilElbConnectionsDrained": boolean,
// "ExecutionTimeout": number
// }
// },
// "Name": "string",
// "Packages": [
// "string"
// ],
// "Shortname": "string",
// "StackId": "string",
// "Type": "string",
// "UseEbsOptimizedInstances": boolean,
// "VolumeConfigurations": [
// {
// "Encrypted": boolean,
// "Iops": number,
// "MountPoint": "string",
// "NumberOfDisks": number,
// "RaidLevel": number,
// "Size": number,
// "VolumeType": "string"
// }
// ]
// }
// ]
// }
End_Procedure