Chilkat Online Tools

DescribeRuleGroup autoit Example

AWS Network Firewall

; 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 = "network-firewall"
; SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
$oRest.SetAuthAws($oAuthAws)

; URL: https://network-firewall.us-west-2.amazonaws.com/
; Use the same region as specified above.
$bSuccess = $oRest.Connect("network-firewall.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.UpdateString("RuleGroupArn","string")
$oJson.UpdateString("RuleGroupName","string")
$oJson.UpdateString("Type","string")

; The JSON request body created by the above code:

; {
;   "RuleGroupArn": "string",
;   "RuleGroupName": "string",
;   "Type": "string"
; }

$oRest.AddHeader("Content-Type","application/x-amz-json-1.0")
$oRest.AddHeader("X-Amz-Target","NetworkFirewall_20201112.DescribeRuleGroup")

$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 $strVal
Local $sAction
Local $sDestination
Local $sDestinationPort
Local $sDirection
Local $sProtocol
Local $sSource
Local $sSourcePort
Local $iJ
Local $iCount_j
Local $sKeyword
Local $iK
Local $iCount_k
Local $sActionName
Local $sValue
Local $iPriority
Local $iFromPort
Local $iToPort
Local $sAddressDefinition
Local $intVal
Local $sKey

Local $sGeneratedRulesType = $oJResp.StringOf("RuleGroup.RulesSource.RulesSourceList.GeneratedRulesType")
Local $sRulesString = $oJResp.StringOf("RuleGroup.RulesSource.RulesString")
Local $sRuleOrder = $oJResp.StringOf("RuleGroup.StatefulRuleOptions.RuleOrder")
Local $iCapacity = $oJResp.IntOf("RuleGroupResponse.Capacity")
Local $iConsumedCapacity = $oJResp.IntOf("RuleGroupResponse.ConsumedCapacity")
Local $sDescription = $oJResp.StringOf("RuleGroupResponse.Description")
Local $sKeyId = $oJResp.StringOf("RuleGroupResponse.EncryptionConfiguration.KeyId")
Local $sV_Type = $oJResp.StringOf("RuleGroupResponse.EncryptionConfiguration.Type")
Local $iLastModifiedTime = $oJResp.IntOf("RuleGroupResponse.LastModifiedTime")
Local $iNumberOfAssociations = $oJResp.IntOf("RuleGroupResponse.NumberOfAssociations")
Local $sRuleGroupArn = $oJResp.StringOf("RuleGroupResponse.RuleGroupArn")
Local $sRuleGroupId = $oJResp.StringOf("RuleGroupResponse.RuleGroupId")
Local $sRuleGroupName = $oJResp.StringOf("RuleGroupResponse.RuleGroupName")
Local $sRuleGroupStatus = $oJResp.StringOf("RuleGroupResponse.RuleGroupStatus")
Local $sSnsTopic = $oJResp.StringOf("RuleGroupResponse.SnsTopic")
Local $sSourceArn = $oJResp.StringOf("RuleGroupResponse.SourceMetadata.SourceArn")
Local $sSourceUpdateToken = $oJResp.StringOf("RuleGroupResponse.SourceMetadata.SourceUpdateToken")
Local $sRuleGroupResponseType = $oJResp.StringOf("RuleGroupResponse.Type")
Local $sUpdateToken = $oJResp.StringOf("UpdateToken")
Local $i = 0
Local $iCount_i = $oJResp.SizeOfArray("RuleGroup.RulesSource.RulesSourceList.Targets")
While $i < $iCount_i
    $oJResp.I = $i
    $strVal = $oJResp.StringOf("RuleGroup.RulesSource.RulesSourceList.Targets[i]")
    $i = $i + 1
Wend
$i = 0
$iCount_i = $oJResp.SizeOfArray("RuleGroup.RulesSource.RulesSourceList.TargetTypes")
While $i < $iCount_i
    $oJResp.I = $i
    $strVal = $oJResp.StringOf("RuleGroup.RulesSource.RulesSourceList.TargetTypes[i]")
    $i = $i + 1
Wend
$i = 0
$iCount_i = $oJResp.SizeOfArray("RuleGroup.RulesSource.StatefulRules")
While $i < $iCount_i
    $oJResp.I = $i
    $sAction = $oJResp.StringOf("RuleGroup.RulesSource.StatefulRules[i].Action")
    $sDestination = $oJResp.StringOf("RuleGroup.RulesSource.StatefulRules[i].Header.Destination")
    $sDestinationPort = $oJResp.StringOf("RuleGroup.RulesSource.StatefulRules[i].Header.DestinationPort")
    $sDirection = $oJResp.StringOf("RuleGroup.RulesSource.StatefulRules[i].Header.Direction")
    $sProtocol = $oJResp.StringOf("RuleGroup.RulesSource.StatefulRules[i].Header.Protocol")
    $sSource = $oJResp.StringOf("RuleGroup.RulesSource.StatefulRules[i].Header.Source")
    $sSourcePort = $oJResp.StringOf("RuleGroup.RulesSource.StatefulRules[i].Header.SourcePort")
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("RuleGroup.RulesSource.StatefulRules[i].RuleOptions")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $sKeyword = $oJResp.StringOf("RuleGroup.RulesSource.StatefulRules[i].RuleOptions[j].Keyword")
        $iK = 0
        $iCount_k = $oJResp.SizeOfArray("RuleGroup.RulesSource.StatefulRules[i].RuleOptions[j].Settings")
        While $iK < $iCount_k
            $oJResp.K = $iK
            $strVal = $oJResp.StringOf("RuleGroup.RulesSource.StatefulRules[i].RuleOptions[j].Settings[k]")
            $iK = $iK + 1
        Wend
        $iJ = $iJ + 1
    Wend
    $i = $i + 1
Wend
$i = 0
$iCount_i = $oJResp.SizeOfArray("RuleGroup.RulesSource.StatelessRulesAndCustomActions.CustomActions")
While $i < $iCount_i
    $oJResp.I = $i
    $sActionName = $oJResp.StringOf("RuleGroup.RulesSource.StatelessRulesAndCustomActions.CustomActions[i].ActionName")
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("RuleGroup.RulesSource.StatelessRulesAndCustomActions.CustomActions[i].ActionDefinition.PublishMetricAction.Dimensions")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $sValue = $oJResp.StringOf("RuleGroup.RulesSource.StatelessRulesAndCustomActions.CustomActions[i].ActionDefinition.PublishMetricAction.Dimensions[j].Value")
        $iJ = $iJ + 1
    Wend
    $i = $i + 1
Wend
$i = 0
$iCount_i = $oJResp.SizeOfArray("RuleGroup.RulesSource.StatelessRulesAndCustomActions.StatelessRules")
While $i < $iCount_i
    $oJResp.I = $i
    $iPriority = $oJResp.IntOf("RuleGroup.RulesSource.StatelessRulesAndCustomActions.StatelessRules[i].Priority")
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("RuleGroup.RulesSource.StatelessRulesAndCustomActions.StatelessRules[i].RuleDefinition.Actions")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $strVal = $oJResp.StringOf("RuleGroup.RulesSource.StatelessRulesAndCustomActions.StatelessRules[i].RuleDefinition.Actions[j]")
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("RuleGroup.RulesSource.StatelessRulesAndCustomActions.StatelessRules[i].RuleDefinition.MatchAttributes.DestinationPorts")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $iFromPort = $oJResp.IntOf("RuleGroup.RulesSource.StatelessRulesAndCustomActions.StatelessRules[i].RuleDefinition.MatchAttributes.DestinationPorts[j].FromPort")
        $iToPort = $oJResp.IntOf("RuleGroup.RulesSource.StatelessRulesAndCustomActions.StatelessRules[i].RuleDefinition.MatchAttributes.DestinationPorts[j].ToPort")
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("RuleGroup.RulesSource.StatelessRulesAndCustomActions.StatelessRules[i].RuleDefinition.MatchAttributes.Destinations")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $sAddressDefinition = $oJResp.StringOf("RuleGroup.RulesSource.StatelessRulesAndCustomActions.StatelessRules[i].RuleDefinition.MatchAttributes.Destinations[j].AddressDefinition")
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("RuleGroup.RulesSource.StatelessRulesAndCustomActions.StatelessRules[i].RuleDefinition.MatchAttributes.Protocols")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $intVal = $oJResp.IntOf("RuleGroup.RulesSource.StatelessRulesAndCustomActions.StatelessRules[i].RuleDefinition.MatchAttributes.Protocols[j]")
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("RuleGroup.RulesSource.StatelessRulesAndCustomActions.StatelessRules[i].RuleDefinition.MatchAttributes.SourcePorts")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $iFromPort = $oJResp.IntOf("RuleGroup.RulesSource.StatelessRulesAndCustomActions.StatelessRules[i].RuleDefinition.MatchAttributes.SourcePorts[j].FromPort")
        $iToPort = $oJResp.IntOf("RuleGroup.RulesSource.StatelessRulesAndCustomActions.StatelessRules[i].RuleDefinition.MatchAttributes.SourcePorts[j].ToPort")
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("RuleGroup.RulesSource.StatelessRulesAndCustomActions.StatelessRules[i].RuleDefinition.MatchAttributes.Sources")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $sAddressDefinition = $oJResp.StringOf("RuleGroup.RulesSource.StatelessRulesAndCustomActions.StatelessRules[i].RuleDefinition.MatchAttributes.Sources[j].AddressDefinition")
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("RuleGroup.RulesSource.StatelessRulesAndCustomActions.StatelessRules[i].RuleDefinition.MatchAttributes.TCPFlags")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $iK = 0
        $iCount_k = $oJResp.SizeOfArray("RuleGroup.RulesSource.StatelessRulesAndCustomActions.StatelessRules[i].RuleDefinition.MatchAttributes.TCPFlags[j].Flags")
        While $iK < $iCount_k
            $oJResp.K = $iK
            $strVal = $oJResp.StringOf("RuleGroup.RulesSource.StatelessRulesAndCustomActions.StatelessRules[i].RuleDefinition.MatchAttributes.TCPFlags[j].Flags[k]")
            $iK = $iK + 1
        Wend
        $iK = 0
        $iCount_k = $oJResp.SizeOfArray("RuleGroup.RulesSource.StatelessRulesAndCustomActions.StatelessRules[i].RuleDefinition.MatchAttributes.TCPFlags[j].Masks")
        While $iK < $iCount_k
            $oJResp.K = $iK
            $strVal = $oJResp.StringOf("RuleGroup.RulesSource.StatelessRulesAndCustomActions.StatelessRules[i].RuleDefinition.MatchAttributes.TCPFlags[j].Masks[k]")
            $iK = $iK + 1
        Wend
        $iJ = $iJ + 1
    Wend
    $i = $i + 1
Wend
$i = 0
$iCount_i = $oJResp.SizeOfArray("RuleGroup.RuleVariables.IPSets.string.Definition")
While $i < $iCount_i
    $oJResp.I = $i
    $strVal = $oJResp.StringOf("RuleGroup.RuleVariables.IPSets.string.Definition[i]")
    $i = $i + 1
Wend
$i = 0
$iCount_i = $oJResp.SizeOfArray("RuleGroup.RuleVariables.PortSets.string.Definition")
While $i < $iCount_i
    $oJResp.I = $i
    $strVal = $oJResp.StringOf("RuleGroup.RuleVariables.PortSets.string.Definition[i]")
    $i = $i + 1
Wend
$i = 0
$iCount_i = $oJResp.SizeOfArray("RuleGroupResponse.Tags")
While $i < $iCount_i
    $oJResp.I = $i
    $sKey = $oJResp.StringOf("RuleGroupResponse.Tags[i].Key")
    $sValue = $oJResp.StringOf("RuleGroupResponse.Tags[i].Value")
    $i = $i + 1
Wend

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

; {
;   "RuleGroup": {
;     "RulesSource": {
;       "RulesSourceList": {
;         "GeneratedRulesType": "string",
;         "Targets": [
;           "string"
;         ],
;         "TargetTypes": [
;           "string"
;         ]
;       },
;       "RulesString": "string",
;       "StatefulRules": [
;         {
;           "Action": "string",
;           "Header": {
;             "Destination": "string",
;             "DestinationPort": "string",
;             "Direction": "string",
;             "Protocol": "string",
;             "Source": "string",
;             "SourcePort": "string"
;           },
;           "RuleOptions": [
;             {
;               "Keyword": "string",
;               "Settings": [
;                 "string"
;               ]
;             }
;           ]
;         }
;       ],
;       "StatelessRulesAndCustomActions": {
;         "CustomActions": [
;           {
;             "ActionDefinition": {
;               "PublishMetricAction": {
;                 "Dimensions": [
;                   {
;                     "Value": "string"
;                   }
;                 ]
;               }
;             },
;             "ActionName": "string"
;           }
;         ],
;         "StatelessRules": [
;           {
;             "Priority": number,
;             "RuleDefinition": {
;               "Actions": [
;                 "string"
;               ],
;               "MatchAttributes": {
;                 "DestinationPorts": [
;                   {
;                     "FromPort": number,
;                     "ToPort": number
;                   }
;                 ],
;                 "Destinations": [
;                   {
;                     "AddressDefinition": "string"
;                   }
;                 ],
;                 "Protocols": [
;                   number
;                 ],
;                 "SourcePorts": [
;                   {
;                     "FromPort": number,
;                     "ToPort": number
;                   }
;                 ],
;                 "Sources": [
;                   {
;                     "AddressDefinition": "string"
;                   }
;                 ],
;                 "TCPFlags": [
;                   {
;                     "Flags": [
;                       "string"
;                     ],
;                     "Masks": [
;                       "string"
;                     ]
;                   }
;                 ]
;               }
;             }
;           }
;         ]
;       }
;     },
;     "RuleVariables": {
;       "IPSets": {
;         "string": {
;           "Definition": [
;             "string"
;           ]
;         }
;       },
;       "PortSets": {
;         "string": {
;           "Definition": [
;             "string"
;           ]
;         }
;       }
;     },
;     "StatefulRuleOptions": {
;       "RuleOrder": "string"
;     }
;   },
;   "RuleGroupResponse": {
;     "Capacity": number,
;     "ConsumedCapacity": number,
;     "Description": "string",
;     "EncryptionConfiguration": {
;       "KeyId": "string",
;       "Type": "string"
;     },
;     "LastModifiedTime": number,
;     "NumberOfAssociations": number,
;     "RuleGroupArn": "string",
;     "RuleGroupId": "string",
;     "RuleGroupName": "string",
;     "RuleGroupStatus": "string",
;     "SnsTopic": "string",
;     "SourceMetadata": {
;       "SourceArn": "string",
;       "SourceUpdateToken": "string"
;     },
;     "Tags": [
;       {
;         "Key": "string",
;         "Value": "string"
;       }
;     ],
;     "Type": "string"
;   },
;   "UpdateToken": "string"
; }