protected override void ProcessRecord() { base.ProcessRecord(); ChangeTopicCompartmentRequest request; try { request = new ChangeTopicCompartmentRequest { TopicId = TopicId, ChangeTopicCompartmentDetails = ChangeTopicCompartmentDetails, OpcRetryToken = OpcRetryToken, OpcRequestId = OpcRequestId, IfMatch = IfMatch }; response = client.ChangeTopicCompartment(request).GetAwaiter().GetResult(); WriteOutput(response); FinishProcessing(response); } catch (Exception ex) { TerminatingErrorDuringExecution(ex); } }
/// <summary> /// Moves a topic into a different compartment within the same tenancy. For information about moving resources /// between compartments, see /// [Moving Resources to a Different Compartment](https://docs.cloud.oracle.com/iaas/Content/Identity/Tasks/managingcompartments.htm#moveRes). /// <br/> /// Transactions Per Minute (TPM) per-tenancy limit for this operation: 60. /// /// </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/ons/ChangeTopicCompartment.cs.html">here</a> to see an example of how to use ChangeTopicCompartment API.</example> public async Task <ChangeTopicCompartmentResponse> ChangeTopicCompartment(ChangeTopicCompartmentRequest request, RetryConfiguration retryConfiguration = null, CancellationToken cancellationToken = default) { logger.Trace("Called changeTopicCompartment"); Uri uri = new Uri(this.restClient.GetEndpoint(), System.IO.Path.Combine(basePathWithoutHost, "/topics/{topicId}/actions/changeCompartment".Trim('/'))); HttpMethod method = new HttpMethod("POST"); 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 <ChangeTopicCompartmentResponse>(responseMessage)); } catch (Exception e) { logger.Error($"ChangeTopicCompartment failed with error: {e.Message}"); throw; } }
/// <summary> /// Moves a topic into a different compartment within the same tenancy. /// For information about moving resources between compartments, see Moving Resources to a Different Compartment. /// /// Transactions Per Minute (TPM) per-tenancy limit for this operation: 60. /// </summary> /// <param name="request"></param> /// <returns></returns> public async Task <ChangeTopicCompartmentResponse> ChangeTopicCompartment(ChangeTopicCompartmentRequest request) { var uri = new Uri($"{GetEndPoint(NotificationServices.Topics, this.Region)}/{request.TopicId}/actions/changeCompartment"); var httpRequestHeaderParam = new HttpRequestHeaderParam() { OpcRetryToken = request.OpcRetryToken, OpcRequestId = request.OpcRequestId, IfMatch = request.IfMatch }; var webResponse = await this.RestClientAsync.Post(uri, request.ChangeCompartmentDetails, httpRequestHeaderParam); using (var stream = webResponse.GetResponseStream()) using (var reader = new StreamReader(stream)) { var response = reader.ReadToEnd(); return(new ChangeTopicCompartmentResponse() { OpcRequestId = webResponse.Headers.Get("opc-request-id") }); } }