private static ShowKeyRotationStatusResponse GetKeyRotationStatus(KmsClient kmsClient)
        {
            try
            {
                var request = new ShowKeyRotationStatusRequest
                {
                    VersionId = "v1.0",
                    Body      = new OperateKeyRequestBody()
                    {
                        KeyId = GetKeyByStatus.GetKeyByKeyStatus(kmsClient, "2")
                    }
                };
                var resp = kmsClient.ShowKeyRotationStatus(request);
                Console.WriteLine(resp);
                return(resp);
            }
            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);
            }

            return(null);
        }
Esempio n. 2
0
        /// <summary>
        /// 查询密钥轮换状态
        /// </summary>
        public async Task <ShowKeyRotationStatusResponse> ShowKeyRotationStatusAsync(ShowKeyRotationStatusRequest showKeyRotationStatusRequest)
        {
            Dictionary <string, string> urlParam = new Dictionary <string, string>();

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

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