//获取规则的详细信息 public void TestGetRule() { DefaultAcsClient acsClient = Demo.IotClient.GetClient(); long ruleId = 321103; GetRuleRequest request = new GetRuleRequest(); request.RuleId = ruleId; GetRuleResponse response = acsClient.GetAcsResponse(request); Console.WriteLine("Get Rule: " + response.Success); if (!(bool)response.Success) { Console.WriteLine(response.Code + ", " + response.ErrorMessage); return; } GetRuleResponse.GetRule_RuleInfo RuleInfo = response.RuleInfo; Console.WriteLine("Rule ID: " + RuleInfo.Id); Console.WriteLine("Rule Name: " + RuleInfo.Name); Console.WriteLine("Rule DataType: " + RuleInfo.DataType); Console.WriteLine("Rule ProductKey: " + RuleInfo.ProductKey); Console.WriteLine("Rule ShortTopic: " + RuleInfo.ShortTopic); Console.WriteLine("Rule Topic: " + RuleInfo.Topic); Console.WriteLine("Rule Select: " + RuleInfo.Select); Console.WriteLine("Rule Where: " + RuleInfo._Where); Console.WriteLine("Rule UtcCreated: " + RuleInfo.UtcCreated); }
/// <summary> /// Retrieves 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/GetRule.cs.html">here</a> to see an example of how to use GetRule API.</example> public async Task <GetRuleResponse> GetRule(GetRuleRequest request, RetryConfiguration retryConfiguration = null, CancellationToken cancellationToken = default) { logger.Trace("Called getRule"); Uri uri = new Uri(this.restClient.GetEndpoint(), System.IO.Path.Combine(basePathWithoutHost, "/rules/{ruleId}".Trim('/'))); HttpMethod method = new HttpMethod("GET"); 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 <GetRuleResponse>(responseMessage)); } catch (Exception e) { logger.Error($"GetRule failed with error: {e.Message}"); throw; } }
/// <summary> /// Gets information about a Recycle Bin retention rule. /// </summary> /// <param name="request">Container for the necessary parameters to execute the GetRule 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 GetRule 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/GetRule">REST API Reference for GetRule Operation</seealso> public virtual Task <GetRuleResponse> GetRuleAsync(GetRuleRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var options = new InvokeOptions(); options.RequestMarshaller = GetRuleRequestMarshaller.Instance; options.ResponseUnmarshaller = GetRuleResponseUnmarshaller.Instance; return(InvokeAsync <GetRuleResponse>(request, options, cancellationToken)); }
/// <summary> /// Gets information about a Recycle Bin retention rule. /// </summary> /// <param name="request">Container for the necessary parameters to execute the GetRule service method.</param> /// /// <returns>The response from the GetRule 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/GetRule">REST API Reference for GetRule Operation</seealso> public virtual GetRuleResponse GetRule(GetRuleRequest request) { var options = new InvokeOptions(); options.RequestMarshaller = GetRuleRequestMarshaller.Instance; options.ResponseUnmarshaller = GetRuleResponseUnmarshaller.Instance; return(Invoke <GetRuleResponse>(request, options)); }
/// <summary> /// Initiates the asynchronous execution of the GetRule operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the GetRule 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 EndGetRule /// operation.</returns> /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/rbin-2021-06-15/GetRule">REST API Reference for GetRule Operation</seealso> public virtual IAsyncResult BeginGetRule(GetRuleRequest request, AsyncCallback callback, object state) { var options = new InvokeOptions(); options.RequestMarshaller = GetRuleRequestMarshaller.Instance; options.ResponseUnmarshaller = GetRuleResponseUnmarshaller.Instance; return(BeginInvoke(request, options, callback, state)); }
public async Task GetRuleAsync() { var request = new GetRuleRequest() { DomainId = Domain.Id, RuleId = Rule.Id }; var response = await mailinatorClient.RulesClient.GetRuleAsync(request); Assert.IsTrue(response != null); }
/// <summary> /// Creates a waiter using the provided configuration. /// </summary> /// <param name="request">Request to send.</param> /// <param name="config">Wait Configuration</param> /// <param name="targetStates">Desired resource states. If multiple states are provided then the waiter will return once the resource reaches any of the provided states</param> /// <returns>a new Oci.common.Waiter instance</returns> public Waiter <GetRuleRequest, GetRuleResponse> ForRule(GetRuleRequest request, WaiterConfiguration config, params Rule.LifecycleStateEnum[] targetStates) { var agent = new WaiterAgent <GetRuleRequest, GetRuleResponse>( request, request => client.GetRule(request), response => targetStates.Contains(response.Rule.LifecycleState.Value), targetStates.Contains(Rule.LifecycleStateEnum.Deleted) ); return(new Waiter <GetRuleRequest, GetRuleResponse>(config, agent)); }
/// <summary> /// This endpoint fetches a Rules for a Domain /// </summary> /// <param name="request">GetRuleRequest object.</param> /// <returns></returns> public async Task <GetRuleResponse> GetRuleAsync(GetRuleRequest request) { var requestObject = httpClient.GetRequest(endpointUrl + "/{domain_id}/rules/{ruleId}", Method.GET); requestObject.AddUrlSegment("domain_id", request.DomainId); requestObject.AddUrlSegment("ruleId", request.RuleId); var response = await httpClient.ExecuteAsync <GetRuleResponse>(requestObject); return(response); }
/// <summary> /// 获取事件规则详情 /// </summary> /// <param name="req"><see cref="GetRuleRequest"/></param> /// <returns><see cref="GetRuleResponse"/></returns> public GetRuleResponse GetRuleSync(GetRuleRequest req) { JsonResponseModel <GetRuleResponse> rsp = null; try { var strResp = this.InternalRequestSync(req, "GetRule"); rsp = JsonConvert.DeserializeObject <JsonResponseModel <GetRuleResponse> >(strResp); } catch (JsonSerializationException e) { throw new TencentCloudSDKException(e.Message); } return(rsp.Response); }
//更新规则的名称和描述 public void TestUpdateRule() { DefaultAcsClient acsClient = Demo.IotClient.GetClient(); long ruleId = 321103; UpdateRuleRequest request = new UpdateRuleRequest(); request.RuleId = ruleId; request.Name = "Rule_Test_082601"; request.ProductKey = "a163Bcy1oyR"; request.ShortTopic = "firstDevice/thing/event/property/post"; request.Select = " a, b, c"; request._Where = " a > 2"; request.RuleDesc = "This is a test."; UpdateRuleResponse response = acsClient.GetAcsResponse(request); Console.WriteLine("Update Rule: " + response.Success); if (!(bool)response.Success) { Console.WriteLine(response.Code + ", " + response.ErrorMessage); return; } GetRuleRequest request2 = new GetRuleRequest(); request2.RuleId = ruleId; GetRuleResponse response2 = acsClient.GetAcsResponse(request2); Console.WriteLine("Get Rule: " + response.Success); if (!(bool)response2.Success) { Console.WriteLine(response2.Code + ", " + response2.ErrorMessage); return; } GetRuleResponse.GetRule_RuleInfo RuleInfo = response2.RuleInfo; Console.WriteLine("Rule ID: " + RuleInfo.Id); Console.WriteLine("Rule Name: " + RuleInfo.Name); Console.WriteLine("Rule DataType: " + RuleInfo.DataType); Console.WriteLine("Rule ProductKey: " + RuleInfo.ProductKey); Console.WriteLine("Rule ShortTopic: " + RuleInfo.ShortTopic); Console.WriteLine("Rule Topic: " + RuleInfo.Topic); Console.WriteLine("Rule Select: " + RuleInfo.Select); Console.WriteLine("Rule Where: " + RuleInfo._Where); Console.WriteLine("Rule UtcCreated: " + RuleInfo.UtcCreated); }
private void HandleOutput(GetRuleRequest request) { var waiterConfig = new WaiterConfiguration { MaxAttempts = MaxWaitAttempts, GetNextDelayInSeconds = (_) => WaitIntervalSeconds }; switch (ParameterSetName) { case LifecycleStateParamSet: response = client.Waiters.ForRule(request, waiterConfig, WaitForLifecycleState).Execute(); break; case Default: response = client.GetRule(request).GetAwaiter().GetResult(); break; } WriteOutput(response, response.Rule); }
protected override void ProcessRecord() { base.ProcessRecord(); GetRuleRequest request; try { request = new GetRuleRequest { RuleId = RuleId, OpcRequestId = OpcRequestId }; HandleOutput(request); FinishProcessing(response); } catch (Exception ex) { TerminatingErrorDuringExecution(ex); } }
/// <summary> /// Creates a waiter using default wait configuration. /// </summary> /// <param name="request">Request to send.</param> /// <param name="targetStates">Desired resource states. If multiple states are provided then the waiter will return once the resource reaches any of the provided states</param> /// <returns>a new Oci.common.Waiter instance</returns> public Waiter <GetRuleRequest, GetRuleResponse> ForRule(GetRuleRequest request, params Rule.LifecycleStateEnum[] targetStates) { return(this.ForRule(request, WaiterConfiguration.DefaultWaiterConfiguration, targetStates)); }