GetContainerRecipe delphiDll Example
var
rest: HCkRest;
success: Boolean;
authAws: HCkAuthAws;
sbResponseBody: HCkStringBuilder;
respStatusCode: Integer;
jResp: HCkJsonObject;
componentArn: PWideChar;
j: Integer;
count_j: Integer;
name: PWideChar;
k: Integer;
count_k: Integer;
strVal: PWideChar;
deviceName: PWideChar;
DeleteOnTermination: Integer;
ebsEncrypted: Integer;
Iops: Integer;
ebsKmsKeyId: PWideChar;
SnapshotId: PWideChar;
Throughput: Integer;
VolumeSize: Integer;
VolumeType: PWideChar;
noDevice: PWideChar;
virtualName: PWideChar;
Arn: PWideChar;
ContainerType: PWideChar;
DateCreated: PWideChar;
Description: PWideChar;
DockerfileTemplateData: PWideChar;
Encrypted: Integer;
Image: PWideChar;
KmsKeyId: PWideChar;
Name: PWideChar;
Owner: PWideChar;
ParentImage: PWideChar;
Platform: PWideChar;
v_String: PWideChar;
RepositoryName: PWideChar;
Service: PWideChar;
Version: PWideChar;
WorkingDirectory: PWideChar;
requestId: 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,'imagebuilder');
// SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
CkRest_SetAuthAws(rest,authAws);
// URL: https://imagebuilder.us-west-2.amazonaws.com/
// Use the same region as specified above.
success := CkRest_Connect(rest,'imagebuilder.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','GetContainerRecipe');
sbResponseBody := CkStringBuilder_Create();
success := CkRest_FullRequestNoBodySb(rest,'GET','/GetContainerRecipe',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
Arn := CkJsonObject__stringOf(jResp,'containerRecipe.arn');
ContainerType := CkJsonObject__stringOf(jResp,'containerRecipe.containerType');
DateCreated := CkJsonObject__stringOf(jResp,'containerRecipe.dateCreated');
Description := CkJsonObject__stringOf(jResp,'containerRecipe.description');
DockerfileTemplateData := CkJsonObject__stringOf(jResp,'containerRecipe.dockerfileTemplateData');
Encrypted := CkJsonObject_IntOf(jResp,'containerRecipe.encrypted');
Image := CkJsonObject__stringOf(jResp,'containerRecipe.instanceConfiguration.image');
KmsKeyId := CkJsonObject__stringOf(jResp,'containerRecipe.kmsKeyId');
Name := CkJsonObject__stringOf(jResp,'containerRecipe.name');
Owner := CkJsonObject__stringOf(jResp,'containerRecipe.owner');
ParentImage := CkJsonObject__stringOf(jResp,'containerRecipe.parentImage');
Platform := CkJsonObject__stringOf(jResp,'containerRecipe.platform');
v_String := CkJsonObject__stringOf(jResp,'containerRecipe.tags.string');
RepositoryName := CkJsonObject__stringOf(jResp,'containerRecipe.targetRepository.repositoryName');
Service := CkJsonObject__stringOf(jResp,'containerRecipe.targetRepository.service');
Version := CkJsonObject__stringOf(jResp,'containerRecipe.version');
WorkingDirectory := CkJsonObject__stringOf(jResp,'containerRecipe.workingDirectory');
requestId := CkJsonObject__stringOf(jResp,'requestId');
i := 0;
count_i := CkJsonObject_SizeOfArray(jResp,'containerRecipe.components');
while i < count_i do
begin
CkJsonObject_putI(jResp,i);
componentArn := CkJsonObject__stringOf(jResp,'containerRecipe.components[i].componentArn');
j := 0;
count_j := CkJsonObject_SizeOfArray(jResp,'containerRecipe.components[i].parameters');
while j < count_j do
begin
CkJsonObject_putJ(jResp,j);
name := CkJsonObject__stringOf(jResp,'containerRecipe.components[i].parameters[j].name');
k := 0;
count_k := CkJsonObject_SizeOfArray(jResp,'containerRecipe.components[i].parameters[j].value');
while k < count_k do
begin
CkJsonObject_putK(jResp,k);
strVal := CkJsonObject__stringOf(jResp,'containerRecipe.components[i].parameters[j].value[k]');
k := k + 1;
end;
j := j + 1;
end;
i := i + 1;
end;
i := 0;
count_i := CkJsonObject_SizeOfArray(jResp,'containerRecipe.instanceConfiguration.blockDeviceMappings');
while i < count_i do
begin
CkJsonObject_putI(jResp,i);
deviceName := CkJsonObject__stringOf(jResp,'containerRecipe.instanceConfiguration.blockDeviceMappings[i].deviceName');
DeleteOnTermination := CkJsonObject_IntOf(jResp,'containerRecipe.instanceConfiguration.blockDeviceMappings[i].ebs.deleteOnTermination');
ebsEncrypted := CkJsonObject_IntOf(jResp,'containerRecipe.instanceConfiguration.blockDeviceMappings[i].ebs.encrypted');
Iops := CkJsonObject_IntOf(jResp,'containerRecipe.instanceConfiguration.blockDeviceMappings[i].ebs.iops');
ebsKmsKeyId := CkJsonObject__stringOf(jResp,'containerRecipe.instanceConfiguration.blockDeviceMappings[i].ebs.kmsKeyId');
SnapshotId := CkJsonObject__stringOf(jResp,'containerRecipe.instanceConfiguration.blockDeviceMappings[i].ebs.snapshotId');
Throughput := CkJsonObject_IntOf(jResp,'containerRecipe.instanceConfiguration.blockDeviceMappings[i].ebs.throughput');
VolumeSize := CkJsonObject_IntOf(jResp,'containerRecipe.instanceConfiguration.blockDeviceMappings[i].ebs.volumeSize');
VolumeType := CkJsonObject__stringOf(jResp,'containerRecipe.instanceConfiguration.blockDeviceMappings[i].ebs.volumeType');
noDevice := CkJsonObject__stringOf(jResp,'containerRecipe.instanceConfiguration.blockDeviceMappings[i].noDevice');
virtualName := CkJsonObject__stringOf(jResp,'containerRecipe.instanceConfiguration.blockDeviceMappings[i].virtualName');
i := i + 1;
end;
// A sample JSON response body parsed by the above code:
// {
// "containerRecipe": {
// "arn": "string",
// "components": [
// {
// "componentArn": "string",
// "parameters": [
// {
// "name": "string",
// "value": [
// "string"
// ]
// }
// ]
// }
// ],
// "containerType": "string",
// "dateCreated": "string",
// "description": "string",
// "dockerfileTemplateData": "string",
// "encrypted": boolean,
// "instanceConfiguration": {
// "blockDeviceMappings": [
// {
// "deviceName": "string",
// "ebs": {
// "deleteOnTermination": boolean,
// "encrypted": boolean,
// "iops": number,
// "kmsKeyId": "string",
// "snapshotId": "string",
// "throughput": number,
// "volumeSize": number,
// "volumeType": "string"
// },
// "noDevice": "string",
// "virtualName": "string"
// }
// ],
// "image": "string"
// },
// "kmsKeyId": "string",
// "name": "string",
// "owner": "string",
// "parentImage": "string",
// "platform": "string",
// "tags": {
// "string": "string"
// },
// "targetRepository": {
// "repositoryName": "string",
// "service": "string"
// },
// "version": "string",
// "workingDirectory": "string"
// },
// "requestId": "string"
// }
CkRest_Dispose(rest);
CkAuthAws_Dispose(authAws);
CkStringBuilder_Dispose(sbResponseBody);
CkJsonObject_Dispose(jResp);