Chilkat Online Tools

ListApps delphiDll Example

Amplify

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

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

sbResponseBody := CkStringBuilder_Create();
success := CkRest_FullRequestNoBodySb(rest,'GET','/apps',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

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

    j := 0;
    count_j := CkJsonObject_SizeOfArray(jResp,'apps[i].customRules');
    while j < count_j do
      begin
        CkJsonObject_putJ(jResp,j);
        condition := CkJsonObject__stringOf(jResp,'apps[i].customRules[j].condition');
        source := CkJsonObject__stringOf(jResp,'apps[i].customRules[j].source');
        status := CkJsonObject__stringOf(jResp,'apps[i].customRules[j].status');
        target := CkJsonObject__stringOf(jResp,'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"
// }

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