コード例 #1
0
 private static void UpdateKeyAlias(KmsClient kmsClient)
 {
     try
     {
         var req = new UpdateKeyAliasRequest
         {
             VersionId = "v1.0",
             Body      = new UpdateKeyAliasRequestBody
             {
                 KeyId    = GetKeyByStatus.GetKeyByKeyStatus(kmsClient, "2"),
                 KeyAlias = "0000"
             }
         };
         var resp = kmsClient.UpdateKeyAlias(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);
     }
 }
コード例 #2
0
        /// <summary>
        /// 修改密钥别名
        /// </summary>
        public async Task <UpdateKeyAliasResponse> UpdateKeyAliasAsync(UpdateKeyAliasRequest updateKeyAliasRequest)
        {
            Dictionary <string, string> urlParam = new Dictionary <string, string>();

            urlParam.Add("version_id", updateKeyAliasRequest.VersionId.ToString());
            string              urlPath  = HttpUtils.AddUrlPath("/{version_id}/{project_id}/kms/update-key-alias", urlParam);
            SdkRequest          request  = HttpUtils.InitSdkRequest(urlPath, "application/json;charset=UTF-8", updateKeyAliasRequest);
            HttpResponseMessage response = await DoHttpRequestAsync("POST", request);

            return(JsonUtils.DeSerialize <UpdateKeyAliasResponse>(response));
        }