DescribeLayers TCL Example
load ./chilkat.dll
# This example requires the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.
set rest [new_CkRest]
set authAws [new_CkAuthAws]
CkAuthAws_put_AccessKey $authAws "AWS_ACCESS_KEY"
CkAuthAws_put_SecretKey $authAws "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.)
CkAuthAws_put_Region $authAws "us-west-2"
CkAuthAws_put_ServiceName $authAws "opsworks"
# SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
CkRest_SetAuthAws $rest $authAws
# URL: https://opsworks.us-west-2.amazonaws.com/
# Use the same region as specified above.
set success [CkRest_Connect $rest "opsworks.us-west-2.amazonaws.com" 443 1 1]
if {$success != 1} then {
puts "ConnectFailReason: [CkRest_get_ConnectFailReason $rest]"
puts [CkRest_lastErrorText $rest]
delete_CkRest $rest
delete_CkAuthAws $authAws
exit
}
# 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
set json [new_CkJsonObject]
CkJsonObject_UpdateString $json "LayerIds[0]" "string"
CkJsonObject_UpdateString $json "StackId" "string"
# The JSON request body created by the above code:
# {
# "LayerIds": [
# "string"
# ],
# "StackId": "string"
# }
CkRest_AddHeader $rest "Content-Type" "application/x-amz-json-1.1"
CkRest_AddHeader $rest "X-Amz-Target" "OpsWorks_20130218.DescribeLayers"
set sbRequestBody [new_CkStringBuilder]
CkJsonObject_EmitSb $json $sbRequestBody
set sbResponseBody [new_CkStringBuilder]
set success [CkRest_FullRequestSb $rest "POST" "/" $sbRequestBody $sbResponseBody]
if {$success != 1} then {
puts [CkRest_lastErrorText $rest]
delete_CkRest $rest
delete_CkAuthAws $authAws
delete_CkJsonObject $json
delete_CkStringBuilder $sbRequestBody
delete_CkStringBuilder $sbResponseBody
exit
}
set respStatusCode [CkRest_get_ResponseStatusCode $rest]
puts "response status code = $respStatusCode"
if {$respStatusCode != 200} then {
puts "Response Header:"
puts [CkRest_responseHeader $rest]
puts "Response Body:"
puts [CkStringBuilder_getAsString $sbResponseBody]
delete_CkRest $rest
delete_CkAuthAws $authAws
delete_CkJsonObject $json
delete_CkStringBuilder $sbRequestBody
delete_CkStringBuilder $sbResponseBody
exit
}
set jResp [new_CkJsonObject]
CkJsonObject_LoadSb $jResp $sbResponseBody
# 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
set i 0
set count_i [CkJsonObject_SizeOfArray $jResp "Layers"]
while {$i < $count_i} {
CkJsonObject_put_I $jResp $i
set Arn [CkJsonObject_stringOf $jResp "Layers[i].Arn"]
set v_String [CkJsonObject_stringOf $jResp "Layers[i].Attributes.string"]
set AutoAssignElasticIps [CkJsonObject_IntOf $jResp "Layers[i].AutoAssignElasticIps"]
set AutoAssignPublicIps [CkJsonObject_IntOf $jResp "Layers[i].AutoAssignPublicIps"]
set Enabled [CkJsonObject_IntOf $jResp "Layers[i].CloudWatchLogsConfiguration.Enabled"]
set CreatedAt [CkJsonObject_stringOf $jResp "Layers[i].CreatedAt"]
set CustomInstanceProfileArn [CkJsonObject_stringOf $jResp "Layers[i].CustomInstanceProfileArn"]
set CustomJson [CkJsonObject_stringOf $jResp "Layers[i].CustomJson"]
set EnableAutoHealing [CkJsonObject_IntOf $jResp "Layers[i].EnableAutoHealing"]
set InstallUpdatesOnBoot [CkJsonObject_IntOf $jResp "Layers[i].InstallUpdatesOnBoot"]
set LayerId [CkJsonObject_stringOf $jResp "Layers[i].LayerId"]
set DelayUntilElbConnectionsDrained [CkJsonObject_IntOf $jResp "Layers[i].LifecycleEventConfiguration.Shutdown.DelayUntilElbConnectionsDrained"]
set ExecutionTimeout [CkJsonObject_IntOf $jResp "Layers[i].LifecycleEventConfiguration.Shutdown.ExecutionTimeout"]
set Name [CkJsonObject_stringOf $jResp "Layers[i].Name"]
set Shortname [CkJsonObject_stringOf $jResp "Layers[i].Shortname"]
set StackId [CkJsonObject_stringOf $jResp "Layers[i].StackId"]
set v_Type [CkJsonObject_stringOf $jResp "Layers[i].Type"]
set UseEbsOptimizedInstances [CkJsonObject_IntOf $jResp "Layers[i].UseEbsOptimizedInstances"]
set j 0
set count_j [CkJsonObject_SizeOfArray $jResp "Layers[i].CloudWatchLogsConfiguration.LogStreams"]
while {$j < $count_j} {
CkJsonObject_put_J $jResp $j
set BatchCount [CkJsonObject_IntOf $jResp "Layers[i].CloudWatchLogsConfiguration.LogStreams[j].BatchCount"]
set BatchSize [CkJsonObject_IntOf $jResp "Layers[i].CloudWatchLogsConfiguration.LogStreams[j].BatchSize"]
set BufferDuration [CkJsonObject_IntOf $jResp "Layers[i].CloudWatchLogsConfiguration.LogStreams[j].BufferDuration"]
set DatetimeFormat [CkJsonObject_stringOf $jResp "Layers[i].CloudWatchLogsConfiguration.LogStreams[j].DatetimeFormat"]
set Encoding [CkJsonObject_stringOf $jResp "Layers[i].CloudWatchLogsConfiguration.LogStreams[j].Encoding"]
set File [CkJsonObject_stringOf $jResp "Layers[i].CloudWatchLogsConfiguration.LogStreams[j].File"]
set FileFingerprintLines [CkJsonObject_stringOf $jResp "Layers[i].CloudWatchLogsConfiguration.LogStreams[j].FileFingerprintLines"]
set InitialPosition [CkJsonObject_stringOf $jResp "Layers[i].CloudWatchLogsConfiguration.LogStreams[j].InitialPosition"]
set LogGroupName [CkJsonObject_stringOf $jResp "Layers[i].CloudWatchLogsConfiguration.LogStreams[j].LogGroupName"]
set MultiLineStartPattern [CkJsonObject_stringOf $jResp "Layers[i].CloudWatchLogsConfiguration.LogStreams[j].MultiLineStartPattern"]
set TimeZone [CkJsonObject_stringOf $jResp "Layers[i].CloudWatchLogsConfiguration.LogStreams[j].TimeZone"]
set j [expr $j + 1]
}
set j 0
set count_j [CkJsonObject_SizeOfArray $jResp "Layers[i].CustomRecipes.Configure"]
while {$j < $count_j} {
CkJsonObject_put_J $jResp $j
set strVal [CkJsonObject_stringOf $jResp "Layers[i].CustomRecipes.Configure[j]"]
set j [expr $j + 1]
}
set j 0
set count_j [CkJsonObject_SizeOfArray $jResp "Layers[i].CustomRecipes.Deploy"]
while {$j < $count_j} {
CkJsonObject_put_J $jResp $j
set strVal [CkJsonObject_stringOf $jResp "Layers[i].CustomRecipes.Deploy[j]"]
set j [expr $j + 1]
}
set j 0
set count_j [CkJsonObject_SizeOfArray $jResp "Layers[i].CustomRecipes.Setup"]
while {$j < $count_j} {
CkJsonObject_put_J $jResp $j
set strVal [CkJsonObject_stringOf $jResp "Layers[i].CustomRecipes.Setup[j]"]
set j [expr $j + 1]
}
set j 0
set count_j [CkJsonObject_SizeOfArray $jResp "Layers[i].CustomRecipes.Shutdown"]
while {$j < $count_j} {
CkJsonObject_put_J $jResp $j
set strVal [CkJsonObject_stringOf $jResp "Layers[i].CustomRecipes.Shutdown[j]"]
set j [expr $j + 1]
}
set j 0
set count_j [CkJsonObject_SizeOfArray $jResp "Layers[i].CustomRecipes.Undeploy"]
while {$j < $count_j} {
CkJsonObject_put_J $jResp $j
set strVal [CkJsonObject_stringOf $jResp "Layers[i].CustomRecipes.Undeploy[j]"]
set j [expr $j + 1]
}
set j 0
set count_j [CkJsonObject_SizeOfArray $jResp "Layers[i].CustomSecurityGroupIds"]
while {$j < $count_j} {
CkJsonObject_put_J $jResp $j
set strVal [CkJsonObject_stringOf $jResp "Layers[i].CustomSecurityGroupIds[j]"]
set j [expr $j + 1]
}
set j 0
set count_j [CkJsonObject_SizeOfArray $jResp "Layers[i].DefaultRecipes.Configure"]
while {$j < $count_j} {
CkJsonObject_put_J $jResp $j
set strVal [CkJsonObject_stringOf $jResp "Layers[i].DefaultRecipes.Configure[j]"]
set j [expr $j + 1]
}
set j 0
set count_j [CkJsonObject_SizeOfArray $jResp "Layers[i].DefaultRecipes.Deploy"]
while {$j < $count_j} {
CkJsonObject_put_J $jResp $j
set strVal [CkJsonObject_stringOf $jResp "Layers[i].DefaultRecipes.Deploy[j]"]
set j [expr $j + 1]
}
set j 0
set count_j [CkJsonObject_SizeOfArray $jResp "Layers[i].DefaultRecipes.Setup"]
while {$j < $count_j} {
CkJsonObject_put_J $jResp $j
set strVal [CkJsonObject_stringOf $jResp "Layers[i].DefaultRecipes.Setup[j]"]
set j [expr $j + 1]
}
set j 0
set count_j [CkJsonObject_SizeOfArray $jResp "Layers[i].DefaultRecipes.Shutdown"]
while {$j < $count_j} {
CkJsonObject_put_J $jResp $j
set strVal [CkJsonObject_stringOf $jResp "Layers[i].DefaultRecipes.Shutdown[j]"]
set j [expr $j + 1]
}
set j 0
set count_j [CkJsonObject_SizeOfArray $jResp "Layers[i].DefaultRecipes.Undeploy"]
while {$j < $count_j} {
CkJsonObject_put_J $jResp $j
set strVal [CkJsonObject_stringOf $jResp "Layers[i].DefaultRecipes.Undeploy[j]"]
set j [expr $j + 1]
}
set j 0
set count_j [CkJsonObject_SizeOfArray $jResp "Layers[i].DefaultSecurityGroupNames"]
while {$j < $count_j} {
CkJsonObject_put_J $jResp $j
set strVal [CkJsonObject_stringOf $jResp "Layers[i].DefaultSecurityGroupNames[j]"]
set j [expr $j + 1]
}
set j 0
set count_j [CkJsonObject_SizeOfArray $jResp "Layers[i].Packages"]
while {$j < $count_j} {
CkJsonObject_put_J $jResp $j
set strVal [CkJsonObject_stringOf $jResp "Layers[i].Packages[j]"]
set j [expr $j + 1]
}
set j 0
set count_j [CkJsonObject_SizeOfArray $jResp "Layers[i].VolumeConfigurations"]
while {$j < $count_j} {
CkJsonObject_put_J $jResp $j
set Encrypted [CkJsonObject_IntOf $jResp "Layers[i].VolumeConfigurations[j].Encrypted"]
set Iops [CkJsonObject_IntOf $jResp "Layers[i].VolumeConfigurations[j].Iops"]
set MountPoint [CkJsonObject_stringOf $jResp "Layers[i].VolumeConfigurations[j].MountPoint"]
set NumberOfDisks [CkJsonObject_IntOf $jResp "Layers[i].VolumeConfigurations[j].NumberOfDisks"]
set RaidLevel [CkJsonObject_IntOf $jResp "Layers[i].VolumeConfigurations[j].RaidLevel"]
set Size [CkJsonObject_IntOf $jResp "Layers[i].VolumeConfigurations[j].Size"]
set VolumeType [CkJsonObject_stringOf $jResp "Layers[i].VolumeConfigurations[j].VolumeType"]
set j [expr $j + 1]
}
set i [expr $i + 1]
}
# 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"
# }
# ]
# }
# ]
# }
delete_CkRest $rest
delete_CkAuthAws $authAws
delete_CkJsonObject $json
delete_CkStringBuilder $sbRequestBody
delete_CkStringBuilder $sbResponseBody
delete_CkJsonObject $jResp