Chilkat Online Tools

DeleteCluster C# Example

Amazon Elastic Kubernetes Service

// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

Chilkat.Rest rest = new Chilkat.Rest();
bool success;

Chilkat.AuthAws authAws = new Chilkat.AuthAws();
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",443,true,true);
if (success != true) {
    Debug.WriteLine("ConnectFailReason: " + Convert.ToString(rest.ConnectFailReason));
    Debug.WriteLine(rest.LastErrorText);
    return;
}

rest.AddHeader("Content-Type","application/x-amz-json-1.1");
rest.AddHeader("X-Amz-Target","DeleteCluster");

Chilkat.StringBuilder sbResponseBody = new Chilkat.StringBuilder();
success = rest.FullRequestNoBodySb("DELETE","/clusters/{name}",sbResponseBody);
if (success != true) {
    Debug.WriteLine(rest.LastErrorText);
    return;
}

int respStatusCode = rest.ResponseStatusCode;
Debug.WriteLine("response status code = " + Convert.ToString(respStatusCode));
if (respStatusCode != 200) {
    Debug.WriteLine("Response Header:");
    Debug.WriteLine(rest.ResponseHeader);
    Debug.WriteLine("Response Body:");
    Debug.WriteLine(sbResponseBody.GetAsString());
    return;
}

Chilkat.JsonObject jResp = new Chilkat.JsonObject();
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

string KeyArn;
int j;
int count_j;
string strVal;
int enabled;

string Arn = jResp.StringOf("cluster.arn");
string Data = jResp.StringOf("cluster.certificateAuthority.data");
string ClientRequestToken = jResp.StringOf("cluster.clientRequestToken");
string ActivationCode = jResp.StringOf("cluster.connectorConfig.activationCode");
int ActivationExpiry = jResp.IntOf("cluster.connectorConfig.activationExpiry");
string ActivationId = jResp.StringOf("cluster.connectorConfig.activationId");
string Provider = jResp.StringOf("cluster.connectorConfig.provider");
string RoleArn = jResp.StringOf("cluster.connectorConfig.roleArn");
int CreatedAt = jResp.IntOf("cluster.createdAt");
string Endpoint = jResp.StringOf("cluster.endpoint");
string Issuer = jResp.StringOf("cluster.identity.oidc.issuer");
string IpFamily = jResp.StringOf("cluster.kubernetesNetworkConfig.ipFamily");
string ServiceIpv4Cidr = jResp.StringOf("cluster.kubernetesNetworkConfig.serviceIpv4Cidr");
string ServiceIpv6Cidr = jResp.StringOf("cluster.kubernetesNetworkConfig.serviceIpv6Cidr");
string Name = jResp.StringOf("cluster.name");
string PlatformVersion = jResp.StringOf("cluster.platformVersion");
string ClusterSecurityGroupId = jResp.StringOf("cluster.resourcesVpcConfig.clusterSecurityGroupId");
int EndpointPrivateAccess = jResp.IntOf("cluster.resourcesVpcConfig.endpointPrivateAccess");
int EndpointPublicAccess = jResp.IntOf("cluster.resourcesVpcConfig.endpointPublicAccess");
string VpcId = jResp.StringOf("cluster.resourcesVpcConfig.vpcId");
string clusterRoleArn = jResp.StringOf("cluster.roleArn");
string Status = jResp.StringOf("cluster.status");
string v_String = jResp.StringOf("cluster.tags.string");
string Version = jResp.StringOf("cluster.version");
int i = 0;
int count_i = jResp.SizeOfArray("cluster.encryptionConfig");
while (i < count_i) {
    jResp.I = i;
    KeyArn = jResp.StringOf("cluster.encryptionConfig[i].provider.keyArn");
    j = 0;
    count_j = jResp.SizeOfArray("cluster.encryptionConfig[i].resources");
    while (j < count_j) {
        jResp.J = j;
        strVal = jResp.StringOf("cluster.encryptionConfig[i].resources[j]");
        j = j + 1;
    }

    i = i + 1;
}

i = 0;
count_i = jResp.SizeOfArray("cluster.logging.clusterLogging");
while (i < count_i) {
    jResp.I = i;
    enabled = jResp.IntOf("cluster.logging.clusterLogging[i].enabled");
    j = 0;
    count_j = jResp.SizeOfArray("cluster.logging.clusterLogging[i].types");
    while (j < count_j) {
        jResp.J = 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");
while (i < count_i) {
    jResp.I = i;
    strVal = jResp.StringOf("cluster.resourcesVpcConfig.publicAccessCidrs[i]");
    i = i + 1;
}

i = 0;
count_i = jResp.SizeOfArray("cluster.resourcesVpcConfig.securityGroupIds");
while (i < count_i) {
    jResp.I = i;
    strVal = jResp.StringOf("cluster.resourcesVpcConfig.securityGroupIds[i]");
    i = i + 1;
}

i = 0;
count_i = jResp.SizeOfArray("cluster.resourcesVpcConfig.subnetIds");
while (i < count_i) {
    jResp.I = 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"
//   }
// }