DescribeLayers Foxpro Example
LOCAL loRest
LOCAL lnSuccess
LOCAL loAuthAws
LOCAL loJson
LOCAL loSbRequestBody
LOCAL loSbResponseBody
LOCAL lnRespStatusCode
LOCAL loJResp
LOCAL lcArn
LOCAL lcV_String
LOCAL lnAutoAssignElasticIps
LOCAL lnAutoAssignPublicIps
LOCAL lnEnabled
LOCAL lcCreatedAt
LOCAL lcCustomInstanceProfileArn
LOCAL lcCustomJson
LOCAL lnEnableAutoHealing
LOCAL lnInstallUpdatesOnBoot
LOCAL lcLayerId
LOCAL lnDelayUntilElbConnectionsDrained
LOCAL lnExecutionTimeout
LOCAL lcName
LOCAL lcShortname
LOCAL lcStackId
LOCAL lcV_Type
LOCAL lnUseEbsOptimizedInstances
LOCAL j
LOCAL lnCount_j
LOCAL lnBatchCount
LOCAL lnBatchSize
LOCAL lnBufferDuration
LOCAL lcDatetimeFormat
LOCAL lcEncoding
LOCAL lcFile
LOCAL lcFileFingerprintLines
LOCAL lcInitialPosition
LOCAL lcLogGroupName
LOCAL lcMultiLineStartPattern
LOCAL lcTimeZone
LOCAL lcStrVal
LOCAL lnEncrypted
LOCAL lnIops
LOCAL lcMountPoint
LOCAL lnNumberOfDisks
LOCAL lnRaidLevel
LOCAL lnSize
LOCAL lcVolumeType
LOCAL i
LOCAL lnCount_i
* This example requires the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.
loRest = CreateObject('Chilkat_9_5_0.Rest')
loAuthAws = CreateObject('Chilkat_9_5_0.AuthAws')
loAuthAws.AccessKey = "AWS_ACCESS_KEY"
loAuthAws.SecretKey = "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.)
loAuthAws.Region = "us-west-2"
loAuthAws.ServiceName = "opsworks"
* SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
loRest.SetAuthAws(loAuthAws)
* URL: https://opsworks.us-west-2.amazonaws.com/
* Use the same region as specified above.
lnSuccess = loRest.Connect("opsworks.us-west-2.amazonaws.com",443,1,1)
IF (lnSuccess <> 1) THEN
? "ConnectFailReason: " + STR(loRest.ConnectFailReason)
? loRest.LastErrorText
RELEASE loRest
RELEASE loAuthAws
CANCEL
ENDIF
* 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
loJson = CreateObject('Chilkat_9_5_0.JsonObject')
loJson.UpdateString("LayerIds[0]","string")
loJson.UpdateString("StackId","string")
* The JSON request body created by the above code:
* {
* "LayerIds": [
* "string"
* ],
* "StackId": "string"
* }
loRest.AddHeader("Content-Type","application/x-amz-json-1.1")
loRest.AddHeader("X-Amz-Target","OpsWorks_20130218.DescribeLayers")
loSbRequestBody = CreateObject('Chilkat_9_5_0.StringBuilder')
loJson.EmitSb(loSbRequestBody)
loSbResponseBody = CreateObject('Chilkat_9_5_0.StringBuilder')
lnSuccess = loRest.FullRequestSb("POST","/",loSbRequestBody,loSbResponseBody)
IF (lnSuccess <> 1) THEN
? loRest.LastErrorText
RELEASE loRest
RELEASE loAuthAws
RELEASE loJson
RELEASE loSbRequestBody
RELEASE loSbResponseBody
CANCEL
ENDIF
lnRespStatusCode = loRest.ResponseStatusCode
? "response status code = " + STR(lnRespStatusCode)
IF (lnRespStatusCode <> 200) THEN
? "Response Header:"
? loRest.ResponseHeader
? "Response Body:"
? loSbResponseBody.GetAsString()
RELEASE loRest
RELEASE loAuthAws
RELEASE loJson
RELEASE loSbRequestBody
RELEASE loSbResponseBody
CANCEL
ENDIF
loJResp = CreateObject('Chilkat_9_5_0.JsonObject')
loJResp.LoadSb(loSbResponseBody)
* 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
i = 0
lnCount_i = loJResp.SizeOfArray("Layers")
DO WHILE i < lnCount_i
loJResp.I = i
lcArn = loJResp.StringOf("Layers[i].Arn")
lcV_String = loJResp.StringOf("Layers[i].Attributes.string")
lnAutoAssignElasticIps = loJResp.IntOf("Layers[i].AutoAssignElasticIps")
lnAutoAssignPublicIps = loJResp.IntOf("Layers[i].AutoAssignPublicIps")
lnEnabled = loJResp.IntOf("Layers[i].CloudWatchLogsConfiguration.Enabled")
lcCreatedAt = loJResp.StringOf("Layers[i].CreatedAt")
lcCustomInstanceProfileArn = loJResp.StringOf("Layers[i].CustomInstanceProfileArn")
lcCustomJson = loJResp.StringOf("Layers[i].CustomJson")
lnEnableAutoHealing = loJResp.IntOf("Layers[i].EnableAutoHealing")
lnInstallUpdatesOnBoot = loJResp.IntOf("Layers[i].InstallUpdatesOnBoot")
lcLayerId = loJResp.StringOf("Layers[i].LayerId")
lnDelayUntilElbConnectionsDrained = loJResp.IntOf("Layers[i].LifecycleEventConfiguration.Shutdown.DelayUntilElbConnectionsDrained")
lnExecutionTimeout = loJResp.IntOf("Layers[i].LifecycleEventConfiguration.Shutdown.ExecutionTimeout")
lcName = loJResp.StringOf("Layers[i].Name")
lcShortname = loJResp.StringOf("Layers[i].Shortname")
lcStackId = loJResp.StringOf("Layers[i].StackId")
lcV_Type = loJResp.StringOf("Layers[i].Type")
lnUseEbsOptimizedInstances = loJResp.IntOf("Layers[i].UseEbsOptimizedInstances")
j = 0
lnCount_j = loJResp.SizeOfArray("Layers[i].CloudWatchLogsConfiguration.LogStreams")
DO WHILE j < lnCount_j
loJResp.J = j
lnBatchCount = loJResp.IntOf("Layers[i].CloudWatchLogsConfiguration.LogStreams[j].BatchCount")
lnBatchSize = loJResp.IntOf("Layers[i].CloudWatchLogsConfiguration.LogStreams[j].BatchSize")
lnBufferDuration = loJResp.IntOf("Layers[i].CloudWatchLogsConfiguration.LogStreams[j].BufferDuration")
lcDatetimeFormat = loJResp.StringOf("Layers[i].CloudWatchLogsConfiguration.LogStreams[j].DatetimeFormat")
lcEncoding = loJResp.StringOf("Layers[i].CloudWatchLogsConfiguration.LogStreams[j].Encoding")
lcFile = loJResp.StringOf("Layers[i].CloudWatchLogsConfiguration.LogStreams[j].File")
lcFileFingerprintLines = loJResp.StringOf("Layers[i].CloudWatchLogsConfiguration.LogStreams[j].FileFingerprintLines")
lcInitialPosition = loJResp.StringOf("Layers[i].CloudWatchLogsConfiguration.LogStreams[j].InitialPosition")
lcLogGroupName = loJResp.StringOf("Layers[i].CloudWatchLogsConfiguration.LogStreams[j].LogGroupName")
lcMultiLineStartPattern = loJResp.StringOf("Layers[i].CloudWatchLogsConfiguration.LogStreams[j].MultiLineStartPattern")
lcTimeZone = loJResp.StringOf("Layers[i].CloudWatchLogsConfiguration.LogStreams[j].TimeZone")
j = j + 1
ENDDO
j = 0
lnCount_j = loJResp.SizeOfArray("Layers[i].CustomRecipes.Configure")
DO WHILE j < lnCount_j
loJResp.J = j
lcStrVal = loJResp.StringOf("Layers[i].CustomRecipes.Configure[j]")
j = j + 1
ENDDO
j = 0
lnCount_j = loJResp.SizeOfArray("Layers[i].CustomRecipes.Deploy")
DO WHILE j < lnCount_j
loJResp.J = j
lcStrVal = loJResp.StringOf("Layers[i].CustomRecipes.Deploy[j]")
j = j + 1
ENDDO
j = 0
lnCount_j = loJResp.SizeOfArray("Layers[i].CustomRecipes.Setup")
DO WHILE j < lnCount_j
loJResp.J = j
lcStrVal = loJResp.StringOf("Layers[i].CustomRecipes.Setup[j]")
j = j + 1
ENDDO
j = 0
lnCount_j = loJResp.SizeOfArray("Layers[i].CustomRecipes.Shutdown")
DO WHILE j < lnCount_j
loJResp.J = j
lcStrVal = loJResp.StringOf("Layers[i].CustomRecipes.Shutdown[j]")
j = j + 1
ENDDO
j = 0
lnCount_j = loJResp.SizeOfArray("Layers[i].CustomRecipes.Undeploy")
DO WHILE j < lnCount_j
loJResp.J = j
lcStrVal = loJResp.StringOf("Layers[i].CustomRecipes.Undeploy[j]")
j = j + 1
ENDDO
j = 0
lnCount_j = loJResp.SizeOfArray("Layers[i].CustomSecurityGroupIds")
DO WHILE j < lnCount_j
loJResp.J = j
lcStrVal = loJResp.StringOf("Layers[i].CustomSecurityGroupIds[j]")
j = j + 1
ENDDO
j = 0
lnCount_j = loJResp.SizeOfArray("Layers[i].DefaultRecipes.Configure")
DO WHILE j < lnCount_j
loJResp.J = j
lcStrVal = loJResp.StringOf("Layers[i].DefaultRecipes.Configure[j]")
j = j + 1
ENDDO
j = 0
lnCount_j = loJResp.SizeOfArray("Layers[i].DefaultRecipes.Deploy")
DO WHILE j < lnCount_j
loJResp.J = j
lcStrVal = loJResp.StringOf("Layers[i].DefaultRecipes.Deploy[j]")
j = j + 1
ENDDO
j = 0
lnCount_j = loJResp.SizeOfArray("Layers[i].DefaultRecipes.Setup")
DO WHILE j < lnCount_j
loJResp.J = j
lcStrVal = loJResp.StringOf("Layers[i].DefaultRecipes.Setup[j]")
j = j + 1
ENDDO
j = 0
lnCount_j = loJResp.SizeOfArray("Layers[i].DefaultRecipes.Shutdown")
DO WHILE j < lnCount_j
loJResp.J = j
lcStrVal = loJResp.StringOf("Layers[i].DefaultRecipes.Shutdown[j]")
j = j + 1
ENDDO
j = 0
lnCount_j = loJResp.SizeOfArray("Layers[i].DefaultRecipes.Undeploy")
DO WHILE j < lnCount_j
loJResp.J = j
lcStrVal = loJResp.StringOf("Layers[i].DefaultRecipes.Undeploy[j]")
j = j + 1
ENDDO
j = 0
lnCount_j = loJResp.SizeOfArray("Layers[i].DefaultSecurityGroupNames")
DO WHILE j < lnCount_j
loJResp.J = j
lcStrVal = loJResp.StringOf("Layers[i].DefaultSecurityGroupNames[j]")
j = j + 1
ENDDO
j = 0
lnCount_j = loJResp.SizeOfArray("Layers[i].Packages")
DO WHILE j < lnCount_j
loJResp.J = j
lcStrVal = loJResp.StringOf("Layers[i].Packages[j]")
j = j + 1
ENDDO
j = 0
lnCount_j = loJResp.SizeOfArray("Layers[i].VolumeConfigurations")
DO WHILE j < lnCount_j
loJResp.J = j
lnEncrypted = loJResp.IntOf("Layers[i].VolumeConfigurations[j].Encrypted")
lnIops = loJResp.IntOf("Layers[i].VolumeConfigurations[j].Iops")
lcMountPoint = loJResp.StringOf("Layers[i].VolumeConfigurations[j].MountPoint")
lnNumberOfDisks = loJResp.IntOf("Layers[i].VolumeConfigurations[j].NumberOfDisks")
lnRaidLevel = loJResp.IntOf("Layers[i].VolumeConfigurations[j].RaidLevel")
lnSize = loJResp.IntOf("Layers[i].VolumeConfigurations[j].Size")
lcVolumeType = loJResp.StringOf("Layers[i].VolumeConfigurations[j].VolumeType")
j = j + 1
ENDDO
i = i + 1
ENDDO
* 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"
* }
* ]
* }
* ]
* }
RELEASE loRest
RELEASE loAuthAws
RELEASE loJson
RELEASE loSbRequestBody
RELEASE loSbResponseBody
RELEASE loJResp