protected override void ProcessRecord()
        {
            base.ProcessRecord();
            ChangeClusterNetworkCompartmentRequest request;

            try
            {
                request = new ChangeClusterNetworkCompartmentRequest
                {
                    ClusterNetworkId = ClusterNetworkId,
                    ChangeClusterNetworkCompartmentDetails = ChangeClusterNetworkCompartmentDetails,
                    IfMatch       = IfMatch,
                    OpcRequestId  = OpcRequestId,
                    OpcRetryToken = OpcRetryToken
                };

                response = client.ChangeClusterNetworkCompartment(request).GetAwaiter().GetResult();
                WriteOutput(response);
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }
Exemple #2
0
        /// <summary>
        /// Moves a cluster network into a different compartment within the same tenancy. For information about
        /// moving resources between compartments, see Moving Resources to a Different Compartment.
        ///
        /// When you move a cluster network to a different compartment, associated resources such as the instances
        /// in the cluster network, boot volumes, and VNICs are not moved.
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public async Task <ChangeClusterNetworkCompartmentResponse> ChangeClusterNetworkCompartment(ChangeClusterNetworkCompartmentRequest request)
        {
            var uri = new Uri($"{GetEndPoint(CoreServices.ClusterNetworks, this.Region)}/{request.ClusterNetworkId}/actions/changeCompartment");

            var headers = new HttpRequestHeaderParam {
                IfMatch       = request.IfMatch,
                OpcRequestId  = request.OpcRequestId,
                OpcRetryToken = request.OpcRetryToken
            };
            var webResponse = await this.RestClientAsync.Post(uri, request.ChangeClusterNetworkCompartmentDetails, headers);

            using (var stream = webResponse.GetResponseStream())
                using (var reader = new StreamReader(stream))
                {
                    var response = reader.ReadToEnd();

                    return(new ChangeClusterNetworkCompartmentResponse()
                    {
                        ETag = webResponse.Headers.Get("ETag"),
                        OpcRequestId = webResponse.Headers.Get("opc-request-id")
                    });
                }
        }