Chilkat Online Tools

PutLoggingConfiguration PowerBuilder Example

AWS WAFV2

integer li_rc
oleobject loo_Rest
integer li_Success
oleobject loo_AuthAws
oleobject loo_Json
oleobject loo_SbRequestBody
oleobject loo_SbResponseBody
integer li_RespStatusCode
oleobject loo_JResp
string ls_StrVal
string ls_Behavior
string ls_Requirement
integer j
integer li_Count_j
string ls_Action
string ls_LabelName
string ls_OversizeHandling
string ls_MatchScope
string ls_CookiesOversizeHandling
string ls_HeadersMatchScope
string ls_HeadersOversizeHandling
string ls_InvalidFallbackBehavior
string ls_JsonBodyMatchScope
string ls_JsonBodyOversizeHandling
string ls_Name
string ls_SingleQueryArgumentName
string ls_DefaultBehavior
integer li_ManagedByFirewallManager
string ls_ResourceArn
integer i
integer li_Count_i

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

loo_Rest = create oleobject
li_rc = loo_Rest.ConnectToNewObject("Chilkat_9_5_0.Rest")
if li_rc < 0 then
    destroy loo_Rest
    MessageBox("Error","Connecting to COM object failed")
    return
end if

loo_AuthAws = create oleobject
li_rc = loo_AuthAws.ConnectToNewObject("Chilkat_9_5_0.AuthAws")

loo_AuthAws.AccessKey = "AWS_ACCESS_KEY"
loo_AuthAws.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.)
loo_AuthAws.Region = "us-west-2"
loo_AuthAws.ServiceName = "wafv2"
// SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
loo_Rest.SetAuthAws(loo_AuthAws)

// URL: https://wafv2.us-west-2.amazonaws.com/
// Use the same region as specified above.
li_Success = loo_Rest.Connect("wafv2.us-west-2.amazonaws.com",443,1,1)
if li_Success <> 1 then
    Write-Debug "ConnectFailReason: " + string(loo_Rest.ConnectFailReason)
    Write-Debug loo_Rest.LastErrorText
    destroy loo_Rest
    destroy loo_AuthAws
    return
end if

// 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

loo_Json = create oleobject
li_rc = loo_Json.ConnectToNewObject("Chilkat_9_5_0.JsonObject")

loo_Json.UpdateString("LoggingConfiguration.LogDestinationConfigs[0]","string")
loo_Json.UpdateString("LoggingConfiguration.LoggingFilter.DefaultBehavior","string")
loo_Json.UpdateString("LoggingConfiguration.LoggingFilter.Filters[0].Behavior","string")
loo_Json.UpdateString("LoggingConfiguration.LoggingFilter.Filters[0].Conditions[0].ActionCondition.Action","string")
loo_Json.UpdateString("LoggingConfiguration.LoggingFilter.Filters[0].Conditions[0].LabelNameCondition.LabelName","string")
loo_Json.UpdateString("LoggingConfiguration.LoggingFilter.Filters[0].Requirement","string")
loo_Json.UpdateInt("LoggingConfiguration.ManagedByFirewallManager",123)
loo_Json.UpdateNewObject("LoggingConfiguration.RedactedFields[0].AllQueryArguments")
loo_Json.UpdateString("LoggingConfiguration.RedactedFields[0].Body.OversizeHandling","string")
loo_Json.UpdateNewObject("LoggingConfiguration.RedactedFields[0].Cookies.MatchPattern.All")
loo_Json.UpdateString("LoggingConfiguration.RedactedFields[0].Cookies.MatchPattern.ExcludedCookies[0]","string")
loo_Json.UpdateString("LoggingConfiguration.RedactedFields[0].Cookies.MatchPattern.IncludedCookies[0]","string")
loo_Json.UpdateString("LoggingConfiguration.RedactedFields[0].Cookies.MatchScope","string")
loo_Json.UpdateString("LoggingConfiguration.RedactedFields[0].Cookies.OversizeHandling","string")
loo_Json.UpdateNewObject("LoggingConfiguration.RedactedFields[0].Headers.MatchPattern.All")
loo_Json.UpdateString("LoggingConfiguration.RedactedFields[0].Headers.MatchPattern.ExcludedHeaders[0]","string")
loo_Json.UpdateString("LoggingConfiguration.RedactedFields[0].Headers.MatchPattern.IncludedHeaders[0]","string")
loo_Json.UpdateString("LoggingConfiguration.RedactedFields[0].Headers.MatchScope","string")
loo_Json.UpdateString("LoggingConfiguration.RedactedFields[0].Headers.OversizeHandling","string")
loo_Json.UpdateString("LoggingConfiguration.RedactedFields[0].JsonBody.InvalidFallbackBehavior","string")
loo_Json.UpdateNewObject("LoggingConfiguration.RedactedFields[0].JsonBody.MatchPattern.All")
loo_Json.UpdateString("LoggingConfiguration.RedactedFields[0].JsonBody.MatchPattern.IncludedPaths[0]","string")
loo_Json.UpdateString("LoggingConfiguration.RedactedFields[0].JsonBody.MatchScope","string")
loo_Json.UpdateString("LoggingConfiguration.RedactedFields[0].JsonBody.OversizeHandling","string")
loo_Json.UpdateNewObject("LoggingConfiguration.RedactedFields[0].Method")
loo_Json.UpdateNewObject("LoggingConfiguration.RedactedFields[0].QueryString")
loo_Json.UpdateString("LoggingConfiguration.RedactedFields[0].SingleHeader.Name","string")
loo_Json.UpdateString("LoggingConfiguration.RedactedFields[0].SingleQueryArgument.Name","string")
loo_Json.UpdateNewObject("LoggingConfiguration.RedactedFields[0].UriPath")
loo_Json.UpdateString("LoggingConfiguration.ResourceArn","string")

// The JSON request body created by the above code:

// {
//   "LoggingConfiguration": {
//     "LogDestinationConfigs": [
//       "string"
//     ],
//     "LoggingFilter": {
//       "DefaultBehavior": "string",
//       "Filters": [
//         {
//           "Behavior": "string",
//           "Conditions": [
//             {
//               "ActionCondition": {
//                 "Action": "string"
//               },
//               "LabelNameCondition": {
//                 "LabelName": "string"
//               }
//             }
//           ],
//           "Requirement": "string"
//         }
//       ]
//     },
//     "ManagedByFirewallManager": boolean,
//     "RedactedFields": [
//       {
//         "AllQueryArguments": {},
//         "Body": {
//           "OversizeHandling": "string"
//         },
//         "Cookies": {
//           "MatchPattern": {
//             "All": {},
//             "ExcludedCookies": [
//               "string"
//             ],
//             "IncludedCookies": [
//               "string"
//             ]
//           },
//           "MatchScope": "string",
//           "OversizeHandling": "string"
//         },
//         "Headers": {
//           "MatchPattern": {
//             "All": {},
//             "ExcludedHeaders": [
//               "string"
//             ],
//             "IncludedHeaders": [
//               "string"
//             ]
//           },
//           "MatchScope": "string",
//           "OversizeHandling": "string"
//         },
//         "JsonBody": {
//           "InvalidFallbackBehavior": "string",
//           "MatchPattern": {
//             "All": {},
//             "IncludedPaths": [
//               "string"
//             ]
//           },
//           "MatchScope": "string",
//           "OversizeHandling": "string"
//         },
//         "Method": {},
//         "QueryString": {},
//         "SingleHeader": {
//           "Name": "string"
//         },
//         "SingleQueryArgument": {
//           "Name": "string"
//         },
//         "UriPath": {}
//       }
//     ],
//     "ResourceArn": "string"
//   }
// }

loo_Rest.AddHeader("Content-Type","application/x-amz-json-1.1")
loo_Rest.AddHeader("X-Amz-Target","AWSWAF_20190729.PutLoggingConfiguration")

loo_SbRequestBody = create oleobject
li_rc = loo_SbRequestBody.ConnectToNewObject("Chilkat_9_5_0.StringBuilder")

loo_Json.EmitSb(loo_SbRequestBody)
loo_SbResponseBody = create oleobject
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat_9_5_0.StringBuilder")

li_Success = loo_Rest.FullRequestSb("POST","/",loo_SbRequestBody,loo_SbResponseBody)
if li_Success <> 1 then
    Write-Debug loo_Rest.LastErrorText
    destroy loo_Rest
    destroy loo_AuthAws
    destroy loo_Json
    destroy loo_SbRequestBody
    destroy loo_SbResponseBody
    return
end if

li_RespStatusCode = loo_Rest.ResponseStatusCode
Write-Debug "response status code = " + string(li_RespStatusCode)
if li_RespStatusCode <> 200 then
    Write-Debug "Response Header:"
    Write-Debug loo_Rest.ResponseHeader
    Write-Debug "Response Body:"
    Write-Debug loo_SbResponseBody.GetAsString()
    destroy loo_Rest
    destroy loo_AuthAws
    destroy loo_Json
    destroy loo_SbRequestBody
    destroy loo_SbResponseBody
    return
end if

loo_JResp = create oleobject
li_rc = loo_JResp.ConnectToNewObject("Chilkat_9_5_0.JsonObject")

loo_JResp.LoadSb(loo_SbResponseBody)

// 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

ls_DefaultBehavior = loo_JResp.StringOf("LoggingConfiguration.LoggingFilter.DefaultBehavior")
li_ManagedByFirewallManager = loo_JResp.IntOf("LoggingConfiguration.ManagedByFirewallManager")
ls_ResourceArn = loo_JResp.StringOf("LoggingConfiguration.ResourceArn")
i = 0
li_Count_i = loo_JResp.SizeOfArray("LoggingConfiguration.LogDestinationConfigs")
do while i < li_Count_i
    loo_JResp.I = i
    ls_StrVal = loo_JResp.StringOf("LoggingConfiguration.LogDestinationConfigs[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_JResp.SizeOfArray("LoggingConfiguration.LoggingFilter.Filters")
do while i < li_Count_i
    loo_JResp.I = i
    ls_Behavior = loo_JResp.StringOf("LoggingConfiguration.LoggingFilter.Filters[i].Behavior")
    ls_Requirement = loo_JResp.StringOf("LoggingConfiguration.LoggingFilter.Filters[i].Requirement")
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("LoggingConfiguration.LoggingFilter.Filters[i].Conditions")
    do while j < li_Count_j
        loo_JResp.J = j
        ls_Action = loo_JResp.StringOf("LoggingConfiguration.LoggingFilter.Filters[i].Conditions[j].ActionCondition.Action")
        ls_LabelName = loo_JResp.StringOf("LoggingConfiguration.LoggingFilter.Filters[i].Conditions[j].LabelNameCondition.LabelName")
        j = j + 1
    loop
    i = i + 1
loop
i = 0
li_Count_i = loo_JResp.SizeOfArray("LoggingConfiguration.RedactedFields")
do while i < li_Count_i
    loo_JResp.I = i
    ls_OversizeHandling = loo_JResp.StringOf("LoggingConfiguration.RedactedFields[i].Body.OversizeHandling")
    ls_MatchScope = loo_JResp.StringOf("LoggingConfiguration.RedactedFields[i].Cookies.MatchScope")
    ls_CookiesOversizeHandling = loo_JResp.StringOf("LoggingConfiguration.RedactedFields[i].Cookies.OversizeHandling")
    ls_HeadersMatchScope = loo_JResp.StringOf("LoggingConfiguration.RedactedFields[i].Headers.MatchScope")
    ls_HeadersOversizeHandling = loo_JResp.StringOf("LoggingConfiguration.RedactedFields[i].Headers.OversizeHandling")
    ls_InvalidFallbackBehavior = loo_JResp.StringOf("LoggingConfiguration.RedactedFields[i].JsonBody.InvalidFallbackBehavior")
    ls_JsonBodyMatchScope = loo_JResp.StringOf("LoggingConfiguration.RedactedFields[i].JsonBody.MatchScope")
    ls_JsonBodyOversizeHandling = loo_JResp.StringOf("LoggingConfiguration.RedactedFields[i].JsonBody.OversizeHandling")
    ls_Name = loo_JResp.StringOf("LoggingConfiguration.RedactedFields[i].SingleHeader.Name")
    ls_SingleQueryArgumentName = loo_JResp.StringOf("LoggingConfiguration.RedactedFields[i].SingleQueryArgument.Name")
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("LoggingConfiguration.RedactedFields[i].Cookies.MatchPattern.ExcludedCookies")
    do while j < li_Count_j
        loo_JResp.J = j
        ls_StrVal = loo_JResp.StringOf("LoggingConfiguration.RedactedFields[i].Cookies.MatchPattern.ExcludedCookies[j]")
        j = j + 1
    loop
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("LoggingConfiguration.RedactedFields[i].Cookies.MatchPattern.IncludedCookies")
    do while j < li_Count_j
        loo_JResp.J = j
        ls_StrVal = loo_JResp.StringOf("LoggingConfiguration.RedactedFields[i].Cookies.MatchPattern.IncludedCookies[j]")
        j = j + 1
    loop
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("LoggingConfiguration.RedactedFields[i].Headers.MatchPattern.ExcludedHeaders")
    do while j < li_Count_j
        loo_JResp.J = j
        ls_StrVal = loo_JResp.StringOf("LoggingConfiguration.RedactedFields[i].Headers.MatchPattern.ExcludedHeaders[j]")
        j = j + 1
    loop
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("LoggingConfiguration.RedactedFields[i].Headers.MatchPattern.IncludedHeaders")
    do while j < li_Count_j
        loo_JResp.J = j
        ls_StrVal = loo_JResp.StringOf("LoggingConfiguration.RedactedFields[i].Headers.MatchPattern.IncludedHeaders[j]")
        j = j + 1
    loop
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("LoggingConfiguration.RedactedFields[i].JsonBody.MatchPattern.IncludedPaths")
    do while j < li_Count_j
        loo_JResp.J = j
        ls_StrVal = loo_JResp.StringOf("LoggingConfiguration.RedactedFields[i].JsonBody.MatchPattern.IncludedPaths[j]")
        j = j + 1
    loop
    i = i + 1
loop

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

// {
//   "LoggingConfiguration": {
//     "LogDestinationConfigs": [
//       "string"
//     ],
//     "LoggingFilter": {
//       "DefaultBehavior": "string",
//       "Filters": [
//         {
//           "Behavior": "string",
//           "Conditions": [
//             {
//               "ActionCondition": {
//                 "Action": "string"
//               },
//               "LabelNameCondition": {
//                 "LabelName": "string"
//               }
//             }
//           ],
//           "Requirement": "string"
//         }
//       ]
//     },
//     "ManagedByFirewallManager": boolean,
//     "RedactedFields": [
//       {
//         "AllQueryArguments": {},
//         "Body": {
//           "OversizeHandling": "string"
//         },
//         "Cookies": {
//           "MatchPattern": {
//             "All": {},
//             "ExcludedCookies": [
//               "string"
//             ],
//             "IncludedCookies": [
//               "string"
//             ]
//           },
//           "MatchScope": "string",
//           "OversizeHandling": "string"
//         },
//         "Headers": {
//           "MatchPattern": {
//             "All": {},
//             "ExcludedHeaders": [
//               "string"
//             ],
//             "IncludedHeaders": [
//               "string"
//             ]
//           },
//           "MatchScope": "string",
//           "OversizeHandling": "string"
//         },
//         "JsonBody": {
//           "InvalidFallbackBehavior": "string",
//           "MatchPattern": {
//             "All": {},
//             "IncludedPaths": [
//               "string"
//             ]
//           },
//           "MatchScope": "string",
//           "OversizeHandling": "string"
//         },
//         "Method": {},
//         "QueryString": {},
//         "SingleHeader": {
//           "Name": "string"
//         },
//         "SingleQueryArgument": {
//           "Name": "string"
//         },
//         "UriPath": {}
//       }
//     ],
//     "ResourceArn": "string"
//   }
// }


destroy loo_Rest
destroy loo_AuthAws
destroy loo_Json
destroy loo_SbRequestBody
destroy loo_SbResponseBody
destroy loo_JResp