CreateGraphqlApi autoit Example
; 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
; 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("additionalAuthenticationProviders[0].authenticationType","string")
$oJson.UpdateInt("additionalAuthenticationProviders[0].lambdaAuthorizerConfig.authorizerResultTtlInSeconds",123)
$oJson.UpdateString("additionalAuthenticationProviders[0].lambdaAuthorizerConfig.authorizerUri","string")
$oJson.UpdateString("additionalAuthenticationProviders[0].lambdaAuthorizerConfig.identityValidationExpression","string")
$oJson.UpdateInt("additionalAuthenticationProviders[0].openIDConnectConfig.authTTL",123)
$oJson.UpdateString("additionalAuthenticationProviders[0].openIDConnectConfig.clientId","string")
$oJson.UpdateInt("additionalAuthenticationProviders[0].openIDConnectConfig.iatTTL",123)
$oJson.UpdateString("additionalAuthenticationProviders[0].openIDConnectConfig.issuer","string")
$oJson.UpdateString("additionalAuthenticationProviders[0].userPoolConfig.appIdClientRegex","string")
$oJson.UpdateString("additionalAuthenticationProviders[0].userPoolConfig.awsRegion","string")
$oJson.UpdateString("additionalAuthenticationProviders[0].userPoolConfig.userPoolId","string")
$oJson.UpdateString("authenticationType","string")
$oJson.UpdateInt("lambdaAuthorizerConfig.authorizerResultTtlInSeconds",123)
$oJson.UpdateString("lambdaAuthorizerConfig.authorizerUri","string")
$oJson.UpdateString("lambdaAuthorizerConfig.identityValidationExpression","string")
$oJson.UpdateString("logConfig.cloudWatchLogsRoleArn","string")
$oJson.UpdateInt("logConfig.excludeVerboseContent",123)
$oJson.UpdateString("logConfig.fieldLogLevel","string")
$oJson.UpdateString("name","string")
$oJson.UpdateInt("openIDConnectConfig.authTTL",123)
$oJson.UpdateString("openIDConnectConfig.clientId","string")
$oJson.UpdateInt("openIDConnectConfig.iatTTL",123)
$oJson.UpdateString("openIDConnectConfig.issuer","string")
$oJson.UpdateString("tags.string","string")
$oJson.UpdateString("userPoolConfig.appIdClientRegex","string")
$oJson.UpdateString("userPoolConfig.awsRegion","string")
$oJson.UpdateString("userPoolConfig.defaultAction","string")
$oJson.UpdateString("userPoolConfig.userPoolId","string")
$oJson.UpdateInt("xrayEnabled",123)
; The JSON request body created by the above code:
; {
; "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"
; }
; }
; ],
; "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"
; },
; "userPoolConfig": {
; "appIdClientRegex": "string",
; "awsRegion": "string",
; "defaultAction": "string",
; "userPoolId": "string"
; },
; "xrayEnabled": boolean
; }
$oRest.AddHeader("Content-Type","application/x-amz-json-1.1")
$oRest.AddHeader("X-Amz-Target","CreateGraphqlApi")
$oSbRequestBody = ObjCreate("Chilkat_9_5_0.StringBuilder")
$oJson.EmitSb($oSbRequestBody)
$oSbResponseBody = ObjCreate("Chilkat_9_5_0.StringBuilder")
$bSuccess = $oRest.FullRequestSb("POST","/v1/apis",$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 $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
; }
; }