Example #1
0
        public async Task CreateTXTRecord(DomainId parentDomainId, DomainName name, string value, TimeToLive timeToLive, GlobalTrafficDirectorLocation globalTrafficDirectorLocation = default, CancellationToken cancellationToken = default)
        {
            var parentDomain = await DomainCache.EnsureAndGet(parentDomainId, cancellationToken).ConfigureAwait(false);

            if (!name.IsSubdomainOf(parentDomain))
            {
                throw new ArgumentException($"The specified domain `{name}` is not a subdomain of the parent `{parentDomain}`", nameof(name));
            }

            await Post($"dns/managed/{parentDomainId}/records", new
            {
                type = "TXT",
                name = name.WithoutParent(parentDomain),
                value,
                ttl         = timeToLive,
                gtdLocation = globalTrafficDirectorLocation
            }, cancellationToken).ConfigureAwait(false);
        }
Example #2
0
        public async Task CreateARecord(DomainId parentDomainId, DomainName name, IPv4 target, TimeToLive timeToLive, string?dynamicDnsPassword = null, GlobalTrafficDirectorLocation globalTrafficDirectorLocation = default, bool isSystemMonitoringEnabled = false, bool isFailoverEnabled = false, CancellationToken cancellationToken = default)
        {
            var parentDomain = await DomainCache.EnsureAndGet(parentDomainId, cancellationToken).ConfigureAwait(false);

            if (!name.IsSubdomainOf(parentDomain))
            {
                throw new ArgumentException($"The specified domain `{name}` is not a subdomain of the parent `{parentDomain}`", nameof(name));
            }

            await Post($"dns/managed/{parentDomainId}/records", new
            {
                type        = "A",
                name        = name.WithoutParent(parentDomain),
                value       = target,
                ttl         = timeToLive,
                dynamicDns  = dynamicDnsPassword != null,
                password    = dynamicDnsPassword,
                gtdLocation = globalTrafficDirectorLocation,
                monitor     = isSystemMonitoringEnabled,
                failover    = isFailoverEnabled
            }, cancellationToken).ConfigureAwait(false);
        }
Example #3
0
        public DnsRecords CreateARecord(DomainName name, IPv4 target, TimeToLive timeToLive, string?dynamicDnsPassword = null, GlobalTrafficDirectorLocation globalTrafficDirectorLocation = default, bool isSystemMonitoringEnabled = false, bool isFailoverEnabled = false)
        {
            if (!name.IsSubdomainOf(ParentDomain))
            {
                throw new ArgumentException($"The specified domain `{name}` is not a subdomain of the parent `{ParentDomain}`", nameof(name));
            }

            return(AddCreate(new
            {
                type = "A",
                name = name.WithoutParent(ParentDomain),
                value = target,
                ttl = timeToLive,
                dynamicDns = dynamicDnsPassword != null,
                password = dynamicDnsPassword,
                gtdLocation = globalTrafficDirectorLocation,
                monitor = isSystemMonitoringEnabled,
                failover = isFailoverEnabled
            }));
        }
Example #4
0
        public DnsRecords CreateCNameRecord(DomainName name, DomainName target, TimeToLive timeToLive, GlobalTrafficDirectorLocation globalTrafficDirectorLocation = default)
        {
            if (!name.IsSubdomainOf(ParentDomain))
            {
                throw new ArgumentException($"The specified domain `{name}` is not a subdomain of the parent `{ParentDomain}`", nameof(name));
            }

            return(AddCreate(new
            {
                type = "CNAME",
                name = name.WithoutParent(ParentDomain),
                value = target.IsSubdomainOf(ParentDomain)
                                                                ? target.WithoutParent(ParentDomain)
                                                                : target + ".",
                ttl = timeToLive,
                gtdLocation = globalTrafficDirectorLocation
            }));
        }
Example #5
0
        public DnsRecords CreateTXTRecord(DomainName name, string value, TimeToLive timeToLive, GlobalTrafficDirectorLocation globalTrafficDirectorLocation = default)
        {
            if (!name.IsSubdomainOf(ParentDomain))
            {
                throw new ArgumentException($"The specified domain `{name}` is not a subdomain of the parent `{ParentDomain}`", nameof(name));
            }

            if (string.IsNullOrEmpty(value))
            {
                throw new ArgumentException("TXT record value cannot be empty or null");
            }

            return(AddCreate(new
            {
                type = "TXT",
                name = name.WithoutParent(ParentDomain),
                value,
                ttl = timeToLive,
                gtdLocation = globalTrafficDirectorLocation
            }));
        }