Chilkat Online Tools

BatchGetDeployments unicodeCpp Example

AWS CodeDeploy

#include <CkRestW.h>
#include <CkAuthAwsW.h>
#include <CkJsonObjectW.h>
#include <CkStringBuilderW.h>

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

    CkRestW rest;
    bool success;

    CkAuthAwsW authAws;
    authAws.put_AccessKey(L"AWS_ACCESS_KEY");
    authAws.put_SecretKey(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.)
    authAws.put_Region(L"us-west-2");
    authAws.put_ServiceName(L"codedeploy");
    // SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
    rest.SetAuthAws(authAws);

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

    CkJsonObjectW json;
    json.UpdateString(L"deploymentIds[0]",L"string");

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

    // {
    //   "deploymentIds": [
    //     "string"
    //   ]
    // }

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

    CkStringBuilderW sbRequestBody;
    json.EmitSb(sbRequestBody);
    CkStringBuilderW sbResponseBody;
    success = rest.FullRequestSb(L"POST",L"/",sbRequestBody,sbResponseBody);
    if (success != true) {
        wprintf(L"%s\n",rest.lastErrorText());
        return;
    }

    int respStatusCode = rest.get_ResponseStatusCode();
    wprintf(L"response status code = %d\n",respStatusCode);
    if (respStatusCode != 200) {
        wprintf(L"Response Header:\n");
        wprintf(L"%s\n",rest.responseHeader());
        wprintf(L"Response Body:\n");
        wprintf(L"%s\n",sbResponseBody.getAsString());
        return;
    }

    CkJsonObjectW jResp;
    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

    // 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.

    const wchar_t *additionalDeploymentStatusInfo = 0;
    const wchar_t *applicationName = 0;
    int Enabled;
    const wchar_t *ActionOnTimeout = 0;
    int WaitTimeInMinutes;
    const wchar_t *Action = 0;
    const wchar_t *TerminateBlueInstancesOnDeploymentSuccessAction = 0;
    int TerminationWaitTimeInMinutes;
    int completeTime;
    const wchar_t *computePlatform = 0;
    int createTime;
    const wchar_t *creator = 0;
    const wchar_t *deploymentConfigName = 0;
    const wchar_t *deploymentGroupName = 0;
    const wchar_t *deploymentId = 0;
    int Failed;
    int InProgress;
    int Pending;
    int Ready;
    int Skipped;
    int Succeeded;
    const wchar_t *DeploymentOption = 0;
    const wchar_t *DeploymentType = 0;
    const wchar_t *description = 0;
    const wchar_t *Code = 0;
    const wchar_t *Message = 0;
    const wchar_t *externalId = 0;
    const wchar_t *fileExistsBehavior = 0;
    int ignoreApplicationStopFailures;
    int instanceTerminationWaitTimeStarted;
    const wchar_t *Content = 0;
    const wchar_t *Sha256 = 0;
    const wchar_t *CommitId = 0;
    const wchar_t *Repository = 0;
    const wchar_t *RevisionType = 0;
    const wchar_t *Bucket = 0;
    const wchar_t *BundleType = 0;
    const wchar_t *ETag = 0;
    const wchar_t *Key = 0;
    const wchar_t *Version = 0;
    const wchar_t *StringContent = 0;
    const wchar_t *StringSha256 = 0;
    const wchar_t *AutoUpdateOutdatedInstancesRootDeploymentId = 0;
    const wchar_t *AppSpecContentContent = 0;
    const wchar_t *AppSpecContentSha256 = 0;
    const wchar_t *GitHubLocationCommitId = 0;
    const wchar_t *GitHubLocationRepository = 0;
    const wchar_t *revisionRevisionType = 0;
    const wchar_t *S3LocationBucket = 0;
    const wchar_t *S3LocationBundleType = 0;
    const wchar_t *S3LocationETag = 0;
    const wchar_t *S3LocationKey = 0;
    const wchar_t *S3LocationVersion = 0;
    const wchar_t *RollbackDeploymentId = 0;
    const wchar_t *RollbackMessage = 0;
    const wchar_t *RollbackTriggeringDeploymentId = 0;
    int startTime;
    const wchar_t *status = 0;
    int updateOutdatedInstancesOnly;
    int j;
    int count_j;
    const wchar_t *strVal = 0;
    const wchar_t *name = 0;
    int k;
    int count_k;
    const wchar_t *v_Type = 0;
    const wchar_t *Value = 0;

    int i = 0;
    int count_i = jResp.SizeOfArray(L"deploymentsInfo");
    while (i < count_i) {
        jResp.put_I(i);
        additionalDeploymentStatusInfo = jResp.stringOf(L"deploymentsInfo[i].additionalDeploymentStatusInfo");
        applicationName = jResp.stringOf(L"deploymentsInfo[i].applicationName");
        Enabled = jResp.IntOf(L"deploymentsInfo[i].autoRollbackConfiguration.enabled");
        ActionOnTimeout = jResp.stringOf(L"deploymentsInfo[i].blueGreenDeploymentConfiguration.deploymentReadyOption.actionOnTimeout");
        WaitTimeInMinutes = jResp.IntOf(L"deploymentsInfo[i].blueGreenDeploymentConfiguration.deploymentReadyOption.waitTimeInMinutes");
        Action = jResp.stringOf(L"deploymentsInfo[i].blueGreenDeploymentConfiguration.greenFleetProvisioningOption.action");
        TerminateBlueInstancesOnDeploymentSuccessAction = jResp.stringOf(L"deploymentsInfo[i].blueGreenDeploymentConfiguration.terminateBlueInstancesOnDeploymentSuccess.action");
        TerminationWaitTimeInMinutes = jResp.IntOf(L"deploymentsInfo[i].blueGreenDeploymentConfiguration.terminateBlueInstancesOnDeploymentSuccess.terminationWaitTimeInMinutes");
        completeTime = jResp.IntOf(L"deploymentsInfo[i].completeTime");
        computePlatform = jResp.stringOf(L"deploymentsInfo[i].computePlatform");
        createTime = jResp.IntOf(L"deploymentsInfo[i].createTime");
        creator = jResp.stringOf(L"deploymentsInfo[i].creator");
        deploymentConfigName = jResp.stringOf(L"deploymentsInfo[i].deploymentConfigName");
        deploymentGroupName = jResp.stringOf(L"deploymentsInfo[i].deploymentGroupName");
        deploymentId = jResp.stringOf(L"deploymentsInfo[i].deploymentId");
        Failed = jResp.IntOf(L"deploymentsInfo[i].deploymentOverview.Failed");
        InProgress = jResp.IntOf(L"deploymentsInfo[i].deploymentOverview.InProgress");
        Pending = jResp.IntOf(L"deploymentsInfo[i].deploymentOverview.Pending");
        Ready = jResp.IntOf(L"deploymentsInfo[i].deploymentOverview.Ready");
        Skipped = jResp.IntOf(L"deploymentsInfo[i].deploymentOverview.Skipped");
        Succeeded = jResp.IntOf(L"deploymentsInfo[i].deploymentOverview.Succeeded");
        DeploymentOption = jResp.stringOf(L"deploymentsInfo[i].deploymentStyle.deploymentOption");
        DeploymentType = jResp.stringOf(L"deploymentsInfo[i].deploymentStyle.deploymentType");
        description = jResp.stringOf(L"deploymentsInfo[i].description");
        Code = jResp.stringOf(L"deploymentsInfo[i].errorInformation.code");
        Message = jResp.stringOf(L"deploymentsInfo[i].errorInformation.message");
        externalId = jResp.stringOf(L"deploymentsInfo[i].externalId");
        fileExistsBehavior = jResp.stringOf(L"deploymentsInfo[i].fileExistsBehavior");
        ignoreApplicationStopFailures = jResp.IntOf(L"deploymentsInfo[i].ignoreApplicationStopFailures");
        instanceTerminationWaitTimeStarted = jResp.IntOf(L"deploymentsInfo[i].instanceTerminationWaitTimeStarted");
        Content = jResp.stringOf(L"deploymentsInfo[i].previousRevision.appSpecContent.content");
        Sha256 = jResp.stringOf(L"deploymentsInfo[i].previousRevision.appSpecContent.sha256");
        CommitId = jResp.stringOf(L"deploymentsInfo[i].previousRevision.gitHubLocation.commitId");
        Repository = jResp.stringOf(L"deploymentsInfo[i].previousRevision.gitHubLocation.repository");
        RevisionType = jResp.stringOf(L"deploymentsInfo[i].previousRevision.revisionType");
        Bucket = jResp.stringOf(L"deploymentsInfo[i].previousRevision.s3Location.bucket");
        BundleType = jResp.stringOf(L"deploymentsInfo[i].previousRevision.s3Location.bundleType");
        ETag = jResp.stringOf(L"deploymentsInfo[i].previousRevision.s3Location.eTag");
        Key = jResp.stringOf(L"deploymentsInfo[i].previousRevision.s3Location.key");
        Version = jResp.stringOf(L"deploymentsInfo[i].previousRevision.s3Location.version");
        StringContent = jResp.stringOf(L"deploymentsInfo[i].previousRevision.string.content");
        StringSha256 = jResp.stringOf(L"deploymentsInfo[i].previousRevision.string.sha256");
        AutoUpdateOutdatedInstancesRootDeploymentId = jResp.stringOf(L"deploymentsInfo[i].relatedDeployments.autoUpdateOutdatedInstancesRootDeploymentId");
        AppSpecContentContent = jResp.stringOf(L"deploymentsInfo[i].revision.appSpecContent.content");
        AppSpecContentSha256 = jResp.stringOf(L"deploymentsInfo[i].revision.appSpecContent.sha256");
        GitHubLocationCommitId = jResp.stringOf(L"deploymentsInfo[i].revision.gitHubLocation.commitId");
        GitHubLocationRepository = jResp.stringOf(L"deploymentsInfo[i].revision.gitHubLocation.repository");
        revisionRevisionType = jResp.stringOf(L"deploymentsInfo[i].revision.revisionType");
        S3LocationBucket = jResp.stringOf(L"deploymentsInfo[i].revision.s3Location.bucket");
        S3LocationBundleType = jResp.stringOf(L"deploymentsInfo[i].revision.s3Location.bundleType");
        S3LocationETag = jResp.stringOf(L"deploymentsInfo[i].revision.s3Location.eTag");
        S3LocationKey = jResp.stringOf(L"deploymentsInfo[i].revision.s3Location.key");
        S3LocationVersion = jResp.stringOf(L"deploymentsInfo[i].revision.s3Location.version");
        StringContent = jResp.stringOf(L"deploymentsInfo[i].revision.string.content");
        StringSha256 = jResp.stringOf(L"deploymentsInfo[i].revision.string.sha256");
        RollbackDeploymentId = jResp.stringOf(L"deploymentsInfo[i].rollbackInfo.rollbackDeploymentId");
        RollbackMessage = jResp.stringOf(L"deploymentsInfo[i].rollbackInfo.rollbackMessage");
        RollbackTriggeringDeploymentId = jResp.stringOf(L"deploymentsInfo[i].rollbackInfo.rollbackTriggeringDeploymentId");
        startTime = jResp.IntOf(L"deploymentsInfo[i].startTime");
        status = jResp.stringOf(L"deploymentsInfo[i].status");
        updateOutdatedInstancesOnly = jResp.IntOf(L"deploymentsInfo[i].updateOutdatedInstancesOnly");
        j = 0;
        count_j = jResp.SizeOfArray(L"deploymentsInfo[i].autoRollbackConfiguration.events");
        while (j < count_j) {
            jResp.put_J(j);
            strVal = jResp.stringOf(L"deploymentsInfo[i].autoRollbackConfiguration.events[j]");
            j = j + 1;
        }

        j = 0;
        count_j = jResp.SizeOfArray(L"deploymentsInfo[i].deploymentStatusMessages");
        while (j < count_j) {
            jResp.put_J(j);
            strVal = jResp.stringOf(L"deploymentsInfo[i].deploymentStatusMessages[j]");
            j = j + 1;
        }

        j = 0;
        count_j = jResp.SizeOfArray(L"deploymentsInfo[i].loadBalancerInfo.elbInfoList");
        while (j < count_j) {
            jResp.put_J(j);
            name = jResp.stringOf(L"deploymentsInfo[i].loadBalancerInfo.elbInfoList[j].name");
            j = j + 1;
        }

        j = 0;
        count_j = jResp.SizeOfArray(L"deploymentsInfo[i].loadBalancerInfo.targetGroupInfoList");
        while (j < count_j) {
            jResp.put_J(j);
            name = jResp.stringOf(L"deploymentsInfo[i].loadBalancerInfo.targetGroupInfoList[j].name");
            j = j + 1;
        }

        j = 0;
        count_j = jResp.SizeOfArray(L"deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList");
        while (j < count_j) {
            jResp.put_J(j);
            k = 0;
            count_k = jResp.SizeOfArray(L"deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].prodTrafficRoute.listenerArns");
            while (k < count_k) {
                jResp.put_K(k);
                strVal = jResp.stringOf(L"deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].prodTrafficRoute.listenerArns[k]");
                k = k + 1;
            }

            k = 0;
            count_k = jResp.SizeOfArray(L"deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].targetGroups");
            while (k < count_k) {
                jResp.put_K(k);
                name = jResp.stringOf(L"deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].targetGroups[k].name");
                k = k + 1;
            }

            k = 0;
            count_k = jResp.SizeOfArray(L"deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].testTrafficRoute.listenerArns");
            while (k < count_k) {
                jResp.put_K(k);
                strVal = jResp.stringOf(L"deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].testTrafficRoute.listenerArns[k]");
                k = k + 1;
            }

            j = j + 1;
        }

        j = 0;
        count_j = jResp.SizeOfArray(L"deploymentsInfo[i].relatedDeployments.autoUpdateOutdatedInstancesDeploymentIds");
        while (j < count_j) {
            jResp.put_J(j);
            strVal = jResp.stringOf(L"deploymentsInfo[i].relatedDeployments.autoUpdateOutdatedInstancesDeploymentIds[j]");
            j = j + 1;
        }

        j = 0;
        count_j = jResp.SizeOfArray(L"deploymentsInfo[i].targetInstances.autoScalingGroups");
        while (j < count_j) {
            jResp.put_J(j);
            strVal = jResp.stringOf(L"deploymentsInfo[i].targetInstances.autoScalingGroups[j]");
            j = j + 1;
        }

        j = 0;
        count_j = jResp.SizeOfArray(L"deploymentsInfo[i].targetInstances.ec2TagSet.ec2TagSetList");
        while (j < count_j) {
            jResp.put_J(j);
            k = 0;
            count_k = jResp.SizeOfArray(L"deploymentsInfo[i].targetInstances.ec2TagSet.ec2TagSetList[j]");
            while (k < count_k) {
                jResp.put_K(k);
                Key = jResp.stringOf(L"deploymentsInfo[i].targetInstances.ec2TagSet.ec2TagSetList[j][k].Key");
                v_Type = jResp.stringOf(L"deploymentsInfo[i].targetInstances.ec2TagSet.ec2TagSetList[j][k].Type");
                Value = jResp.stringOf(L"deploymentsInfo[i].targetInstances.ec2TagSet.ec2TagSetList[j][k].Value");
                k = k + 1;
            }

            j = j + 1;
        }

        j = 0;
        count_j = jResp.SizeOfArray(L"deploymentsInfo[i].targetInstances.tagFilters");
        while (j < count_j) {
            jResp.put_J(j);
            Key = jResp.stringOf(L"deploymentsInfo[i].targetInstances.tagFilters[j].Key");
            v_Type = jResp.stringOf(L"deploymentsInfo[i].targetInstances.tagFilters[j].Type");
            Value = jResp.stringOf(L"deploymentsInfo[i].targetInstances.tagFilters[j].Value");
            j = j + 1;
        }

        i = i + 1;
    }

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

    // {
    //   "deploymentsInfo": [
    //     {
    //       "additionalDeploymentStatusInfo": "string",
    //       "applicationName": "string",
    //       "autoRollbackConfiguration": {
    //         "enabled": boolean,
    //         "events": [
    //           "string"
    //         ]
    //       },
    //       "blueGreenDeploymentConfiguration": {
    //         "deploymentReadyOption": {
    //           "actionOnTimeout": "string",
    //           "waitTimeInMinutes": number
    //         },
    //         "greenFleetProvisioningOption": {
    //           "action": "string"
    //         },
    //         "terminateBlueInstancesOnDeploymentSuccess": {
    //           "action": "string",
    //           "terminationWaitTimeInMinutes": number
    //         }
    //       },
    //       "completeTime": number,
    //       "computePlatform": "string",
    //       "createTime": number,
    //       "creator": "string",
    //       "deploymentConfigName": "string",
    //       "deploymentGroupName": "string",
    //       "deploymentId": "string",
    //       "deploymentOverview": {
    //         "Failed": number,
    //         "InProgress": number,
    //         "Pending": number,
    //         "Ready": number,
    //         "Skipped": number,
    //         "Succeeded": number
    //       },
    //       "deploymentStatusMessages": [
    //         "string"
    //       ],
    //       "deploymentStyle": {
    //         "deploymentOption": "string",
    //         "deploymentType": "string"
    //       },
    //       "description": "string",
    //       "errorInformation": {
    //         "code": "string",
    //         "message": "string"
    //       },
    //       "externalId": "string",
    //       "fileExistsBehavior": "string",
    //       "ignoreApplicationStopFailures": boolean,
    //       "instanceTerminationWaitTimeStarted": boolean,
    //       "loadBalancerInfo": {
    //         "elbInfoList": [
    //           {
    //             "name": "string"
    //           }
    //         ],
    //         "targetGroupInfoList": [
    //           {
    //             "name": "string"
    //           }
    //         ],
    //         "targetGroupPairInfoList": [
    //           {
    //             "prodTrafficRoute": {
    //               "listenerArns": [
    //                 "string"
    //               ]
    //             },
    //             "targetGroups": [
    //               {
    //                 "name": "string"
    //               }
    //             ],
    //             "testTrafficRoute": {
    //               "listenerArns": [
    //                 "string"
    //               ]
    //             }
    //           }
    //         ]
    //       },
    //       "previousRevision": {
    //         "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"
    //         }
    //       },
    //       "relatedDeployments": {
    //         "autoUpdateOutdatedInstancesDeploymentIds": [
    //           "string"
    //         ],
    //         "autoUpdateOutdatedInstancesRootDeploymentId": "string"
    //       },
    //       "revision": {
    //         "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"
    //         }
    //       },
    //       "rollbackInfo": {
    //         "rollbackDeploymentId": "string",
    //         "rollbackMessage": "string",
    //         "rollbackTriggeringDeploymentId": "string"
    //       },
    //       "startTime": number,
    //       "status": "string",
    //       "targetInstances": {
    //         "autoScalingGroups": [
    //           "string"
    //         ],
    //         "ec2TagSet": {
    //           "ec2TagSetList": [
    //             [
    //               {
    //                 "Key": "string",
    //                 "Type": "string",
    //                 "Value": "string"
    //               }
    //             ]
    //           ]
    //         },
    //         "tagFilters": [
    //           {
    //             "Key": "string",
    //             "Type": "string",
    //             "Value": "string"
    //           }
    //         ]
    //       },
    //       "updateOutdatedInstancesOnly": boolean
    //     }
    //   ]
    // }
    }