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

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

            DeleteRRSetRequest request;

            try
            {
                request = new DeleteRRSetRequest
                {
                    ZoneNameOrId      = ZoneNameOrId,
                    Domain            = Domain,
                    Rtype             = Rtype,
                    IfMatch           = IfMatch,
                    IfUnmodifiedSince = IfUnmodifiedSince,
                    OpcRequestId      = OpcRequestId,
                    CompartmentId     = CompartmentId,
                    Scope             = Scope,
                    ViewId            = ViewId
                };

                response = client.DeleteRRSet(request).GetAwaiter().GetResult();
                WriteOutput(response);
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Deletes all records in the specified RRSet.
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public async Task <DeleteRRSetResponse> DeleteRRSet(DeleteRRSetRequest request)
        {
            var uriStr = $"{GetEndPoint(DNSServices.Zones, this.Region)}/{request.ZoneNameOrId}/records/{request.Domain}/{request.Rtype}";

            if (!string.IsNullOrEmpty(request.CompartmentId))
            {
                uriStr = $"{uriStr}?compartmentId={request.CompartmentId}";
            }

            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 DeleteRRSetResponse()
                    {
                        OpcRequestId = webResponse.Headers.Get("opc-request-id")
                    });
                }
        }