예제 #1
0
        internal static async Task <PasteClasses.CreateOrUpdateDnsRecordResponse> CreateOrUpdateDnsRecord(string zoneId, string recordName, DnsRecordType dnsRecordType, string content, bool proxied)
        {
            var request = new PasteClasses.CreateOrUpdateDnsRecordRequest
            {
                name    = recordName,
                content = content,
                proxied = proxied,
                type    = dnsRecordType.ToString(),
            };
            var recordExists = await DoesRecordExist(zoneId, recordName);

            if (recordExists)
            {
                var recordId = await GetRecordId(zoneId, recordName);

                return(await UpdateDnsRecord(zoneId, recordId, request));
            }
            else
            {
                return(await CreateDnsRecord(zoneId, request));
            }
        }
예제 #2
0
        internal static async Task <PasteClasses.CreateOrUpdateDnsRecordResponse> UpdateDnsRecord(string zoneId, string recordId, PasteClasses.CreateOrUpdateDnsRecordRequest request)
        {
            if (!await IsCloudflareAuthReady())
            {
                return(null);
            }
            if (string.IsNullOrEmpty(zoneId))
            {
                Output.WriteError($"ZoneId not configured.");
                return(null);
            }
            var response = await Put <PasteClasses.CreateOrUpdateDnsRecordResponse>($"{CloudflareApiRoot}/zones/{zoneId}/dns_records/{recordId}", request);

            ClearCache();
            return(response);
        }