Chilkat Online Tools

ListApps delphiAx Example

Amplify

var
rest: TChilkatRest;
success: Integer;
authAws: TChilkatAuthAws;
sbResponseBody: TChilkatStringBuilder;
respStatusCode: Integer;
jResp: TChilkatJsonObject;
appArn: WideString;
appId: WideString;
BasicAuthCredentials: WideString;
BuildSpec: WideString;
EnableAutoBuild: Integer;
EnableBasicAuth: Integer;
EnablePerformanceMode: Integer;
EnablePullRequestPreview: Integer;
v_String: WideString;
Framework: WideString;
PullRequestEnvironmentName: WideString;
Stage: WideString;
basicAuthCredentials: WideString;
buildSpec: WideString;
createTime: Integer;
customHeaders: WideString;
defaultDomain: WideString;
description: WideString;
enableAutoBranchCreation: Integer;
enableBasicAuth: Integer;
enableBranchAutoBuild: Integer;
enableBranchAutoDeletion: Integer;
environmentVariablesString: WideString;
iamServiceRoleArn: WideString;
name: WideString;
platform: WideString;
BranchName: WideString;
LastDeployTime: Integer;
Status: WideString;
ThumbnailUrl: WideString;
repository: WideString;
repositoryCloneMethod: WideString;
tagsString: WideString;
updateTime: Integer;
j: Integer;
count_j: Integer;
strVal: WideString;
condition: WideString;
source: WideString;
status: WideString;
target: WideString;
nextToken: WideString;
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 := 'amplify';
// SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
rest.SetAuthAws(authAws.ControlInterface);

// URL: https://amplify.us-west-2.amazonaws.com/
// Use the same region as specified above.
success := rest.Connect('amplify.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;

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

sbResponseBody := TChilkatStringBuilder.Create(Self);
success := rest.FullRequestNoBodySb('GET','/apps',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

nextToken := jResp.StringOf('nextToken');
i := 0;
count_i := jResp.SizeOfArray('apps');
while i < count_i do
  begin
    jResp.I := i;
    appArn := jResp.StringOf('apps[i].appArn');
    appId := jResp.StringOf('apps[i].appId');
    BasicAuthCredentials := jResp.StringOf('apps[i].autoBranchCreationConfig.basicAuthCredentials');
    BuildSpec := jResp.StringOf('apps[i].autoBranchCreationConfig.buildSpec');
    EnableAutoBuild := jResp.IntOf('apps[i].autoBranchCreationConfig.enableAutoBuild');
    EnableBasicAuth := jResp.IntOf('apps[i].autoBranchCreationConfig.enableBasicAuth');
    EnablePerformanceMode := jResp.IntOf('apps[i].autoBranchCreationConfig.enablePerformanceMode');
    EnablePullRequestPreview := jResp.IntOf('apps[i].autoBranchCreationConfig.enablePullRequestPreview');
    v_String := jResp.StringOf('apps[i].autoBranchCreationConfig.environmentVariables.string');
    Framework := jResp.StringOf('apps[i].autoBranchCreationConfig.framework');
    PullRequestEnvironmentName := jResp.StringOf('apps[i].autoBranchCreationConfig.pullRequestEnvironmentName');
    Stage := jResp.StringOf('apps[i].autoBranchCreationConfig.stage');
    basicAuthCredentials := jResp.StringOf('apps[i].basicAuthCredentials');
    buildSpec := jResp.StringOf('apps[i].buildSpec');
    createTime := jResp.IntOf('apps[i].createTime');
    customHeaders := jResp.StringOf('apps[i].customHeaders');
    defaultDomain := jResp.StringOf('apps[i].defaultDomain');
    description := jResp.StringOf('apps[i].description');
    enableAutoBranchCreation := jResp.IntOf('apps[i].enableAutoBranchCreation');
    enableBasicAuth := jResp.IntOf('apps[i].enableBasicAuth');
    enableBranchAutoBuild := jResp.IntOf('apps[i].enableBranchAutoBuild');
    enableBranchAutoDeletion := jResp.IntOf('apps[i].enableBranchAutoDeletion');
    environmentVariablesString := jResp.StringOf('apps[i].environmentVariables.string');
    iamServiceRoleArn := jResp.StringOf('apps[i].iamServiceRoleArn');
    name := jResp.StringOf('apps[i].name');
    platform := jResp.StringOf('apps[i].platform');
    BranchName := jResp.StringOf('apps[i].productionBranch.branchName');
    LastDeployTime := jResp.IntOf('apps[i].productionBranch.lastDeployTime');
    Status := jResp.StringOf('apps[i].productionBranch.status');
    ThumbnailUrl := jResp.StringOf('apps[i].productionBranch.thumbnailUrl');
    repository := jResp.StringOf('apps[i].repository');
    repositoryCloneMethod := jResp.StringOf('apps[i].repositoryCloneMethod');
    tagsString := jResp.StringOf('apps[i].tags.string');
    updateTime := jResp.IntOf('apps[i].updateTime');
    j := 0;
    count_j := jResp.SizeOfArray('apps[i].autoBranchCreationPatterns');
    while j < count_j do
      begin
        jResp.J := j;
        strVal := jResp.StringOf('apps[i].autoBranchCreationPatterns[j]');
        j := j + 1;
      end;

    j := 0;
    count_j := jResp.SizeOfArray('apps[i].customRules');
    while j < count_j do
      begin
        jResp.J := j;
        condition := jResp.StringOf('apps[i].customRules[j].condition');
        source := jResp.StringOf('apps[i].customRules[j].source');
        status := jResp.StringOf('apps[i].customRules[j].status');
        target := jResp.StringOf('apps[i].customRules[j].target');
        j := j + 1;
      end;

    i := i + 1;
  end;

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

// {
//   "apps": [
//     {
//       "appArn": "string",
//       "appId": "string",
//       "autoBranchCreationConfig": {
//         "basicAuthCredentials": "string",
//         "buildSpec": "string",
//         "enableAutoBuild": boolean,
//         "enableBasicAuth": boolean,
//         "enablePerformanceMode": boolean,
//         "enablePullRequestPreview": boolean,
//         "environmentVariables": {
//           "string": "string"
//         },
//         "framework": "string",
//         "pullRequestEnvironmentName": "string",
//         "stage": "string"
//       },
//       "autoBranchCreationPatterns": [
//         "string"
//       ],
//       "basicAuthCredentials": "string",
//       "buildSpec": "string",
//       "createTime": number,
//       "customHeaders": "string",
//       "customRules": [
//         {
//           "condition": "string",
//           "source": "string",
//           "status": "string",
//           "target": "string"
//         }
//       ],
//       "defaultDomain": "string",
//       "description": "string",
//       "enableAutoBranchCreation": boolean,
//       "enableBasicAuth": boolean,
//       "enableBranchAutoBuild": boolean,
//       "enableBranchAutoDeletion": boolean,
//       "environmentVariables": {
//         "string": "string"
//       },
//       "iamServiceRoleArn": "string",
//       "name": "string",
//       "platform": "string",
//       "productionBranch": {
//         "branchName": "string",
//         "lastDeployTime": number,
//         "status": "string",
//         "thumbnailUrl": "string"
//       },
//       "repository": "string",
//       "repositoryCloneMethod": "string",
//       "tags": {
//         "string": "string"
//       },
//       "updateTime": number
//     }
//   ],
//   "nextToken": "string"
// }