Example #1
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            UpdateDomainRecordsRequest request;

            try
            {
                request = new UpdateDomainRecordsRequest
                {
                    ZoneNameOrId = ZoneNameOrId,
                    Domain       = Domain,
                    UpdateDomainRecordsDetails = UpdateDomainRecordsDetails,
                    IfMatch           = IfMatch,
                    IfUnmodifiedSince = IfUnmodifiedSince,
                    OpcRequestId      = OpcRequestId,
                    CompartmentId     = CompartmentId
                };

                response = client.UpdateDomainRecords(request).GetAwaiter().GetResult();
                WriteOutput(response, response.RecordCollection);
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }
Example #2
0
        /// <summary>
        /// Replaces records in the specified zone at a domain with the records specified in the request body.
        /// If a specified record does not exist, it will be created. If the record exists, then it will be updated to represent the record in the body of the request.
        /// If a record in the zone does not exist in the request body, the record will be removed from the zone.
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public async Task <UpdateDomainRecordsResponse> UpdateDomainRecords(UpdateDomainRecordsRequest request)
        {
            var uriStr = $"{GetEndPoint(DNSServices.Zones, this.Region)}/{request.ZoneNameOrId}/records/{request.Domain}";

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

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

                    return(new UpdateDomainRecordsResponse()
                    {
                        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")
                    });
                }
        }