Chilkat Online Tools

GetDeployment delphiAx Example

AWS CodeDeploy

var
rest: TChilkatRest;
success: Integer;
authAws: TChilkatAuthAws;
json: TChilkatJsonObject;
sbRequestBody: TChilkatStringBuilder;
sbResponseBody: TChilkatStringBuilder;
respStatusCode: Integer;
jResp: TChilkatJsonObject;
strVal: WideString;
name: WideString;
j: Integer;
count_j: Integer;
v_Type: WideString;
Value: WideString;
AdditionalDeploymentStatusInfo: WideString;
ApplicationName: WideString;
Enabled: Integer;
ActionOnTimeout: WideString;
WaitTimeInMinutes: Integer;
Action: WideString;
TerminateBlueInstancesOnDeploymentSuccessAction: WideString;
TerminationWaitTimeInMinutes: Integer;
CompleteTime: Integer;
ComputePlatform: WideString;
CreateTime: Integer;
Creator: WideString;
DeploymentConfigName: WideString;
DeploymentGroupName: WideString;
DeploymentId: WideString;
Failed: Integer;
InProgress: Integer;
Pending: Integer;
Ready: Integer;
Skipped: Integer;
Succeeded: Integer;
DeploymentOption: WideString;
DeploymentType: WideString;
Description: WideString;
Code: WideString;
Message: WideString;
ExternalId: WideString;
FileExistsBehavior: WideString;
IgnoreApplicationStopFailures: Integer;
InstanceTerminationWaitTimeStarted: Integer;
Content: WideString;
Sha256: WideString;
CommitId: WideString;
Repository: WideString;
RevisionType: WideString;
Bucket: WideString;
BundleType: WideString;
ETag: WideString;
Key: WideString;
Version: WideString;
StringContent: WideString;
StringSha256: WideString;
AutoUpdateOutdatedInstancesRootDeploymentId: WideString;
AppSpecContentContent: WideString;
AppSpecContentSha256: WideString;
GitHubLocationCommitId: WideString;
GitHubLocationRepository: WideString;
RevisionRevisionType: WideString;
S3LocationBucket: WideString;
S3LocationBundleType: WideString;
S3LocationETag: WideString;
S3LocationKey: WideString;
S3LocationVersion: WideString;
RollbackDeploymentId: WideString;
RollbackMessage: WideString;
RollbackTriggeringDeploymentId: WideString;
StartTime: Integer;
Status: WideString;
UpdateOutdatedInstancesOnly: Integer;
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 := TChilkatRest.Create(Self);

authAws := TChilkatAuthAws.Create(Self);
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 := 'codedeploy';
// SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
rest.SetAuthAws(authAws.ControlInterface);

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

// 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 := TChilkatJsonObject.Create(Self);
json.UpdateString('deploymentId','string');

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

// {
//   "deploymentId": "string"
// }

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

sbRequestBody := TChilkatStringBuilder.Create(Self);
json.EmitSb(sbRequestBody.ControlInterface);
sbResponseBody := TChilkatStringBuilder.Create(Self);
success := rest.FullRequestSb('POST','/',sbRequestBody.ControlInterface,sbResponseBody.ControlInterface);
if (success <> 1) then
  begin
    Memo1.Lines.Add(rest.LastErrorText);
    Exit;
  end;
respStatusCode := rest.ResponseStatusCode;
Memo1.Lines.Add('response status code = ' + IntToStr(respStatusCode));
if (respStatusCode <> 200) then
  begin
    Memo1.Lines.Add('Response Header:');
    Memo1.Lines.Add(rest.ResponseHeader);
    Memo1.Lines.Add('Response Body:');
    Memo1.Lines.Add(sbResponseBody.GetAsString());
    Exit;
  end;

jResp := TChilkatJsonObject.Create(Self);
jResp.LoadSb(sbResponseBody.ControlInterface);

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

AdditionalDeploymentStatusInfo := jResp.StringOf('deploymentInfo.additionalDeploymentStatusInfo');
ApplicationName := jResp.StringOf('deploymentInfo.applicationName');
Enabled := jResp.IntOf('deploymentInfo.autoRollbackConfiguration.enabled');
ActionOnTimeout := jResp.StringOf('deploymentInfo.blueGreenDeploymentConfiguration.deploymentReadyOption.actionOnTimeout');
WaitTimeInMinutes := jResp.IntOf('deploymentInfo.blueGreenDeploymentConfiguration.deploymentReadyOption.waitTimeInMinutes');
Action := jResp.StringOf('deploymentInfo.blueGreenDeploymentConfiguration.greenFleetProvisioningOption.action');
TerminateBlueInstancesOnDeploymentSuccessAction := jResp.StringOf('deploymentInfo.blueGreenDeploymentConfiguration.terminateBlueInstancesOnDeploymentSuccess.action');
TerminationWaitTimeInMinutes := jResp.IntOf('deploymentInfo.blueGreenDeploymentConfiguration.terminateBlueInstancesOnDeploymentSuccess.terminationWaitTimeInMinutes');
CompleteTime := jResp.IntOf('deploymentInfo.completeTime');
ComputePlatform := jResp.StringOf('deploymentInfo.computePlatform');
CreateTime := jResp.IntOf('deploymentInfo.createTime');
Creator := jResp.StringOf('deploymentInfo.creator');
DeploymentConfigName := jResp.StringOf('deploymentInfo.deploymentConfigName');
DeploymentGroupName := jResp.StringOf('deploymentInfo.deploymentGroupName');
DeploymentId := jResp.StringOf('deploymentInfo.deploymentId');
Failed := jResp.IntOf('deploymentInfo.deploymentOverview.Failed');
InProgress := jResp.IntOf('deploymentInfo.deploymentOverview.InProgress');
Pending := jResp.IntOf('deploymentInfo.deploymentOverview.Pending');
Ready := jResp.IntOf('deploymentInfo.deploymentOverview.Ready');
Skipped := jResp.IntOf('deploymentInfo.deploymentOverview.Skipped');
Succeeded := jResp.IntOf('deploymentInfo.deploymentOverview.Succeeded');
DeploymentOption := jResp.StringOf('deploymentInfo.deploymentStyle.deploymentOption');
DeploymentType := jResp.StringOf('deploymentInfo.deploymentStyle.deploymentType');
Description := jResp.StringOf('deploymentInfo.description');
Code := jResp.StringOf('deploymentInfo.errorInformation.code');
Message := jResp.StringOf('deploymentInfo.errorInformation.message');
ExternalId := jResp.StringOf('deploymentInfo.externalId');
FileExistsBehavior := jResp.StringOf('deploymentInfo.fileExistsBehavior');
IgnoreApplicationStopFailures := jResp.IntOf('deploymentInfo.ignoreApplicationStopFailures');
InstanceTerminationWaitTimeStarted := jResp.IntOf('deploymentInfo.instanceTerminationWaitTimeStarted');
Content := jResp.StringOf('deploymentInfo.previousRevision.appSpecContent.content');
Sha256 := jResp.StringOf('deploymentInfo.previousRevision.appSpecContent.sha256');
CommitId := jResp.StringOf('deploymentInfo.previousRevision.gitHubLocation.commitId');
Repository := jResp.StringOf('deploymentInfo.previousRevision.gitHubLocation.repository');
RevisionType := jResp.StringOf('deploymentInfo.previousRevision.revisionType');
Bucket := jResp.StringOf('deploymentInfo.previousRevision.s3Location.bucket');
BundleType := jResp.StringOf('deploymentInfo.previousRevision.s3Location.bundleType');
ETag := jResp.StringOf('deploymentInfo.previousRevision.s3Location.eTag');
Key := jResp.StringOf('deploymentInfo.previousRevision.s3Location.key');
Version := jResp.StringOf('deploymentInfo.previousRevision.s3Location.version');
StringContent := jResp.StringOf('deploymentInfo.previousRevision.string.content');
StringSha256 := jResp.StringOf('deploymentInfo.previousRevision.string.sha256');
AutoUpdateOutdatedInstancesRootDeploymentId := jResp.StringOf('deploymentInfo.relatedDeployments.autoUpdateOutdatedInstancesRootDeploymentId');
AppSpecContentContent := jResp.StringOf('deploymentInfo.revision.appSpecContent.content');
AppSpecContentSha256 := jResp.StringOf('deploymentInfo.revision.appSpecContent.sha256');
GitHubLocationCommitId := jResp.StringOf('deploymentInfo.revision.gitHubLocation.commitId');
GitHubLocationRepository := jResp.StringOf('deploymentInfo.revision.gitHubLocation.repository');
RevisionRevisionType := jResp.StringOf('deploymentInfo.revision.revisionType');
S3LocationBucket := jResp.StringOf('deploymentInfo.revision.s3Location.bucket');
S3LocationBundleType := jResp.StringOf('deploymentInfo.revision.s3Location.bundleType');
S3LocationETag := jResp.StringOf('deploymentInfo.revision.s3Location.eTag');
S3LocationKey := jResp.StringOf('deploymentInfo.revision.s3Location.key');
S3LocationVersion := jResp.StringOf('deploymentInfo.revision.s3Location.version');
StringContent := jResp.StringOf('deploymentInfo.revision.string.content');
StringSha256 := jResp.StringOf('deploymentInfo.revision.string.sha256');
RollbackDeploymentId := jResp.StringOf('deploymentInfo.rollbackInfo.rollbackDeploymentId');
RollbackMessage := jResp.StringOf('deploymentInfo.rollbackInfo.rollbackMessage');
RollbackTriggeringDeploymentId := jResp.StringOf('deploymentInfo.rollbackInfo.rollbackTriggeringDeploymentId');
StartTime := jResp.IntOf('deploymentInfo.startTime');
Status := jResp.StringOf('deploymentInfo.status');
UpdateOutdatedInstancesOnly := jResp.IntOf('deploymentInfo.updateOutdatedInstancesOnly');
i := 0;
count_i := jResp.SizeOfArray('deploymentInfo.autoRollbackConfiguration.events');
while i < count_i do
  begin
    jResp.I := i;
    strVal := jResp.StringOf('deploymentInfo.autoRollbackConfiguration.events[i]');
    i := i + 1;
  end;

i := 0;
count_i := jResp.SizeOfArray('deploymentInfo.deploymentStatusMessages');
while i < count_i do
  begin
    jResp.I := i;
    strVal := jResp.StringOf('deploymentInfo.deploymentStatusMessages[i]');
    i := i + 1;
  end;

i := 0;
count_i := jResp.SizeOfArray('deploymentInfo.loadBalancerInfo.elbInfoList');
while i < count_i do
  begin
    jResp.I := i;
    name := jResp.StringOf('deploymentInfo.loadBalancerInfo.elbInfoList[i].name');
    i := i + 1;
  end;

i := 0;
count_i := jResp.SizeOfArray('deploymentInfo.loadBalancerInfo.targetGroupInfoList');
while i < count_i do
  begin
    jResp.I := i;
    name := jResp.StringOf('deploymentInfo.loadBalancerInfo.targetGroupInfoList[i].name');
    i := i + 1;
  end;

i := 0;
count_i := jResp.SizeOfArray('deploymentInfo.loadBalancerInfo.targetGroupPairInfoList');
while i < count_i do
  begin
    jResp.I := i;
    j := 0;
    count_j := jResp.SizeOfArray('deploymentInfo.loadBalancerInfo.targetGroupPairInfoList[i].prodTrafficRoute.listenerArns');
    while j < count_j do
      begin
        jResp.J := j;
        strVal := jResp.StringOf('deploymentInfo.loadBalancerInfo.targetGroupPairInfoList[i].prodTrafficRoute.listenerArns[j]');
        j := j + 1;
      end;

    j := 0;
    count_j := jResp.SizeOfArray('deploymentInfo.loadBalancerInfo.targetGroupPairInfoList[i].targetGroups');
    while j < count_j do
      begin
        jResp.J := j;
        name := jResp.StringOf('deploymentInfo.loadBalancerInfo.targetGroupPairInfoList[i].targetGroups[j].name');
        j := j + 1;
      end;

    j := 0;
    count_j := jResp.SizeOfArray('deploymentInfo.loadBalancerInfo.targetGroupPairInfoList[i].testTrafficRoute.listenerArns');
    while j < count_j do
      begin
        jResp.J := j;
        strVal := jResp.StringOf('deploymentInfo.loadBalancerInfo.targetGroupPairInfoList[i].testTrafficRoute.listenerArns[j]');
        j := j + 1;
      end;

    i := i + 1;
  end;

i := 0;
count_i := jResp.SizeOfArray('deploymentInfo.relatedDeployments.autoUpdateOutdatedInstancesDeploymentIds');
while i < count_i do
  begin
    jResp.I := i;
    strVal := jResp.StringOf('deploymentInfo.relatedDeployments.autoUpdateOutdatedInstancesDeploymentIds[i]');
    i := i + 1;
  end;

i := 0;
count_i := jResp.SizeOfArray('deploymentInfo.targetInstances.autoScalingGroups');
while i < count_i do
  begin
    jResp.I := i;
    strVal := jResp.StringOf('deploymentInfo.targetInstances.autoScalingGroups[i]');
    i := i + 1;
  end;

i := 0;
count_i := jResp.SizeOfArray('deploymentInfo.targetInstances.ec2TagSet.ec2TagSetList');
while i < count_i do
  begin
    jResp.I := i;
    j := 0;
    count_j := jResp.SizeOfArray('deploymentInfo.targetInstances.ec2TagSet.ec2TagSetList[i]');
    while j < count_j do
      begin
        jResp.J := j;
        Key := jResp.StringOf('deploymentInfo.targetInstances.ec2TagSet.ec2TagSetList[i][j].Key');
        v_Type := jResp.StringOf('deploymentInfo.targetInstances.ec2TagSet.ec2TagSetList[i][j].Type');
        Value := jResp.StringOf('deploymentInfo.targetInstances.ec2TagSet.ec2TagSetList[i][j].Value');
        j := j + 1;
      end;

    i := i + 1;
  end;

i := 0;
count_i := jResp.SizeOfArray('deploymentInfo.targetInstances.tagFilters');
while i < count_i do
  begin
    jResp.I := i;
    Key := jResp.StringOf('deploymentInfo.targetInstances.tagFilters[i].Key');
    v_Type := jResp.StringOf('deploymentInfo.targetInstances.tagFilters[i].Type');
    Value := jResp.StringOf('deploymentInfo.targetInstances.tagFilters[i].Value');
    i := i + 1;
  end;

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

// {
//   "deploymentInfo": {
//     "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
//   }
// }