Exemple #1
0
        /// <summary>
        /// Updates 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/UpdateRule.cs.html">here</a> to see an example of how to use UpdateRule API.</example>
        public async Task <UpdateRuleResponse> UpdateRule(UpdateRuleRequest request, RetryConfiguration retryConfiguration = null, CancellationToken cancellationToken = default)
        {
            logger.Trace("Called updateRule");
            Uri                uri            = new Uri(this.restClient.GetEndpoint(), System.IO.Path.Combine(basePathWithoutHost, "/rules/{ruleId}".Trim('/')));
            HttpMethod         method         = new HttpMethod("PUT");
            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 <UpdateRuleResponse>(responseMessage));
            }
            catch (Exception e)
            {
                logger.Error($"UpdateRule failed with error: {e.Message}");
                throw;
            }
        }
        /// <summary>
        /// Updates an existing 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-update-rule">
        /// Update 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 UpdateRule service method.</param>
        ///
        /// <returns>The response from the UpdateRule 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/UpdateRule">REST API Reference for UpdateRule Operation</seealso>
        public virtual UpdateRuleResponse UpdateRule(UpdateRuleRequest request)
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = UpdateRuleRequestMarshaller.Instance;
            options.ResponseUnmarshaller = UpdateRuleResponseUnmarshaller.Instance;

            return(Invoke <UpdateRuleResponse>(request, options));
        }
        /// <summary>
        /// Updates an existing 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-update-rule">
        /// Update 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 UpdateRule 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 UpdateRule 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/UpdateRule">REST API Reference for UpdateRule Operation</seealso>
        public virtual Task <UpdateRuleResponse> UpdateRuleAsync(UpdateRuleRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = UpdateRuleRequestMarshaller.Instance;
            options.ResponseUnmarshaller = UpdateRuleResponseUnmarshaller.Instance;

            return(InvokeAsync <UpdateRuleResponse>(request, options, cancellationToken));
        }
        /// <summary>
        /// Initiates the asynchronous execution of the UpdateRule operation.
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the UpdateRule 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 EndUpdateRule
        ///         operation.</returns>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/rbin-2021-06-15/UpdateRule">REST API Reference for UpdateRule Operation</seealso>
        public virtual IAsyncResult BeginUpdateRule(UpdateRuleRequest request, AsyncCallback callback, object state)
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = UpdateRuleRequestMarshaller.Instance;
            options.ResponseUnmarshaller = UpdateRuleResponseUnmarshaller.Instance;

            return(BeginInvoke(request, options, callback, state));
        }
Exemple #5
0
        /// <summary>
        /// 修改规则
        /// </summary>
        public async Task <UpdateRuleResponse> UpdateRuleAsync(UpdateRuleRequest updateRuleRequest)
        {
            Dictionary <string, string> urlParam = new Dictionary <string, string>();

            urlParam.Add("rule_id", updateRuleRequest.RuleId.ToString());
            string              urlPath  = HttpUtils.AddUrlPath("/v5/iot/{project_id}/rules/{rule_id}", urlParam);
            SdkRequest          request  = HttpUtils.InitSdkRequest(urlPath, "application/json", updateRuleRequest);
            HttpResponseMessage response = await DoHttpRequestAsync("PUT", request);

            return(JsonUtils.DeSerialize <UpdateRuleResponse>(response));
        }
        /// <summary>
        /// 更新事件规则
        /// </summary>
        /// <param name="req"><see cref="UpdateRuleRequest"/></param>
        /// <returns><see cref="UpdateRuleResponse"/></returns>
        public UpdateRuleResponse UpdateRuleSync(UpdateRuleRequest req)
        {
            JsonResponseModel <UpdateRuleResponse> rsp = null;

            try
            {
                var strResp = this.InternalRequestSync(req, "UpdateRule");
                rsp = JsonConvert.DeserializeObject <JsonResponseModel <UpdateRuleResponse> >(strResp);
            }
            catch (JsonSerializationException e)
            {
                throw new TencentCloudSDKException(e.Message);
            }
            return(rsp.Response);
        }
Exemple #7
0
        //更新规则的名称和描述
        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);
        }
Exemple #8
0
        //更新规则的名称和描述
        public void TestSimpleUpdateRule()
        {
            DefaultAcsClient acsClient = Demo.IotClient.GetClient();
            long             ruleId    = 321103;

            UpdateRuleRequest request = new UpdateRuleRequest();

            request.RuleId = ruleId;
            request.Name   = "Rule_Test_0826";

            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;
            }
        }
Exemple #9
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            UpdateRuleRequest request;

            try
            {
                request = new UpdateRuleRequest
                {
                    RuleId            = RuleId,
                    UpdateRuleDetails = UpdateRuleDetails,
                    IfMatch           = IfMatch,
                    OpcRequestId      = OpcRequestId
                };

                response = client.UpdateRule(request).GetAwaiter().GetResult();
                WriteOutput(response, response.Rule);
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }
        private static void updateRule(IoTDAClient client)
        {
            UpdateRuleRequest req = new UpdateRuleRequest
            {
                RuleId = "5ea8ebe75d6efc01e5a022c8",
                Body   = new Rule()
                {
                    Actions = new List <RuleAction>()
                    {
                        new RuleAction()
                        {
                            Type     = "IoTA_FORWARDING",
                            Addition = new List <string>()
                            {
                                "88cce89f943646cfbda057aed55c4841"
                            },
                            IotaForwarding = new ActionIoTAForwarding()
                            {
                                ProjectId  = "88cce89f943646cfbda057aed55c4841",
                                RegionName = "update"
                            },
                        }
                    },
                    ConditionGroup = new ConditionGroup()
                    {
                        Conditions = new List <RuleCondition>()
                        {
                            new RuleCondition()
                            {
                                DevicePropertyCondition = new DeviceDataCondition()
                                {
                                    Filters = new List <PropertyFilter>()
                                    {
                                        new PropertyFilter()
                                        {
                                            Operator = ">",
                                            Path     = "Meter/signalStrength",
                                            Value    = "0"
                                        }
                                    }
                                },
                                Type = "DEVICE_DATA"
                            }
                        },
                        TimeRange = new TimeRange()
                        {
                            EndTime   = "12:02",
                            StartTime = "12:00"
                        }
                    },
                    Name     = "test_createRule_Success",
                    RuleType = "DATA_FORWARDING",
                    Status   = "inactive"
                }
            };

            try
            {
                var resp = client.UpdateRule(req);
                Console.WriteLine(resp.HttpStatusCode);
                Console.WriteLine(JsonConvert.SerializeObject(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);
            }
        }