/// <inheritdoc/>
 public Task<ZoneSetting<SettingCacheLevelTypes>> GetCacheLevelSettingAsync(
     IdentifierTag zoneId,
     CancellationToken cancellationToken,
     CloudFlareAuth auth = null)
 {
     return _client.GetCacheLevelSettingAsync(zoneId, cancellationToken, auth ?? _auth);
 }
 /// <inheritdoc/>
 public Task <ZoneSetting <int> > GetChallengeTtlSettingAsync(
     IdentifierTag zoneId,
     CancellationToken cancellationToken,
     CloudFlareAuth auth = null)
 {
     return(_client.GetChallengeTtlSettingAsync(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<ZoneSetting<int>> GetChallengeTtlSettingAsync(
     IdentifierTag zoneId,
     CancellationToken cancellationToken,
     CloudFlareAuth auth = null)
 {
     return _client.GetChallengeTtlSettingAsync(zoneId, cancellationToken, auth ?? _auth);
 }
 /// <inheritdoc/>
 public Task <ZoneDevelopmentModeSetting> GetDevelopmentModeSettingAsync(
     IdentifierTag zoneId,
     CancellationToken cancellationToken,
     CloudFlareAuth auth = null)
 {
     return(_client.GetDevelopmentModeSettingAsync(zoneId, cancellationToken, auth ?? _auth));
 }
Пример #6
0
 /// <inheritdoc/>
 public Task <CloudFlareResponse <IReadOnlyList <Zone> > > GetZonesAsync(
     CancellationToken cancellationToken,
     ZoneGetParameters parameters = null,
     CloudFlareAuth auth          = null)
 {
     return(_client.GetZonesAsync(cancellationToken, auth ?? _auth, parameters));
 }
 /// <inheritdoc/>
 public Task<IEnumerable<ZoneSettingBase>> GetAllZoneSettingsAsync(
     IdentifierTag zoneId,
     CancellationToken cancellationToken,
     CloudFlareAuth auth = null)
 {
     return _client.GetAllZoneSettingsAsync(zoneId, cancellationToken, auth ?? _auth);
 }
 /// <inheritdoc/>
 public Task <ZoneSetting <SettingOnOffTypes> > GetServerSideExcludeSettingAsync(
     IdentifierTag zoneId,
     CancellationToken cancellationToken,
     CloudFlareAuth auth = null)
 {
     return(_client.GetServerSideExcludeSettingAsync(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 <ZoneSetting <SettingMobileRedirect> > GetMobileRedirectSettingAsync(
     IdentifierTag zoneId,
     CancellationToken cancellationToken,
     CloudFlareAuth auth = null)
 {
     return(_client.GetMobileRedirectSettingAsync(zoneId, cancellationToken, auth ?? _auth));
 }
 /// <inheritdoc/>
 public Task <ZoneSetting <SettingOnOffTypes> > GetEnableQueryStringSortSettingAsync(
     IdentifierTag zoneId,
     CancellationToken cancellationToken,
     CloudFlareAuth auth = null)
 {
     return(_client.GetEnableQueryStringSortSettingAsync(zoneId, cancellationToken, auth ?? _auth));
 }
 /// <inheritdoc/>
 public Task<ZoneDevelopmentModeSetting> GetDevelopmentModeSettingAsync(
     IdentifierTag zoneId,
     CancellationToken cancellationToken,
     CloudFlareAuth auth = null)
 {
     return _client.GetDevelopmentModeSettingAsync(zoneId, cancellationToken, auth ?? _auth);
 }
 /// <inheritdoc/>
 public Task<Zone> GetZoneAsync(
     IdentifierTag zoneId,
     CancellationToken cancellationToken,
     CloudFlareAuth auth = null)
 {
     return _client.GetZoneAsync(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<CloudFlareResponse<IReadOnlyList<Zone>>> GetZonesAsync(
     CancellationToken cancellationToken,
     ZoneGetParameters parameters = null,
     CloudFlareAuth auth = null)
 {
     return _client.GetZonesAsync(cancellationToken, auth ?? _auth, parameters);
 }
 /// <inheritdoc/>
 public Task <ZoneSetting <SettingOnOffTypes> > GetHotlinkProtectionSettingAsync(
     IdentifierTag zoneId,
     CancellationToken cancellationToken,
     CloudFlareAuth auth = null)
 {
     return(_client.GetHotlinkProtectionSettingAsync(zoneId, cancellationToken, auth ?? _auth));
 }
Пример #17
0
 /// <inheritdoc/>
 public Task <Zone> GetZoneAsync(
     IdentifierTag zoneId,
     CancellationToken cancellationToken,
     CloudFlareAuth auth = null)
 {
     return(_client.GetZoneAsync(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<ZoneSetting<SettingOnOffTypes>> GetBrowserCheckSettingAsync(
     IdentifierTag zoneId,
     CancellationToken cancellationToken,
     CloudFlareAuth auth = null)
 {
     return _client.GetBrowserCheckSettingAsync(zoneId, cancellationToken, auth ?? _auth);
 }
 /// <inheritdoc/>
 public Task <ZoneSetting <SettingOnOffTypes> > GetWebApplicationFirewallSettingAsync(
     IdentifierTag zoneId,
     CancellationToken cancellationToken,
     CloudFlareAuth auth = null)
 {
     return(_client.GetWebApplicationFirewallSettingAsync(zoneId, cancellationToken, auth ?? _auth));
 }
 /// <inheritdoc/>
 public Task <ZoneSetting <SettingOnOffTypes> > GetResponseBufferingSettingAsync(
     IdentifierTag zoneId,
     CancellationToken cancellationToken,
     CloudFlareAuth auth = null)
 {
     return(_client.GetResponseBufferingSettingAsync(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<CloudFlareResponse<IReadOnlyList<DnsRecord>>> GetDnsRecordsAsync(
     IdentifierTag zoneId,
     CancellationToken cancellationToken,
     DnsRecordGetParameters parameters = null,
     CloudFlareAuth auth = null)
 {
     return _client.GetDnsRecordsAsync(zoneId, cancellationToken, auth ?? _auth, parameters);
 }
Пример #24
0
 /// <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));
 }
Пример #25
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CloudFlareClient"/> class.
        /// </summary>
        /// <param name="client">A custom <see cref="HttpClient"/> to be used instead of the internal client.</param>
        /// <param name="auth">
        /// <para>The authentication details for accessing the CloudFlare API.</para>
        /// <para>If authentication details are not provided via the constructor, they must be provided to every method
        /// call.</para>
        /// </param>
        public CloudFlareClient(HttpClient client, CloudFlareAuth auth = null)
        {
            if (client == null)
            {
                throw new ArgumentNullException(nameof(client));
            }

            _client = client;
            _auth   = auth;
        }
Пример #26
0
 /// <inheritdoc/>
 public Task <IEnumerable <Zone> > GetAllZonesAsync(
     CancellationToken cancellationToken,
     ZoneGetParameters parameters = null,
     CloudFlareAuth auth          = null)
 {
     return(GetAllPagedResultsAsync <Zone, ZoneGetParameters, ZoneOrderTypes>(
                _client.GetZonesAsync,
                cancellationToken,
                auth ?? _auth,
                50,
                parameters));
 }
Пример #27
0
        /// <summary>
        /// Executes a <see cref="HttpMethod.Get"/> request returning the type specified by <typeparamref name="T"/>.
        /// </summary>
        /// <typeparam name="T">The type of the <see cref="CloudFlareResponse{T}.Result"/>.</typeparam>
        public static async Task <T> GetCloudFlareResultAsync <T>(
            this HttpClient client,
            Uri uri,
            CloudFlareAuth auth,
            CancellationToken cancellationToken)
            where T : class
        {
            CloudFlareResponse <T> cloudFlareResponse =
                await client.GetCloudFlareResponseAsync <T>(uri, auth, cancellationToken).ConfigureAwait(false);

            return(cloudFlareResponse.Result);
        }
 /// <inheritdoc/>
 public Task<IEnumerable<Zone>> GetAllZonesAsync(
     CancellationToken cancellationToken,
     ZoneGetParameters parameters = null,
     CloudFlareAuth auth = null)
 {
     return GetAllPagedResultsAsync<Zone, ZoneGetParameters, ZoneOrderTypes>(
         _client.GetZonesAsync,
         cancellationToken,
         auth ?? _auth,
         50,
         parameters);
 }
Пример #29
0
        /// <summary>
        /// Gets the zones for the subscription.
        /// </summary>
        /// <seealso href="https://api.cloudflare.com/#zone-list-zones"/>
        public static Task<IEnumerable<Zone>> GetAllZonesAsync(
            this IZoneClient client,
            CloudFlareAuth auth,
            ZoneGetParameters parameters = null)
        {
            if (client == null)
                throw new ArgumentNullException(nameof(client));
            if (auth == null)
                throw new ArgumentNullException(nameof(auth));

            return client.GetAllZonesAsync(CancellationToken.None, parameters, auth);
        }
Пример #30
0
        /// <summary>
        /// Gets the zones for the subscription.
        /// </summary>
        /// <seealso href="https://api.cloudflare.com/#zone-list-zones"/>
        public static Task<CloudFlareResponse<IReadOnlyList<Zone>>> GetZonesAsync(
            this IZoneClient client,
            CloudFlareAuth auth,
            ZoneGetParameters parameters = null)
        {
            if (client == null)
                throw new ArgumentNullException(nameof(client));
            if (auth == null)
                throw new ArgumentNullException(nameof(auth));

            return client.GetZonesAsync(CancellationToken.None, parameters, auth);
        }
Пример #31
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 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>
        /// 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>
        /// 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);
        }
        /// <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 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);
        }
        /// <summary>
        /// Gets the zones for the account specified by the <paramref name="auth"/> details.
        /// </summary>
        /// <seealso href="https://api.cloudflare.com/#zone-list-zones"/>
        public static Task<CloudFlareResponse<IReadOnlyList<Zone>>> GetZonesAsync(
            this HttpClient client,
            CancellationToken cancellationToken,
            CloudFlareAuth auth,
            ZoneGetParameters parameters = null)
        {
            Uri uri = new Uri(CloudFlareConstants.BaseUri, "zones");
            if (parameters != null)
            {
                uri = new UriBuilder(uri) { Query = parameters.ToQuery() }.Uri;
            }

            return client.GetCloudFlareResponseAsync<IReadOnlyList<Zone>>(uri, auth, cancellationToken);
        }
Пример #39
0
        /// <summary>
        /// Adds the authentication headers to the <paramref name="request"/>.
        /// </summary>
        public static void AddAuth(this HttpRequestMessage request, CloudFlareAuth auth)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }
            if (auth == null)
            {
                throw new ArgumentNullException(nameof(auth));
            }

            request.Headers.Add("X-Auth-Key", auth.Key);
            request.Headers.Add("X-Auth-Email", auth.Email);
        }
        /// <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));
        }
Пример #41
0
        /// <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));
        }
        /// <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>
        /// 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);
        }
        /// <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>
        /// The WAF examines HTTP requests to your website.
        /// </summary>
        /// <seealso href="https://api.cloudflare.com/#zone-settings-get-web-application-firewall-waf-setting"/>
        public static Task <ZoneSetting <SettingOnOffTypes> > GetWebApplicationFirewallSettingAsync(
            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.GetWebApplicationFirewallSettingAsync(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));
        }
        /// <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);
        }
Пример #48
0
        /// <summary>
        /// Gets the zones for the subscription.
        /// </summary>
        /// <seealso href="https://api.cloudflare.com/#zone-list-zones"/>
        public static Task <IEnumerable <Zone> > GetAllZonesAsync(
            this IZoneClient client,
            CloudFlareAuth auth,
            ZoneGetParameters parameters = null)
        {
            if (client == null)
            {
                throw new ArgumentNullException(nameof(client));
            }
            if (auth == null)
            {
                throw new ArgumentNullException(nameof(auth));
            }

            return(client.GetAllZonesAsync(CancellationToken.None, parameters, auth));
        }
Пример #49
0
        /// <summary>
        /// Gets the zones for the subscription.
        /// </summary>
        /// <seealso href="https://api.cloudflare.com/#zone-list-zones"/>
        public static Task <CloudFlareResponse <IReadOnlyList <Zone> > > GetZonesAsync(
            this IZoneClient client,
            CloudFlareAuth auth,
            ZoneGetParameters parameters = null)
        {
            if (client == null)
            {
                throw new ArgumentNullException(nameof(client));
            }
            if (auth == null)
            {
                throw new ArgumentNullException(nameof(auth));
            }

            return(client.GetZonesAsync(CancellationToken.None, parameters, auth));
        }
Пример #50
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 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>());
        }
Пример #52
0
        /// <summary>
        /// Gets the zones for the account specified by the <paramref name="auth"/> details.
        /// </summary>
        /// <seealso href="https://api.cloudflare.com/#zone-list-zones"/>
        public static Task <CloudFlareResponse <IReadOnlyList <Zone> > > GetZonesAsync(
            this HttpClient client,
            CancellationToken cancellationToken,
            CloudFlareAuth auth,
            ZoneGetParameters parameters = null)
        {
            Uri uri = new Uri(CloudFlareConstants.BaseUri, "zones");

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

            return(client.GetCloudFlareResponseAsync <IReadOnlyList <Zone> >(uri, auth, cancellationToken));
        }
        /// <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);
        }
        /// <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());
        }
 /// <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>
        /// 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);
        }