DescribeInsight delphiDll Example
var
rest: HCkRest;
success: Boolean;
authAws: HCkAuthAws;
sbResponseBody: HCkStringBuilder;
respStatusCode: Integer;
jResp: HCkJsonObject;
strVal: PWideChar;
AppBoundaryKey: PWideChar;
j: Integer;
count_j: Integer;
Description: PWideChar;
Id: PWideChar;
EndTime: Integer;
StartTime: Integer;
Name: PWideChar;
PredictionTimeRangeEndTime: Integer;
PredictionTimeRangeStartTime: Integer;
Severity: PWideChar;
SsmOpsItemId: PWideChar;
Status: PWideChar;
ReactiveInsightDescription: PWideChar;
ReactiveInsightId: PWideChar;
InsightTimeRangeEndTime: Integer;
InsightTimeRangeStartTime: Integer;
ReactiveInsightName: PWideChar;
ReactiveInsightSeverity: PWideChar;
ReactiveInsightSsmOpsItemId: PWideChar;
ReactiveInsightStatus: 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,'devops-guru');
// SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
CkRest_SetAuthAws(rest,authAws);
// URL: https://devops-guru.us-west-2.amazonaws.com/
// Use the same region as specified above.
success := CkRest_Connect(rest,'devops-guru.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','DescribeInsight');
sbResponseBody := CkStringBuilder_Create();
success := CkRest_FullRequestNoBodySb(rest,'GET','/insights/{Id}',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
Description := CkJsonObject__stringOf(jResp,'ProactiveInsight.Description');
Id := CkJsonObject__stringOf(jResp,'ProactiveInsight.Id');
EndTime := CkJsonObject_IntOf(jResp,'ProactiveInsight.InsightTimeRange.EndTime');
StartTime := CkJsonObject_IntOf(jResp,'ProactiveInsight.InsightTimeRange.StartTime');
Name := CkJsonObject__stringOf(jResp,'ProactiveInsight.Name');
PredictionTimeRangeEndTime := CkJsonObject_IntOf(jResp,'ProactiveInsight.PredictionTimeRange.EndTime');
PredictionTimeRangeStartTime := CkJsonObject_IntOf(jResp,'ProactiveInsight.PredictionTimeRange.StartTime');
Severity := CkJsonObject__stringOf(jResp,'ProactiveInsight.Severity');
SsmOpsItemId := CkJsonObject__stringOf(jResp,'ProactiveInsight.SsmOpsItemId');
Status := CkJsonObject__stringOf(jResp,'ProactiveInsight.Status');
ReactiveInsightDescription := CkJsonObject__stringOf(jResp,'ReactiveInsight.Description');
ReactiveInsightId := CkJsonObject__stringOf(jResp,'ReactiveInsight.Id');
InsightTimeRangeEndTime := CkJsonObject_IntOf(jResp,'ReactiveInsight.InsightTimeRange.EndTime');
InsightTimeRangeStartTime := CkJsonObject_IntOf(jResp,'ReactiveInsight.InsightTimeRange.StartTime');
ReactiveInsightName := CkJsonObject__stringOf(jResp,'ReactiveInsight.Name');
ReactiveInsightSeverity := CkJsonObject__stringOf(jResp,'ReactiveInsight.Severity');
ReactiveInsightSsmOpsItemId := CkJsonObject__stringOf(jResp,'ReactiveInsight.SsmOpsItemId');
ReactiveInsightStatus := CkJsonObject__stringOf(jResp,'ReactiveInsight.Status');
i := 0;
count_i := CkJsonObject_SizeOfArray(jResp,'ProactiveInsight.ResourceCollection.CloudFormation.StackNames');
while i < count_i do
begin
CkJsonObject_putI(jResp,i);
strVal := CkJsonObject__stringOf(jResp,'ProactiveInsight.ResourceCollection.CloudFormation.StackNames[i]');
i := i + 1;
end;
i := 0;
count_i := CkJsonObject_SizeOfArray(jResp,'ProactiveInsight.ResourceCollection.Tags');
while i < count_i do
begin
CkJsonObject_putI(jResp,i);
AppBoundaryKey := CkJsonObject__stringOf(jResp,'ProactiveInsight.ResourceCollection.Tags[i].AppBoundaryKey');
j := 0;
count_j := CkJsonObject_SizeOfArray(jResp,'ProactiveInsight.ResourceCollection.Tags[i].TagValues');
while j < count_j do
begin
CkJsonObject_putJ(jResp,j);
strVal := CkJsonObject__stringOf(jResp,'ProactiveInsight.ResourceCollection.Tags[i].TagValues[j]');
j := j + 1;
end;
i := i + 1;
end;
i := 0;
count_i := CkJsonObject_SizeOfArray(jResp,'ReactiveInsight.ResourceCollection.CloudFormation.StackNames');
while i < count_i do
begin
CkJsonObject_putI(jResp,i);
strVal := CkJsonObject__stringOf(jResp,'ReactiveInsight.ResourceCollection.CloudFormation.StackNames[i]');
i := i + 1;
end;
i := 0;
count_i := CkJsonObject_SizeOfArray(jResp,'ReactiveInsight.ResourceCollection.Tags');
while i < count_i do
begin
CkJsonObject_putI(jResp,i);
AppBoundaryKey := CkJsonObject__stringOf(jResp,'ReactiveInsight.ResourceCollection.Tags[i].AppBoundaryKey');
j := 0;
count_j := CkJsonObject_SizeOfArray(jResp,'ReactiveInsight.ResourceCollection.Tags[i].TagValues');
while j < count_j do
begin
CkJsonObject_putJ(jResp,j);
strVal := CkJsonObject__stringOf(jResp,'ReactiveInsight.ResourceCollection.Tags[i].TagValues[j]');
j := j + 1;
end;
i := i + 1;
end;
// A sample JSON response body parsed by the above code:
// {
// "ProactiveInsight": {
// "Description": "string",
// "Id": "string",
// "InsightTimeRange": {
// "EndTime": number,
// "StartTime": number
// },
// "Name": "string",
// "PredictionTimeRange": {
// "EndTime": number,
// "StartTime": number
// },
// "ResourceCollection": {
// "CloudFormation": {
// "StackNames": [
// "string"
// ]
// },
// "Tags": [
// {
// "AppBoundaryKey": "string",
// "TagValues": [
// "string"
// ]
// }
// ]
// },
// "Severity": "string",
// "SsmOpsItemId": "string",
// "Status": "string"
// },
// "ReactiveInsight": {
// "Description": "string",
// "Id": "string",
// "InsightTimeRange": {
// "EndTime": number,
// "StartTime": number
// },
// "Name": "string",
// "ResourceCollection": {
// "CloudFormation": {
// "StackNames": [
// "string"
// ]
// },
// "Tags": [
// {
// "AppBoundaryKey": "string",
// "TagValues": [
// "string"
// ]
// }
// ]
// },
// "Severity": "string",
// "SsmOpsItemId": "string",
// "Status": "string"
// }
// }
CkRest_Dispose(rest);
CkAuthAws_Dispose(authAws);
CkStringBuilder_Dispose(sbResponseBody);
CkJsonObject_Dispose(jResp);