UpdateGraphqlApi DataFlex Example
Use ChilkatAx-9.5.0-win32.pkg
Procedure Test
Handle hoRest
Boolean iSuccess
Variant vAuthAws
Handle hoAuthAws
Handle hoJson
Variant vSbRequestBody
Handle hoSbRequestBody
Variant vSbResponseBody
Handle hoSbResponseBody
Integer iRespStatusCode
Handle hoJResp
String sAuthenticationType
Integer iLambdaAuthorizerConfigAuthorizerResultTtlInSeconds
String sLambdaAuthorizerConfigAuthorizerUri
String sLambdaAuthorizerConfigIdentityValidationExpression
Integer iOpenIDConnectConfigAuthTTL
String sOpenIDConnectConfigClientId
Integer iOpenIDConnectConfigIatTTL
String sOpenIDConnectConfigIssuer
String sUserPoolConfigAppIdClientRegex
String sUserPoolConfigAwsRegion
String sUserPoolConfigUserPoolId
String sApiId
String sArn
String sAuthenticationType
Integer iAuthorizerResultTtlInSeconds
String sAuthorizerUri
String sIdentityValidationExpression
String sCloudWatchLogsRoleArn
Integer iExcludeVerboseContent
String sFieldLogLevel
String sName
Integer iAuthTTL
String sClientId
Integer iIatTTL
String sIssuer
String sV_String
String sUrisString
String sAppIdClientRegex
String sAwsRegion
String sDefaultAction
String sUserPoolId
String sWafWebAclArn
Integer iXrayEnabled
Integer i
Integer iCount_i
String sTemp1
Integer iTemp1
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Get Create (RefClass(cComChilkatRest)) To hoRest
If (Not(IsComObjectCreated(hoRest))) Begin
Send CreateComObject of hoRest
End
Get Create (RefClass(cComChilkatAuthAws)) To hoAuthAws
If (Not(IsComObjectCreated(hoAuthAws))) Begin
Send CreateComObject of hoAuthAws
End
Set ComAccessKey Of hoAuthAws To "AWS_ACCESS_KEY"
Set ComSecretKey Of hoAuthAws To "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.)
Set ComRegion Of hoAuthAws To "us-west-2"
Set ComServiceName Of hoAuthAws To "appsync"
// SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
Get pvComObject of hoAuthAws to vAuthAws
Get ComSetAuthAws Of hoRest vAuthAws To iSuccess
// URL: https://appsync.us-west-2.amazonaws.com/
// Use the same region as specified above.
Get ComConnect Of hoRest "appsync.us-west-2.amazonaws.com" 443 True True To iSuccess
If (iSuccess <> True) Begin
Get ComConnectFailReason Of hoRest To iTemp1
Showln "ConnectFailReason: " iTemp1
Get ComLastErrorText Of hoRest To sTemp1
Showln sTemp1
Procedure_Return
End
// 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
Get Create (RefClass(cComChilkatJsonObject)) To hoJson
If (Not(IsComObjectCreated(hoJson))) Begin
Send CreateComObject of hoJson
End
Get ComUpdateString Of hoJson "additionalAuthenticationProviders[0].authenticationType" "string" To iSuccess
Get ComUpdateInt Of hoJson "additionalAuthenticationProviders[0].lambdaAuthorizerConfig.authorizerResultTtlInSeconds" 123 To iSuccess
Get ComUpdateString Of hoJson "additionalAuthenticationProviders[0].lambdaAuthorizerConfig.authorizerUri" "string" To iSuccess
Get ComUpdateString Of hoJson "additionalAuthenticationProviders[0].lambdaAuthorizerConfig.identityValidationExpression" "string" To iSuccess
Get ComUpdateInt Of hoJson "additionalAuthenticationProviders[0].openIDConnectConfig.authTTL" 123 To iSuccess
Get ComUpdateString Of hoJson "additionalAuthenticationProviders[0].openIDConnectConfig.clientId" "string" To iSuccess
Get ComUpdateInt Of hoJson "additionalAuthenticationProviders[0].openIDConnectConfig.iatTTL" 123 To iSuccess
Get ComUpdateString Of hoJson "additionalAuthenticationProviders[0].openIDConnectConfig.issuer" "string" To iSuccess
Get ComUpdateString Of hoJson "additionalAuthenticationProviders[0].userPoolConfig.appIdClientRegex" "string" To iSuccess
Get ComUpdateString Of hoJson "additionalAuthenticationProviders[0].userPoolConfig.awsRegion" "string" To iSuccess
Get ComUpdateString Of hoJson "additionalAuthenticationProviders[0].userPoolConfig.userPoolId" "string" To iSuccess
Get ComUpdateString Of hoJson "authenticationType" "string" To iSuccess
Get ComUpdateInt Of hoJson "lambdaAuthorizerConfig.authorizerResultTtlInSeconds" 123 To iSuccess
Get ComUpdateString Of hoJson "lambdaAuthorizerConfig.authorizerUri" "string" To iSuccess
Get ComUpdateString Of hoJson "lambdaAuthorizerConfig.identityValidationExpression" "string" To iSuccess
Get ComUpdateString Of hoJson "logConfig.cloudWatchLogsRoleArn" "string" To iSuccess
Get ComUpdateInt Of hoJson "logConfig.excludeVerboseContent" 123 To iSuccess
Get ComUpdateString Of hoJson "logConfig.fieldLogLevel" "string" To iSuccess
Get ComUpdateString Of hoJson "name" "string" To iSuccess
Get ComUpdateInt Of hoJson "openIDConnectConfig.authTTL" 123 To iSuccess
Get ComUpdateString Of hoJson "openIDConnectConfig.clientId" "string" To iSuccess
Get ComUpdateInt Of hoJson "openIDConnectConfig.iatTTL" 123 To iSuccess
Get ComUpdateString Of hoJson "openIDConnectConfig.issuer" "string" To iSuccess
Get ComUpdateString Of hoJson "userPoolConfig.appIdClientRegex" "string" To iSuccess
Get ComUpdateString Of hoJson "userPoolConfig.awsRegion" "string" To iSuccess
Get ComUpdateString Of hoJson "userPoolConfig.defaultAction" "string" To iSuccess
Get ComUpdateString Of hoJson "userPoolConfig.userPoolId" "string" To iSuccess
Get ComUpdateInt Of hoJson "xrayEnabled" 123 To iSuccess
// 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"
// },
// "userPoolConfig": {
// "appIdClientRegex": "string",
// "awsRegion": "string",
// "defaultAction": "string",
// "userPoolId": "string"
// },
// "xrayEnabled": boolean
// }
Get ComAddHeader Of hoRest "Content-Type" "application/x-amz-json-1.1" To iSuccess
Get ComAddHeader Of hoRest "X-Amz-Target" "UpdateGraphqlApi" To iSuccess
Get Create (RefClass(cComChilkatStringBuilder)) To hoSbRequestBody
If (Not(IsComObjectCreated(hoSbRequestBody))) Begin
Send CreateComObject of hoSbRequestBody
End
Get pvComObject of hoSbRequestBody to vSbRequestBody
Get ComEmitSb Of hoJson vSbRequestBody To iSuccess
Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
Send CreateComObject of hoSbResponseBody
End
Get pvComObject of hoSbRequestBody to vSbRequestBody
Get pvComObject of hoSbResponseBody to vSbResponseBody
Get ComFullRequestSb Of hoRest "POST" "/v1/apis/{apiId}" vSbRequestBody vSbResponseBody To iSuccess
If (iSuccess <> True) Begin
Get ComLastErrorText Of hoRest To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComResponseStatusCode Of hoRest To iRespStatusCode
Showln "response status code = " iRespStatusCode
If (iRespStatusCode <> 200) Begin
Showln "Response Header:"
Get ComResponseHeader Of hoRest To sTemp1
Showln sTemp1
Showln "Response Body:"
Get ComGetAsString Of hoSbResponseBody To sTemp1
Showln sTemp1
Procedure_Return
End
Get Create (RefClass(cComChilkatJsonObject)) To hoJResp
If (Not(IsComObjectCreated(hoJResp))) Begin
Send CreateComObject of hoJResp
End
Get pvComObject of hoSbResponseBody to vSbResponseBody
Get ComLoadSb Of hoJResp vSbResponseBody To iSuccess
// 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
Get ComStringOf Of hoJResp "graphqlApi.apiId" To sApiId
Get ComStringOf Of hoJResp "graphqlApi.arn" To sArn
Get ComStringOf Of hoJResp "graphqlApi.authenticationType" To sAuthenticationType
Get ComIntOf Of hoJResp "graphqlApi.lambdaAuthorizerConfig.authorizerResultTtlInSeconds" To iAuthorizerResultTtlInSeconds
Get ComStringOf Of hoJResp "graphqlApi.lambdaAuthorizerConfig.authorizerUri" To sAuthorizerUri
Get ComStringOf Of hoJResp "graphqlApi.lambdaAuthorizerConfig.identityValidationExpression" To sIdentityValidationExpression
Get ComStringOf Of hoJResp "graphqlApi.logConfig.cloudWatchLogsRoleArn" To sCloudWatchLogsRoleArn
Get ComIntOf Of hoJResp "graphqlApi.logConfig.excludeVerboseContent" To iExcludeVerboseContent
Get ComStringOf Of hoJResp "graphqlApi.logConfig.fieldLogLevel" To sFieldLogLevel
Get ComStringOf Of hoJResp "graphqlApi.name" To sName
Get ComIntOf Of hoJResp "graphqlApi.openIDConnectConfig.authTTL" To iAuthTTL
Get ComStringOf Of hoJResp "graphqlApi.openIDConnectConfig.clientId" To sClientId
Get ComIntOf Of hoJResp "graphqlApi.openIDConnectConfig.iatTTL" To iIatTTL
Get ComStringOf Of hoJResp "graphqlApi.openIDConnectConfig.issuer" To sIssuer
Get ComStringOf Of hoJResp "graphqlApi.tags.string" To sV_String
Get ComStringOf Of hoJResp "graphqlApi.uris.string" To sUrisString
Get ComStringOf Of hoJResp "graphqlApi.userPoolConfig.appIdClientRegex" To sAppIdClientRegex
Get ComStringOf Of hoJResp "graphqlApi.userPoolConfig.awsRegion" To sAwsRegion
Get ComStringOf Of hoJResp "graphqlApi.userPoolConfig.defaultAction" To sDefaultAction
Get ComStringOf Of hoJResp "graphqlApi.userPoolConfig.userPoolId" To sUserPoolId
Get ComStringOf Of hoJResp "graphqlApi.wafWebAclArn" To sWafWebAclArn
Get ComIntOf Of hoJResp "graphqlApi.xrayEnabled" To iXrayEnabled
Move 0 To i
Get ComSizeOfArray Of hoJResp "graphqlApi.additionalAuthenticationProviders" To iCount_i
While (i < iCount_i)
Set ComI Of hoJResp To i
Get ComStringOf Of hoJResp "graphqlApi.additionalAuthenticationProviders[i].authenticationType" To sAuthenticationType
Get ComIntOf Of hoJResp "graphqlApi.additionalAuthenticationProviders[i].lambdaAuthorizerConfig.authorizerResultTtlInSeconds" To iLambdaAuthorizerConfigAuthorizerResultTtlInSeconds
Get ComStringOf Of hoJResp "graphqlApi.additionalAuthenticationProviders[i].lambdaAuthorizerConfig.authorizerUri" To sLambdaAuthorizerConfigAuthorizerUri
Get ComStringOf Of hoJResp "graphqlApi.additionalAuthenticationProviders[i].lambdaAuthorizerConfig.identityValidationExpression" To sLambdaAuthorizerConfigIdentityValidationExpression
Get ComIntOf Of hoJResp "graphqlApi.additionalAuthenticationProviders[i].openIDConnectConfig.authTTL" To iOpenIDConnectConfigAuthTTL
Get ComStringOf Of hoJResp "graphqlApi.additionalAuthenticationProviders[i].openIDConnectConfig.clientId" To sOpenIDConnectConfigClientId
Get ComIntOf Of hoJResp "graphqlApi.additionalAuthenticationProviders[i].openIDConnectConfig.iatTTL" To iOpenIDConnectConfigIatTTL
Get ComStringOf Of hoJResp "graphqlApi.additionalAuthenticationProviders[i].openIDConnectConfig.issuer" To sOpenIDConnectConfigIssuer
Get ComStringOf Of hoJResp "graphqlApi.additionalAuthenticationProviders[i].userPoolConfig.appIdClientRegex" To sUserPoolConfigAppIdClientRegex
Get ComStringOf Of hoJResp "graphqlApi.additionalAuthenticationProviders[i].userPoolConfig.awsRegion" To sUserPoolConfigAwsRegion
Get ComStringOf Of hoJResp "graphqlApi.additionalAuthenticationProviders[i].userPoolConfig.userPoolId" To sUserPoolConfigUserPoolId
Move (i + 1) To i
Loop
// 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
// }
// }
End_Procedure