DeleteNodegroup Objective-C Example
#import <CkoRest.h>
#import <CkoAuthAws.h>
#import <CkoStringBuilder.h>
#import <CkoJsonObject.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 = @"eks";
// SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
[rest SetAuthAws: authAws];
// URL: https://eks.us-west-2.amazonaws.com/
// Use the same region as specified above.
success = [rest Connect: @"eks.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;
}
[rest AddHeader: @"Content-Type" value: @"application/x-amz-json-1.1"];
[rest AddHeader: @"X-Amz-Target" value: @"DeleteNodegroup"];
CkoStringBuilder *sbResponseBody = [[CkoStringBuilder alloc] init];
success = [rest FullRequestNoBodySb: @"DELETE" uriPath: @"/clusters/{name}/node-groups/{nodegroupName}" sb: 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 *code = 0;
NSString *message = 0;
int j;
int count_j;
NSString *strVal = 0;
NSString *name = 0;
NSString *effect = 0;
NSString *key = 0;
NSString *value = 0;
NSString *AmiType = [jResp StringOf: @"nodegroup.amiType"];
NSString *CapacityType = [jResp StringOf: @"nodegroup.capacityType"];
NSString *ClusterName = [jResp StringOf: @"nodegroup.clusterName"];
int CreatedAt = [[jResp IntOf: @"nodegroup.createdAt"] intValue];
int DiskSize = [[jResp IntOf: @"nodegroup.diskSize"] intValue];
NSString *v_String = [jResp StringOf: @"nodegroup.labels.string"];
NSString *Id = [jResp StringOf: @"nodegroup.launchTemplate.id"];
NSString *Name = [jResp StringOf: @"nodegroup.launchTemplate.name"];
NSString *Version = [jResp StringOf: @"nodegroup.launchTemplate.version"];
int ModifiedAt = [[jResp IntOf: @"nodegroup.modifiedAt"] intValue];
NSString *NodegroupArn = [jResp StringOf: @"nodegroup.nodegroupArn"];
NSString *NodegroupName = [jResp StringOf: @"nodegroup.nodegroupName"];
NSString *NodeRole = [jResp StringOf: @"nodegroup.nodeRole"];
NSString *ReleaseVersion = [jResp StringOf: @"nodegroup.releaseVersion"];
NSString *Ec2SshKey = [jResp StringOf: @"nodegroup.remoteAccess.ec2SshKey"];
NSString *RemoteAccessSecurityGroup = [jResp StringOf: @"nodegroup.resources.remoteAccessSecurityGroup"];
int DesiredSize = [[jResp IntOf: @"nodegroup.scalingConfig.desiredSize"] intValue];
int MaxSize = [[jResp IntOf: @"nodegroup.scalingConfig.maxSize"] intValue];
int MinSize = [[jResp IntOf: @"nodegroup.scalingConfig.minSize"] intValue];
NSString *Status = [jResp StringOf: @"nodegroup.status"];
NSString *TagsString = [jResp StringOf: @"nodegroup.tags.string"];
int MaxUnavailable = [[jResp IntOf: @"nodegroup.updateConfig.maxUnavailable"] intValue];
int MaxUnavailablePercentage = [[jResp IntOf: @"nodegroup.updateConfig.maxUnavailablePercentage"] intValue];
NSString *nodegroupVersion = [jResp StringOf: @"nodegroup.version"];
int i = 0;
int count_i = [[jResp SizeOfArray: @"nodegroup.health.issues"] intValue];
while (i < count_i) {
jResp.I = [NSNumber numberWithInt: i];
code = [jResp StringOf: @"nodegroup.health.issues[i].code"];
message = [jResp StringOf: @"nodegroup.health.issues[i].message"];
j = 0;
count_j = [[jResp SizeOfArray: @"nodegroup.health.issues[i].resourceIds"] intValue];
while (j < count_j) {
jResp.J = [NSNumber numberWithInt: j];
strVal = [jResp StringOf: @"nodegroup.health.issues[i].resourceIds[j]"];
j = j + 1;
}
i = i + 1;
}
i = 0;
count_i = [[jResp SizeOfArray: @"nodegroup.instanceTypes"] intValue];
while (i < count_i) {
jResp.I = [NSNumber numberWithInt: i];
strVal = [jResp StringOf: @"nodegroup.instanceTypes[i]"];
i = i + 1;
}
i = 0;
count_i = [[jResp SizeOfArray: @"nodegroup.remoteAccess.sourceSecurityGroups"] intValue];
while (i < count_i) {
jResp.I = [NSNumber numberWithInt: i];
strVal = [jResp StringOf: @"nodegroup.remoteAccess.sourceSecurityGroups[i]"];
i = i + 1;
}
i = 0;
count_i = [[jResp SizeOfArray: @"nodegroup.resources.autoScalingGroups"] intValue];
while (i < count_i) {
jResp.I = [NSNumber numberWithInt: i];
name = [jResp StringOf: @"nodegroup.resources.autoScalingGroups[i].name"];
i = i + 1;
}
i = 0;
count_i = [[jResp SizeOfArray: @"nodegroup.subnets"] intValue];
while (i < count_i) {
jResp.I = [NSNumber numberWithInt: i];
strVal = [jResp StringOf: @"nodegroup.subnets[i]"];
i = i + 1;
}
i = 0;
count_i = [[jResp SizeOfArray: @"nodegroup.taints"] intValue];
while (i < count_i) {
jResp.I = [NSNumber numberWithInt: i];
effect = [jResp StringOf: @"nodegroup.taints[i].effect"];
key = [jResp StringOf: @"nodegroup.taints[i].key"];
value = [jResp StringOf: @"nodegroup.taints[i].value"];
i = i + 1;
}
// A sample JSON response body parsed by the above code:
// {
// "nodegroup": {
// "amiType": "string",
// "capacityType": "string",
// "clusterName": "string",
// "createdAt": number,
// "diskSize": number,
// "health": {
// "issues": [
// {
// "code": "string",
// "message": "string",
// "resourceIds": [
// "string"
// ]
// }
// ]
// },
// "instanceTypes": [
// "string"
// ],
// "labels": {
// "string": "string"
// },
// "launchTemplate": {
// "id": "string",
// "name": "string",
// "version": "string"
// },
// "modifiedAt": number,
// "nodegroupArn": "string",
// "nodegroupName": "string",
// "nodeRole": "string",
// "releaseVersion": "string",
// "remoteAccess": {
// "ec2SshKey": "string",
// "sourceSecurityGroups": [
// "string"
// ]
// },
// "resources": {
// "autoScalingGroups": [
// {
// "name": "string"
// }
// ],
// "remoteAccessSecurityGroup": "string"
// },
// "scalingConfig": {
// "desiredSize": number,
// "maxSize": number,
// "minSize": number
// },
// "status": "string",
// "subnets": [
// "string"
// ],
// "tags": {
// "string": "string"
// },
// "taints": [
// {
// "effect": "string",
// "key": "string",
// "value": "string"
// }
// ],
// "updateConfig": {
// "maxUnavailable": number,
// "maxUnavailablePercentage": number
// },
// "version": "string"
// }
// }