StopRun delphiDll Example
var
rest: HCkRest;
success: Boolean;
authAws: HCkAuthAws;
json: HCkJsonObject;
sbRequestBody: HCkStringBuilder;
sbResponseBody: HCkStringBuilder;
respStatusCode: Integer;
jResp: HCkJsonObject;
strVal: PWideChar;
attribute: PWideChar;
operator: PWideChar;
j: Integer;
count_j: Integer;
AppUpload: PWideChar;
Arn: PWideChar;
BillingMethod: PWideChar;
CompletedJobs: Integer;
Errored: Integer;
Failed: Integer;
Passed: Integer;
Skipped: Integer;
Stopped: Integer;
Total: Integer;
Warned: Integer;
Created: Integer;
Metered: Integer;
DeviceMinutesTotal: Integer;
Unmetered: Integer;
DevicePoolArn: PWideChar;
MatchedDevicesCount: Integer;
MaxDevices: Integer;
EventCount: Integer;
JobTimeoutMinutes: Integer;
Locale: PWideChar;
Latitude: Integer;
Longitude: Integer;
Message: PWideChar;
Name: PWideChar;
NetworkProfileArn: PWideChar;
Description: PWideChar;
DownlinkBandwidthBits: Integer;
DownlinkDelayMs: Integer;
DownlinkJitterMs: Integer;
DownlinkLossPercent: Integer;
NetworkProfileName: PWideChar;
v_Type: PWideChar;
UplinkBandwidthBits: Integer;
UplinkDelayMs: Integer;
UplinkJitterMs: Integer;
UplinkLossPercent: Integer;
ParsingResultUrl: PWideChar;
Platform: PWideChar;
Bluetooth: Integer;
Gps: Integer;
Nfc: Integer;
Wifi: Integer;
Result: PWideChar;
ResultCode: PWideChar;
Seed: Integer;
SkipAppResign: Integer;
Started: Integer;
Status: PWideChar;
runStopped: Integer;
TestSpecArn: PWideChar;
TotalJobs: Integer;
runType: PWideChar;
WebUrl: 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,'devicefarm');
// SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
CkRest_SetAuthAws(rest,authAws);
// URL: https://devicefarm.us-west-2.amazonaws.com/
// Use the same region as specified above.
success := CkRest_Connect(rest,'devicefarm.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;
// The following code creates the JSON request body.
// The JSON created by this code is shown below.
// Use this online tool to generate code from sample JSON:
// Generate Code to Create JSON
json := CkJsonObject_Create();
CkJsonObject_UpdateString(json,'arn','string');
// The JSON request body created by the above code:
// {
// "arn": "string"
// }
CkRest_AddHeader(rest,'Content-Type','application/x-amz-json-1.1');
CkRest_AddHeader(rest,'X-Amz-Target','DeviceFarm_20150623.StopRun');
sbRequestBody := CkStringBuilder_Create();
CkJsonObject_EmitSb(json,sbRequestBody);
sbResponseBody := CkStringBuilder_Create();
success := CkRest_FullRequestSb(rest,'POST','/',sbRequestBody,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
AppUpload := CkJsonObject__stringOf(jResp,'run.appUpload');
Arn := CkJsonObject__stringOf(jResp,'run.arn');
BillingMethod := CkJsonObject__stringOf(jResp,'run.billingMethod');
CompletedJobs := CkJsonObject_IntOf(jResp,'run.completedJobs');
Errored := CkJsonObject_IntOf(jResp,'run.counters.errored');
Failed := CkJsonObject_IntOf(jResp,'run.counters.failed');
Passed := CkJsonObject_IntOf(jResp,'run.counters.passed');
Skipped := CkJsonObject_IntOf(jResp,'run.counters.skipped');
Stopped := CkJsonObject_IntOf(jResp,'run.counters.stopped');
Total := CkJsonObject_IntOf(jResp,'run.counters.total');
Warned := CkJsonObject_IntOf(jResp,'run.counters.warned');
Created := CkJsonObject_IntOf(jResp,'run.created');
Metered := CkJsonObject_IntOf(jResp,'run.deviceMinutes.metered');
DeviceMinutesTotal := CkJsonObject_IntOf(jResp,'run.deviceMinutes.total');
Unmetered := CkJsonObject_IntOf(jResp,'run.deviceMinutes.unmetered');
DevicePoolArn := CkJsonObject__stringOf(jResp,'run.devicePoolArn');
MatchedDevicesCount := CkJsonObject_IntOf(jResp,'run.deviceSelectionResult.matchedDevicesCount');
MaxDevices := CkJsonObject_IntOf(jResp,'run.deviceSelectionResult.maxDevices');
EventCount := CkJsonObject_IntOf(jResp,'run.eventCount');
JobTimeoutMinutes := CkJsonObject_IntOf(jResp,'run.jobTimeoutMinutes');
Locale := CkJsonObject__stringOf(jResp,'run.locale');
Latitude := CkJsonObject_IntOf(jResp,'run.location.latitude');
Longitude := CkJsonObject_IntOf(jResp,'run.location.longitude');
Message := CkJsonObject__stringOf(jResp,'run.message');
Name := CkJsonObject__stringOf(jResp,'run.name');
NetworkProfileArn := CkJsonObject__stringOf(jResp,'run.networkProfile.arn');
Description := CkJsonObject__stringOf(jResp,'run.networkProfile.description');
DownlinkBandwidthBits := CkJsonObject_IntOf(jResp,'run.networkProfile.downlinkBandwidthBits');
DownlinkDelayMs := CkJsonObject_IntOf(jResp,'run.networkProfile.downlinkDelayMs');
DownlinkJitterMs := CkJsonObject_IntOf(jResp,'run.networkProfile.downlinkJitterMs');
DownlinkLossPercent := CkJsonObject_IntOf(jResp,'run.networkProfile.downlinkLossPercent');
NetworkProfileName := CkJsonObject__stringOf(jResp,'run.networkProfile.name');
v_Type := CkJsonObject__stringOf(jResp,'run.networkProfile.type');
UplinkBandwidthBits := CkJsonObject_IntOf(jResp,'run.networkProfile.uplinkBandwidthBits');
UplinkDelayMs := CkJsonObject_IntOf(jResp,'run.networkProfile.uplinkDelayMs');
UplinkJitterMs := CkJsonObject_IntOf(jResp,'run.networkProfile.uplinkJitterMs');
UplinkLossPercent := CkJsonObject_IntOf(jResp,'run.networkProfile.uplinkLossPercent');
ParsingResultUrl := CkJsonObject__stringOf(jResp,'run.parsingResultUrl');
Platform := CkJsonObject__stringOf(jResp,'run.platform');
Bluetooth := CkJsonObject_IntOf(jResp,'run.radios.bluetooth');
Gps := CkJsonObject_IntOf(jResp,'run.radios.gps');
Nfc := CkJsonObject_IntOf(jResp,'run.radios.nfc');
Wifi := CkJsonObject_IntOf(jResp,'run.radios.wifi');
Result := CkJsonObject__stringOf(jResp,'run.result');
ResultCode := CkJsonObject__stringOf(jResp,'run.resultCode');
Seed := CkJsonObject_IntOf(jResp,'run.seed');
SkipAppResign := CkJsonObject_IntOf(jResp,'run.skipAppResign');
Started := CkJsonObject_IntOf(jResp,'run.started');
Status := CkJsonObject__stringOf(jResp,'run.status');
runStopped := CkJsonObject_IntOf(jResp,'run.stopped');
TestSpecArn := CkJsonObject__stringOf(jResp,'run.testSpecArn');
TotalJobs := CkJsonObject_IntOf(jResp,'run.totalJobs');
runType := CkJsonObject__stringOf(jResp,'run.type');
WebUrl := CkJsonObject__stringOf(jResp,'run.webUrl');
i := 0;
count_i := CkJsonObject_SizeOfArray(jResp,'run.customerArtifactPaths.androidPaths');
while i < count_i do
begin
CkJsonObject_putI(jResp,i);
strVal := CkJsonObject__stringOf(jResp,'run.customerArtifactPaths.androidPaths[i]');
i := i + 1;
end;
i := 0;
count_i := CkJsonObject_SizeOfArray(jResp,'run.customerArtifactPaths.deviceHostPaths');
while i < count_i do
begin
CkJsonObject_putI(jResp,i);
strVal := CkJsonObject__stringOf(jResp,'run.customerArtifactPaths.deviceHostPaths[i]');
i := i + 1;
end;
i := 0;
count_i := CkJsonObject_SizeOfArray(jResp,'run.customerArtifactPaths.iosPaths');
while i < count_i do
begin
CkJsonObject_putI(jResp,i);
strVal := CkJsonObject__stringOf(jResp,'run.customerArtifactPaths.iosPaths[i]');
i := i + 1;
end;
i := 0;
count_i := CkJsonObject_SizeOfArray(jResp,'run.deviceSelectionResult.filters');
while i < count_i do
begin
CkJsonObject_putI(jResp,i);
attribute := CkJsonObject__stringOf(jResp,'run.deviceSelectionResult.filters[i].attribute');
operator := CkJsonObject__stringOf(jResp,'run.deviceSelectionResult.filters[i].operator');
j := 0;
count_j := CkJsonObject_SizeOfArray(jResp,'run.deviceSelectionResult.filters[i].values');
while j < count_j do
begin
CkJsonObject_putJ(jResp,j);
strVal := CkJsonObject__stringOf(jResp,'run.deviceSelectionResult.filters[i].values[j]');
j := j + 1;
end;
i := i + 1;
end;
// A sample JSON response body parsed by the above code:
// {
// "run": {
// "appUpload": "string",
// "arn": "string",
// "billingMethod": "string",
// "completedJobs": number,
// "counters": {
// "errored": number,
// "failed": number,
// "passed": number,
// "skipped": number,
// "stopped": number,
// "total": number,
// "warned": number
// },
// "created": number,
// "customerArtifactPaths": {
// "androidPaths": [
// "string"
// ],
// "deviceHostPaths": [
// "string"
// ],
// "iosPaths": [
// "string"
// ]
// },
// "deviceMinutes": {
// "metered": number,
// "total": number,
// "unmetered": number
// },
// "devicePoolArn": "string",
// "deviceSelectionResult": {
// "filters": [
// {
// "attribute": "string",
// "operator": "string",
// "values": [
// "string"
// ]
// }
// ],
// "matchedDevicesCount": number,
// "maxDevices": number
// },
// "eventCount": number,
// "jobTimeoutMinutes": number,
// "locale": "string",
// "location": {
// "latitude": number,
// "longitude": number
// },
// "message": "string",
// "name": "string",
// "networkProfile": {
// "arn": "string",
// "description": "string",
// "downlinkBandwidthBits": number,
// "downlinkDelayMs": number,
// "downlinkJitterMs": number,
// "downlinkLossPercent": number,
// "name": "string",
// "type": "string",
// "uplinkBandwidthBits": number,
// "uplinkDelayMs": number,
// "uplinkJitterMs": number,
// "uplinkLossPercent": number
// },
// "parsingResultUrl": "string",
// "platform": "string",
// "radios": {
// "bluetooth": boolean,
// "gps": boolean,
// "nfc": boolean,
// "wifi": boolean
// },
// "result": "string",
// "resultCode": "string",
// "seed": number,
// "skipAppResign": boolean,
// "started": number,
// "status": "string",
// "stopped": number,
// "testSpecArn": "string",
// "totalJobs": number,
// "type": "string",
// "webUrl": "string"
// }
// }
CkRest_Dispose(rest);
CkAuthAws_Dispose(authAws);
CkJsonObject_Dispose(json);
CkStringBuilder_Dispose(sbRequestBody);
CkStringBuilder_Dispose(sbResponseBody);
CkJsonObject_Dispose(jResp);