internal virtual DeleteRuleResponse DeleteRule(DeleteRuleRequest request) { var marshaller = DeleteRuleRequestMarshaller.Instance; var unmarshaller = DeleteRuleResponseUnmarshaller.Instance; return(Invoke <DeleteRuleRequest, DeleteRuleResponse>(request, marshaller, unmarshaller)); }
public static bool DeleteRule(int ruleID) { try { using (_certonaService = new CertonaServiceClient()) { try { UserDTO user = FormsAuthenticationWrapper.User; var request = new DeleteRuleRequest() { User = user, ApplicationID = null, RuleID = ruleID }; var response = _certonaService.DeleteRule(request); return(response.Success); } catch (TimeoutException exception) { _certonaService.Abort(); throw; } catch (CommunicationException exception) { _certonaService.Abort(); throw; } } } catch (Exception ex) { throw; } }
private static void deleteRule(IoTDAClient client) { DeleteRuleRequest req = new DeleteRuleRequest { RuleId = "5ea8ebe75d6efc01e5a022c8", InstanceId = "1a7ffc5c-d89c-44dd-8265-b1653d951ce0" }; try { var resp = client.DeleteRule(req); Console.WriteLine(resp.HttpStatusCode); Console.WriteLine(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); } }
protected override void ProcessRecord() { base.ProcessRecord(); if (!ConfirmDelete("OCIEventsRule", "Remove")) { return; } DeleteRuleRequest request; try { request = new DeleteRuleRequest { RuleId = RuleId, IfMatch = IfMatch, OpcRequestId = OpcRequestId }; response = client.DeleteRule(request).GetAwaiter().GetResult(); WriteOutput(response); FinishProcessing(response); } catch (Exception ex) { TerminatingErrorDuringExecution(ex); } }
/// <summary> /// Deletes a rule. You must remove all targets from a rule using <a>RemoveTargets</a> /// before you can delete the rule. /// /// /// <para> /// <b>Note:</b> When you delete a rule, incoming events might still continue to match /// to the deleted rule. Please allow a short period of time for changes to take effect. /// /// </para> /// </summary> /// <param name="request">Container for the necessary parameters to execute the DeleteRule service method.</param> /// /// <returns>The response from the DeleteRule service method, as returned by CloudWatchEvents.</returns> /// <exception cref="Amazon.CloudWatchEvents.Model.ConcurrentModificationException"> /// This exception occurs if there is concurrent modification on rule or target. /// </exception> /// <exception cref="Amazon.CloudWatchEvents.Model.InternalException"> /// This exception occurs due to unexpected causes. /// </exception> public DeleteRuleResponse DeleteRule(DeleteRuleRequest request) { var marshaller = new DeleteRuleRequestMarshaller(); var unmarshaller = DeleteRuleResponseUnmarshaller.Instance; return(Invoke <DeleteRuleRequest, DeleteRuleResponse>(request, marshaller, unmarshaller)); }
/// <summary> /// Deletes a rule. /// </summary> /// <param name="request">The request object containing the details to send. Required.</param> /// <param name="retryConfiguration">The retry configuration that will be used by to send this request. Optional.</param> /// <param name="cancellationToken">The cancellation token to cancel this operation. Optional.</param> /// <returns>A response object containing details about the completed operation</returns> /// <example>Click <a href="https://docs.cloud.oracle.com/en-us/iaas/tools/dot-net-examples/latest/events/DeleteRule.cs.html">here</a> to see an example of how to use DeleteRule API.</example> public async Task <DeleteRuleResponse> DeleteRule(DeleteRuleRequest request, RetryConfiguration retryConfiguration = null, CancellationToken cancellationToken = default) { logger.Trace("Called deleteRule"); Uri uri = new Uri(this.restClient.GetEndpoint(), System.IO.Path.Combine(basePathWithoutHost, "/rules/{ruleId}".Trim('/'))); HttpMethod method = new HttpMethod("DELETE"); HttpRequestMessage requestMessage = Converter.ToHttpRequestMessage(uri, method, request); requestMessage.Headers.Add("Accept", "application/json"); GenericRetrier retryingClient = Retrier.GetPreferredRetrier(retryConfiguration, this.retryConfiguration); HttpResponseMessage responseMessage; try { if (retryingClient != null) { responseMessage = await retryingClient.MakeRetryingCall(this.restClient.HttpSend, requestMessage, cancellationToken).ConfigureAwait(false); } else { responseMessage = await this.restClient.HttpSend(requestMessage).ConfigureAwait(false); } this.restClient.CheckHttpResponseMessage(requestMessage, responseMessage); return(Converter.FromHttpResponseMessage <DeleteRuleResponse>(responseMessage)); } catch (Exception e) { logger.Error($"DeleteRule failed with error: {e.Message}"); throw; } }
/// <summary> /// Initiates the asynchronous execution of the DeleteRule operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the DeleteRule operation.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// <returns>The task object representing the asynchronous operation.</returns> public Task <DeleteRuleResponse> DeleteRuleAsync(DeleteRuleRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new DeleteRuleRequestMarshaller(); var unmarshaller = DeleteRuleResponseUnmarshaller.Instance; return(InvokeAsync <DeleteRuleRequest, DeleteRuleResponse>(request, marshaller, unmarshaller, cancellationToken)); }
/// <summary> /// Deletes a Recycle Bin retention rule. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/recycle-bin-working-with-rules.html#recycle-bin-delete-rule"> /// Delete Recycle Bin retention rules</a> in the <i>Amazon Elastic Compute Cloud User /// Guide</i>. /// </summary> /// <param name="request">Container for the necessary parameters to execute the DeleteRule service method.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// /// <returns>The response from the DeleteRule service method, as returned by RecycleBin.</returns> /// <exception cref="Amazon.RecycleBin.Model.InternalServerException"> /// The service could not respond to the request due to an internal problem. /// </exception> /// <exception cref="Amazon.RecycleBin.Model.ResourceNotFoundException"> /// The specified resource was not found. /// </exception> /// <exception cref="Amazon.RecycleBin.Model.ValidationException"> /// One or more of the parameters in the request is not valid. /// </exception> /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/rbin-2021-06-15/DeleteRule">REST API Reference for DeleteRule Operation</seealso> public virtual Task <DeleteRuleResponse> DeleteRuleAsync(DeleteRuleRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var options = new InvokeOptions(); options.RequestMarshaller = DeleteRuleRequestMarshaller.Instance; options.ResponseUnmarshaller = DeleteRuleResponseUnmarshaller.Instance; return(InvokeAsync <DeleteRuleResponse>(request, options, cancellationToken)); }
/// <summary> /// Deletes a Recycle Bin retention rule. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/recycle-bin-working-with-rules.html#recycle-bin-delete-rule"> /// Delete Recycle Bin retention rules</a> in the <i>Amazon Elastic Compute Cloud User /// Guide</i>. /// </summary> /// <param name="request">Container for the necessary parameters to execute the DeleteRule service method.</param> /// /// <returns>The response from the DeleteRule service method, as returned by RecycleBin.</returns> /// <exception cref="Amazon.RecycleBin.Model.InternalServerException"> /// The service could not respond to the request due to an internal problem. /// </exception> /// <exception cref="Amazon.RecycleBin.Model.ResourceNotFoundException"> /// The specified resource was not found. /// </exception> /// <exception cref="Amazon.RecycleBin.Model.ValidationException"> /// One or more of the parameters in the request is not valid. /// </exception> /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/rbin-2021-06-15/DeleteRule">REST API Reference for DeleteRule Operation</seealso> public virtual DeleteRuleResponse DeleteRule(DeleteRuleRequest request) { var options = new InvokeOptions(); options.RequestMarshaller = DeleteRuleRequestMarshaller.Instance; options.ResponseUnmarshaller = DeleteRuleResponseUnmarshaller.Instance; return(Invoke <DeleteRuleResponse>(request, options)); }
/// <summary> /// Initiates the asynchronous execution of the DeleteRule operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the DeleteRule operation on AmazonRecycleBinClient.</param> /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param> /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback /// procedure using the AsyncState property.</param> /// /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndDeleteRule /// operation.</returns> /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/rbin-2021-06-15/DeleteRule">REST API Reference for DeleteRule Operation</seealso> public virtual IAsyncResult BeginDeleteRule(DeleteRuleRequest request, AsyncCallback callback, object state) { var options = new InvokeOptions(); options.RequestMarshaller = DeleteRuleRequestMarshaller.Instance; options.ResponseUnmarshaller = DeleteRuleResponseUnmarshaller.Instance; return(BeginInvoke(request, options, callback, state)); }
public void Construct() { var request = new DeleteRuleRequest("arn"); Assert.Equal("arn", request.RuleArn); string data = string.Join('&', RequestHelper.ToParams(request).Select(a => a.Key + "=" + a.Value)); Assert.Equal("Action=DeleteRule&RuleArn=arn", data); }
public async Task DeleteRuleAsync() { var request = new DeleteRuleRequest() { DomainId = DeleteDomain, RuleId = Rule.Id }; var response = await mailinatorClient.RulesClient.DeleteRuleAsync(request); Assert.IsTrue(response != null); Assert.IsTrue(response.Status == "ok"); }
/// <summary> /// This endpoint deletes a specific Rule from a Domain /// </summary> /// <param name="request">DeleteRuleRequest object.</param> /// <returns></returns> public async Task <DeleteRuleResponse> DeleteRuleAsync(DeleteRuleRequest request) { var requestObject = httpClient.GetRequest(endpointUrl + "/{domain_id}/rules/{ruleId}", Method.DELETE); requestObject.AddUrlSegment("domain_id", request.DomainId); requestObject.AddUrlSegment("ruleId", request.RuleId); var response = await httpClient.ExecuteAsync <DeleteRuleResponse>(requestObject); return(response); }
/// <summary> /// 删除规则 /// </summary> public DeleteRuleResponse DeleteRule(DeleteRuleRequest deleteRuleRequest) { Dictionary <string, string> urlParam = new Dictionary <string, string>(); urlParam.Add("rule_id", deleteRuleRequest.RuleId.ToString()); string urlPath = HttpUtils.AddUrlPath("/v5/iot/{project_id}/rules/{rule_id}", urlParam); SdkRequest request = HttpUtils.InitSdkRequest(urlPath, deleteRuleRequest); HttpResponseMessage response = DoHttpRequestSync("DELETE", request); DeleteRuleResponse deleteRuleResponse = JsonUtils.DeSerializeNull <DeleteRuleResponse>(response); return(deleteRuleResponse); }
/// <summary> /// 删除规则 /// </summary> /// <param name="req"><see cref="DeleteRuleRequest"/></param> /// <returns><see cref="DeleteRuleResponse"/></returns> public DeleteRuleResponse DeleteRuleSync(DeleteRuleRequest req) { JsonResponseModel <DeleteRuleResponse> rsp = null; try { var strResp = this.InternalRequestSync(req, "DeleteRule"); rsp = JsonConvert.DeserializeObject <JsonResponseModel <DeleteRuleResponse> >(strResp); } catch (JsonSerializationException e) { throw new TencentCloudSDKException(e.Message); } return(rsp.Response); }
//删除已经创建好的规则 public void TestDeleteRule() { DefaultAcsClient acsClient = Demo.IotClient.GetClient(); long ruleId = 106844; DeleteRuleRequest request = new DeleteRuleRequest(); request.RuleId = ruleId; DeleteRuleResponse response = acsClient.GetAcsResponse(request); Console.WriteLine("Delete Rule: " + response.Success); if (!(bool)response.Success) { Console.WriteLine(response.Code + ", " + response.ErrorMessage); return; } }
public void Construct() { var request = new DeleteRuleRequest("arn"); Assert.Equal("arn", request.RuleArn); }
public string Add(Notification input, ILambdaContext context) { if (input == null) { throw new ArgumentNullException("Input required"); } //var topicId = Guid.NewGuid().ToString(); var region = RegionEndpoint.APSoutheast1; //Create topic in SNS var snsClient = new AmazonSimpleNotificationServiceClient(region); var createTopicRequest = new CreateTopicRequest(); createTopicRequest.Name = input.TopicName; var createTopicResponse = snsClient.CreateTopicAsync(createTopicRequest).Result; if (createTopicResponse.HttpStatusCode != HttpStatusCode.OK) { throw new TestDonkeyException("Can't add topic"); } //Create rule in CloudWatch Events var cloudWatchEventClient = new AmazonCloudWatchEventsClient(region); var putRuleRequest = new PutRuleRequest(); putRuleRequest.ScheduleExpression = input.Cron; putRuleRequest.Name = $"testdonkey-rule-{ input.TopicId }"; putRuleRequest.State = RuleState.ENABLED; var putRuleResponse = cloudWatchEventClient.PutRuleAsync(putRuleRequest).Result; if (putRuleResponse.HttpStatusCode != HttpStatusCode.OK) { throw new TestDonkeyException("Can't add rule"); } //Set target for CloudWatch Events var putTargetsRequest = new PutTargetsRequest(); putTargetsRequest.Rule = putRuleRequest.Name; putTargetsRequest.Targets = new List <Target> { new Target() { Arn = "arn:aws:lambda:ap-southeast-1:404276529491:function:TestDonkeyLambda", Id = $"testdonkey-target-{ input.TopicId }", Input = $"{{\"TopicId\":\"{ input.TopicId }\"}}" } }; var putTargetsResponse = cloudWatchEventClient.PutTargetsAsync(putTargetsRequest).Result; if (putTargetsResponse.HttpStatusCode != HttpStatusCode.OK) { var deleteRuleRequest = new DeleteRuleRequest(); deleteRuleRequest.Name = putRuleRequest.Name; cloudWatchEventClient.DeleteRuleAsync(deleteRuleRequest); throw new TestDonkeyException("Can't add target"); } //Add permission to accept CloudWatch Events trigger for Lambda var lambdaClient = new AmazonLambdaClient(region); var addPermissionRequest = new Amazon.Lambda.Model.AddPermissionRequest(); addPermissionRequest.FunctionName = "TestDonkeyLambda"; addPermissionRequest.Action = "lambda:InvokeFunction"; addPermissionRequest.StatementId = $"testdonkey-lambda-{ input.TopicId }"; addPermissionRequest.Principal = "events.amazonaws.com"; addPermissionRequest.SourceArn = putRuleResponse.RuleArn; var addPermissionResponse = lambdaClient.AddPermissionAsync(addPermissionRequest).Result; if (addPermissionResponse.HttpStatusCode != HttpStatusCode.Created) { throw new TestDonkeyException("Can't add permission"); } //Save notification to DynamoDB var dynamoDBClient = new AmazonDynamoDBClient(region); var item = new Dictionary <string, AttributeValue>(); item.Add("id", new AttributeValue() { S = input.TopicId }); item.Add("name", new AttributeValue() { S = input.TopicName }); item.Add("arn", new AttributeValue() { S = createTopicResponse.TopicArn }); item.Add("cron", new AttributeValue() { S = input.Cron }); var putItemResponse = dynamoDBClient.PutItemAsync("Topics", item).Result; if (putItemResponse.HttpStatusCode != HttpStatusCode.OK) { throw new TestDonkeyException("Can't add item"); } return("success"); }
public string Remove(Notification input, ILambdaContext context) { var region = RegionEndpoint.APSoutheast1; var topicId = input.TopicId; //Get item from DynamoDB var key = new Dictionary <string, AttributeValue>(); key.Add("id", new AttributeValue() { S = topicId }); var dynamoDBClient = new AmazonDynamoDBClient(region); var getItemResponse = dynamoDBClient.GetItemAsync("Topics", key).Result; if (getItemResponse.HttpStatusCode != HttpStatusCode.OK) { throw new TestDonkeyException("Can't find item"); } var item = getItemResponse.Item; var topicArn = item.GetValueOrDefault("arn").S; //Remove permission to accept CloudWatch Events trigger for Lambda var lambdaClient = new AmazonLambdaClient(region); var removePermissionRequest = new Amazon.Lambda.Model.RemovePermissionRequest(); removePermissionRequest.FunctionName = "TestDonkeyLambda"; removePermissionRequest.StatementId = $"testdonkey-lambda-{ topicId }"; var removePermissionResponse = lambdaClient.RemovePermissionAsync(removePermissionRequest).Result; if (removePermissionResponse.HttpStatusCode != HttpStatusCode.NoContent) { throw new TestDonkeyException("Can't remove permission"); } //Remove target for CloudWatch Events var cloudWatchEventClient = new AmazonCloudWatchEventsClient(region); var removeTargetsRequest = new RemoveTargetsRequest(); removeTargetsRequest.Ids = new List <string> { $"testdonkey-target-{ topicId }" }; removeTargetsRequest.Rule = $"testdonkey-rule-{ topicId }"; var removeTargetsResponse = cloudWatchEventClient.RemoveTargetsAsync(removeTargetsRequest).Result; if (removeTargetsResponse.HttpStatusCode != HttpStatusCode.OK) { throw new TestDonkeyException("Can't remove target"); } //Delete rule in CloudWatch Events var deleteRuleRequest = new DeleteRuleRequest(); deleteRuleRequest.Name = removeTargetsRequest.Rule; var deleteRuleResponse = cloudWatchEventClient.DeleteRuleAsync(deleteRuleRequest).Result; if (deleteRuleResponse.HttpStatusCode != HttpStatusCode.OK) { throw new TestDonkeyException("Can't delete rule"); } //Remove subscribers from SNS var snsClient = new AmazonSimpleNotificationServiceClient(region); var listSubscriptionsByTopicRequest = new ListSubscriptionsByTopicRequest(); listSubscriptionsByTopicRequest.TopicArn = topicArn; ListSubscriptionsByTopicResponse listSubscriptionsByTopicResponse = null; do { listSubscriptionsByTopicResponse = snsClient.ListSubscriptionsByTopicAsync(listSubscriptionsByTopicRequest).Result; if (listSubscriptionsByTopicResponse.HttpStatusCode != HttpStatusCode.OK) { throw new TestDonkeyException("Can't list subscriptions"); } if (listSubscriptionsByTopicResponse.Subscriptions != null && listSubscriptionsByTopicResponse.Subscriptions.Count > 0) { foreach (var subscription in listSubscriptionsByTopicResponse.Subscriptions) { if (!subscription.SubscriptionArn.Equals("pendingconfirmation", StringComparison.OrdinalIgnoreCase)) { snsClient.UnsubscribeAsync(subscription.SubscriptionArn).GetAwaiter().GetResult(); } } } listSubscriptionsByTopicRequest.NextToken = listSubscriptionsByTopicResponse.NextToken; Thread.Sleep(1_000); //Wait for 1 second. Throttle: 100 transactions per second (TPS) } while (!string.IsNullOrWhiteSpace(listSubscriptionsByTopicResponse.NextToken)); //Delete topic from SNS var deleteTopicResponse = snsClient.DeleteTopicAsync(topicArn).Result; if (deleteTopicResponse.HttpStatusCode != HttpStatusCode.OK) { throw new TestDonkeyException("Can't delete topic"); } //Delete item from DynamoDB var dynamoDBDeleteItemResponse = dynamoDBClient.DeleteItemAsync("Topics", key).Result; if (dynamoDBDeleteItemResponse.HttpStatusCode != HttpStatusCode.OK) { throw new TestDonkeyException("Can't delete item"); } return("success"); }