/// <summary> /// Updates the Configuration details. /// </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/mysql/UpdateConfiguration.cs.html">here</a> to see an example of how to use UpdateConfiguration API.</example> public async Task <UpdateConfigurationResponse> UpdateConfiguration(UpdateConfigurationRequest request, RetryConfiguration retryConfiguration = null, CancellationToken cancellationToken = default) { logger.Trace("Called updateConfiguration"); Uri uri = new Uri(this.restClient.GetEndpoint(), System.IO.Path.Combine(basePathWithoutHost, "/configurations/{configurationId}".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 <UpdateConfigurationResponse>(responseMessage)); } catch (Exception e) { logger.Error($"UpdateConfiguration failed with error: {e.Message}"); throw; } }
internal virtual UpdateConfigurationResponse UpdateConfiguration(UpdateConfigurationRequest request) { var marshaller = UpdateConfigurationRequestMarshaller.Instance; var unmarshaller = UpdateConfigurationResponseUnmarshaller.Instance; return(Invoke <UpdateConfigurationRequest, UpdateConfigurationResponse>(request, marshaller, unmarshaller)); }
public async Task <ActionResult> Put(Guid id, [FromBody] UpdateConfigurationModel model) { var request = new UpdateConfigurationRequest(id); var response = await _mediator.Send(request); return(Ok(response)); }
protected override void ProcessRecord() { base.ProcessRecord(); UpdateConfigurationRequest request; try { request = new UpdateConfigurationRequest { UpdateConfigurationDetails = UpdateConfigurationDetails, CompartmentId = CompartmentId, OpcRequestId = OpcRequestId, OpcRetryToken = OpcRetryToken, IfMatch = IfMatch }; response = client.UpdateConfiguration(request).GetAwaiter().GetResult(); WriteOutput(response, response.Configuration); FinishProcessing(response); } catch (Exception ex) { TerminatingErrorDuringExecution(ex); } }
/// <summary> /// Initiates the asynchronous execution of the UpdateConfiguration operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the UpdateConfiguration 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> /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/mq-2017-11-27/UpdateConfiguration">REST API Reference for UpdateConfiguration Operation</seealso> public virtual Task <UpdateConfigurationResponse> UpdateConfigurationAsync(UpdateConfigurationRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = UpdateConfigurationRequestMarshaller.Instance; var unmarshaller = UpdateConfigurationResponseUnmarshaller.Instance; return(InvokeAsync <UpdateConfigurationRequest, UpdateConfigurationResponse>(request, marshaller, unmarshaller, cancellationToken)); }
public async Task <UpdateConfigurationResponse> UpdateConfiguration(UpdateConfigurationRequest o) { var result = new UpdateConfigurationResponse(o.RequestId); result.Updated = await Server.UpdateSettings(o.Application, o.Key, o.Value); return(result); }
/// <summary> /// Initiates the asynchronous execution of the UpdateConfiguration operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the UpdateConfiguration 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> /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/mq-2017-11-27/UpdateConfiguration">REST API Reference for UpdateConfiguration Operation</seealso> public virtual Task <UpdateConfigurationResponse> UpdateConfigurationAsync(UpdateConfigurationRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var options = new InvokeOptions(); options.RequestMarshaller = UpdateConfigurationRequestMarshaller.Instance; options.ResponseUnmarshaller = UpdateConfigurationResponseUnmarshaller.Instance; return(InvokeAsync <UpdateConfigurationResponse>(request, options, cancellationToken)); }
internal virtual UpdateConfigurationResponse UpdateConfiguration(UpdateConfigurationRequest request) { var options = new InvokeOptions(); options.RequestMarshaller = UpdateConfigurationRequestMarshaller.Instance; options.ResponseUnmarshaller = UpdateConfigurationResponseUnmarshaller.Instance; return(Invoke <UpdateConfigurationResponse>(request, options)); }
/// <summary> /// 修改参数模板参数 /// </summary> public async Task <UpdateConfigurationResponse> UpdateConfigurationAsync(UpdateConfigurationRequest updateConfigurationRequest) { Dictionary <string, string> urlParam = new Dictionary <string, string>(); urlParam.Add("config_id", updateConfigurationRequest.ConfigId.ToString()); string urlPath = HttpUtils.AddUrlPath("/v3/{project_id}/configurations/{config_id}", urlParam); SdkRequest request = HttpUtils.InitSdkRequest(urlPath, "application/json", updateConfigurationRequest); HttpResponseMessage response = await DoHttpRequestAsync("PUT", request); return(JsonUtils.DeSerializeNull <UpdateConfigurationResponse>(response)); }
/// <summary> /// Update the configuration /// </summary> /// <param name="updateRequest"></param> /// <returns></returns> public async Task <UpdateConfigurationResponse> UpdateConfiguration(UpdateConfigurationRequest updateRequest) { var uri = new Uri($"{GetEndPoint(AuditServices.CONFIGURATION, this.Region)}?compartmentId={updateRequest.CompartmentId}"); using (var webResponse = await this.RestClientAsync.Put(uri, updateRequest.updateConfigurationDetails)) using (var stream = webResponse.GetResponseStream()) using (var reader = new StreamReader(stream)) { var response = await reader.ReadToEndAsync(); return(new UpdateConfigurationResponse() { OpcRequestId = webResponse.Headers.Get("opc-request-id"), OpcWorkRequestId = webResponse.Headers.Get("opc-work-request-id") }); } }
public async Task <IActionResult> Put([FromRoute] Request meta, [FromBody] UpdateConfigurationRequest request) { IActionResult result = null; var updated = await Server.Update(meta.Application, request.Key, request.Value); if (updated) { result = Factory.CreateSuccessResponse(updated); } else { result = Factory.CreateNoContentResponse(); } return(result); }
/// <summary> /// Update the configuration /// </summary> /// <param name="updateRequest"></param> /// <returns></returns> public UpdateConfigurationResponse UpdateConfiguration(UpdateConfigurationRequest updateRequest) { var uri = new Uri($"{GetEndPoint(ContainerService.CONFIGURATION, this.Region)}?compartmentId={updateRequest.CompartmentId}"); var webResponse = this.RestClient.Put(uri, updateRequest.updateConfigurationDetails); using (var stream = webResponse.GetResponseStream()) using (var reader = new StreamReader(stream)) { var response = reader.ReadToEnd(); return(new UpdateConfigurationResponse() { OpcRequestId = webResponse.Headers.Get("opc-request-id"), OpcWorkRequestId = webResponse.Headers.Get("opc-work-request-id") }); } }
protected override void ProcessRecord() { base.ProcessRecord(); UpdateConfigurationRequest request; try { request = new UpdateConfigurationRequest { CompartmentId = CompartmentId, UpdateConfigurationDetails = UpdateConfigurationDetails }; response = client.UpdateConfiguration(request).GetAwaiter().GetResult(); WriteOutput(response, CreateWorkRequestObject(response.OpcWorkRequestId)); FinishProcessing(response); } catch (Exception ex) { TerminatingErrorDuringExecution(ex); } }
public async Task <IHttpActionResult> Post(UpdateConfigurationRequest updateConfiguration) { var apiKey = updateConfiguration.ApiKey; var hostForwardSettings = await _apiSettingsData.GetByApiKeyAsync(apiKey); if (hostForwardSettings == null) { return(BadRequest(Constants.InvalidApiKey)); } var chaosConfiguration = UpdateRequestToConfigurationConverter.ToChaosConfiguration(updateConfiguration); if (!chaosConfiguration.IsValid()) { return(BadRequest(chaosConfiguration.ValidationErrors.AsFormattingString())); } await _chaosConfigurationSettings.CreateOrUpdateAsync(hostForwardSettings, apiKey, chaosConfiguration); _cacheInvalidator.Invalidate(apiKey); return(Created(hostForwardSettings.ForwardApiHostName, chaosConfiguration)); }
public static async Task Main() { logger.Info("Starting example"); AuditClient client = null; try { // Assumption: the compartment id has been set in environment variable. var compartmentId = Environment.GetEnvironmentVariable("OCI_COMPARTMENT_ID"); logger.Info(compartmentId); // ListEvents var listEventsRequest = new ListEventsRequest { CompartmentId = compartmentId, StartTime = DateTime.Now.AddDays(-1), EndTime = DateTime.Now }; // Create AuditClient var provider = new ConfigFileAuthenticationDetailsProvider("DEFAULT"); using (client = new AuditClient(provider, new ClientConfiguration())) { logger.Info("AuditClient created."); ListEventsResponse listEventsResp = await NoRetryExample(client, listEventsRequest); logger.Info($"Received {listEventsResp?.Items.Count} items"); ListEventsResponse listEventsRespFromRetry = await RetryExample(client, listEventsRequest); logger.Info($"Received {listEventsRespFromRetry?.Items.Count} items"); await CancellationTokenExample(client, listEventsRequest); // GetConfiguration var getConfigurationRequest = new GetConfigurationRequest { CompartmentId = compartmentId }; logger.Info("GetConfigurationRequest created."); GetConfigurationResponse getConfigurationResp = await client.GetConfiguration(getConfigurationRequest); logger.Info($"Retention period days: {getConfigurationResp?.Configuration.RetentionPeriodDays}"); // UpdateConfiguration var updateConfigurationRequest = new UpdateConfigurationRequest { CompartmentId = compartmentId, UpdateConfigurationDetails = new UpdateConfigurationDetails { RetentionPeriodDays = 90 } }; logger.Info("UpdateConfigurationRequest created."); UpdateConfigurationResponse updateConfigurationResp = await client.UpdateConfiguration(updateConfigurationRequest); logger.Info($"opc work request id: {updateConfigurationResp.OpcRequestId}"); } } catch (Exception e) { logger.Error($"Failed Audit example: {e.Message}"); } }
public static ChaosConfiguration ToChaosConfiguration(UpdateConfigurationRequest updateRequest) { var config = new ChaosConfiguration { ChaosInterval = new TimeSpan(0, 0, updateRequest.ChaosInterval), ConfigurationRotationInterval = new TimeSpan(0, 0, updateRequest.ConfigurationRotationInterval), Enabled = updateRequest.Enabled, HttpClientTimeoutInSeconds = updateRequest.HttpClientTimeoutInSeconds }; foreach (var updateChaosSettings in updateRequest.ChaosSettings) { var chaosConfiguration = new ChaosSettings { Name = updateChaosSettings.Name, MaxResponseDelayTime = updateChaosSettings.MaxResponseDelayTime, MinResponseDelayTime = updateChaosSettings.MinResponseDelayTime, PercentageOfChaos = updateChaosSettings.PercentageOfChaos, PercentageOfSlowResponses = updateChaosSettings.PercentageOfSlowResponses, ResponseTypeMediaType = updateChaosSettings.ResponseTypeMediaType }; if (updateChaosSettings.IgnoreUrls != null) { foreach (var url in updateChaosSettings.IgnoreUrls) { chaosConfiguration.IgnoreUrlPattern.Add(url.Pattern); } } foreach (var updateResponse in updateChaosSettings.HttpResponses) { var httpResponse = new ResponseDetails { StatusCode = updateResponse.StatusCode }; foreach (var payload in updateResponse.Payloads.Select(chaosResponsePayload => new ChaosResponsePayload { Code = chaosResponsePayload.Code, Content = chaosResponsePayload.Content })) { httpResponse.Payloads.Add(payload); } chaosConfiguration.HttpResponses.Add(httpResponse); } foreach (var responseFiddle in updateChaosSettings.ResponseFiddles) { var fiddle = new ResponseFiddle { Match = responseFiddle.Match, ReplaceMatchingWith = responseFiddle.ReplaceMatchingWith }; chaosConfiguration.ResponseFiddles.Add(fiddle); } config.ChaosSettings.Add(chaosConfiguration); } return(config); }