DeleteCluster 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: @"DeleteCluster"];
CkoStringBuilder *sbResponseBody = [[CkoStringBuilder alloc] init];
success = [rest FullRequestNoBodySb: @"DELETE" uriPath: @"/clusters/{name}" 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 *KeyArn = 0;
int j;
int count_j;
NSString *strVal = 0;
int enabled;
NSString *Arn = [jResp StringOf: @"cluster.arn"];
NSString *Data = [jResp StringOf: @"cluster.certificateAuthority.data"];
NSString *ClientRequestToken = [jResp StringOf: @"cluster.clientRequestToken"];
NSString *ActivationCode = [jResp StringOf: @"cluster.connectorConfig.activationCode"];
int ActivationExpiry = [[jResp IntOf: @"cluster.connectorConfig.activationExpiry"] intValue];
NSString *ActivationId = [jResp StringOf: @"cluster.connectorConfig.activationId"];
NSString *Provider = [jResp StringOf: @"cluster.connectorConfig.provider"];
NSString *RoleArn = [jResp StringOf: @"cluster.connectorConfig.roleArn"];
int CreatedAt = [[jResp IntOf: @"cluster.createdAt"] intValue];
NSString *Endpoint = [jResp StringOf: @"cluster.endpoint"];
NSString *Issuer = [jResp StringOf: @"cluster.identity.oidc.issuer"];
NSString *IpFamily = [jResp StringOf: @"cluster.kubernetesNetworkConfig.ipFamily"];
NSString *ServiceIpv4Cidr = [jResp StringOf: @"cluster.kubernetesNetworkConfig.serviceIpv4Cidr"];
NSString *ServiceIpv6Cidr = [jResp StringOf: @"cluster.kubernetesNetworkConfig.serviceIpv6Cidr"];
NSString *Name = [jResp StringOf: @"cluster.name"];
NSString *PlatformVersion = [jResp StringOf: @"cluster.platformVersion"];
NSString *ClusterSecurityGroupId = [jResp StringOf: @"cluster.resourcesVpcConfig.clusterSecurityGroupId"];
int EndpointPrivateAccess = [[jResp IntOf: @"cluster.resourcesVpcConfig.endpointPrivateAccess"] intValue];
int EndpointPublicAccess = [[jResp IntOf: @"cluster.resourcesVpcConfig.endpointPublicAccess"] intValue];
NSString *VpcId = [jResp StringOf: @"cluster.resourcesVpcConfig.vpcId"];
NSString *clusterRoleArn = [jResp StringOf: @"cluster.roleArn"];
NSString *Status = [jResp StringOf: @"cluster.status"];
NSString *v_String = [jResp StringOf: @"cluster.tags.string"];
NSString *Version = [jResp StringOf: @"cluster.version"];
int i = 0;
int count_i = [[jResp SizeOfArray: @"cluster.encryptionConfig"] intValue];
while (i < count_i) {
jResp.I = [NSNumber numberWithInt: i];
KeyArn = [jResp StringOf: @"cluster.encryptionConfig[i].provider.keyArn"];
j = 0;
count_j = [[jResp SizeOfArray: @"cluster.encryptionConfig[i].resources"] intValue];
while (j < count_j) {
jResp.J = [NSNumber numberWithInt: j];
strVal = [jResp StringOf: @"cluster.encryptionConfig[i].resources[j]"];
j = j + 1;
}
i = i + 1;
}
i = 0;
count_i = [[jResp SizeOfArray: @"cluster.logging.clusterLogging"] intValue];
while (i < count_i) {
jResp.I = [NSNumber numberWithInt: i];
enabled = [[jResp IntOf: @"cluster.logging.clusterLogging[i].enabled"] intValue];
j = 0;
count_j = [[jResp SizeOfArray: @"cluster.logging.clusterLogging[i].types"] intValue];
while (j < count_j) {
jResp.J = [NSNumber numberWithInt: j];
strVal = [jResp StringOf: @"cluster.logging.clusterLogging[i].types[j]"];
j = j + 1;
}
i = i + 1;
}
i = 0;
count_i = [[jResp SizeOfArray: @"cluster.resourcesVpcConfig.publicAccessCidrs"] intValue];
while (i < count_i) {
jResp.I = [NSNumber numberWithInt: i];
strVal = [jResp StringOf: @"cluster.resourcesVpcConfig.publicAccessCidrs[i]"];
i = i + 1;
}
i = 0;
count_i = [[jResp SizeOfArray: @"cluster.resourcesVpcConfig.securityGroupIds"] intValue];
while (i < count_i) {
jResp.I = [NSNumber numberWithInt: i];
strVal = [jResp StringOf: @"cluster.resourcesVpcConfig.securityGroupIds[i]"];
i = i + 1;
}
i = 0;
count_i = [[jResp SizeOfArray: @"cluster.resourcesVpcConfig.subnetIds"] intValue];
while (i < count_i) {
jResp.I = [NSNumber numberWithInt: i];
strVal = [jResp StringOf: @"cluster.resourcesVpcConfig.subnetIds[i]"];
i = i + 1;
}
// A sample JSON response body parsed by the above code:
// {
// "cluster": {
// "arn": "string",
// "certificateAuthority": {
// "data": "string"
// },
// "clientRequestToken": "string",
// "connectorConfig": {
// "activationCode": "string",
// "activationExpiry": number,
// "activationId": "string",
// "provider": "string",
// "roleArn": "string"
// },
// "createdAt": number,
// "encryptionConfig": [
// {
// "provider": {
// "keyArn": "string"
// },
// "resources": [
// "string"
// ]
// }
// ],
// "endpoint": "string",
// "identity": {
// "oidc": {
// "issuer": "string"
// }
// },
// "kubernetesNetworkConfig": {
// "ipFamily": "string",
// "serviceIpv4Cidr": "string",
// "serviceIpv6Cidr": "string"
// },
// "logging": {
// "clusterLogging": [
// {
// "enabled": boolean,
// "types": [
// "string"
// ]
// }
// ]
// },
// "name": "string",
// "platformVersion": "string",
// "resourcesVpcConfig": {
// "clusterSecurityGroupId": "string",
// "endpointPrivateAccess": boolean,
// "endpointPublicAccess": boolean,
// "publicAccessCidrs": [
// "string"
// ],
// "securityGroupIds": [
// "string"
// ],
// "subnetIds": [
// "string"
// ],
// "vpcId": "string"
// },
// "roleArn": "string",
// "status": "string",
// "tags": {
// "string": "string"
// },
// "version": "string"
// }
// }