Dart
Dart
Glacier Get Job Information and Status
See more Amazon Glacier Examples
Demonstrates how to get information and status for a glacier job.Chilkat Dart Downloads
import 'package:chilkat/chilkat.dart';
void main() {
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
final rest = CkRest();
// Connect to the Amazon AWS REST server in the desired region.
final bTls = true;
final port = 443;
final bAutoReconnect = true;
rest.connect('glacier.us-west-2.amazonaws.com', port, bTls, bAutoReconnect);
// Provide AWS credentials.
final authAws = CkAuthAws();
authAws.accessKey = 'AWS_ACCESS_KEY';
authAws.secretKey = 'AWS_SECRET_KEY';
authAws.serviceName = 'glacier';
authAws.region = 'us-west-2';
rest.setAuthAws(authAws);
// --------------------------------------------------------------------------
// 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
//
rest.addHeader('x-amz-glacier-version', '2012-06-01');
final sbResponseBody = CkStringBuilder();
try {
rest.fullRequestNoBodySb('GET', '/AWS_ACCOUNT_ID/vaults/chilkat/jobs/JOB_ID', sbResponseBody);
} on ChilkatException catch (e) {
print(e.lastErrorText);
return;
}
final respStatusCode = rest.responseStatusCode;
if (respStatusCode >= 400) {
print('Response Status Code = $respStatusCode');
print('Response Header:');
print(rest.responseHeader);
print('Response Body:');
print(sbResponseBody.getAsString());
return;
}
// Success is indicated by a 200 response status.
print('response status code = $respStatusCode');
final json = CkJsonObject();
json.loadSb(sbResponseBody);
json.emitCompact = false;
print(json.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"
// }
//
final action = json.stringOf('Action');
final archiveId = json.stringOf('ArchiveId');
final archiveSHA256TreeHash = json.stringOf('ArchiveSHA256TreeHash');
final archiveSizeInBytes = json.stringOf('ArchiveSizeInBytes');
final completionDate = json.stringOf('CompletionDate');
final creationDate = json.stringOf('CreationDate');
final inventoryRetrievalParametersEndDate = json.stringOf('InventoryRetrievalParameters.EndDate');
final inventoryRetrievalParametersFormat = json.stringOf('InventoryRetrievalParameters.Format');
final inventoryRetrievalParametersLimit = json.stringOf('InventoryRetrievalParameters.Limit');
final inventoryRetrievalParametersMarker = json.stringOf('InventoryRetrievalParameters.Marker');
final inventoryRetrievalParametersStartDate = json.stringOf('InventoryRetrievalParameters.StartDate');
final inventorySizeInBytes = json.stringOf('InventorySizeInBytes');
final jobDescription = json.stringOf('JobDescription');
final jobId = json.stringOf('JobId');
final jobOutputPath = json.stringOf('JobOutputPath');
final outputLocation = json.stringOf('OutputLocation');
final retrievalByteRange = json.stringOf('RetrievalByteRange');
final sha256TreeHash = json.stringOf('SHA256TreeHash');
final snsTopic = json.stringOf('SNSTopic');
final selectParameters = json.stringOf('SelectParameters');
final statusCode = json.stringOf('StatusCode');
final statusMessage = json.stringOf('StatusMessage');
final tier = json.stringOf('Tier');
final vaultARN = json.stringOf('VaultARN');
}