/// <inheritdoc/>
 public Task<ZoneDevelopmentModeSetting> GetDevelopmentModeSettingAsync(
     IdentifierTag zoneId,
     CancellationToken cancellationToken,
     CloudFlareAuth auth = null)
 {
     return _client.GetDevelopmentModeSettingAsync(zoneId, cancellationToken, auth ?? _auth);
 }
 /// <inheritdoc/>
 public Task<ZoneSetting<SettingCacheLevelTypes>> GetCacheLevelSettingAsync(
     IdentifierTag zoneId,
     CancellationToken cancellationToken,
     CloudFlareAuth auth = null)
 {
     return _client.GetCacheLevelSettingAsync(zoneId, cancellationToken, auth ?? _auth);
 }
 /// <inheritdoc/>
 public Task<ZoneSetting<SettingOnOffTypes>> GetEmailObfuscationSettingAsync(
     IdentifierTag zoneId,
     CancellationToken cancellationToken,
     CloudFlareAuth auth = null)
 {
     return _client.GetEmailObfuscationSettingAsync(zoneId, cancellationToken, auth ?? _auth);
 }
 /// <summary>
 /// Gets the all the zone data.
 /// </summary>
 public static Task<ZoneData> GetZoneDataAsync(
     this ICloudFlareClient client,
     IdentifierTag zoneId,
     CloudFlareAuth auth = null)
 {
     return client.GetZoneDataAsync(zoneId, CancellationToken.None, auth);
 }
 /// <inheritdoc/>
 public Task<Zone> GetZoneAsync(
     IdentifierTag zoneId,
     CancellationToken cancellationToken,
     CloudFlareAuth auth = null)
 {
     return _client.GetZoneAsync(zoneId, cancellationToken, auth ?? _auth);
 }
Exemplo n.º 6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Zone"/> class.
        /// </summary>
        public Zone(
            IdentifierTag id,
            DateTimeOffset? createdOn,
            DateTimeOffset modifiedOn,
            string name,
            int developmentMode,
            IReadOnlyList<string> originalNameServers = null,
            string originalRegistrar = null,
            string originalDnshost = null,
            IReadOnlyList<string> nameServers = null,
            ZoneStatusType status = ZoneStatusType.active)
        {
            if (id == null)
                throw new ArgumentNullException(nameof(id));
            if (string.IsNullOrWhiteSpace(name))
                throw new ArgumentNullException(nameof(name));

            Id = id;
            CreatedOn = createdOn;
            ModifiedOn = modifiedOn;
            Name = name;
            DevelopmentMode = developmentMode;
            OriginalNameServers = originalNameServers ?? EmptyStrings;
            OriginalRegistrar = originalRegistrar ?? string.Empty;
            OriginalDnshost = originalDnshost ?? string.Empty;
            NameServers = nameServers ?? EmptyStrings;
            Status = status;
        }
 /// <inheritdoc/>
 public Task<ZoneSetting<int>> GetChallengeTtlSettingAsync(
     IdentifierTag zoneId,
     CancellationToken cancellationToken,
     CloudFlareAuth auth = null)
 {
     return _client.GetChallengeTtlSettingAsync(zoneId, cancellationToken, auth ?? _auth);
 }
 /// <inheritdoc/>
 public Task<IEnumerable<ZoneSettingBase>> GetAllZoneSettingsAsync(
     IdentifierTag zoneId,
     CancellationToken cancellationToken,
     CloudFlareAuth auth = null)
 {
     return _client.GetAllZoneSettingsAsync(zoneId, cancellationToken, auth ?? _auth);
 }
 /// <inheritdoc/>
 public Task<CloudFlareResponse<IReadOnlyList<DnsRecord>>> GetDnsRecordsAsync(
     IdentifierTag zoneId,
     CancellationToken cancellationToken,
     DnsRecordGetParameters parameters = null,
     CloudFlareAuth auth = null)
 {
     return _client.GetDnsRecordsAsync(zoneId, cancellationToken, auth ?? _auth, parameters);
 }
        /// <summary>
        /// Gets the zones for the account specified by the <paramref name="auth"/> details.
        /// </summary>
        /// <seealso href="https://api.cloudflare.com/#zone-zone-details"/>
        public static Task<Zone> GetZoneAsync(
            this HttpClient client,
            IdentifierTag zoneId,
            CancellationToken cancellationToken,
            CloudFlareAuth auth)
        {
            if (zoneId == null)
                throw new ArgumentNullException(nameof(zoneId));

            Uri uri = new Uri(CloudFlareConstants.BaseUri, $"zones/{zoneId}");
            return client.GetCloudFlareResultAsync<Zone>(uri, auth, cancellationToken);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Gets the zones for the subscription.
        /// </summary>
        /// <seealso href="https://api.cloudflare.com/#zone-zone-details"/>
        public static Task<Zone> GetZoneAsync(
            this IZoneClient client,
            IdentifierTag zoneId,
            CloudFlareAuth auth = null)
        {
            if (zoneId == null)
                throw new ArgumentNullException(nameof(zoneId));
            if (client == null)
                throw new ArgumentNullException(nameof(client));

            return client.GetZoneAsync(zoneId, CancellationToken.None, auth);
        }
        /// <summary>
        /// Gets the zones for the subscription.
        /// </summary>
        /// <seealso href="https://api.cloudflare.com/#dns-records-for-a-zone-list-dns-records"/>
        public static Task<CloudFlareResponse<IReadOnlyList<DnsRecord>>> GetDnsRecordsAsync(
            this IDnsRecordClient client,
            IdentifierTag zoneId,
            DnsRecordGetParameters parameters = null)
        {
            if (client == null)
                throw new ArgumentNullException(nameof(client));
            if (zoneId == null)
                throw new ArgumentNullException(nameof(zoneId));

            return client.GetDnsRecordsAsync(zoneId, CancellationToken.None, parameters);
        }
        /// <summary>
        /// Gets the zones for the subscription.
        /// </summary>
        /// <seealso href="https://api.cloudflare.com/#dns-records-for-a-zone-list-dns-records"/>
        public static Task<IEnumerable<DnsRecord>> GetAllDnsRecordsAsync(
            this IDnsRecordClient client,
            IdentifierTag zoneId,
            DnsRecordGetParameters parameters = null)
        {
            if (client == null)
                throw new ArgumentNullException(nameof(client));
            if (zoneId == null)
                throw new ArgumentNullException(nameof(zoneId));

            return client.GetAllDnsRecordsAsync(zoneId, CancellationToken.None, parameters);
        }
        /// <summary>
        /// Gets the zone settings for the zone with the specified <paramref name="zoneId"/>.
        /// </summary>
        /// <seealso href="https://api.cloudflare.com/#zone-settings-get-all-zone-settings"/>
        public static Task<IEnumerable<ZoneSettingBase>> GetAllZoneSettingsAsync(
            this IZoneSettingsClient client,
            IdentifierTag zoneId,
            CloudFlareAuth auth = null)
        {
            if (client == null)
                throw new ArgumentNullException(nameof(client));
            if (zoneId == null)
                throw new ArgumentNullException(nameof(zoneId));

            return client.GetAllZoneSettingsAsync(zoneId, CancellationToken.None, auth);
        }
        /// <summary>
        /// When enabled, Always Online will serve pages from our cache if your server is offline.
        /// </summary>
        /// <seealso href="https://api.cloudflare.com/#zone-settings-get-always-online-setting"/>
        public static Task<ZoneSetting<SettingOnOffTypes>> GetAlwaysOnlineSettingAsync(
            this IZoneSettingsClient client,
            IdentifierTag zoneId,
            CloudFlareAuth auth = null)
        {
            if (client == null)
                throw new ArgumentNullException(nameof(client));
            if (zoneId == null)
                throw new ArgumentNullException(nameof(zoneId));

            return client.GetAlwaysOnlineSettingAsync(zoneId, CancellationToken.None, auth);
        }
        /// <summary>
        /// Browser Cache TTL (in seconds) specifies how long CloudFlare-cached resources will remain on your visitors'
        /// computers.
        /// </summary>
        /// <seealso href="https://api.cloudflare.com/#zone-settings-get-browser-cache-ttl-setting"/>
        public static Task<ZoneSetting<int>> GetBrowserCacheTtlSettingAsync(
            this IZoneSettingsClient client,
            IdentifierTag zoneId,
            CloudFlareAuth auth = null)
        {
            if (client == null)
                throw new ArgumentNullException(nameof(client));
            if (zoneId == null)
                throw new ArgumentNullException(nameof(zoneId));

            return client.GetBrowserCacheTtlSettingAsync(zoneId, CancellationToken.None, auth);
        }
        /// <summary>
        /// Browser Cache TTL (in seconds) specifies how long CloudFlare-cached resources will remain on your visitors'
        /// computers.
        /// </summary>
        /// <seealso href="https://api.cloudflare.com/#zone-settings-get-browser-cache-ttl-setting"/>
        public static Task<ZoneSetting<int>> GetBrowserCacheTtlSettingAsync(
            this HttpClient client,
            IdentifierTag zoneId,
            CancellationToken cancellationToken,
            CloudFlareAuth auth)
        {
            if (zoneId == null)
                throw new ArgumentNullException(nameof(zoneId));

            Uri uri = new Uri(CloudFlareConstants.BaseUri, $"zones/{zoneId}/settings/browser_cache_ttl");

            return client.GetCloudFlareResultAsync<ZoneSetting<int>>(uri, auth, cancellationToken);
        }
        /// <summary>
        /// When enabled, Always Online will serve pages from our cache if your server is offline.
        /// </summary>
        /// <seealso href="https://api.cloudflare.com/#zone-settings-get-always-online-setting"/>
        public static Task<ZoneSetting<SettingOnOffTypes>> GetAlwaysOnlineSettingAsync(
            this HttpClient client,
            IdentifierTag zoneId,
            CancellationToken cancellationToken,
            CloudFlareAuth auth)
        {
            if (zoneId == null)
                throw new ArgumentNullException(nameof(zoneId));

            Uri uri = new Uri(CloudFlareConstants.BaseUri, $"zones/{zoneId}/settings/always_online");

            return client.GetCloudFlareResultAsync<ZoneSetting<SettingOnOffTypes>>(uri, auth, cancellationToken);
        }
        /// <inheritdoc/>
        public Task<IEnumerable<DnsRecord>> GetAllDnsRecordsAsync(
            IdentifierTag zoneId,
            CancellationToken cancellationToken,
            DnsRecordGetParameters parameters = null,
            CloudFlareAuth auth = null)
        {
            if (zoneId == null)
                throw new ArgumentNullException(nameof(zoneId));

            return GetAllPagedResultsAsync<DnsRecord, DnsRecordGetParameters, DnsRecordOrderTypes>(
                (ct, a, p) => _client.GetDnsRecordsAsync(zoneId, ct, a, p),
                cancellationToken,
                auth ?? _auth,
                100,
                parameters);
        }
        /// <summary>
        /// Gets the zone settings for the zone with the specified <paramref name="zoneId"/>.
        /// </summary>
        /// <seealso href="https://api.cloudflare.com/#zone-settings-get-all-zone-settings"/>
        public static async Task<IEnumerable<ZoneSettingBase>> GetAllZoneSettingsAsync(
            this HttpClient client,
            IdentifierTag zoneId,
            CancellationToken cancellationToken,
            CloudFlareAuth auth)
        {
            if (zoneId == null)
                throw new ArgumentNullException(nameof(zoneId));

            Uri uri = new Uri(CloudFlareConstants.BaseUri, $"zones/{zoneId}/settings");

            JArray jsonSettings = await client.GetCloudFlareResultAsync<JArray>(uri, auth, cancellationToken)
                .ConfigureAwait(false);

            return GetZoneSetting(jsonSettings.Cast<JObject>());
        }
        /// <summary>
        /// Gets the DNS records for the zone with the specified <paramref name="zoneId"/>.
        /// </summary>
        /// <seealso href="https://api.cloudflare.com/#dns-records-for-a-zone-list-dns-records"/>
        public static Task<CloudFlareResponse<IReadOnlyList<DnsRecord>>> GetDnsRecordsAsync(
            this HttpClient client,
            IdentifierTag zoneId,
            CancellationToken cancellationToken,
            CloudFlareAuth auth,
            DnsRecordGetParameters parameters = null)
        {
            if (zoneId == null)
                throw new ArgumentNullException(nameof(zoneId));

            Uri uri = new Uri(CloudFlareConstants.BaseUri, $"zones/{zoneId}/dns_records");
            if (parameters != null)
            {
                uri = new UriBuilder(uri) { Query = parameters.ToQuery() }.Uri;
            }

            return client.GetCloudFlareResponseAsync<IReadOnlyList<DnsRecord>>(uri, auth, cancellationToken);
        }
Exemplo n.º 22
0
        /// <inheritdoc/>
        public Task <IEnumerable <DnsRecord> > GetAllDnsRecordsAsync(
            IdentifierTag zoneId,
            CancellationToken cancellationToken,
            DnsRecordGetParameters parameters = null,
            CloudFlareAuth auth = null)
        {
            if (zoneId == null)
            {
                throw new ArgumentNullException(nameof(zoneId));
            }

            return(GetAllPagedResultsAsync <DnsRecord, DnsRecordGetParameters, DnsRecordOrderTypes>(
                       (ct, a, p) => _client.GetDnsRecordsAsync(zoneId, ct, a, p),
                       cancellationToken,
                       auth ?? _auth,
                       100,
                       parameters));
        }
        /// <summary>
        /// Gets the all the zone data.
        /// </summary>
        public static async Task<ZoneData> GetZoneDataAsync(
            this ICloudFlareClient client,
            IdentifierTag zoneId,
            CancellationToken cancellationToken,
            CloudFlareAuth auth = null)
        {
            if (client == null)
                throw new ArgumentNullException(nameof(client));
            if (zoneId == null)
                throw new ArgumentNullException(nameof(zoneId));

            Task<Zone> zoneTask = client.GetZoneAsync(zoneId, cancellationToken, auth);
            Task<IEnumerable<DnsRecord>> dnsRecordsTask =
                client.GetAllDnsRecordsAsync(zoneId, cancellationToken, auth: auth);

            await Task.WhenAll(zoneTask, dnsRecordsTask).ConfigureAwait(false);

            return new ZoneData(zoneTask.Result, dnsRecordsTask.Result.ToArray());
        }
        /// <summary>
        /// Gets the zones for the subscription.
        /// </summary>
        /// <seealso href="https://api.cloudflare.com/#dns-records-for-a-zone-list-dns-records"/>
        public static Task <IEnumerable <DnsRecord> > GetAllDnsRecordsAsync(
            this IDnsRecordClient client,
            IdentifierTag zoneId,
            CloudFlareAuth auth,
            DnsRecordGetParameters parameters = null)
        {
            if (client == null)
            {
                throw new ArgumentNullException(nameof(client));
            }
            if (zoneId == null)
            {
                throw new ArgumentNullException(nameof(zoneId));
            }
            if (auth == null)
            {
                throw new ArgumentNullException(nameof(auth));
            }

            return(client.GetAllDnsRecordsAsync(zoneId, CancellationToken.None, parameters, auth));
        }
Exemplo n.º 25
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DnsRecord"/> class.
        /// </summary>
        public DnsRecord(
            IdentifierTag id,
            DateTimeOffset? createdOn,
            DateTimeOffset modifiedOn,
            DnsRecordType type,
            string name,
            bool proxiable,
            bool proxied,
            int ttl,
            bool locked,
            IdentifierTag zoneId,
            int priority,
            string content = null,
            string zoneName = null,
            JObject data = null,
            JObject meta = null)
        {
            if (id == null)
                throw new ArgumentNullException(nameof(id));
            if (name == null)
                throw new ArgumentNullException(nameof(name));
            if (zoneId == null)
                throw new ArgumentNullException(nameof(zoneId));

            Id = id;
            CreatedOn = createdOn;
            ModifiedOn = modifiedOn;
            Type = type;
            Name = name;
            Content = content ?? string.Empty;
            Proxiable = proxiable;
            Proxied = proxied;
            Ttl = ttl;
            Locked = locked;
            ZoneId = zoneId;
            ZoneName = zoneName ?? string.Empty;
            Data = data ?? new JObject();
            Meta = meta ?? new JObject();
            Priority = priority;
        }
        /// <summary>
        /// Gets the all the zone data.
        /// </summary>
        public static async Task <ZoneData> GetZoneDataAsync(
            this ICloudFlareClient client,
            IdentifierTag zoneId,
            CancellationToken cancellationToken,
            CloudFlareAuth auth = null)
        {
            if (client == null)
            {
                throw new ArgumentNullException(nameof(client));
            }
            if (zoneId == null)
            {
                throw new ArgumentNullException(nameof(zoneId));
            }

            Task <Zone> zoneTask = client.GetZoneAsync(zoneId, cancellationToken, auth);
            Task <IEnumerable <DnsRecord> > dnsRecordsTask =
                client.GetAllDnsRecordsAsync(zoneId, cancellationToken, auth: auth);

            await Task.WhenAll(zoneTask, dnsRecordsTask).ConfigureAwait(false);

            return(new ZoneData(zoneTask.Result, dnsRecordsTask.Result.ToArray()));
        }
        /// <summary>
        /// Gets the DNS records for the zone with the specified <paramref name="zoneId"/>.
        /// </summary>
        /// <seealso href="https://api.cloudflare.com/#dns-records-for-a-zone-list-dns-records"/>
        public static Task <CloudFlareResponse <IReadOnlyList <DnsRecord> > > GetDnsRecordsAsync(
            this HttpClient client,
            IdentifierTag zoneId,
            CancellationToken cancellationToken,
            CloudFlareAuth auth,
            DnsRecordGetParameters parameters = null)
        {
            if (zoneId == null)
            {
                throw new ArgumentNullException(nameof(zoneId));
            }

            Uri uri = new Uri(CloudFlareConstants.BaseUri, $"zones/{zoneId}/dns_records");

            if (parameters != null)
            {
                uri = new UriBuilder(uri)
                {
                    Query = parameters.ToQuery()
                }.Uri;
            }

            return(client.GetCloudFlareResponseAsync <IReadOnlyList <DnsRecord> >(uri, auth, cancellationToken));
        }
        /// <summary>
        /// CloudFlare will treat files with the same query strings as the same file in cache, regardless of the order
        /// of the query strings.
        /// </summary>
        /// <seealso href="https://api.cloudflare.com/#zone-settings-get-enable-query-string-sort-setting"/>
        public static Task<ZoneSetting<SettingOnOffTypes>> GetEnableQueryStringSortSettingAsync(
            this HttpClient client,
            IdentifierTag zoneId,
            CancellationToken cancellationToken,
            CloudFlareAuth auth)
        {
            if (zoneId == null)
                throw new ArgumentNullException(nameof(zoneId));

            Uri uri = new Uri(CloudFlareConstants.BaseUri, $"zones/{zoneId}/settings/sort_query_string_for_cache");

            return client.GetCloudFlareResultAsync<ZoneSetting<SettingOnOffTypes>>(uri, auth, cancellationToken);
        }
 /// <inheritdoc/>
 public Task<ZoneSetting<SettingMobileRedirect>> GetMobileRedirectSettingAsync(
     IdentifierTag zoneId,
     CancellationToken cancellationToken,
     CloudFlareAuth auth = null)
 {
     return _client.GetMobileRedirectSettingAsync(zoneId, cancellationToken, auth ?? _auth);
 }
 /// <inheritdoc/>
 public Task<ZoneSetting<SettingRocketLoaderTypes>> GetRocketLoaderSettingAsync(
     IdentifierTag zoneId,
     CancellationToken cancellationToken,
     CloudFlareAuth auth = null)
 {
     return _client.GetRocketLoaderSettingAsync(zoneId, cancellationToken, auth ?? _auth);
 }
 /// <inheritdoc/>
 public Task<ZoneSetting<SettingSecurityHeader>> GetSecurityHeaderSettingAsync(
     IdentifierTag zoneId,
     CancellationToken cancellationToken,
     CloudFlareAuth auth = null)
 {
     return _client.GetSecurityHeaderSettingAsync(zoneId, cancellationToken, auth ?? _auth);
 }
 /// <inheritdoc/>
 public Task<ZoneSetting<SettingOnOffTypes>> GetEnableQueryStringSortSettingAsync(
     IdentifierTag zoneId,
     CancellationToken cancellationToken,
     CloudFlareAuth auth = null)
 {
     return _client.GetEnableQueryStringSortSettingAsync(zoneId, cancellationToken, auth ?? _auth);
 }
        /// <summary>
        /// Automatically redirect visitors on mobile devices to a mobile-optimized subdomain.
        /// </summary>
        /// <seealso href="https://api.cloudflare.com/#zone-settings-get-mobile-redirect-setting"/>
        public static Task<ZoneSetting<SettingMobileRedirect>> GetMobileRedirectSettingAsync(
            this HttpClient client,
            IdentifierTag zoneId,
            CancellationToken cancellationToken,
            CloudFlareAuth auth)
        {
            if (zoneId == null)
                throw new ArgumentNullException(nameof(zoneId));

            Uri uri = new Uri(CloudFlareConstants.BaseUri, $"zones/{zoneId}/settings/mobile_redirect");

            return client.GetCloudFlareResultAsync<ZoneSetting<SettingMobileRedirect>>(uri, auth, cancellationToken);
        }