GetApp delphiDll Example
ãāļîá
n style="color: rgb(0,123,181)">var
rest: HCkRest;
success: Boolean;
authAws: HCkAuthAws;
sbResponseBody: HCkStringBuilder;
respStatusCode: Integer;
jResp: HCkJsonObject;
strVal: PWideChar;
condition: PWideChar;
source: PWideChar;
status: PWideChar;
target: PWideChar;
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;
appBasicAuthCredentials: PWideChar;
appBuildSpec: PWideChar;
CreateTime: Integer;
CustomHeaders: PWideChar;
DefaultDomain: PWideChar;
Description: PWideChar;
EnableAutoBranchCreation: Integer;
appEnableBasicAuth: 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;
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','GetApp');
sbResponseBody := CkStringBuilder_Create();
success := CkRest_FullRequestNoBodySb(rest,'GET','/apps/{appId}',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
AppArn := CkJsonObject__stringOf(jResp,'app.appArn');
AppId := CkJsonObject__stringOf(jResp,'app.appId');
BasicAuthCredentials := CkJsonObject__stringOf(jResp,'app.autoBranchCreationConfig.basicAuthCredentials');
BuildSpec := CkJsonObject__stringOf(jResp,'app.autoBranchCreationConfig.buildSpec');
EnableAutoBuild := CkJsonObject_IntOf(jResp,'app.autoBranchCreationConfig.enableAutoBuild');
EnableBasicAuth := CkJsonObject_IntOf(jResp,'app.autoBranchCreationConfig.enableBasicAuth');
EnablePerformanceMode := CkJsonObject_IntOf(jResp,'app.autoBranchCreationConfig.enablePerformanceMode');
EnablePullRequestPreview := CkJsonObject_IntOf(jResp,'app.autoBranchCreationConfig.enablePullRequestPreview');
v_String := CkJsonObject__stringOf(jResp,'app.autoBranchCreationConfig.environmentVariables.string');
Framework := CkJsonObject__stringOf(jResp,'app.autoBranchCreationConfig.framework');
PullRequestEnvironmentName := CkJsonObject__stringOf(jResp,'app.autoBranchCreationConfig.pullRequestEnvironmentName');
Stage := CkJsonObject__stringOf(jResp,'app.autoBranchCreationConfig.stage');
appBasicAuthCredentials := CkJsonObject__stringOf(jResp,'app.basicAuthCredentials');
appBuildSpec := CkJsonObject__stringOf(jResp,'app.buildSpec');
CreateTime := CkJsonObject_IntOf(jResp,'app.createTime');
CustomHeaders := CkJsonObject__stringOf(jResp,'app.customHeaders');
DefaultDomain := CkJsonObject__stringOf(jResp,'app.defaultDomain');
Description := CkJsonObject__stringOf(jResp,'app.description');
EnableAutoBranchCreation := CkJsonObject_IntOf(jResp,'app.enableAutoBranchCreation');
appEnableBasicAuth := CkJsonObject_IntOf(jResp,'app.enableBasicAuth');
EnableBranchAutoBuild := CkJsonObject_IntOf(jResp,'app.enableBranchAutoBuild');
EnableBranchAutoDeletion := CkJsonObject_IntOf(jResp,'app.enableBranchAutoDeletion');
EnvironmentVariablesString := CkJsonObject__stringOf(jResp,'app.environmentVariables.string');
IamServiceRoleArn := CkJsonObject__stringOf(jResp,'app.iamServiceRoleArn');
Name := CkJsonObject__stringOf(jResp,'app.name');
Platform := CkJsonObject__stringOf(jResp,'app.platform');
BranchName := CkJsonObject__stringOf(jResp,'app.productionBranch.branchName');
LastDeployTime := CkJsonObject_IntOf(jResp,'app.productionBranch.lastDeployTime');
Status := CkJsonObject__stringOf(jResp,'app.productionBranch.status');
ThumbnailUrl := CkJsonObject__stringOf(jResp,'app.productionBranch.thumbnailUrl');
Repository := CkJsonObject__stringOf(jResp,'app.repository');
RepositoryCloneMethod := CkJsonObject__stringOf(jResp,'app.repositoryCloneMethod');
TagsString := CkJsonObject__stringOf(jResp,'app.tags.string');
UpdateTime := CkJsonObject_IntOf(jResp,'app.updateTime');
i := 0;
count_i := CkJsonObject_SizeOfArray(jResp,'app.autoBranchCreationPatterns');
while i < count_i do
begin
CkJsonObject_putI(jResp,i);
strVal := CkJsonObject__stringOf(jResp,'app.autoBranchCreationPatterns[i]');
i := i + 1;
end;
i := 0;
count_i := CkJsonObject_SizeOfArray(jResp,'app.customRules');
while i < count_i do
begin
CkJsonObject_putI(jResp,i);
condition := CkJsonObject__stringOf(jResp,'app.customRules[i].condition');
source := CkJsonObject__stringOf(jResp,'app.customRules[i].source');
status := CkJsonObject__stringOf(jResp,'app.customRules[i].status');
target := CkJsonObject__stringOf(jResp,'app.customRules[i].target');
i := i + 1;
end;
// A sample JSON response body parsed by the above code:
// {
// "app": {
// "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
// }
// }
CkRest_Dispose(rest);
CkAuthAws_Dispose(authAws);
CkStringBuilder_Dispose(sbResponseBody);
CkJsonObject_Dispose(jResp);