Rust
Rust
Glacier Get Job Information and Status
See more Amazon Glacier Examples
Demonstrates how to get information and status for a glacier job.Chilkat Rust Downloads
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let rest = chilkat::Rest::new();
// Connect to the Amazon AWS REST server in the desired region.
let b_tls = true;
let port = 443;
let b_auto_reconnect = true;
let _ = rest.connect("glacier.us-west-2.amazonaws.com", port, b_tls, b_auto_reconnect).is_ok();
// Provide AWS credentials.
let auth_aws = chilkat::AuthAws::new();
auth_aws.set_access_key("AWS_ACCESS_KEY");
auth_aws.set_secret_key("AWS_SECRET_KEY");
auth_aws.set_service_name("glacier");
auth_aws.set_region("us-west-2");
let _ = rest.set_auth_aws(&auth_aws).is_ok();
// --------------------------------------------------------------------------
// 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
//
let _ = rest.add_header("x-amz-glacier-version", "2012-06-01");
let sb_response_body = chilkat::StringBuilder::new();
if rest.full_request_no_body_sb("GET", "/AWS_ACCOUNT_ID/vaults/chilkat/jobs/JOB_ID", &sb_response_body).is_err() {
println!("{}", rest.last_error_text());
return;
}
let resp_status_code = rest.response_status_code();
if resp_status_code >= 400 {
println!("Response Status Code = {}", resp_status_code);
println!("Response Header:");
println!("{}", rest.response_header());
println!("Response Body:");
println!("{}", sb_response_body.get_as_string().unwrap_or_default());
return;
}
// Success is indicated by a 200 response status.
println!("response status code = {}", resp_status_code);
let json = chilkat::JsonObject::new();
let _ = json.load_sb(&sb_response_body);
json.set_emit_compact(false);
println!("{}", json.emit().unwrap_or_default());
// 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"
// }
//
let action = json.string_of("Action").unwrap_or_default();
let archive_id = json.string_of("ArchiveId").unwrap_or_default();
let archive_sha256_tree_hash = json.string_of("ArchiveSHA256TreeHash").unwrap_or_default();
let archive_size_in_bytes = json.string_of("ArchiveSizeInBytes").unwrap_or_default();
let completed = json.bool_of("Completed");
let completion_date = json.string_of("CompletionDate").unwrap_or_default();
let creation_date = json.string_of("CreationDate").unwrap_or_default();
let inventory_retrieval_parameters_end_date = json.string_of("InventoryRetrievalParameters.EndDate").unwrap_or_default();
let inventory_retrieval_parameters_format = json.string_of("InventoryRetrievalParameters.Format").unwrap_or_default();
let inventory_retrieval_parameters_limit = json.string_of("InventoryRetrievalParameters.Limit").unwrap_or_default();
let inventory_retrieval_parameters_marker = json.string_of("InventoryRetrievalParameters.Marker").unwrap_or_default();
let inventory_retrieval_parameters_start_date = json.string_of("InventoryRetrievalParameters.StartDate").unwrap_or_default();
let inventory_size_in_bytes = json.string_of("InventorySizeInBytes").unwrap_or_default();
let job_description = json.string_of("JobDescription").unwrap_or_default();
let job_id = json.string_of("JobId").unwrap_or_default();
let job_output_path = json.string_of("JobOutputPath").unwrap_or_default();
let output_location = json.string_of("OutputLocation").unwrap_or_default();
let retrieval_byte_range = json.string_of("RetrievalByteRange").unwrap_or_default();
let sha256_tree_hash = json.string_of("SHA256TreeHash").unwrap_or_default();
let sns_topic = json.string_of("SNSTopic").unwrap_or_default();
let select_parameters = json.string_of("SelectParameters").unwrap_or_default();
let status_code = json.string_of("StatusCode").unwrap_or_default();
let status_message = json.string_of("StatusMessage").unwrap_or_default();
let tier = json.string_of("Tier").unwrap_or_default();
let vault_arn = json.string_of("VaultARN").unwrap_or_default();