Chilkat Online Tools

DescribeOrganizationConfigRules autoit Example

AWS Config

; This example requires the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.

$oRest = ObjCreate("Chilkat_9_5_0.Rest")
Local $bSuccess

$oAuthAws = ObjCreate("Chilkat_9_5_0.AuthAws")
$oAuthAws.AccessKey = "AWS_ACCESS_KEY"
$oAuthAws.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.)
$oAuthAws.Region = "us-west-2"
$oAuthAws.ServiceName = "config"
; SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
$oRest.SetAuthAws($oAuthAws)

; URL: https://config.us-west-2.amazonaws.com/
; Use the same region as specified above.
$bSuccess = $oRest.Connect("config.us-west-2.amazonaws.com",443,True,True)
If ($bSuccess <> True) Then
    ConsoleWrite("ConnectFailReason: " & $oRest.ConnectFailReason & @CRLF)
    ConsoleWrite($oRest.LastErrorText & @CRLF)
    Exit
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

$oJson = ObjCreate("Chilkat_9_5_0.JsonObject")
$oJson.UpdateInt("Limit",123)
$oJson.UpdateString("NextToken","string")
$oJson.UpdateString("OrganizationConfigRuleNames[0]","string")

; The JSON request body created by the above code:

; {
;   "Limit": number,
;   "NextToken": "string",
;   "OrganizationConfigRuleNames": [
;     "string"
;   ]
; }

$oRest.AddHeader("Content-Type","application/x-amz-json-1.1")
$oRest.AddHeader("X-Amz-Target","StarlingDoveService.DescribeOrganizationConfigRules")

$oSbRequestBody = ObjCreate("Chilkat_9_5_0.StringBuilder")
$oJson.EmitSb($oSbRequestBody)
$oSbResponseBody = ObjCreate("Chilkat_9_5_0.StringBuilder")
$bSuccess = $oRest.FullRequestSb("POST","/",$oSbRequestBody,$oSbResponseBody)
If ($bSuccess <> True) Then
    ConsoleWrite($oRest.LastErrorText & @CRLF)
    Exit
EndIf

Local $iRespStatusCode = $oRest.ResponseStatusCode
ConsoleWrite("response status code = " & $iRespStatusCode & @CRLF)
If ($iRespStatusCode <> 200) Then
    ConsoleWrite("Response Header:" & @CRLF)
    ConsoleWrite($oRest.ResponseHeader & @CRLF)
    ConsoleWrite("Response Body:" & @CRLF)
    ConsoleWrite($oSbResponseBody.GetAsString() & @CRLF)
    Exit
EndIf

$oJResp = ObjCreate("Chilkat_9_5_0.JsonObject")
$oJResp.LoadSb($oSbResponseBody)

; 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

Local $iLastUpdateTime
Local $sOrganizationConfigRuleArn
Local $sOrganizationConfigRuleName
Local $sDescription
Local $sInputParameters
Local $sMaximumExecutionFrequency
Local $sPolicyRuntime
Local $sResourceIdScope
Local $sTagKeyScope
Local $sTagValueScope
Local $sOrganizationCustomRuleMetadataDescription
Local $sOrganizationCustomRuleMetadataInputParameters
Local $sLambdaFunctionArn
Local $sOrganizationCustomRuleMetadataMaximumExecutionFrequency
Local $sOrganizationCustomRuleMetadataResourceIdScope
Local $sOrganizationCustomRuleMetadataTagKeyScope
Local $sOrganizationCustomRuleMetadataTagValueScope
Local $sOrganizationManagedRuleMetadataDescription
Local $sOrganizationManagedRuleMetadataInputParameters
Local $sOrganizationManagedRuleMetadataMaximumExecutionFrequency
Local $sOrganizationManagedRuleMetadataResourceIdScope
Local $sRuleIdentifier
Local $sOrganizationManagedRuleMetadataTagKeyScope
Local $sOrganizationManagedRuleMetadataTagValueScope
Local $iJ
Local $iCount_j
Local $strVal

Local $sNextToken = $oJResp.StringOf("NextToken")
Local $i = 0
Local $iCount_i = $oJResp.SizeOfArray("OrganizationConfigRules")
While $i < $iCount_i
    $oJResp.I = $i
    $iLastUpdateTime = $oJResp.IntOf("OrganizationConfigRules[i].LastUpdateTime")
    $sOrganizationConfigRuleArn = $oJResp.StringOf("OrganizationConfigRules[i].OrganizationConfigRuleArn")
    $sOrganizationConfigRuleName = $oJResp.StringOf("OrganizationConfigRules[i].OrganizationConfigRuleName")
    $sDescription = $oJResp.StringOf("OrganizationConfigRules[i].OrganizationCustomPolicyRuleMetadata.Description")
    $sInputParameters = $oJResp.StringOf("OrganizationConfigRules[i].OrganizationCustomPolicyRuleMetadata.InputParameters")
    $sMaximumExecutionFrequency = $oJResp.StringOf("OrganizationConfigRules[i].OrganizationCustomPolicyRuleMetadata.MaximumExecutionFrequency")
    $sPolicyRuntime = $oJResp.StringOf("OrganizationConfigRules[i].OrganizationCustomPolicyRuleMetadata.PolicyRuntime")
    $sResourceIdScope = $oJResp.StringOf("OrganizationConfigRules[i].OrganizationCustomPolicyRuleMetadata.ResourceIdScope")
    $sTagKeyScope = $oJResp.StringOf("OrganizationConfigRules[i].OrganizationCustomPolicyRuleMetadata.TagKeyScope")
    $sTagValueScope = $oJResp.StringOf("OrganizationConfigRules[i].OrganizationCustomPolicyRuleMetadata.TagValueScope")
    $sOrganizationCustomRuleMetadataDescription = $oJResp.StringOf("OrganizationConfigRules[i].OrganizationCustomRuleMetadata.Description")
    $sOrganizationCustomRuleMetadataInputParameters = $oJResp.StringOf("OrganizationConfigRules[i].OrganizationCustomRuleMetadata.InputParameters")
    $sLambdaFunctionArn = $oJResp.StringOf("OrganizationConfigRules[i].OrganizationCustomRuleMetadata.LambdaFunctionArn")
    $sOrganizationCustomRuleMetadataMaximumExecutionFrequency = $oJResp.StringOf("OrganizationConfigRules[i].OrganizationCustomRuleMetadata.MaximumExecutionFrequency")
    $sOrganizationCustomRuleMetadataResourceIdScope = $oJResp.StringOf("OrganizationConfigRules[i].OrganizationCustomRuleMetadata.ResourceIdScope")
    $sOrganizationCustomRuleMetadataTagKeyScope = $oJResp.StringOf("OrganizationConfigRules[i].OrganizationCustomRuleMetadata.TagKeyScope")
    $sOrganizationCustomRuleMetadataTagValueScope = $oJResp.StringOf("OrganizationConfigRules[i].OrganizationCustomRuleMetadata.TagValueScope")
    $sOrganizationManagedRuleMetadataDescription = $oJResp.StringOf("OrganizationConfigRules[i].OrganizationManagedRuleMetadata.Description")
    $sOrganizationManagedRuleMetadataInputParameters = $oJResp.StringOf("OrganizationConfigRules[i].OrganizationManagedRuleMetadata.InputParameters")
    $sOrganizationManagedRuleMetadataMaximumExecutionFrequency = $oJResp.StringOf("OrganizationConfigRules[i].OrganizationManagedRuleMetadata.MaximumExecutionFrequency")
    $sOrganizationManagedRuleMetadataResourceIdScope = $oJResp.StringOf("OrganizationConfigRules[i].OrganizationManagedRuleMetadata.ResourceIdScope")
    $sRuleIdentifier = $oJResp.StringOf("OrganizationConfigRules[i].OrganizationManagedRuleMetadata.RuleIdentifier")
    $sOrganizationManagedRuleMetadataTagKeyScope = $oJResp.StringOf("OrganizationConfigRules[i].OrganizationManagedRuleMetadata.TagKeyScope")
    $sOrganizationManagedRuleMetadataTagValueScope = $oJResp.StringOf("OrganizationConfigRules[i].OrganizationManagedRuleMetadata.TagValueScope")
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("OrganizationConfigRules[i].ExcludedAccounts")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $strVal = $oJResp.StringOf("OrganizationConfigRules[i].ExcludedAccounts[j]")
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("OrganizationConfigRules[i].OrganizationCustomPolicyRuleMetadata.DebugLogDeliveryAccounts")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $strVal = $oJResp.StringOf("OrganizationConfigRules[i].OrganizationCustomPolicyRuleMetadata.DebugLogDeliveryAccounts[j]")
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("OrganizationConfigRules[i].OrganizationCustomPolicyRuleMetadata.OrganizationConfigRuleTriggerTypes")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $strVal = $oJResp.StringOf("OrganizationConfigRules[i].OrganizationCustomPolicyRuleMetadata.OrganizationConfigRuleTriggerTypes[j]")
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("OrganizationConfigRules[i].OrganizationCustomPolicyRuleMetadata.ResourceTypesScope")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $strVal = $oJResp.StringOf("OrganizationConfigRules[i].OrganizationCustomPolicyRuleMetadata.ResourceTypesScope[j]")
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("OrganizationConfigRules[i].OrganizationCustomRuleMetadata.OrganizationConfigRuleTriggerTypes")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $strVal = $oJResp.StringOf("OrganizationConfigRules[i].OrganizationCustomRuleMetadata.OrganizationConfigRuleTriggerTypes[j]")
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("OrganizationConfigRules[i].OrganizationCustomRuleMetadata.ResourceTypesScope")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $strVal = $oJResp.StringOf("OrganizationConfigRules[i].OrganizationCustomRuleMetadata.ResourceTypesScope[j]")
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("OrganizationConfigRules[i].OrganizationManagedRuleMetadata.ResourceTypesScope")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $strVal = $oJResp.StringOf("OrganizationConfigRules[i].OrganizationManagedRuleMetadata.ResourceTypesScope[j]")
        $iJ = $iJ + 1
    Wend
    $i = $i + 1
Wend

; A sample JSON response body parsed by the above code:

; {
;   "NextToken": "string",
;   "OrganizationConfigRules": [
;     {
;       "ExcludedAccounts": [
;         "string"
;       ],
;       "LastUpdateTime": number,
;       "OrganizationConfigRuleArn": "string",
;       "OrganizationConfigRuleName": "string",
;       "OrganizationCustomPolicyRuleMetadata": {
;         "DebugLogDeliveryAccounts": [
;           "string"
;         ],
;         "Description": "string",
;         "InputParameters": "string",
;         "MaximumExecutionFrequency": "string",
;         "OrganizationConfigRuleTriggerTypes": [
;           "string"
;         ],
;         "PolicyRuntime": "string",
;         "ResourceIdScope": "string",
;         "ResourceTypesScope": [
;           "string"
;         ],
;         "TagKeyScope": "string",
;         "TagValueScope": "string"
;       },
;       "OrganizationCustomRuleMetadata": {
;         "Description": "string",
;         "InputParameters": "string",
;         "LambdaFunctionArn": "string",
;         "MaximumExecutionFrequency": "string",
;         "OrganizationConfigRuleTriggerTypes": [
;           "string"
;         ],
;         "ResourceIdScope": "string",
;         "ResourceTypesScope": [
;           "string"
;         ],
;         "TagKeyScope": "string",
;         "TagValueScope": "string"
;       },
;       "OrganizationManagedRuleMetadata": {
;         "Description": "string",
;         "InputParameters": "string",
;         "MaximumExecutionFrequency": "string",
;         "ResourceIdScope": "string",
;         "ResourceTypesScope": [
;           "string"
;         ],
;         "RuleIdentifier": "string",
;         "TagKeyScope": "string",
;         "TagValueScope": "string"
;       }
;     }
;   ]
; }