Chilkat Online Tools

GetGraphqlApi autoit Example

AWS AppSync

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

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

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

$oSbResponseBody = ObjCreate("Chilkat_9_5_0.StringBuilder")
$bSuccess = $oRest.FullRequestNoBodySb("GET","/v1/apis/{apiId}",$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 $sAuthenticationType
Local $iLambdaAuthorizerConfigAuthorizerResultTtlInSeconds
Local $sLambdaAuthorizerConfigAuthorizerUri
Local $sLambdaAuthorizerConfigIdentityValidationExpression
Local $iOpenIDConnectConfigAuthTTL
Local $sOpenIDConnectConfigClientId
Local $iOpenIDConnectConfigIatTTL
Local $sOpenIDConnectConfigIssuer
Local $sUserPoolConfigAppIdClientRegex
Local $sUserPoolConfigAwsRegion
Local $sUserPoolConfigUserPoolId

Local $sApiId = $oJResp.StringOf("graphqlApi.apiId")
Local $sArn = $oJResp.StringOf("graphqlApi.arn")
Local $sAuthenticationType = $oJResp.StringOf("graphqlApi.authenticationType")
Local $iAuthorizerResultTtlInSeconds = $oJResp.IntOf("graphqlApi.lambdaAuthorizerConfig.authorizerResultTtlInSeconds")
Local $sAuthorizerUri = $oJResp.StringOf("graphqlApi.lambdaAuthorizerConfig.authorizerUri")
Local $sIdentityValidationExpression = $oJResp.StringOf("graphqlApi.lambdaAuthorizerConfig.identityValidationExpression")
Local $sCloudWatchLogsRoleArn = $oJResp.StringOf("graphqlApi.logConfig.cloudWatchLogsRoleArn")
Local $iExcludeVerboseContent = $oJResp.IntOf("graphqlApi.logConfig.excludeVerboseContent")
Local $sFieldLogLevel = $oJResp.StringOf("graphqlApi.logConfig.fieldLogLevel")
Local $sName = $oJResp.StringOf("graphqlApi.name")
Local $iAuthTTL = $oJResp.IntOf("graphqlApi.openIDConnectConfig.authTTL")
Local $sClientId = $oJResp.StringOf("graphqlApi.openIDConnectConfig.clientId")
Local $iIatTTL = $oJResp.IntOf("graphqlApi.openIDConnectConfig.iatTTL")
Local $sIssuer = $oJResp.StringOf("graphqlApi.openIDConnectConfig.issuer")
Local $sV_String = $oJResp.StringOf("graphqlApi.tags.string")
Local $sUrisString = $oJResp.StringOf("graphqlApi.uris.string")
Local $sAppIdClientRegex = $oJResp.StringOf("graphqlApi.userPoolConfig.appIdClientRegex")
Local $sAwsRegion = $oJResp.StringOf("graphqlApi.userPoolConfig.awsRegion")
Local $sDefaultAction = $oJResp.StringOf("graphqlApi.userPoolConfig.defaultAction")
Local $sUserPoolId = $oJResp.StringOf("graphqlApi.userPoolConfig.userPoolId")
Local $sWafWebAclArn = $oJResp.StringOf("graphqlApi.wafWebAclArn")
Local $iXrayEnabled = $oJResp.IntOf("graphqlApi.xrayEnabled")
Local $i = 0
Local $iCount_i = $oJResp.SizeOfArray("graphqlApi.additionalAuthenticationProviders")
While $i < $iCount_i
    $oJResp.I = $i
    $sAuthenticationType = $oJResp.StringOf("graphqlApi.additionalAuthenticationProviders[i].authenticationType")
    $iLambdaAuthorizerConfigAuthorizerResultTtlInSeconds = $oJResp.IntOf("graphqlApi.additionalAuthenticationProviders[i].lambdaAuthorizerConfig.authorizerResultTtlInSeconds")
    $sLambdaAuthorizerConfigAuthorizerUri = $oJResp.StringOf("graphqlApi.additionalAuthenticationProviders[i].lambdaAuthorizerConfig.authorizerUri")
    $sLambdaAuthorizerConfigIdentityValidationExpression = $oJResp.StringOf("graphqlApi.additionalAuthenticationProviders[i].lambdaAuthorizerConfig.identityValidationExpression")
    $iOpenIDConnectConfigAuthTTL = $oJResp.IntOf("graphqlApi.additionalAuthenticationProviders[i].openIDConnectConfig.authTTL")
    $sOpenIDConnectConfigClientId = $oJResp.StringOf("graphqlApi.additionalAuthenticationProviders[i].openIDConnectConfig.clientId")
    $iOpenIDConnectConfigIatTTL = $oJResp.IntOf("graphqlApi.additionalAuthenticationProviders[i].openIDConnectConfig.iatTTL")
    $sOpenIDConnectConfigIssuer = $oJResp.StringOf("graphqlApi.additionalAuthenticationProviders[i].openIDConnectConfig.issuer")
    $sUserPoolConfigAppIdClientRegex = $oJResp.StringOf("graphqlApi.additionalAuthenticationProviders[i].userPoolConfig.appIdClientRegex")
    $sUserPoolConfigAwsRegion = $oJResp.StringOf("graphqlApi.additionalAuthenticationProviders[i].userPoolConfig.awsRegion")
    $sUserPoolConfigUserPoolId = $oJResp.StringOf("graphqlApi.additionalAuthenticationProviders[i].userPoolConfig.userPoolId")
    $i = $i + 1
Wend

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

; {
;   "graphqlApi": {
;     "additionalAuthenticationProviders": [
;       {
;         "authenticationType": "string",
;         "lambdaAuthorizerConfig": {
;           "authorizerResultTtlInSeconds": number,
;           "authorizerUri": "string",
;           "identityValidationExpression": "string"
;         },
;         "openIDConnectConfig": {
;           "authTTL": number,
;           "clientId": "string",
;           "iatTTL": number,
;           "issuer": "string"
;         },
;         "userPoolConfig": {
;           "appIdClientRegex": "string",
;           "awsRegion": "string",
;           "userPoolId": "string"
;         }
;       }
;     ],
;     "apiId": "string",
;     "arn": "string",
;     "authenticationType": "string",
;     "lambdaAuthorizerConfig": {
;       "authorizerResultTtlInSeconds": number,
;       "authorizerUri": "string",
;       "identityValidationExpression": "string"
;     },
;     "logConfig": {
;       "cloudWatchLogsRoleArn": "string",
;       "excludeVerboseContent": boolean,
;       "fieldLogLevel": "string"
;     },
;     "name": "string",
;     "openIDConnectConfig": {
;       "authTTL": number,
;       "clientId": "string",
;       "iatTTL": number,
;       "issuer": "string"
;     },
;     "tags": {
;       "string": "string"
;     },
;     "uris": {
;       "string": "string"
;     },
;     "userPoolConfig": {
;       "appIdClientRegex": "string",
;       "awsRegion": "string",
;       "defaultAction": "string",
;       "userPoolId": "string"
;     },
;     "wafWebAclArn": "string",
;     "xrayEnabled": boolean
;   }
; }