Chilkat Online Tools

GetDeploymentGroup unicodeC Example

AWS CodeDeploy

#include <C_CkRestW.h>
#include <C_CkAuthAwsW.h>
#include <C_CkJsonObjectW.h>
#include <C_CkStringBuilderW.h>

void ChilkatSample(void)
    {
    HCkRestW rest;
    BOOL success;
    HCkAuthAwsW authAws;
    HCkJsonObjectW json;
    HCkStringBuilderW sbRequestBody;
    HCkStringBuilderW sbResponseBody;
    int respStatusCode;
    HCkJsonObjectW jResp;
    const wchar_t *name;
    const wchar_t *strVal;
    const wchar_t *hook;
    const wchar_t *v_Type;
    const wchar_t *Value;
    int j;
    int count_j;
    const wchar_t *clusterName;
    const wchar_t *serviceName;
    const wchar_t *triggerName;
    const wchar_t *triggerTargetArn;
    int Enabled;
    int IgnorePollAlarmFailure;
    const wchar_t *ApplicationName;
    int AutoRollbackConfigurationEnabled;
    const wchar_t *ActionOnTimeout;
    int WaitTimeInMinutes;
    const wchar_t *Action;
    const wchar_t *TerminateBlueInstancesOnDeploymentSuccessAction;
    int TerminationWaitTimeInMinutes;
    const wchar_t *ComputePlatform;
    const wchar_t *DeploymentConfigName;
    const wchar_t *DeploymentGroupId;
    const wchar_t *DeploymentGroupName;
    const wchar_t *DeploymentOption;
    const wchar_t *DeploymentType;
    int CreateTime;
    const wchar_t *DeploymentId;
    int EndTime;
    const wchar_t *Status;
    int LastSuccessfulDeploymentCreateTime;
    const wchar_t *LastSuccessfulDeploymentDeploymentId;
    int LastSuccessfulDeploymentEndTime;
    const wchar_t *LastSuccessfulDeploymentStatus;
    const wchar_t *OutdatedInstancesStrategy;
    const wchar_t *ServiceRoleArn;
    const wchar_t *Content;
    const wchar_t *Sha256;
    const wchar_t *CommitId;
    const wchar_t *Repository;
    const wchar_t *RevisionType;
    const wchar_t *Bucket;
    const wchar_t *BundleType;
    const wchar_t *ETag;
    const wchar_t *Key;
    const wchar_t *Version;
    const wchar_t *StringContent;
    const wchar_t *StringSha256;
    int i;
    int count_i;

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

    rest = CkRestW_Create();

    authAws = CkAuthAwsW_Create();
    CkAuthAwsW_putAccessKey(authAws,L"AWS_ACCESS_KEY");
    CkAuthAwsW_putSecretKey(authAws,L"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.)
    CkAuthAwsW_putRegion(authAws,L"us-west-2");
    CkAuthAwsW_putServiceName(authAws,L"codedeploy");
    // SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
    CkRestW_SetAuthAws(rest,authAws);

    // URL: https://codedeploy.us-west-2.amazonaws.com/
    // Use the same region as specified above.
    success = CkRestW_Connect(rest,L"codedeploy.us-west-2.amazonaws.com",443,TRUE,TRUE);
    if (success != TRUE) {
        wprintf(L"ConnectFailReason: %d\n",CkRestW_getConnectFailReason(rest));
        wprintf(L"%s\n",CkRestW_lastErrorText(rest));
        CkRestW_Dispose(rest);
        CkAuthAwsW_Dispose(authAws);
        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

    json = CkJsonObjectW_Create();
    CkJsonObjectW_UpdateString(json,L"applicationName",L"string");
    CkJsonObjectW_UpdateString(json,L"deploymentGroupName",L"string");

    // The JSON request body created by the above code:

    // {
    //   "applicationName": "string",
    //   "deploymentGroupName": "string"
    // }

    CkRestW_AddHeader(rest,L"Content-Type",L"application/x-amz-json-1.1");
    CkRestW_AddHeader(rest,L"X-Amz-Target",L"CodeDeploy_20141006.GetDeploymentGroup");

    sbRequestBody = CkStringBuilderW_Create();
    CkJsonObjectW_EmitSb(json,sbRequestBody);
    sbResponseBody = CkStringBuilderW_Create();
    success = CkRestW_FullRequestSb(rest,L"POST",L"/",sbRequestBody,sbResponseBody);
    if (success != TRUE) {
        wprintf(L"%s\n",CkRestW_lastErrorText(rest));
        CkRestW_Dispose(rest);
        CkAuthAwsW_Dispose(authAws);
        CkJsonObjectW_Dispose(json);
        CkStringBuilderW_Dispose(sbRequestBody);
        CkStringBuilderW_Dispose(sbResponseBody);
        return;
    }

    respStatusCode = CkRestW_getResponseStatusCode(rest);
    wprintf(L"response status code = %d\n",respStatusCode);
    if (respStatusCode != 200) {
        wprintf(L"Response Header:\n");
        wprintf(L"%s\n",CkRestW_responseHeader(rest));
        wprintf(L"Response Body:\n");
        wprintf(L"%s\n",CkStringBuilderW_getAsString(sbResponseBody));
        CkRestW_Dispose(rest);
        CkAuthAwsW_Dispose(authAws);
        CkJsonObjectW_Dispose(json);
        CkStringBuilderW_Dispose(sbRequestBody);
        CkStringBuilderW_Dispose(sbResponseBody);
        return;
    }

    jResp = CkJsonObjectW_Create();
    CkJsonObjectW_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

    // Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat.
    // See this example explaining how this memory should be used: const char * functions.

    Enabled = CkJsonObjectW_IntOf(jResp,L"deploymentGroupInfo.alarmConfiguration.enabled");
    IgnorePollAlarmFailure = CkJsonObjectW_IntOf(jResp,L"deploymentGroupInfo.alarmConfiguration.ignorePollAlarmFailure");
    ApplicationName = CkJsonObjectW_stringOf(jResp,L"deploymentGroupInfo.applicationName");
    AutoRollbackConfigurationEnabled = CkJsonObjectW_IntOf(jResp,L"deploymentGroupInfo.autoRollbackConfiguration.enabled");
    ActionOnTimeout = CkJsonObjectW_stringOf(jResp,L"deploymentGroupInfo.blueGreenDeploymentConfiguration.deploymentReadyOption.actionOnTimeout");
    WaitTimeInMinutes = CkJsonObjectW_IntOf(jResp,L"deploymentGroupInfo.blueGreenDeploymentConfiguration.deploymentReadyOption.waitTimeInMinutes");
    Action = CkJsonObjectW_stringOf(jResp,L"deploymentGroupInfo.blueGreenDeploymentConfiguration.greenFleetProvisioningOption.action");
    TerminateBlueInstancesOnDeploymentSuccessAction = CkJsonObjectW_stringOf(jResp,L"deploymentGroupInfo.blueGreenDeploymentConfiguration.terminateBlueInstancesOnDeploymentSuccess.action");
    TerminationWaitTimeInMinutes = CkJsonObjectW_IntOf(jResp,L"deploymentGroupInfo.blueGreenDeploymentConfiguration.terminateBlueInstancesOnDeploymentSuccess.terminationWaitTimeInMinutes");
    ComputePlatform = CkJsonObjectW_stringOf(jResp,L"deploymentGroupInfo.computePlatform");
    DeploymentConfigName = CkJsonObjectW_stringOf(jResp,L"deploymentGroupInfo.deploymentConfigName");
    DeploymentGroupId = CkJsonObjectW_stringOf(jResp,L"deploymentGroupInfo.deploymentGroupId");
    DeploymentGroupName = CkJsonObjectW_stringOf(jResp,L"deploymentGroupInfo.deploymentGroupName");
    DeploymentOption = CkJsonObjectW_stringOf(jResp,L"deploymentGroupInfo.deploymentStyle.deploymentOption");
    DeploymentType = CkJsonObjectW_stringOf(jResp,L"deploymentGroupInfo.deploymentStyle.deploymentType");
    CreateTime = CkJsonObjectW_IntOf(jResp,L"deploymentGroupInfo.lastAttemptedDeployment.createTime");
    DeploymentId = CkJsonObjectW_stringOf(jResp,L"deploymentGroupInfo.lastAttemptedDeployment.deploymentId");
    EndTime = CkJsonObjectW_IntOf(jResp,L"deploymentGroupInfo.lastAttemptedDeployment.endTime");
    Status = CkJsonObjectW_stringOf(jResp,L"deploymentGroupInfo.lastAttemptedDeployment.status");
    LastSuccessfulDeploymentCreateTime = CkJsonObjectW_IntOf(jResp,L"deploymentGroupInfo.lastSuccessfulDeployment.createTime");
    LastSuccessfulDeploymentDeploymentId = CkJsonObjectW_stringOf(jResp,L"deploymentGroupInfo.lastSuccessfulDeployment.deploymentId");
    LastSuccessfulDeploymentEndTime = CkJsonObjectW_IntOf(jResp,L"deploymentGroupInfo.lastSuccessfulDeployment.endTime");
    LastSuccessfulDeploymentStatus = CkJsonObjectW_stringOf(jResp,L"deploymentGroupInfo.lastSuccessfulDeployment.status");
    OutdatedInstancesStrategy = CkJsonObjectW_stringOf(jResp,L"deploymentGroupInfo.outdatedInstancesStrategy");
    ServiceRoleArn = CkJsonObjectW_stringOf(jResp,L"deploymentGroupInfo.serviceRoleArn");
    Content = CkJsonObjectW_stringOf(jResp,L"deploymentGroupInfo.targetRevision.appSpecContent.content");
    Sha256 = CkJsonObjectW_stringOf(jResp,L"deploymentGroupInfo.targetRevision.appSpecContent.sha256");
    CommitId = CkJsonObjectW_stringOf(jResp,L"deploymentGroupInfo.targetRevision.gitHubLocation.commitId");
    Repository = CkJsonObjectW_stringOf(jResp,L"deploymentGroupInfo.targetRevision.gitHubLocation.repository");
    RevisionType = CkJsonObjectW_stringOf(jResp,L"deploymentGroupInfo.targetRevision.revisionType");
    Bucket = CkJsonObjectW_stringOf(jResp,L"deploymentGroupInfo.targetRevision.s3Location.bucket");
    BundleType = CkJsonObjectW_stringOf(jResp,L"deploymentGroupInfo.targetRevision.s3Location.bundleType");
    ETag = CkJsonObjectW_stringOf(jResp,L"deploymentGroupInfo.targetRevision.s3Location.eTag");
    Key = CkJsonObjectW_stringOf(jResp,L"deploymentGroupInfo.targetRevision.s3Location.key");
    Version = CkJsonObjectW_stringOf(jResp,L"deploymentGroupInfo.targetRevision.s3Location.version");
    StringContent = CkJsonObjectW_stringOf(jResp,L"deploymentGroupInfo.targetRevision.string.content");
    StringSha256 = CkJsonObjectW_stringOf(jResp,L"deploymentGroupInfo.targetRevision.string.sha256");
    i = 0;
    count_i = CkJsonObjectW_SizeOfArray(jResp,L"deploymentGroupInfo.alarmConfiguration.alarms");
    while (i < count_i) {
        CkJsonObjectW_putI(jResp,i);
        name = CkJsonObjectW_stringOf(jResp,L"deploymentGroupInfo.alarmConfiguration.alarms[i].name");
        i = i + 1;
    }

    i = 0;
    count_i = CkJsonObjectW_SizeOfArray(jResp,L"deploymentGroupInfo.autoRollbackConfiguration.events");
    while (i < count_i) {
        CkJsonObjectW_putI(jResp,i);
        strVal = CkJsonObjectW_stringOf(jResp,L"deploymentGroupInfo.autoRollbackConfiguration.events[i]");
        i = i + 1;
    }

    i = 0;
    count_i = CkJsonObjectW_SizeOfArray(jResp,L"deploymentGroupInfo.autoScalingGroups");
    while (i < count_i) {
        CkJsonObjectW_putI(jResp,i);
        hook = CkJsonObjectW_stringOf(jResp,L"deploymentGroupInfo.autoScalingGroups[i].hook");
        name = CkJsonObjectW_stringOf(jResp,L"deploymentGroupInfo.autoScalingGroups[i].name");
        i = i + 1;
    }

    i = 0;
    count_i = CkJsonObjectW_SizeOfArray(jResp,L"deploymentGroupInfo.ec2TagFilters");
    while (i < count_i) {
        CkJsonObjectW_putI(jResp,i);
        Key = CkJsonObjectW_stringOf(jResp,L"deploymentGroupInfo.ec2TagFilters[i].Key");
        v_Type = CkJsonObjectW_stringOf(jResp,L"deploymentGroupInfo.ec2TagFilters[i].Type");
        Value = CkJsonObjectW_stringOf(jResp,L"deploymentGroupInfo.ec2TagFilters[i].Value");
        i = i + 1;
    }

    i = 0;
    count_i = CkJsonObjectW_SizeOfArray(jResp,L"deploymentGroupInfo.ec2TagSet.ec2TagSetList");
    while (i < count_i) {
        CkJsonObjectW_putI(jResp,i);
        j = 0;
        count_j = CkJsonObjectW_SizeOfArray(jResp,L"deploymentGroupInfo.ec2TagSet.ec2TagSetList[i]");
        while (j < count_j) {
            CkJsonObjectW_putJ(jResp,j);
            Key = CkJsonObjectW_stringOf(jResp,L"deploymentGroupInfo.ec2TagSet.ec2TagSetList[i][j].Key");
            v_Type = CkJsonObjectW_stringOf(jResp,L"deploymentGroupInfo.ec2TagSet.ec2TagSetList[i][j].Type");
            Value = CkJsonObjectW_stringOf(jResp,L"deploymentGroupInfo.ec2TagSet.ec2TagSetList[i][j].Value");
            j = j + 1;
        }

        i = i + 1;
    }

    i = 0;
    count_i = CkJsonObjectW_SizeOfArray(jResp,L"deploymentGroupInfo.ecsServices");
    while (i < count_i) {
        CkJsonObjectW_putI(jResp,i);
        clusterName = CkJsonObjectW_stringOf(jResp,L"deploymentGroupInfo.ecsServices[i].clusterName");
        serviceName = CkJsonObjectW_stringOf(jResp,L"deploymentGroupInfo.ecsServices[i].serviceName");
        i = i + 1;
    }

    i = 0;
    count_i = CkJsonObjectW_SizeOfArray(jResp,L"deploymentGroupInfo.loadBalancerInfo.elbInfoList");
    while (i < count_i) {
        CkJsonObjectW_putI(jResp,i);
        name = CkJsonObjectW_stringOf(jResp,L"deploymentGroupInfo.loadBalancerInfo.elbInfoList[i].name");
        i = i + 1;
    }

    i = 0;
    count_i = CkJsonObjectW_SizeOfArray(jResp,L"deploymentGroupInfo.loadBalancerInfo.targetGroupInfoList");
    while (i < count_i) {
        CkJsonObjectW_putI(jResp,i);
        name = CkJsonObjectW_stringOf(jResp,L"deploymentGroupInfo.loadBalancerInfo.targetGroupInfoList[i].name");
        i = i + 1;
    }

    i = 0;
    count_i = CkJsonObjectW_SizeOfArray(jResp,L"deploymentGroupInfo.loadBalancerInfo.targetGroupPairInfoList");
    while (i < count_i) {
        CkJsonObjectW_putI(jResp,i);
        j = 0;
        count_j = CkJsonObjectW_SizeOfArray(jResp,L"deploymentGroupInfo.loadBalancerInfo.targetGroupPairInfoList[i].prodTrafficRoute.listenerArns");
        while (j < count_j) {
            CkJsonObjectW_putJ(jResp,j);
            strVal = CkJsonObjectW_stringOf(jResp,L"deploymentGroupInfo.loadBalancerInfo.targetGroupPairInfoList[i].prodTrafficRoute.listenerArns[j]");
            j = j + 1;
        }

        j = 0;
        count_j = CkJsonObjectW_SizeOfArray(jResp,L"deploymentGroupInfo.loadBalancerInfo.targetGroupPairInfoList[i].targetGroups");
        while (j < count_j) {
            CkJsonObjectW_putJ(jResp,j);
            name = CkJsonObjectW_stringOf(jResp,L"deploymentGroupInfo.loadBalancerInfo.targetGroupPairInfoList[i].targetGroups[j].name");
            j = j + 1;
        }

        j = 0;
        count_j = CkJsonObjectW_SizeOfArray(jResp,L"deploymentGroupInfo.loadBalancerInfo.targetGroupPairInfoList[i].testTrafficRoute.listenerArns");
        while (j < count_j) {
            CkJsonObjectW_putJ(jResp,j);
            strVal = CkJsonObjectW_stringOf(jResp,L"deploymentGroupInfo.loadBalancerInfo.targetGroupPairInfoList[i].testTrafficRoute.listenerArns[j]");
            j = j + 1;
        }

        i = i + 1;
    }

    i = 0;
    count_i = CkJsonObjectW_SizeOfArray(jResp,L"deploymentGroupInfo.onPremisesInstanceTagFilters");
    while (i < count_i) {
        CkJsonObjectW_putI(jResp,i);
        Key = CkJsonObjectW_stringOf(jResp,L"deploymentGroupInfo.onPremisesInstanceTagFilters[i].Key");
        v_Type = CkJsonObjectW_stringOf(jResp,L"deploymentGroupInfo.onPremisesInstanceTagFilters[i].Type");
        Value = CkJsonObjectW_stringOf(jResp,L"deploymentGroupInfo.onPremisesInstanceTagFilters[i].Value");
        i = i + 1;
    }

    i = 0;
    count_i = CkJsonObjectW_SizeOfArray(jResp,L"deploymentGroupInfo.onPremisesTagSet.onPremisesTagSetList");
    while (i < count_i) {
        CkJsonObjectW_putI(jResp,i);
        j = 0;
        count_j = CkJsonObjectW_SizeOfArray(jResp,L"deploymentGroupInfo.onPremisesTagSet.onPremisesTagSetList[i]");
        while (j < count_j) {
            CkJsonObjectW_putJ(jResp,j);
            Key = CkJsonObjectW_stringOf(jResp,L"deploymentGroupInfo.onPremisesTagSet.onPremisesTagSetList[i][j].Key");
            v_Type = CkJsonObjectW_stringOf(jResp,L"deploymentGroupInfo.onPremisesTagSet.onPremisesTagSetList[i][j].Type");
            Value = CkJsonObjectW_stringOf(jResp,L"deploymentGroupInfo.onPremisesTagSet.onPremisesTagSetList[i][j].Value");
            j = j + 1;
        }

        i = i + 1;
    }

    i = 0;
    count_i = CkJsonObjectW_SizeOfArray(jResp,L"deploymentGroupInfo.triggerConfigurations");
    while (i < count_i) {
        CkJsonObjectW_putI(jResp,i);
        triggerName = CkJsonObjectW_stringOf(jResp,L"deploymentGroupInfo.triggerConfigurations[i].triggerName");
        triggerTargetArn = CkJsonObjectW_stringOf(jResp,L"deploymentGroupInfo.triggerConfigurations[i].triggerTargetArn");
        j = 0;
        count_j = CkJsonObjectW_SizeOfArray(jResp,L"deploymentGroupInfo.triggerConfigurations[i].triggerEvents");
        while (j < count_j) {
            CkJsonObjectW_putJ(jResp,j);
            strVal = CkJsonObjectW_stringOf(jResp,L"deploymentGroupInfo.triggerConfigurations[i].triggerEvents[j]");
            j = j + 1;
        }

        i = i + 1;
    }

    // A sample JSON response body parsed by the above code:

    // {
    //   "deploymentGroupInfo": {
    //     "alarmConfiguration": {
    //       "alarms": [
    //         {
    //           "name": "string"
    //         }
    //       ],
    //       "enabled": boolean,
    //       "ignorePollAlarmFailure": boolean
    //     },
    //     "applicationName": "string",
    //     "autoRollbackConfiguration": {
    //       "enabled": boolean,
    //       "events": [
    //         "string"
    //       ]
    //     },
    //     "autoScalingGroups": [
    //       {
    //         "hook": "string",
    //         "name": "string"
    //       }
    //     ],
    //     "blueGreenDeploymentConfiguration": {
    //       "deploymentReadyOption": {
    //         "actionOnTimeout": "string",
    //         "waitTimeInMinutes": number
    //       },
    //       "greenFleetProvisioningOption": {
    //         "action": "string"
    //       },
    //       "terminateBlueInstancesOnDeploymentSuccess": {
    //         "action": "string",
    //         "terminationWaitTimeInMinutes": number
    //       }
    //     },
    //     "computePlatform": "string",
    //     "deploymentConfigName": "string",
    //     "deploymentGroupId": "string",
    //     "deploymentGroupName": "string",
    //     "deploymentStyle": {
    //       "deploymentOption": "string",
    //       "deploymentType": "string"
    //     },
    //     "ec2TagFilters": [
    //       {
    //         "Key": "string",
    //         "Type": "string",
    //         "Value": "string"
    //       }
    //     ],
    //     "ec2TagSet": {
    //       "ec2TagSetList": [
    //         [
    //           {
    //             "Key": "string",
    //             "Type": "string",
    //             "Value": "string"
    //           }
    //         ]
    //       ]
    //     },
    //     "ecsServices": [
    //       {
    //         "clusterName": "string",
    //         "serviceName": "string"
    //       }
    //     ],
    //     "lastAttemptedDeployment": {
    //       "createTime": number,
    //       "deploymentId": "string",
    //       "endTime": number,
    //       "status": "string"
    //     },
    //     "lastSuccessfulDeployment": {
    //       "createTime": number,
    //       "deploymentId": "string",
    //       "endTime": number,
    //       "status": "string"
    //     },
    //     "loadBalancerInfo": {
    //       "elbInfoList": [
    //         {
    //           "name": "string"
    //         }
    //       ],
    //       "targetGroupInfoList": [
    //         {
    //           "name": "string"
    //         }
    //       ],
    //       "targetGroupPairInfoList": [
    //         {
    //           "prodTrafficRoute": {
    //             "listenerArns": [
    //               "string"
    //             ]
    //           },
    //           "targetGroups": [
    //             {
    //               "name": "string"
    //             }
    //           ],
    //           "testTrafficRoute": {
    //             "listenerArns": [
    //               "string"
    //             ]
    //           }
    //         }
    //       ]
    //     },
    //     "onPremisesInstanceTagFilters": [
    //       {
    //         "Key": "string",
    //         "Type": "string",
    //         "Value": "string"
    //       }
    //     ],
    //     "onPremisesTagSet": {
    //       "onPremisesTagSetList": [
    //         [
    //           {
    //             "Key": "string",
    //             "Type": "string",
    //             "Value": "string"
    //           }
    //         ]
    //       ]
    //     },
    //     "outdatedInstancesStrategy": "string",
    //     "serviceRoleArn": "string",
    //     "targetRevision": {
    //       "appSpecContent": {
    //         "content": "string",
    //         "sha256": "string"
    //       },
    //       "gitHubLocation": {
    //         "commitId": "string",
    //         "repository": "string"
    //       },
    //       "revisionType": "string",
    //       "s3Location": {
    //         "bucket": "string",
    //         "bundleType": "string",
    //         "eTag": "string",
    //         "key": "string",
    //         "version": "string"
    //       },
    //       "string": {
    //         "content": "string",
    //         "sha256": "string"
    //       }
    //     },
    //     "triggerConfigurations": [
    //       {
    //         "triggerEvents": [
    //           "string"
    //         ],
    //         "triggerName": "string",
    //         "triggerTargetArn": "string"
    //       }
    //     ]
    //   }
    // }


    CkRestW_Dispose(rest);
    CkAuthAwsW_Dispose(authAws);
    CkJsonObjectW_Dispose(json);
    CkStringBuilderW_Dispose(sbRequestBody);
    CkStringBuilderW_Dispose(sbResponseBody);
    CkJsonObjectW_Dispose(jResp);

    }