private static void GetKeyTag(KmsClient kmsClient) { try { var req = new ShowKmsTagsRequest { VersionId = "v1.0", KeyId = GetKeyByStatus.GetKeyByKeyStatus(kmsClient, "2") }; var resp = kmsClient.ShowKmsTags(req); Console.WriteLine(resp.ToString()); } catch (RequestTimeoutException requestTimeoutException) { Console.WriteLine(requestTimeoutException.ErrorMessage); } catch (ServiceResponseException clientRequestException) { Console.WriteLine(clientRequestException.HttpStatusCode); Console.WriteLine(clientRequestException.ErrorCode); Console.WriteLine(clientRequestException.ErrorMsg); } catch (ConnectionException connectionException) { Console.WriteLine(connectionException.ErrorMessage); } }
/// <summary> /// 查询密钥标签 /// </summary> public async Task <ShowKmsTagsResponse> ShowKmsTagsAsync(ShowKmsTagsRequest showKmsTagsRequest) { Dictionary <string, string> urlParam = new Dictionary <string, string>(); urlParam.Add("version_id", showKmsTagsRequest.VersionId.ToString()); urlParam.Add("key_id", showKmsTagsRequest.KeyId.ToString()); string urlPath = HttpUtils.AddUrlPath("/{version_id}/{project_id}/kms/{key_id}/tags", urlParam); SdkRequest request = HttpUtils.InitSdkRequest(urlPath, "application/json", showKmsTagsRequest); HttpResponseMessage response = await DoHttpRequestAsync("GET", request); return(JsonUtils.DeSerialize <ShowKmsTagsResponse>(response)); }