Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Unicode C++) Glacier Get Job Information and StatusDemonstrates how to get information and status for a glacier job.
#include <CkRestW.h> #include <CkAuthAwsW.h> #include <CkStringBuilderW.h> #include <CkJsonObjectW.h> void ChilkatSample(void) { // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. CkRestW rest; // Connect to the Amazon AWS REST server in the desired region. bool bTls = true; int port = 443; bool bAutoReconnect = true; bool success = rest.Connect(L"glacier.us-west-2.amazonaws.com",port,bTls,bAutoReconnect); // Provide AWS credentials. CkAuthAwsW authAws; authAws.put_AccessKey(L"AWS_ACCESS_KEY"); authAws.put_SecretKey(L"AWS_SECRET_KEY"); authAws.put_ServiceName(L"glacier"); authAws.put_Region(L"us-west-2"); success = 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(L"x-amz-glacier-version",L"2012-06-01"); CkStringBuilderW sbResponseBody; success = rest.FullRequestNoBodySb(L"GET",L"/AWS_ACCOUNT_ID/vaults/chilkat/jobs/JOB_ID",sbResponseBody); if (success != true) { wprintf(L"%s\n",rest.lastErrorText()); return; } int respStatusCode = rest.get_ResponseStatusCode(); if (respStatusCode >= 400) { wprintf(L"Response Status Code = %d\n",respStatusCode); wprintf(L"Response Header:\n"); wprintf(L"%s\n",rest.responseHeader()); wprintf(L"Response Body:\n"); wprintf(L"%s\n",sbResponseBody.getAsString()); return; } // Success is indicated by a 200 response status. wprintf(L"response status code = %d\n",respStatusCode); CkJsonObjectW json; json.LoadSb(sbResponseBody); json.put_EmitCompact(false); wprintf(L"%s\n",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" // } // const wchar_t *Action = 0; const wchar_t *ArchiveId = 0; const wchar_t *ArchiveSHA256TreeHash = 0; const wchar_t *ArchiveSizeInBytes = 0; bool Completed; const wchar_t *CompletionDate = 0; const wchar_t *CreationDate = 0; const wchar_t *InventoryRetrievalParametersEndDate = 0; const wchar_t *InventoryRetrievalParametersFormat = 0; const wchar_t *InventoryRetrievalParametersLimit = 0; const wchar_t *InventoryRetrievalParametersMarker = 0; const wchar_t *InventoryRetrievalParametersStartDate = 0; const wchar_t *InventorySizeInBytes = 0; const wchar_t *JobDescription = 0; const wchar_t *JobId = 0; const wchar_t *JobOutputPath = 0; const wchar_t *OutputLocation = 0; const wchar_t *RetrievalByteRange = 0; const wchar_t *SHA256TreeHash = 0; const wchar_t *SNSTopic = 0; const wchar_t *SelectParameters = 0; const wchar_t *StatusCode = 0; const wchar_t *StatusMessage = 0; const wchar_t *Tier = 0; const wchar_t *VaultARN = 0; Action = json.stringOf(L"Action"); ArchiveId = json.stringOf(L"ArchiveId"); ArchiveSHA256TreeHash = json.stringOf(L"ArchiveSHA256TreeHash"); ArchiveSizeInBytes = json.stringOf(L"ArchiveSizeInBytes"); Completed = json.BoolOf(L"Completed"); CompletionDate = json.stringOf(L"CompletionDate"); CreationDate = json.stringOf(L"CreationDate"); InventoryRetrievalParametersEndDate = json.stringOf(L"InventoryRetrievalParameters.EndDate"); InventoryRetrievalParametersFormat = json.stringOf(L"InventoryRetrievalParameters.Format"); InventoryRetrievalParametersLimit = json.stringOf(L"InventoryRetrievalParameters.Limit"); InventoryRetrievalParametersMarker = json.stringOf(L"InventoryRetrievalParameters.Marker"); InventoryRetrievalParametersStartDate = json.stringOf(L"InventoryRetrievalParameters.StartDate"); InventorySizeInBytes = json.stringOf(L"InventorySizeInBytes"); JobDescription = json.stringOf(L"JobDescription"); JobId = json.stringOf(L"JobId"); JobOutputPath = json.stringOf(L"JobOutputPath"); OutputLocation = json.stringOf(L"OutputLocation"); RetrievalByteRange = json.stringOf(L"RetrievalByteRange"); SHA256TreeHash = json.stringOf(L"SHA256TreeHash"); SNSTopic = json.stringOf(L"SNSTopic"); SelectParameters = json.stringOf(L"SelectParameters"); StatusCode = json.stringOf(L"StatusCode"); StatusMessage = json.stringOf(L"StatusMessage"); Tier = json.stringOf(L"Tier"); VaultARN = json.stringOf(L"VaultARN"); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.