コード例 #1
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            PatchZoneRecordsRequest request;

            try
            {
                request = new PatchZoneRecordsRequest
                {
                    ZoneNameOrId            = ZoneNameOrId,
                    PatchZoneRecordsDetails = PatchZoneRecordsDetails,
                    IfMatch           = IfMatch,
                    IfUnmodifiedSince = IfUnmodifiedSince,
                    OpcRequestId      = OpcRequestId,
                    Scope             = Scope,
                    ViewId            = ViewId,
                    CompartmentId     = CompartmentId
                };

                response = client.PatchZoneRecords(request).GetAwaiter().GetResult();
                WriteOutput(response, response.RecordCollection);
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }
コード例 #2
0
        /// <summary>
        /// Updates a collection of records in the specified zone.
        /// You can update one record or all records for the specified zone depending on the changes provided in the request body.
        /// You can also add or remove records using this function.
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public async Task <PatchZoneRecordsResponse> PatchZoneRecords(PatchZoneRecordsRequest request)
        {
            var uriStr = $"{GetEndPoint(DNSServices.Zones, this.Region)}/{request.ZoneNameOrId}/records";

            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.Patch(uri, request.PatchZoneRecordsDetails, httpRequestHeaderParam);

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

                    return(new PatchZoneRecordsResponse()
                    {
                        RecordCollection = this.JsonSerializer.Deserialize <RecordCollection>(response),
                        OpcRequestId = webResponse.Headers.Get("opc-request-id"),
                        OpcTotalItems = webResponse.Headers.Get("opc-total-items"),
                        OpcNextPage = webResponse.Headers.Get("opc-next-page"),
                        ETag = webResponse.Headers.Get("ETag")
                    });
                }
        }