Chilkat Online Tools

DeleteCluster delphiDll Example

Amazon Elastic Kubernetes Service

var
rest: HCkRest;
success: Boolean;
authAws: HCkAuthAws;
sbResponseBody: HCkStringBuilder;
respStatusCode: Integer;
jResp: HCkJsonObject;
KeyArn: PWideChar;
j: Integer;
count_j: Integer;
strVal: PWideChar;
enabled: Integer;
Arn: PWideChar;
Data: PWideChar;
ClientRequestToken: PWideChar;
ActivationCode: PWideChar;
ActivationExpiry: Integer;
ActivationId: PWideChar;
Provider: PWideChar;
RoleArn: PWideChar;
CreatedAt: Integer;
Endpoint: PWideChar;
Issuer: PWideChar;
IpFamily: PWideChar;
ServiceIpv4Cidr: PWideChar;
ServiceIpv6Cidr: PWideChar;
Name: PWideChar;
PlatformVersion: PWideChar;
ClusterSecurityGroupId: PWideChar;
EndpointPrivateAccess: Integer;
EndpointPublicAccess: Integer;
VpcId: PWideChar;
clusterRoleArn: PWideChar;
Status: PWideChar;
v_String: PWideChar;
Version: PWideChar;
i: Integer;
count_i: Integer;

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

rest := CkRest_Create();

authAws := CkAuthAws_Create();
CkAuthAws_putAccessKey(authAws,'AWS_ACCESS_KEY');
CkAuthAws_putSecretKey(authAws,'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.)
CkAuthAws_putRegion(authAws,'us-west-2');
CkAuthAws_putServiceName(authAws,'eks');
// SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
CkRest_SetAuthAws(rest,authAws);

// URL: https://eks.us-west-2.amazonaws.com/
// Use the same region as specified above.
success := CkRest_Connect(rest,'eks.us-west-2.amazonaws.com',443,True,True);
if (success <> True) then
  begin
    Memo1.Lines.Add('ConnectFailReason: ' + IntToStr(CkRest_getConnectFailReason(rest)));
    Memo1.Lines.Add(CkRest__lastErrorText(rest));
    Exit;
  end;

CkRest_AddHeader(rest,'Content-Type','application/x-amz-json-1.1');
CkRest_AddHeader(rest,'X-Amz-Target','DeleteCluster');

sbResponseBody := CkStringBuilder_Create();
success := CkRest_FullRequestNoBodySb(rest,'DELETE','/clusters/{name}',sbResponseBody);
if (success <> True) then
  begin
    Memo1.Lines.Add(CkRest__lastErrorText(rest));
    Exit;
  end;
respStatusCode := CkRest_getResponseStatusCode(rest);
Memo1.Lines.Add('response status code = ' + IntToStr(respStatusCode));
if (respStatusCode <> 200) then
  begin
    Memo1.Lines.Add('Response Header:');
    Memo1.Lines.Add(CkRest__responseHeader(rest));
    Memo1.Lines.Add('Response Body:');
    Memo1.Lines.Add(CkStringBuilder__getAsString(sbResponseBody));
    Exit;
  end;

jResp := CkJsonObject_Create();
CkJsonObject_LoadSb(jResp,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

Arn := CkJsonObject__stringOf(jResp,'cluster.arn');
Data := CkJsonObject__stringOf(jResp,'cluster.certificateAuthority.data');
ClientRequestToken := CkJsonObject__stringOf(jResp,'cluster.clientRequestToken');
ActivationCode := CkJsonObject__stringOf(jResp,'cluster.connectorConfig.activationCode');
ActivationExpiry := CkJsonObject_IntOf(jResp,'cluster.connectorConfig.activationExpiry');
ActivationId := CkJsonObject__stringOf(jResp,'cluster.connectorConfig.activationId');
Provider := CkJsonObject__stringOf(jResp,'cluster.connectorConfig.provider');
RoleArn := CkJsonObject__stringOf(jResp,'cluster.connectorConfig.roleArn');
CreatedAt := CkJsonObject_IntOf(jResp,'cluster.createdAt');
Endpoint := CkJsonObject__stringOf(jResp,'cluster.endpoint');
Issuer := CkJsonObject__stringOf(jResp,'cluster.identity.oidc.issuer');
IpFamily := CkJsonObject__stringOf(jResp,'cluster.kubernetesNetworkConfig.ipFamily');
ServiceIpv4Cidr := CkJsonObject__stringOf(jResp,'cluster.kubernetesNetworkConfig.serviceIpv4Cidr');
ServiceIpv6Cidr := CkJsonObject__stringOf(jResp,'cluster.kubernetesNetworkConfig.serviceIpv6Cidr');
Name := CkJsonObject__stringOf(jResp,'cluster.name');
PlatformVersion := CkJsonObject__stringOf(jResp,'cluster.platformVersion');
ClusterSecurityGroupId := CkJsonObject__stringOf(jResp,'cluster.resourcesVpcConfig.clusterSecurityGroupId');
EndpointPrivateAccess := CkJsonObject_IntOf(jResp,'cluster.resourcesVpcConfig.endpointPrivateAccess');
EndpointPublicAccess := CkJsonObject_IntOf(jResp,'cluster.resourcesVpcConfig.endpointPublicAccess');
VpcId := CkJsonObject__stringOf(jResp,'cluster.resourcesVpcConfig.vpcId');
clusterRoleArn := CkJsonObject__stringOf(jResp,'cluster.roleArn');
Status := CkJsonObject__stringOf(jResp,'cluster.status');
v_String := CkJsonObject__stringOf(jResp,'cluster.tags.string');
Version := CkJsonObject__stringOf(jResp,'cluster.version');
i := 0;
count_i := CkJsonObject_SizeOfArray(jResp,'cluster.encryptionConfig');
while i < count_i do
  begin
    CkJsonObject_putI(jResp,i);
    KeyArn := CkJsonObject__stringOf(jResp,'cluster.encryptionConfig[i].provider.keyArn');
    j := 0;
    count_j := CkJsonObject_SizeOfArray(jResp,'cluster.encryptionConfig[i].resources');
    while j < count_j do
      begin
        CkJsonObject_putJ(jResp,j);
        strVal := CkJsonObject__stringOf(jResp,'cluster.encryptionConfig[i].resources[j]');
        j := j + 1;
      end;

    i := i + 1;
  end;

i := 0;
count_i := CkJsonObject_SizeOfArray(jResp,'cluster.logging.clusterLogging');
while i < count_i do
  begin
    CkJsonObject_putI(jResp,i);
    enabled := CkJsonObject_IntOf(jResp,'cluster.logging.clusterLogging[i].enabled');
    j := 0;
    count_j := CkJsonObject_SizeOfArray(jResp,'cluster.logging.clusterLogging[i].types');
    while j < count_j do
      begin
        CkJsonObject_putJ(jResp,j);
        strVal := CkJsonObject__stringOf(jResp,'cluster.logging.clusterLogging[i].types[j]');
        j := j + 1;
      end;

    i := i + 1;
  end;

i := 0;
count_i := CkJsonObject_SizeOfArray(jResp,'cluster.resourcesVpcConfig.publicAccessCidrs');
while i < count_i do
  begin
    CkJsonObject_putI(jResp,i);
    strVal := CkJsonObject__stringOf(jResp,'cluster.resourcesVpcConfig.publicAccessCidrs[i]');
    i := i + 1;
  end;

i := 0;
count_i := CkJsonObject_SizeOfArray(jResp,'cluster.resourcesVpcConfig.securityGroupIds');
while i < count_i do
  begin
    CkJsonObject_putI(jResp,i);
    strVal := CkJsonObject__stringOf(jResp,'cluster.resourcesVpcConfig.securityGroupIds[i]');
    i := i + 1;
  end;

i := 0;
count_i := CkJsonObject_SizeOfArray(jResp,'cluster.resourcesVpcConfig.subnetIds');
while i < count_i do
  begin
    CkJsonObject_putI(jResp,i);
    strVal := CkJsonObject__stringOf(jResp,'cluster.resourcesVpcConfig.subnetIds[i]');
    i := i + 1;
  end;

// 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"
//   }
// }

CkRest_Dispose(rest);
CkAuthAws_Dispose(authAws);
CkStringBuilder_Dispose(sbResponseBody);
CkJsonObject_Dispose(jResp);