UpdateGraphqlApi Objective-C Example
#import <CkoRest.h>
#import <CkoAuthAws.h>
#import <CkoJsonObject.h>
#import <CkoStringBuilder.h>
#import <NSString.h>
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkoRest *rest = [[CkoRest alloc] init];
BOOL success;
CkoAuthAws *authAws = [[CkoAuthAws alloc] init];
authAws.AccessKey = @"AWS_ACCESS_KEY";
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.)
authAws.Region = @"us-west-2";
authAws.ServiceName = @"appsync";
// SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
[rest SetAuthAws: authAws];
// URL: https://appsync.us-west-2.amazonaws.com/
// Use the same region as specified above.
success = [rest Connect: @"appsync.us-west-2.amazonaws.com" port: [NSNumber numberWithInt: 443] tls: YES autoReconnect: YES];
if (success != YES) {
NSLog(@"%@%d",@"ConnectFailReason: ",[rest.ConnectFailReason intValue]);
NSLog(@"%@",rest.LastErrorText);
return;
}
// 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
CkoJsonObject *json = [[CkoJsonObject alloc] init];
[json UpdateString: @"additionalAuthenticationProviders[0].authenticationType" value: @"string"];
[json UpdateInt: @"additionalAuthenticationProviders[0].lambdaAuthorizerConfig.authorizerResultTtlInSeconds" value: [NSNumber numberWithInt: 123]];
[json UpdateString: @"additionalAuthenticationProviders[0].lambdaAuthorizerConfig.authorizerUri" value: @"string"];
[json UpdateString: @"additionalAuthenticationProviders[0].lambdaAuthorizerConfig.identityValidationExpression" value: @"string"];
[json UpdateInt: @"additionalAuthenticationProviders[0].openIDConnectConfig.authTTL" value: [NSNumber numberWithInt: 123]];
[json UpdateString: @"additionalAuthenticationProviders[0].openIDConnectConfig.clientId" value: @"string"];
[json UpdateInt: @"additionalAuthenticationProviders[0].openIDConnectConfig.iatTTL" value: [NSNumber numberWithInt: 123]];
[json UpdateString: @"additionalAuthenticationProviders[0].openIDConnectConfig.issuer" value: @"string"];
[json UpdateString: @"additionalAuthenticationProviders[0].userPoolConfig.appIdClientRegex" value: @"string"];
[json UpdateString: @"additionalAuthenticationProviders[0].userPoolConfig.awsRegion" value: @"string"];
[json UpdateString: @"additionalAuthenticationProviders[0].userPoolConfig.userPoolId" value: @"string"];
[json UpdateString: @"authenticationType" value: @"string"];
[json UpdateInt: @"lambdaAuthorizerConfig.authorizerResultTtlInSeconds" value: [NSNumber numberWithInt: 123]];
[json UpdateString: @"lambdaAuthorizerConfig.authorizerUri" value: @"string"];
[json UpdateString: @"lambdaAuthorizerConfig.identityValidationExpression" value: @"string"];
[json UpdateString: @"logConfig.cloudWatchLogsRoleArn" value: @"string"];
[json UpdateInt: @"logConfig.excludeVerboseContent" value: [NSNumber numberWithInt: 123]];
[json UpdateString: @"logConfig.fieldLogLevel" value: @"string"];
[json UpdateString: @"name" value: @"string"];
[json UpdateInt: @"openIDConnectConfig.authTTL" value: [NSNumber numberWithInt: 123]];
[json UpdateString: @"openIDConnectConfig.clientId" value: @"string"];
[json UpdateInt: @"openIDConnectConfig.iatTTL" value: [NSNumber numberWithInt: 123]];
[json UpdateString: @"openIDConnectConfig.issuer" value: @"string"];
[json UpdateString: @"userPoolConfig.appIdClientRegex" value: @"string"];
[json UpdateString: @"userPoolConfig.awsRegion" value: @"string"];
[json UpdateString: @"userPoolConfig.defaultAction" value: @"string"];
[json UpdateString: @"userPoolConfig.userPoolId" value: @"string"];
[json UpdateInt: @"xrayEnabled" value: [NSNumber numberWithInt: 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"
// },
// "userPoolConfig": {
// "appIdClientRegex": "string",
// "awsRegion": "string",
// "defaultAction": "string",
// "userPoolId": "string"
// },
// "xrayEnabled": boolean
// }
[rest AddHeader: @"Content-Type" value: @"application/x-amz-json-1.1"];
[rest AddHeader: @"X-Amz-Target" value: @"UpdateGraphqlApi"];
CkoStringBuilder *sbRequestBody = [[CkoStringBuilder alloc] init];
[json EmitSb: sbRequestBody];
CkoStringBuilder *sbResponseBody = [[CkoStringBuilder alloc] init];
success = [rest FullRequestSb: @"POST" uriPath: @"/v1/apis/{apiId}" requestBody: sbRequestBody responseBody: sbResponseBody];
if (success != YES) {
NSLog(@"%@",rest.LastErrorText);
return;
}
int respStatusCode = [rest.ResponseStatusCode intValue];
NSLog(@"%@%d",@"response status code = ",respStatusCode);
if (respStatusCode != 200) {
NSLog(@"%@",@"Response Header:");
NSLog(@"%@",rest.ResponseHeader);
NSLog(@"%@",@"Response Body:");
NSLog(@"%@",[sbResponseBody GetAsString]);
return;
}
CkoJsonObject *jResp = [[CkoJsonObject alloc] init];
[jResp LoadSb: 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
NSString *authenticationType = 0;
int lambdaAuthorizerConfigAuthorizerResultTtlInSeconds;
NSString *lambdaAuthorizerConfigAuthorizerUri = 0;
NSString *lambdaAuthorizerConfigIdentityValidationExpression = 0;
int openIDConnectConfigAuthTTL;
NSString *openIDConnectConfigClientId = 0;
int openIDConnectConfigIatTTL;
NSString *openIDConnectConfigIssuer = 0;
NSString *userPoolConfigAppIdClientRegex = 0;
NSString *userPoolConfigAwsRegion = 0;
NSString *userPoolConfigUserPoolId = 0;
NSString *ApiId = [jResp StringOf: @"graphqlApi.apiId"];
NSString *Arn = [jResp StringOf: @"graphqlApi.arn"];
NSString *AuthenticationType = [jResp StringOf: @"graphqlApi.authenticationType"];
int AuthorizerResultTtlInSeconds = [[jResp IntOf: @"graphqlApi.lambdaAuthorizerConfig.authorizerResultTtlInSeconds"] intValue];
NSString *AuthorizerUri = [jResp StringOf: @"graphqlApi.lambdaAuthorizerConfig.authorizerUri"];
NSString *IdentityValidationExpression = [jResp StringOf: @"graphqlApi.lambdaAuthorizerConfig.identityValidationExpression"];
NSString *CloudWatchLogsRoleArn = [jResp StringOf: @"graphqlApi.logConfig.cloudWatchLogsRoleArn"];
int ExcludeVerboseContent = [[jResp IntOf: @"graphqlApi.logConfig.excludeVerboseContent"] intValue];
NSString *FieldLogLevel = [jResp StringOf: @"graphqlApi.logConfig.fieldLogLevel"];
NSString *Name = [jResp StringOf: @"graphqlApi.name"];
int AuthTTL = [[jResp IntOf: @"graphqlApi.openIDConnectConfig.authTTL"] intValue];
NSString *ClientId = [jResp StringOf: @"graphqlApi.openIDConnectConfig.clientId"];
int IatTTL = [[jResp IntOf: @"graphqlApi.openIDConnectConfig.iatTTL"] intValue];
NSString *Issuer = [jResp StringOf: @"graphqlApi.openIDConnectConfig.issuer"];
NSString *v_String = [jResp StringOf: @"graphqlApi.tags.string"];
NSString *UrisString = [jResp StringOf: @"graphqlApi.uris.string"];
NSString *AppIdClientRegex = [jResp StringOf: @"graphqlApi.userPoolConfig.appIdClientRegex"];
NSString *AwsRegion = [jResp StringOf: @"graphqlApi.userPoolConfig.awsRegion"];
NSString *DefaultAction = [jResp StringOf: @"graphqlApi.userPoolConfig.defaultAction"];
NSString *UserPoolId = [jResp StringOf: @"graphqlApi.userPoolConfig.userPoolId"];
NSString *WafWebAclArn = [jResp StringOf: @"graphqlApi.wafWebAclArn"];
int XrayEnabled = [[jResp IntOf: @"graphqlApi.xrayEnabled"] intValue];
int i = 0;
int count_i = [[jResp SizeOfArray: @"graphqlApi.additionalAuthenticationProviders"] intValue];
while (i < count_i) {
jResp.I = [NSNumber numberWithInt: i];
authenticationType = [jResp StringOf: @"graphqlApi.additionalAuthenticationProviders[i].authenticationType"];
lambdaAuthorizerConfigAuthorizerResultTtlInSeconds = [[jResp IntOf: @"graphqlApi.additionalAuthenticationProviders[i].lambdaAuthorizerConfig.authorizerResultTtlInSeconds"] intValue];
lambdaAuthorizerConfigAuthorizerUri = [jResp StringOf: @"graphqlApi.additionalAuthenticationProviders[i].lambdaAuthorizerConfig.authorizerUri"];
lambdaAuthorizerConfigIdentityValidationExpression = [jResp StringOf: @"graphqlApi.additionalAuthenticationProviders[i].lambdaAuthorizerConfig.identityValidationExpression"];
openIDConnectConfigAuthTTL = [[jResp IntOf: @"graphqlApi.additionalAuthenticationProviders[i].openIDConnectConfig.authTTL"] intValue];
openIDConnectConfigClientId = [jResp StringOf: @"graphqlApi.additionalAuthenticationProviders[i].openIDConnectConfig.clientId"];
openIDConnectConfigIatTTL = [[jResp IntOf: @"graphqlApi.additionalAuthenticationProviders[i].openIDConnectConfig.iatTTL"] intValue];
openIDConnectConfigIssuer = [jResp StringOf: @"graphqlApi.additionalAuthenticationProviders[i].openIDConnectConfig.issuer"];
userPoolConfigAppIdClientRegex = [jResp StringOf: @"graphqlApi.additionalAuthenticationProviders[i].userPoolConfig.appIdClientRegex"];
userPoolConfigAwsRegion = [jResp StringOf: @"graphqlApi.additionalAuthenticationProviders[i].userPoolConfig.awsRegion"];
userPoolConfigUserPoolId = [jResp StringOf: @"graphqlApi.additionalAuthenticationProviders[i].userPoolConfig.userPoolId"];
i = i + 1;
}
// 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
// }
// }