DescribeStacks 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 sAgentVersion
String sArn
String sV_String
String sBerkshelfVersion
Integer iManageBerkshelf
String sName
String sVersion
String sCreatedAt
String sPassword
String sRevision
String sV_SshKey
String sV_Type
String sV_Url
String sUsername
String sCustomJson
String sDefaultAvailabilityZone
String sDefaultInstanceProfileArn
String sDefaultOs
String sDefaultRootDeviceType
String sDefaultSshKeyName
String sDefaultSubnetId
String sHostnameTheme
String sRegion
String sServiceRoleArn
String sStackId
Integer iUseCustomCookbooks
Integer iUseOpsworksSecurityGroups
String sVpcId
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 "StackIds[0]" "string" To iSuccess
// The JSON request body created by the above code:
// {
// "StackIds": [
// "string"
// ]
// }
Get ComAddHeader Of hoRest "Content-Type" "application/x-amz-json-1.1" To iSuccess
Get ComAddHeader Of hoRest "X-Amz-Target" "OpsWorks_20130218.DescribeStacks" 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 "Stacks" To iCount_i
While (i < iCount_i)
Set ComI Of hoJResp To i
Get ComStringOf Of hoJResp "Stacks[i].AgentVersion" To sAgentVersion
Get ComStringOf Of hoJResp "Stacks[i].Arn" To sArn
Get ComStringOf Of hoJResp "Stacks[i].Attributes.string" To sV_String
Get ComStringOf Of hoJResp "Stacks[i].ChefConfiguration.BerkshelfVersion" To sBerkshelfVersion
Get ComIntOf Of hoJResp "Stacks[i].ChefConfiguration.ManageBerkshelf" To iManageBerkshelf
Get ComStringOf Of hoJResp "Stacks[i].ConfigurationManager.Name" To sName
Get ComStringOf Of hoJResp "Stacks[i].ConfigurationManager.Version" To sVersion
Get ComStringOf Of hoJResp "Stacks[i].CreatedAt" To sCreatedAt
Get ComStringOf Of hoJResp "Stacks[i].CustomCookbooksSource.Password" To sPassword
Get ComStringOf Of hoJResp "Stacks[i].CustomCookbooksSource.Revision" To sRevision
Get ComStringOf Of hoJResp "Stacks[i].CustomCookbooksSource.SshKey" To sV_SshKey
Get ComStringOf Of hoJResp "Stacks[i].CustomCookbooksSource.Type" To sV_Type
Get ComStringOf Of hoJResp "Stacks[i].CustomCookbooksSource.Url" To sV_Url
Get ComStringOf Of hoJResp "Stacks[i].CustomCookbooksSource.Username" To sUsername
Get ComStringOf Of hoJResp "Stacks[i].CustomJson" To sCustomJson
Get ComStringOf Of hoJResp "Stacks[i].DefaultAvailabilityZone" To sDefaultAvailabilityZone
Get ComStringOf Of hoJResp "Stacks[i].DefaultInstanceProfileArn" To sDefaultInstanceProfileArn
Get ComStringOf Of hoJResp "Stacks[i].DefaultOs" To sDefaultOs
Get ComStringOf Of hoJResp "Stacks[i].DefaultRootDeviceType" To sDefaultRootDeviceType
Get ComStringOf Of hoJResp "Stacks[i].DefaultSshKeyName" To sDefaultSshKeyName
Get ComStringOf Of hoJResp "Stacks[i].DefaultSubnetId" To sDefaultSubnetId
Get ComStringOf Of hoJResp "Stacks[i].HostnameTheme" To sHostnameTheme
Get ComStringOf Of hoJResp "Stacks[i].Name" To sName
Get ComStringOf Of hoJResp "Stacks[i].Region" To sRegion
Get ComStringOf Of hoJResp "Stacks[i].ServiceRoleArn" To sServiceRoleArn
Get ComStringOf Of hoJResp "Stacks[i].StackId" To sStackId
Get ComIntOf Of hoJResp "Stacks[i].UseCustomCookbooks" To iUseCustomCookbooks
Get ComIntOf Of hoJResp "Stacks[i].UseOpsworksSecurityGroups" To iUseOpsworksSecurityGroups
Get ComStringOf Of hoJResp "Stacks[i].VpcId" To sVpcId
Move (i + 1) To i
Loop
// A sample JSON response body parsed by the above code:
// {
// "Stacks": [
// {
// "AgentVersion": "string",
// "Arn": "string",
// "Attributes": {
// "string": "string"
// },
// "ChefConfiguration": {
// "BerkshelfVersion": "string",
// "ManageBerkshelf": boolean
// },
// "ConfigurationManager": {
// "Name": "string",
// "Version": "string"
// },
// "CreatedAt": "string",
// "CustomCookbooksSource": {
// "Password": "string",
// "Revision": "string",
// "SshKey": "string",
// "Type": "string",
// "Url": "string",
// "Username": "string"
// },
// "CustomJson": "string",
// "DefaultAvailabilityZone": "string",
// "DefaultInstanceProfileArn": "string",
// "DefaultOs": "string",
// "DefaultRootDeviceType": "string",
// "DefaultSshKeyName": "string",
// "DefaultSubnetId": "string",
// "HostnameTheme": "string",
// "Name": "string",
// "Region": "string",
// "ServiceRoleArn": "string",
// "StackId": "string",
// "UseCustomCookbooks": boolean,
// "UseOpsworksSecurityGroups": boolean,
// "VpcId": "string"
// }
// ]
// }
End_Procedure