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
(DataFlex) AWS KMS List KeysSee more AWS KMS ExamplesGets a list of all KMS keys in the caller's AWS account and Region. For more information, see https://docs.aws.amazon.com/kms/latest/APIReference/API_ListKeys.html
Use ChilkatAx-win32.pkg Procedure Test Handle hoRest Boolean iBTls Integer iPort Boolean iBAutoReconnect Boolean iSuccess Variant vAuthAws Handle hoAuthAws String sStrJson Handle hoJson String sKeyArn String sKeyId Integer iKeyCount Boolean iTruncated Integer i Integer iCount_i String sTemp1 Integer iTemp1 Boolean bTemp1 // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. Get Create (RefClass(cComChilkatRest)) To hoRest If (Not(IsComObjectCreated(hoRest))) Begin Send CreateComObject of hoRest End // Connect to the Amazon AWS REST server. // Make sure to use the region that is correct for you. // such as https://kms.us-west-2.amazonaws.com/ Move True To iBTls Move 443 To iPort Move True To iBAutoReconnect Get ComConnect Of hoRest "kms.us-west-2.amazonaws.com" iPort iBTls iBAutoReconnect To iSuccess // Provide AWS credentials for the REST call. Get Create (RefClass(cComChilkatAuthAws)) To hoAuthAws If (Not(IsComObjectCreated(hoAuthAws))) Begin Send CreateComObject of hoAuthAws End Set ComAccessKey Of hoAuthAws To "AWS_ACCESS_KEY" Set ComSecretKey Of hoAuthAws To "AWS_SECRET_KEY" // the region should match our URL above.. Set ComRegion Of hoAuthAws To "us-west-2" Set ComServiceName Of hoAuthAws To "kms" Get pvComObject of hoAuthAws to vAuthAws Get ComSetAuthAws Of hoRest vAuthAws To iSuccess Get ComAddHeader Of hoRest "X-Amz-Target" "TrentService.ListKeys" To iSuccess Get ComAddHeader Of hoRest "Content-Type" "application/x-amz-json-1.1" To iSuccess Get ComFullRequestString Of hoRest "POST" "/" "{}" To sStrJson Get ComLastMethodSuccess Of hoRest To bTemp1 If (bTemp1 <> True) Begin Get ComLastErrorText Of hoRest To sTemp1 Showln sTemp1 Procedure_Return End // A successful response will have a status code equal to 200. Get ComResponseStatusCode Of hoRest To iTemp1 If (iTemp1 <> 200) Begin Get ComResponseStatusCode Of hoRest To iTemp1 Showln "response status code = " iTemp1 Get ComResponseStatusText Of hoRest To sTemp1 Showln "response status text = " sTemp1 Get ComResponseHeader Of hoRest To sTemp1 Showln "response header: " sTemp1 Showln "response body: " sStrJson Procedure_Return End // Examine the successful JSON response (shown below) Get Create (RefClass(cComChilkatJsonObject)) To hoJson If (Not(IsComObjectCreated(hoJson))) Begin Send CreateComObject of hoJson End Get ComLoad Of hoJson sStrJson To iSuccess Set ComEmitCompact Of hoJson To False Get ComEmit Of hoJson To sTemp1 Showln sTemp1 // Sample output: // { // "KeyCount": 4, // "Keys": [ // { // "KeyArn": "arn:aws:kms:us-west-2:954491834127:key/082f8520-7afc-4a09-b703-89b7243072e5", // "KeyId": "082f8520-7afc-4a09-b703-89b7243072e5" // }, // { // "KeyArn": "arn:aws:kms:us-west-2:954491834127:key/17432483-ff08-4950-93d3-f46ebb5e17d1", // "KeyId": "17432483-ff08-4950-93d3-f46ebb5e17d1" // }, // { // "KeyArn": "arn:aws:kms:us-west-2:954491834127:key/1b0e5b3c-0675-4510-adb6-a75b40a93da0", // "KeyId": "1b0e5b3c-0675-4510-adb6-a75b40a93da0" // }, // { // "KeyArn": "arn:aws:kms:us-west-2:954491834127:key/265e3993-428b-4581-9466-b1030a53062f", // "KeyId": "265e3993-428b-4581-9466-b1030a53062f" // }, // ], // "Truncated": false // } // Use this online tool to generate parsing code from sample JSON: // Generate Parsing Code from JSON Get ComIntOf Of hoJson "KeyCount" To iKeyCount Get ComBoolOf Of hoJson "Truncated" To iTruncated Move 0 To i Get ComSizeOfArray Of hoJson "Keys" To iCount_i While (i < iCount_i) Set ComI Of hoJson To i Get ComStringOf Of hoJson "Keys[i].KeyArn" To sKeyArn Get ComStringOf Of hoJson "Keys[i].KeyId" To sKeyId Move (i + 1) To i Loop End_Procedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.