private static void DeleteKey(KmsClient kmsClient) { try { var req = new DeleteKeyRequest { VersionId = "v1.0", Body = new ScheduleKeyDeletionRequestBody { KeyId = GetKeyByStatus.GetKeyByKeyStatus(kmsClient, "2"), PendingDays = "365" } }; var resp = kmsClient.DeleteKey(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> /// Deletes the application key specified. /// </summary> /// <param name="applicationKeyId">The application key id to delete.</param> /// <exception cref="AuthenticationException">Thrown when authentication fails.</exception> /// <exception cref="ApiException">Thrown when an error occurs during client operation.</exception> async Task <IApiResults <DeleteKeyResponse> > IStorageKeys.DeleteAsync (string applicationKeyId) { var request = new DeleteKeyRequest(applicationKeyId); return(await _client.DeleteKeyAsync(request, _cancellationToken)); }
/// <summary> /// 计划删除密钥 /// </summary> public async Task <DeleteKeyResponse> DeleteKeyAsync(DeleteKeyRequest deleteKeyRequest) { Dictionary <string, string> urlParam = new Dictionary <string, string>(); urlParam.Add("version_id", deleteKeyRequest.VersionId.ToString()); string urlPath = HttpUtils.AddUrlPath("/{version_id}/{project_id}/kms/schedule-key-deletion", urlParam); SdkRequest request = HttpUtils.InitSdkRequest(urlPath, "application/json;charset=UTF-8", deleteKeyRequest); HttpResponseMessage response = await DoHttpRequestAsync("POST", request); return(JsonUtils.DeSerialize <DeleteKeyResponse>(response)); }
public void DeleteKey(DeleteKeyRequest argObj) { try { AdminDAL ws = new AdminDAL(); ws.DeleteKeyUser(argObj); } catch (Exception ex) { } }
/// <summary>Snippet for DeleteKey</summary> public void DeleteKeyRequestObject() { // Snippet: DeleteKey(DeleteKeyRequest, CallSettings) // Create client RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient = RecaptchaEnterpriseServiceClient.Create(); // Initialize request argument(s) DeleteKeyRequest request = new DeleteKeyRequest { KeyName = KeyName.FromProjectKey("[PROJECT]", "[KEY]"), }; // Make the request recaptchaEnterpriseServiceClient.DeleteKey(request); // End snippet }
public void DeleteKeyRequestObject() { moq::Mock <RecaptchaEnterpriseService.RecaptchaEnterpriseServiceClient> mockGrpcClient = new moq::Mock <RecaptchaEnterpriseService.RecaptchaEnterpriseServiceClient>(moq::MockBehavior.Strict); DeleteKeyRequest request = new DeleteKeyRequest { KeyName = KeyName.FromProjectKey("[PROJECT]", "[KEY]"), }; wkt::Empty expectedResponse = new wkt::Empty { }; mockGrpcClient.Setup(x => x.DeleteKey(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); RecaptchaEnterpriseServiceClient client = new RecaptchaEnterpriseServiceClientImpl(mockGrpcClient.Object, null); client.DeleteKey(request); mockGrpcClient.VerifyAll(); }
/// <summary>Snippet for DeleteKeyAsync</summary> public async Task DeleteKeyRequestObjectAsync() { // Snippet: DeleteKeyAsync(DeleteKeyRequest, CallSettings) // Additional: DeleteKeyAsync(DeleteKeyRequest, CancellationToken) // Create client RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient = await RecaptchaEnterpriseServiceClient.CreateAsync(); // Initialize request argument(s) DeleteKeyRequest request = new DeleteKeyRequest { KeyName = KeyName.FromProjectKey("[PROJECT]", "[KEY]"), }; // Make the request await recaptchaEnterpriseServiceClient.DeleteKeyAsync(request); // End snippet }
public async stt::Task DeleteKeyRequestObjectAsync() { moq::Mock <RecaptchaEnterpriseService.RecaptchaEnterpriseServiceClient> mockGrpcClient = new moq::Mock <RecaptchaEnterpriseService.RecaptchaEnterpriseServiceClient>(moq::MockBehavior.Strict); DeleteKeyRequest request = new DeleteKeyRequest { KeyName = KeyName.FromProjectKey("[PROJECT]", "[KEY]"), }; wkt::Empty expectedResponse = new wkt::Empty { }; mockGrpcClient.Setup(x => x.DeleteKeyAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <wkt::Empty>(stt::Task.FromResult(expectedResponse), null, null, null, null)); RecaptchaEnterpriseServiceClient client = new RecaptchaEnterpriseServiceClientImpl(mockGrpcClient.Object, null); await client.DeleteKeyAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); await client.DeleteKeyAsync(request, st::CancellationToken.None); mockGrpcClient.VerifyAll(); }
public void TestDeleteKey() { var client = new DefaultOneNETClient(url, appkey, ""); var permissions = new List <Permission> { new Permission { Access_Methods = new[] { HttpRequestMethod.Get.GetMethodString(), HttpRequestMethod.Delete.GetMethodString() }, Resources = new List <KeyResource> { new KeyResource { Dev_Id = "768672" } } } }; var data = new ApiKeyInfo { Title = "test delete key", Permissions = permissions }; var req = new NewKeyRequest { KeyInfo = data }; var rsp = client.Execute(req); Console.WriteLine("key to delete has added: " + rsp.Body); Assert.IsFalse(rsp.IsError); Assert.IsNotNull(rsp.Data); Assert.IsNotNull(rsp.Data.Key); var c1 = new DefaultOneNETClient(url, appkey, ""); var req1 = new DeleteKeyRequest { KeyString = rsp.Data.Key }; var rsp1 = c1.Execute(req1); Assert.IsFalse(rsp1.IsError); }
private void DeleteItem(string argkeyId) { log4net.ILog logger = log4net.LogManager.GetLogger("File"); try { if (!string.IsNullOrEmpty(argkeyId)) { AdminBLL ws = new AdminBLL(); DeleteKeyRequest _req = new DeleteKeyRequest(); _req.KeyNo = argkeyId.ToString(); ws.DeleteKey(_req); HttpContext.Current.Items.Add(ContextKeys.CTX_COMPLETE, "DELETE"); Server.Transfer("../smsadmin/AlertUpdateComplete.aspx"); } } catch (Exception ex) { logger.Info(ex.Message); } }