DescribeUserHierarchyGroup 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 sArn
String sLevelFiveArn
String sId
String sName
String sLevelFourArn
String sLevelFourId
String sLevelFourName
String sLevelOneArn
String sLevelOneId
String sLevelOneName
String sLevelThreeArn
String sLevelThreeId
String sLevelThreeName
String sLevelTwoArn
String sLevelTwoId
String sLevelTwoName
String sHierarchyGroupId
String sLevelId
String sHierarchyGroupName
String sV_String
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 "connect"
// 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://connect.us-west-2.amazonaws.com/
// Use the same region as specified above.
Get ComConnect Of hoRest "connect.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" "DescribeUserHierarchyGroup" 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" "/user-hierarchy-groups/{InstanceId}/{HierarchyGroupId}" 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 "HierarchyGroup.Arn" To sArn
Get ComStringOf Of hoJResp "HierarchyGroup.HierarchyPath.LevelFive.Arn" To sLevelFiveArn
Get ComStringOf Of hoJResp "HierarchyGroup.HierarchyPath.LevelFive.Id" To sId
Get ComStringOf Of hoJResp "HierarchyGroup.HierarchyPath.LevelFive.Name" To sName
Get ComStringOf Of hoJResp "HierarchyGroup.HierarchyPath.LevelFour.Arn" To sLevelFourArn
Get ComStringOf Of hoJResp "HierarchyGroup.HierarchyPath.LevelFour.Id" To sLevelFourId
Get ComStringOf Of hoJResp "HierarchyGroup.HierarchyPath.LevelFour.Name" To sLevelFourName
Get ComStringOf Of hoJResp "HierarchyGroup.HierarchyPath.LevelOne.Arn" To sLevelOneArn
Get ComStringOf Of hoJResp "HierarchyGroup.HierarchyPath.LevelOne.Id" To sLevelOneId
Get ComStringOf Of hoJResp "HierarchyGroup.HierarchyPath.LevelOne.Name" To sLevelOneName
Get ComStringOf Of hoJResp "HierarchyGroup.HierarchyPath.LevelThree.Arn" To sLevelThreeArn
Get ComStringOf Of hoJResp "HierarchyGroup.HierarchyPath.LevelThree.Id" To sLevelThreeId
Get ComStringOf Of hoJResp "HierarchyGroup.HierarchyPath.LevelThree.Name" To sLevelThreeName
Get ComStringOf Of hoJResp "HierarchyGroup.HierarchyPath.LevelTwo.Arn" To sLevelTwoArn
Get ComStringOf Of hoJResp "HierarchyGroup.HierarchyPath.LevelTwo.Id" To sLevelTwoId
Get ComStringOf Of hoJResp "HierarchyGroup.HierarchyPath.LevelTwo.Name" To sLevelTwoName
Get ComStringOf Of hoJResp "HierarchyGroup.Id" To sHierarchyGroupId
Get ComStringOf Of hoJResp "HierarchyGroup.LevelId" To sLevelId
Get ComStringOf Of hoJResp "HierarchyGroup.Name" To sHierarchyGroupName
Get ComStringOf Of hoJResp "HierarchyGroup.Tags.string" To sV_String
// A sample JSON response body parsed by the above code:
// {
// "HierarchyGroup": {
// "Arn": "string",
// "HierarchyPath": {
// "LevelFive": {
// "Arn": "string",
// "Id": "string",
// "Name": "string"
// },
// "LevelFour": {
// "Arn": "string",
// "Id": "string",
// "Name": "string"
// },
// "LevelOne": {
// "Arn": "string",
// "Id": "string",
// "Name": "string"
// },
// "LevelThree": {
// "Arn": "string",
// "Id": "string",
// "Name": "string"
// },
// "LevelTwo": {
// "Arn": "string",
// "Id": "string",
// "Name": "string"
// }
// },
// "Id": "string",
// "LevelId": "string",
// "Name": "string",
// "Tags": {
// "string": "string"
// }
// }
// }
End_Procedure