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

            if (!ConfirmDelete("OCIDnsSteeringPolicy", "Remove"))
            {
                return;
            }

            DeleteSteeringPolicyRequest request;

            try
            {
                request = new DeleteSteeringPolicyRequest
                {
                    SteeringPolicyId  = SteeringPolicyId,
                    IfMatch           = IfMatch,
                    IfUnmodifiedSince = IfUnmodifiedSince,
                    OpcRequestId      = OpcRequestId
                };

                response = client.DeleteSteeringPolicy(request).GetAwaiter().GetResult();
                WriteOutput(response);
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }
示例#2
0
        /// <summary>
        /// Deletes the specified steering policy. A 204 response indicates that the delete has been successful.
        /// Deletion will fail if the policy is attached to any zones. To detach a policy from a zone, see DeleteSteeringPolicyAttachment.
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public async Task <DeleteSteeringPolicyResponse> DeleteSteeringPolicy(DeleteSteeringPolicyRequest request)
        {
            var uriStr = $"{GetEndPoint(DNSServices.SteeringPolicies, this.Region)}/{request.SteeringPolicyId}";

            var uri = new Uri(uriStr);

            var httpRequestHeaderParam = new HttpRequestHeaderParam()
            {
                IfMatch           = request.IfMatch,
                IfUnmodifiedSince = request.IfUnmodifiedSince
            };
            var webResponse = await this.RestClientAsync.Delete(uri, httpRequestHeaderParam);

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

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