StopRemoteAccessSession Foxpro Example
LOCAL loRest
LOCAL lnSuccess
LOCAL loAuthAws
LOCAL loJson
LOCAL loSbRequestBody
LOCAL loSbResponseBody
LOCAL lnRespStatusCode
LOCAL loJResp
LOCAL lcArn
LOCAL lcDeviceArn
LOCAL lcInstanceProfileArn
LOCAL lcDescription
LOCAL lcInstanceProfileName
LOCAL lnPackageCleanup
LOCAL lnRebootAfterUse
LOCAL lcStatus
LOCAL lcUdid
LOCAL j
LOCAL lnCount_j
LOCAL lcStrVal
LOCAL lcArn
LOCAL lcBillingMethod
LOCAL lcClientId
LOCAL lnCreated
LOCAL lcDeviceArn
LOCAL lcAvailability
LOCAL lcCarrier
LOCAL lcArchitecture
LOCAL lnClock
LOCAL lcFrequency
LOCAL lcFleetName
LOCAL lcFleetType
LOCAL lcFormFactor
LOCAL lnHeapSize
LOCAL lcImage
LOCAL lcManufacturer
LOCAL lnMemory
LOCAL lcModel
LOCAL lcModelId
LOCAL lcName
LOCAL lcOs
LOCAL lcPlatform
LOCAL lcRadio
LOCAL lnRemoteAccessEnabled
LOCAL lnRemoteDebugEnabled
LOCAL lnHeight
LOCAL lnWidth
LOCAL lnMetered
LOCAL lnTotal
LOCAL lnUnmetered
LOCAL lcDeviceUdid
LOCAL lcEndpoint
LOCAL lcHostAddress
LOCAL lcInstanceArn
LOCAL lcInteractionMode
LOCAL lcMessage
LOCAL lcRemoteAccessSessionName
LOCAL lnRemoteAccessSessionRemoteDebugEnabled
LOCAL lcRemoteRecordAppArn
LOCAL lnRemoteRecordEnabled
LOCAL lcResult
LOCAL lnSkipAppResign
LOCAL lnStarted
LOCAL lcStatus
LOCAL lnStopped
LOCAL i
LOCAL lnCount_i
* This example requires the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.
loRest = CreateObject('Chilkat_9_5_0.Rest')
loAuthAws = CreateObject('Chilkat_9_5_0.AuthAws')
loAuthAws.AccessKey = "AWS_ACCESS_KEY"
loAuthAws.SecretKey = "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.)
loAuthAws.Region = "us-west-2"
loAuthAws.ServiceName = "devicefarm"
* SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
loRest.SetAuthAws(loAuthAws)
* URL: https://devicefarm.us-west-2.amazonaws.com/
* Use the same region as specified above.
lnSuccess = loRest.Connect("devicefarm.us-west-2.amazonaws.com",443,1,1)
IF (lnSuccess <> 1) THEN
? "ConnectFailReason: " + STR(loRest.ConnectFailReason)
? loRest.LastErrorText
RELEASE loRest
RELEASE loAuthAws
CANCEL
ENDIF
* 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
loJson = CreateObject('Chilkat_9_5_0.JsonObject')
loJson.UpdateString("arn","string")
* The JSON request body created by the above code:
* {
* "arn": "string"
* }
loRest.AddHeader("Content-Type","application/x-amz-json-1.1")
loRest.AddHeader("X-Amz-Target","DeviceFarm_20150623.StopRemoteAccessSession")
loSbRequestBody = CreateObject('Chilkat_9_5_0.StringBuilder')
loJson.EmitSb(loSbRequestBody)
loSbResponseBody = CreateObject('Chilkat_9_5_0.StringBuilder')
lnSuccess = loRest.FullRequestSb("POST","/",loSbRequestBody,loSbResponseBody)
IF (lnSuccess <> 1) THEN
? loRest.LastErrorText
RELEASE loRest
RELEASE loAuthAws
RELEASE loJson
RELEASE loSbRequestBody
RELEASE loSbResponseBody
CANCEL
ENDIF
lnRespStatusCode = loRest.ResponseStatusCode
? "response status code = " + STR(lnRespStatusCode)
IF (lnRespStatusCode <> 200) THEN
? "Response Header:"
? loRest.ResponseHeader
? "Response Body:"
? loSbResponseBody.GetAsString()
RELEASE loRest
RELEASE loAuthAws
RELEASE loJson
RELEASE loSbRequestBody
RELEASE loSbResponseBody
CANCEL
ENDIF
loJResp = CreateObject('Chilkat_9_5_0.JsonObject')
loJResp.LoadSb(loSbResponseBody)
* 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
lcArn = loJResp.StringOf("remoteAccessSession.arn")
lcBillingMethod = loJResp.StringOf("remoteAccessSession.billingMethod")
lcClientId = loJResp.StringOf("remoteAccessSession.clientId")
lnCreated = loJResp.IntOf("remoteAccessSession.created")
lcDeviceArn = loJResp.StringOf("remoteAccessSession.device.arn")
lcAvailability = loJResp.StringOf("remoteAccessSession.device.availability")
lcCarrier = loJResp.StringOf("remoteAccessSession.device.carrier")
lcArchitecture = loJResp.StringOf("remoteAccessSession.device.cpu.architecture")
lnClock = loJResp.IntOf("remoteAccessSession.device.cpu.clock")
lcFrequency = loJResp.StringOf("remoteAccessSession.device.cpu.frequency")
lcFleetName = loJResp.StringOf("remoteAccessSession.device.fleetName")
lcFleetType = loJResp.StringOf("remoteAccessSession.device.fleetType")
lcFormFactor = loJResp.StringOf("remoteAccessSession.device.formFactor")
lnHeapSize = loJResp.IntOf("remoteAccessSession.device.heapSize")
lcImage = loJResp.StringOf("remoteAccessSession.device.image")
lcManufacturer = loJResp.StringOf("remoteAccessSession.device.manufacturer")
lnMemory = loJResp.IntOf("remoteAccessSession.device.memory")
lcModel = loJResp.StringOf("remoteAccessSession.device.model")
lcModelId = loJResp.StringOf("remoteAccessSession.device.modelId")
lcName = loJResp.StringOf("remoteAccessSession.device.name")
lcOs = loJResp.StringOf("remoteAccessSession.device.os")
lcPlatform = loJResp.StringOf("remoteAccessSession.device.platform")
lcRadio = loJResp.StringOf("remoteAccessSession.device.radio")
lnRemoteAccessEnabled = loJResp.IntOf("remoteAccessSession.device.remoteAccessEnabled")
lnRemoteDebugEnabled = loJResp.IntOf("remoteAccessSession.device.remoteDebugEnabled")
lnHeight = loJResp.IntOf("remoteAccessSession.device.resolution.height")
lnWidth = loJResp.IntOf("remoteAccessSession.device.resolution.width")
lnMetered = loJResp.IntOf("remoteAccessSession.deviceMinutes.metered")
lnTotal = loJResp.IntOf("remoteAccessSession.deviceMinutes.total")
lnUnmetered = loJResp.IntOf("remoteAccessSession.deviceMinutes.unmetered")
lcDeviceUdid = loJResp.StringOf("remoteAccessSession.deviceUdid")
lcEndpoint = loJResp.StringOf("remoteAccessSession.endpoint")
lcHostAddress = loJResp.StringOf("remoteAccessSession.hostAddress")
lcInstanceArn = loJResp.StringOf("remoteAccessSession.instanceArn")
lcInteractionMode = loJResp.StringOf("remoteAccessSession.interactionMode")
lcMessage = loJResp.StringOf("remoteAccessSession.message")
lcRemoteAccessSessionName = loJResp.StringOf("remoteAccessSession.name")
lnRemoteAccessSessionRemoteDebugEnabled = loJResp.IntOf("remoteAccessSession.remoteDebugEnabled")
lcRemoteRecordAppArn = loJResp.StringOf("remoteAccessSession.remoteRecordAppArn")
lnRemoteRecordEnabled = loJResp.IntOf("remoteAccessSession.remoteRecordEnabled")
lcResult = loJResp.StringOf("remoteAccessSession.result")
lnSkipAppResign = loJResp.IntOf("remoteAccessSession.skipAppResign")
lnStarted = loJResp.IntOf("remoteAccessSession.started")
lcStatus = loJResp.StringOf("remoteAccessSession.status")
lnStopped = loJResp.IntOf("remoteAccessSession.stopped")
i = 0
lnCount_i = loJResp.SizeOfArray("remoteAccessSession.device.instances")
DO WHILE i < lnCount_i
loJResp.I = i
lcArn = loJResp.StringOf("remoteAccessSession.device.instances[i].arn")
lcDeviceArn = loJResp.StringOf("remoteAccessSession.device.instances[i].deviceArn")
lcInstanceProfileArn = loJResp.StringOf("remoteAccessSession.device.instances[i].instanceProfile.arn")
lcDescription = loJResp.StringOf("remoteAccessSession.device.instances[i].instanceProfile.description")
lcInstanceProfileName = loJResp.StringOf("remoteAccessSession.device.instances[i].instanceProfile.name")
lnPackageCleanup = loJResp.IntOf("remoteAccessSession.device.instances[i].instanceProfile.packageCleanup")
lnRebootAfterUse = loJResp.IntOf("remoteAccessSession.device.instances[i].instanceProfile.rebootAfterUse")
lcStatus = loJResp.StringOf("remoteAccessSession.device.instances[i].status")
lcUdid = loJResp.StringOf("remoteAccessSession.device.instances[i].udid")
j = 0
lnCount_j = loJResp.SizeOfArray("remoteAccessSession.device.instances[i].instanceProfile.excludeAppPackagesFromCleanup")
DO WHILE j < lnCount_j
loJResp.J = j
lcStrVal = loJResp.StringOf("remoteAccessSession.device.instances[i].instanceProfile.excludeAppPackagesFromCleanup[j]")
j = j + 1
ENDDO
j = 0
lnCount_j = loJResp.SizeOfArray("remoteAccessSession.device.instances[i].labels")
DO WHILE j < lnCount_j
loJResp.J = j
lcStrVal = loJResp.StringOf("remoteAccessSession.device.instances[i].labels[j]")
j = j + 1
ENDDO
i = i + 1
ENDDO
* A sample JSON response body parsed by the above code:
* {
* "remoteAccessSession": {
* "arn": "string",
* "billingMethod": "string",
* "clientId": "string",
* "created": number,
* "device": {
* "arn": "string",
* "availability": "string",
* "carrier": "string",
* "cpu": {
* "architecture": "string",
* "clock": number,
* "frequency": "string"
* },
* "fleetName": "string",
* "fleetType": "string",
* "formFactor": "string",
* "heapSize": number,
* "image": "string",
* "instances": [
* {
* "arn": "string",
* "deviceArn": "string",
* "instanceProfile": {
* "arn": "string",
* "description": "string",
* "excludeAppPackagesFromCleanup": [
* "string"
* ],
* "name": "string",
* "packageCleanup": boolean,
* "rebootAfterUse": boolean
* },
* "labels": [
* "string"
* ],
* "status": "string",
* "udid": "string"
* }
* ],
* "manufacturer": "string",
* "memory": number,
* "model": "string",
* "modelId": "string",
* "name": "string",
* "os": "string",
* "platform": "string",
* "radio": "string",
* "remoteAccessEnabled": boolean,
* "remoteDebugEnabled": boolean,
* "resolution": {
* "height": number,
* "width": number
* }
* },
* "deviceMinutes": {
* "metered": number,
* "total": number,
* "unmetered": number
* },
* "deviceUdid": "string",
* "endpoint": "string",
* "hostAddress": "string",
* "instanceArn": "string",
* "interactionMode": "string",
* "message": "string",
* "name": "string",
* "remoteDebugEnabled": boolean,
* "remoteRecordAppArn": "string",
* "remoteRecordEnabled": boolean,
* "result": "string",
* "skipAppResign": boolean,
* "started": number,
* "status": "string",
* "stopped": number
* }
* }
RELEASE loRest
RELEASE loAuthAws
RELEASE loJson
RELEASE loSbRequestBody
RELEASE loSbResponseBody
RELEASE loJResp