Chilkat Online Tools

GetImagePipeline delphiDll Example

EC2 Image Builder

var
rest: HCkRest;
success: Boolean;
authAws: HCkAuthAws;
sbResponseBody: HCkStringBuilder;
respStatusCode: Integer;
jResp: HCkJsonObject;
Arn: PWideChar;
ContainerRecipeArn: PWideChar;
DateCreated: PWideChar;
DateLastRun: PWideChar;
DateNextRun: PWideChar;
DateUpdated: PWideChar;
Description: PWideChar;
DistributionConfigurationArn: PWideChar;
EnhancedImageMetadataEnabled: Integer;
ImageRecipeArn: PWideChar;
ImageTestsEnabled: Integer;
TimeoutMinutes: Integer;
InfrastructureConfigurationArn: PWideChar;
Name: PWideChar;
Platform: PWideChar;
PipelineExecutionStartCondition: PWideChar;
ScheduleExpression: PWideChar;
Timezone: PWideChar;
Status: PWideChar;
v_String: PWideChar;
requestId: PWideChar;

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','GetImagePipeline');

sbResponseBody := CkStringBuilder_Create();
success := CkRest_FullRequestNoBodySb(rest,'GET','/GetImagePipeline',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,'imagePipeline.arn');
ContainerRecipeArn := CkJsonObject__stringOf(jResp,'imagePipeline.containerRecipeArn');
DateCreated := CkJsonObject__stringOf(jResp,'imagePipeline.dateCreated');
DateLastRun := CkJsonObject__stringOf(jResp,'imagePipeline.dateLastRun');
DateNextRun := CkJsonObject__stringOf(jResp,'imagePipeline.dateNextRun');
DateUpdated := CkJsonObject__stringOf(jResp,'imagePipeline.dateUpdated');
Description := CkJsonObject__stringOf(jResp,'imagePipeline.description');
DistributionConfigurationArn := CkJsonObject__stringOf(jResp,'imagePipeline.distributionConfigurationArn');
EnhancedImageMetadataEnabled := CkJsonObject_IntOf(jResp,'imagePipeline.enhancedImageMetadataEnabled');
ImageRecipeArn := CkJsonObject__stringOf(jResp,'imagePipeline.imageRecipeArn');
ImageTestsEnabled := CkJsonObject_IntOf(jResp,'imagePipeline.imageTestsConfiguration.imageTestsEnabled');
TimeoutMinutes := CkJsonObject_IntOf(jResp,'imagePipeline.imageTestsConfiguration.timeoutMinutes');
InfrastructureConfigurationArn := CkJsonObject__stringOf(jResp,'imagePipeline.infrastructureConfigurationArn');
Name := CkJsonObject__stringOf(jResp,'imagePipeline.name');
Platform := CkJsonObject__stringOf(jResp,'imagePipeline.platform');
PipelineExecutionStartCondition := CkJsonObject__stringOf(jResp,'imagePipeline.schedule.pipelineExecutionStartCondition');
ScheduleExpression := CkJsonObject__stringOf(jResp,'imagePipeline.schedule.scheduleExpression');
Timezone := CkJsonObject__stringOf(jResp,'imagePipeline.schedule.timezone');
Status := CkJsonObject__stringOf(jResp,'imagePipeline.status');
v_String := CkJsonObject__stringOf(jResp,'imagePipeline.tags.string');
requestId := CkJsonObject__stringOf(jResp,'requestId');

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

// {
//   "imagePipeline": {
//     "arn": "string",
//     "containerRecipeArn": "string",
//     "dateCreated": "string",
//     "dateLastRun": "string",
//     "dateNextRun": "string",
//     "dateUpdated": "string",
//     "description": "string",
//     "distributionConfigurationArn": "string",
//     "enhancedImageMetadataEnabled": boolean,
//     "imageRecipeArn": "string",
//     "imageTestsConfiguration": {
//       "imageTestsEnabled": boolean,
//       "timeoutMinutes": number
//     },
//     "infrastructureConfigurationArn": "string",
//     "name": "string",
//     "platform": "string",
//     "schedule": {
//       "pipelineExecutionStartCondition": "string",
//       "scheduleExpression": "string",
//       "timezone": "string"
//     },
//     "status": "string",
//     "tags": {
//       "string": "string"
//     }
//   },
//   "requestId": "string"
// }

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