/// <summary>
        /// Update Rule Update an existing Rule
        /// </summary>
        /// <exception cref="CLOUD.Artik.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="ruleId">Rule ID.</param>
        /// <param name="ruleInfo">Rule object that needs to be updated</param>
        /// <returns>ApiResponse of RuleEnvelope</returns>
        public ApiResponse <RuleEnvelope> UpdateRuleWithHttpInfo(string ruleId, RuleUpdateInfo ruleInfo)
        {
            // verify the required parameter 'ruleId' is set
            if (ruleId == null)
            {
                throw new ApiException(400, "Missing required parameter 'ruleId' when calling RulesApi->UpdateRule");
            }
            // verify the required parameter 'ruleInfo' is set
            if (ruleInfo == null)
            {
                throw new ApiException(400, "Missing required parameter 'ruleInfo' when calling RulesApi->UpdateRule");
            }

            var    localVarPath         = "/rules/{ruleId}";
            var    localVarPathParams   = new Dictionary <String, String>();
            var    localVarQueryParams  = new Dictionary <String, String>();
            var    localVarHeaderParams = new Dictionary <String, String>(Configuration.DefaultHeader);
            var    localVarFormParams   = new Dictionary <String, String>();
            var    localVarFileParams   = new Dictionary <String, FileParameter>();
            Object localVarPostBody     = null;

            // to determine the Content-Type header
            String[] localVarHttpContentTypes = new String[] {
            };
            String localVarHttpContentType    = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);

            // to determine the Accept header
            String[] localVarHttpHeaderAccepts = new String[] {
                "application/json"
            };
            String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);

            if (localVarHttpHeaderAccept != null)
            {
                localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
            }

            // set "format" to json by default
            // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
            localVarPathParams.Add("format", "json");
            if (ruleId != null)
            {
                localVarPathParams.Add("ruleId", Configuration.ApiClient.ParameterToString(ruleId));                 // path parameter
            }
            if (ruleInfo != null && ruleInfo.GetType() != typeof(byte[]))
            {
                localVarPostBody = Configuration.ApiClient.Serialize(ruleInfo); // http body (model) parameter
            }
            else
            {
                localVarPostBody = ruleInfo; // byte array
            }

            // authentication (artikcloud_oauth) required
            // oauth required
            if (!String.IsNullOrEmpty(Configuration.AccessToken))
            {
                localVarHeaderParams["Authorization"] = "Bearer " + Configuration.AccessToken;
            }

            // make the HTTP request
            IRestResponse localVarResponse = (IRestResponse)Configuration.ApiClient.CallApi(localVarPath,
                                                                                            Method.PUT, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
                                                                                            localVarPathParams, localVarHttpContentType);

            int localVarStatusCode = (int)localVarResponse.StatusCode;

            if (ExceptionFactory != null)
            {
                Exception exception = ExceptionFactory("UpdateRule", localVarResponse);
                if (exception != null)
                {
                    throw exception;
                }
            }

            return(new ApiResponse <RuleEnvelope>(localVarStatusCode,
                                                  localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                                                  (RuleEnvelope)Configuration.ApiClient.Deserialize(localVarResponse, typeof(RuleEnvelope))));
        }
        /// <summary>
        /// Update Rule Update an existing Rule
        /// </summary>
        /// <exception cref="CLOUD.Artik.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="ruleId">Rule ID.</param>
        /// <param name="ruleInfo">Rule object that needs to be updated</param>
        /// <returns>Task of RuleEnvelope</returns>
        public async System.Threading.Tasks.Task <RuleEnvelope> UpdateRuleAsync(string ruleId, RuleUpdateInfo ruleInfo)
        {
            ApiResponse <RuleEnvelope> localVarResponse = await UpdateRuleAsyncWithHttpInfo(ruleId, ruleInfo);

            return(localVarResponse.Data);
        }
        /// <summary>
        /// Update Rule Update an existing Rule
        /// </summary>
        /// <exception cref="CLOUD.Artik.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="ruleId">Rule ID.</param>
        /// <param name="ruleInfo">Rule object that needs to be updated</param>
        /// <returns>RuleEnvelope</returns>
        public RuleEnvelope UpdateRule(string ruleId, RuleUpdateInfo ruleInfo)
        {
            ApiResponse <RuleEnvelope> localVarResponse = UpdateRuleWithHttpInfo(ruleId, ruleInfo);

            return(localVarResponse.Data);
        }