Sample code for 30+ languages & platforms
Visual FoxPro

Glacier Get Job Information and Status

See more Amazon Glacier Examples

Demonstrates how to get information and status for a glacier job.

Chilkat Visual FoxPro Downloads

Visual FoxPro
LOCAL lnSuccess
LOCAL loRest
LOCAL lnBTls
LOCAL lnPort
LOCAL lnBAutoReconnect
LOCAL loAuthAws
LOCAL loSbResponseBody
LOCAL lnRespStatusCode
LOCAL loJson
LOCAL lcAction
LOCAL lcArchiveId
LOCAL lcArchiveSHA256TreeHash
LOCAL lcArchiveSizeInBytes
LOCAL lnCompleted
LOCAL lcCompletionDate
LOCAL lcCreationDate
LOCAL lcInventoryRetrievalParametersEndDate
LOCAL lcInventoryRetrievalParametersFormat
LOCAL lcInventoryRetrievalParametersLimit
LOCAL lcInventoryRetrievalParametersMarker
LOCAL lcInventoryRetrievalParametersStartDate
LOCAL lcInventorySizeInBytes
LOCAL lcJobDescription
LOCAL lcJobId
LOCAL lcJobOutputPath
LOCAL lcOutputLocation
LOCAL lcRetrievalByteRange
LOCAL lcSHA256TreeHash
LOCAL lcSNSTopic
LOCAL lcSelectParameters
LOCAL lcStatusCode
LOCAL lcStatusMessage
LOCAL lcTier
LOCAL lcVaultARN

lnSuccess = 0

* This example requires the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.

loRest = CreateObject('Chilkat.Rest')

* Connect to the Amazon AWS REST server in the desired region.
lnBTls = 1
lnPort = 443
lnBAutoReconnect = 1
lnSuccess = loRest.Connect("glacier.us-west-2.amazonaws.com",lnPort,lnBTls,lnBAutoReconnect)

* Provide AWS credentials.
loAuthAws = CreateObject('Chilkat.AuthAws')
loAuthAws.AccessKey = "AWS_ACCESS_KEY"
loAuthAws.SecretKey = "AWS_SECRET_KEY"
loAuthAws.ServiceName = "glacier"
loAuthAws.Region = "us-west-2"

lnSuccess = loRest.SetAuthAws(loAuthAws)

* --------------------------------------------------------------------------
* Note: The above REST connection and setup of the AWS credentials
* can be done once.  After connecting, any number of REST calls can be made.
* The "auto reconnect" property passed to rest.Connect indicates that if
* the connection is lost, a REST method call will automatically reconnect
* if needed.
* --------------------------------------------------------------------------

* 
* For more information, see Glacier Describe Job Reference Documentation
* 
loRest.AddHeader("x-amz-glacier-version","2012-06-01")

loSbResponseBody = CreateObject('Chilkat.StringBuilder')
lnSuccess = loRest.FullRequestNoBodySb("GET","/AWS_ACCOUNT_ID/vaults/chilkat/jobs/JOB_ID",loSbResponseBody)
IF (lnSuccess <> 1) THEN
    ? loRest.LastErrorText
    RELEASE loRest
    RELEASE loAuthAws
    RELEASE loSbResponseBody
    CANCEL
ENDIF

lnRespStatusCode = loRest.ResponseStatusCode
IF (lnRespStatusCode >= 400) THEN
    ? "Response Status Code = " + STR(lnRespStatusCode)
    ? "Response Header:"
    ? loRest.ResponseHeader
    ? "Response Body:"
    ? loSbResponseBody.GetAsString()
    RELEASE loRest
    RELEASE loAuthAws
    RELEASE loSbResponseBody
    CANCEL
ENDIF

* Success is indicated by a 200 response status.
? "response status code = " + STR(lnRespStatusCode)

loJson = CreateObject('Chilkat.JsonObject')
loJson.LoadSb(loSbResponseBody)
loJson.EmitCompact = 0
? loJson.Emit()

* Sample output:
* Use this online tool to generate parsing code from sample JSON: 
* Generate Parsing Code from JSON

* {
*   "Action": "InventoryRetrieval",
*   "ArchiveId": null,
*   "ArchiveSHA256TreeHash": null,
*   "ArchiveSizeInBytes": null,
*   "Completed": false,
*   "CompletionDate": null,
*   "CreationDate": "2019-04-09T22:48:48.700Z",
*   "InventoryRetrievalParameters": {
*     "EndDate": null,
*     "Format": "CSV",
*     "Limit": null,
*     "Marker": null,
*     "StartDate": null
*   },
*   "InventorySizeInBytes": null,
*   "JobDescription": "My inventory job",
*   "JobId": "E-mCnb3j122yvz5PRFGzETmFVXVrkX_pgI8PIuwBKNRyI8pAJqIetKwzkJC5a6blIvYZrrVohiBENQVhZE1a-K-x-uRO",
*   "JobOutputPath": null,
*   "OutputLocation": null,
*   "RetrievalByteRange": null,
*   "SHA256TreeHash": null,
*   "SNSTopic": null,
*   "SelectParameters": null,
*   "StatusCode": "InProgress",
*   "StatusMessage": null,
*   "Tier": null,
*   "VaultARN": "arn:aws:glacier:us-west-2:954491834127:vaults/chilkat"
* }
* 

lcAction = loJson.StringOf("Action")
lcArchiveId = loJson.StringOf("ArchiveId")
lcArchiveSHA256TreeHash = loJson.StringOf("ArchiveSHA256TreeHash")
lcArchiveSizeInBytes = loJson.StringOf("ArchiveSizeInBytes")
lnCompleted = loJson.BoolOf("Completed")
lcCompletionDate = loJson.StringOf("CompletionDate")
lcCreationDate = loJson.StringOf("CreationDate")
lcInventoryRetrievalParametersEndDate = loJson.StringOf("InventoryRetrievalParameters.EndDate")
lcInventoryRetrievalParametersFormat = loJson.StringOf("InventoryRetrievalParameters.Format")
lcInventoryRetrievalParametersLimit = loJson.StringOf("InventoryRetrievalParameters.Limit")
lcInventoryRetrievalParametersMarker = loJson.StringOf("InventoryRetrievalParameters.Marker")
lcInventoryRetrievalParametersStartDate = loJson.StringOf("InventoryRetrievalParameters.StartDate")
lcInventorySizeInBytes = loJson.StringOf("InventorySizeInBytes")
lcJobDescription = loJson.StringOf("JobDescription")
lcJobId = loJson.StringOf("JobId")
lcJobOutputPath = loJson.StringOf("JobOutputPath")
lcOutputLocation = loJson.StringOf("OutputLocation")
lcRetrievalByteRange = loJson.StringOf("RetrievalByteRange")
lcSHA256TreeHash = loJson.StringOf("SHA256TreeHash")
lcSNSTopic = loJson.StringOf("SNSTopic")
lcSelectParameters = loJson.StringOf("SelectParameters")
lcStatusCode = loJson.StringOf("StatusCode")
lcStatusMessage = loJson.StringOf("StatusMessage")
lcTier = loJson.StringOf("Tier")
lcVaultARN = loJson.StringOf("VaultARN")

RELEASE loRest
RELEASE loAuthAws
RELEASE loSbResponseBody
RELEASE loJson