-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from JSkimming/zone-settings
Added support for Get All Settings for a Zone
- Loading branch information
Showing
44 changed files
with
1,019 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
namespace CloudFlare.NET | ||
{ | ||
using System.Diagnostics.CodeAnalysis; | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Converters; | ||
|
||
// ReSharper disable InconsistentNaming | ||
#pragma warning disable 1591 | ||
|
||
/// <summary> | ||
/// The values of Cache Level setting. | ||
/// </summary> | ||
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1602:EnumerationItemsMustBeDocumented", | ||
Justification = "Names are self-explanatory.")] | ||
[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1303:ConstFieldNamesMustBeginWithUpperCaseLetter", | ||
Justification = "Named to match serialized values.")] | ||
[JsonConverter(typeof(StringEnumConverter))] | ||
public enum SettingCacheLevelTypes | ||
{ | ||
basic, | ||
simplified, | ||
aggressive, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
namespace CloudFlare.NET | ||
{ | ||
using System.Diagnostics.CodeAnalysis; | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Converters; | ||
|
||
// ReSharper disable InconsistentNaming | ||
#pragma warning disable 1591 | ||
|
||
/// <summary> | ||
/// The values of an on/off setting. | ||
/// </summary> | ||
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1602:EnumerationItemsMustBeDocumented", | ||
Justification = "Names are self-explanatory.")] | ||
[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1303:ConstFieldNamesMustBeginWithUpperCaseLetter", | ||
Justification = "Named to match serialized values.")] | ||
[JsonConverter(typeof(StringEnumConverter))] | ||
public enum SettingOnOffTypes | ||
{ | ||
off, | ||
on, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
namespace CloudFlare.NET | ||
{ | ||
using System.Diagnostics.CodeAnalysis; | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Converters; | ||
|
||
// ReSharper disable InconsistentNaming | ||
#pragma warning disable 1591 | ||
|
||
/// <summary> | ||
/// The values of Cache Level setting. | ||
/// </summary> | ||
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1602:EnumerationItemsMustBeDocumented", | ||
Justification = "Names are self-explanatory.")] | ||
[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1303:ConstFieldNamesMustBeginWithUpperCaseLetter", | ||
Justification = "Named to match serialized values.")] | ||
[JsonConverter(typeof(StringEnumConverter))] | ||
public enum SettingSecurityLevelTypes | ||
{ | ||
essentially_off, | ||
low, | ||
medium, | ||
high, | ||
under_attack, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
namespace CloudFlare.NET | ||
{ | ||
using System.Diagnostics.CodeAnalysis; | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Converters; | ||
|
||
// ReSharper disable InconsistentNaming | ||
#pragma warning disable 1591 | ||
|
||
/// <summary> | ||
/// The values of Cache Level setting. | ||
/// </summary> | ||
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1602:EnumerationItemsMustBeDocumented", | ||
Justification = "Names are self-explanatory.")] | ||
[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1303:ConstFieldNamesMustBeginWithUpperCaseLetter", | ||
Justification = "Named to match serialized values.")] | ||
[JsonConverter(typeof(StringEnumConverter))] | ||
public enum SettingSslTypes | ||
{ | ||
off, | ||
flexible, | ||
full, | ||
full_strict, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
namespace CloudFlare.NET | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Newtonsoft.Json; | ||
|
||
/// <summary> | ||
/// Development Mode temporarily allows you to enter development mode for your websites if you need to make changes | ||
/// to your site. This will bypass CloudFlare's accelerated cache and slow down your site, but is useful if you are | ||
/// making changes to cacheable content (like images, css, or JavaScript) and would like to see those changes right | ||
/// away. Once entered, development mode will last for 3 hours and then automatically toggle off. | ||
/// </summary> | ||
/// <seealso href="https://api.cloudflare.com/#zone-settings-get-development-mode-setting"/> | ||
public class ZoneDevelopmentModeSetting : ZoneSetting<SettingOnOffTypes> | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="ZoneDevelopmentModeSetting"/> class. | ||
/// </summary> | ||
public ZoneDevelopmentModeSetting( | ||
string id, | ||
SettingOnOffTypes value, | ||
bool editable, | ||
DateTimeOffset? modifiedOn, | ||
int timeRemaining) | ||
: base(id, value, editable, modifiedOn) | ||
{ | ||
TimeRemaining = timeRemaining; | ||
} | ||
|
||
/// <summary> | ||
/// The interval (in seconds) from when development mode expires (positive integer) or last expired (negative | ||
/// integer) for the domain. If development mode has never been enabled, this value is false. | ||
/// </summary> | ||
[JsonProperty("time_remaining")] | ||
public int TimeRemaining { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
namespace CloudFlare.NET | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Newtonsoft.Json; | ||
|
||
/// <summary> | ||
/// A Zone setting changes how the Zone works in relation to caching, security, or other features of CloudFlare. | ||
/// </summary> | ||
/// <typeparam name="TValue">The type of the <see cref="Value"/>.</typeparam> | ||
/// <seealso href="https://api.cloudflare.com/#zone-settings" /> | ||
public class ZoneSetting<TValue> : ZoneSettingBase | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="ZoneSetting{TValue}"/> class. | ||
/// </summary> | ||
public ZoneSetting(string id, TValue value, bool editable, DateTimeOffset? modifiedOn) | ||
: base(id, editable, modifiedOn) | ||
{ | ||
Value = value; | ||
} | ||
|
||
/// <summary> | ||
/// Value of the zone setting. | ||
/// </summary> | ||
[JsonProperty("value")] | ||
public TValue Value { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
namespace CloudFlare.NET | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using CloudFlare.NET.Serialization; | ||
using Newtonsoft.Json; | ||
|
||
/// <summary> | ||
/// The base class for all Zone settings. | ||
/// </summary> | ||
/// <seealso href="https://api.cloudflare.com/#zone-settings" /> | ||
public abstract class ZoneSettingBase | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="ZoneSettingBase"/> class. | ||
/// </summary> | ||
protected ZoneSettingBase(string id, bool editable, DateTimeOffset? modifiedOn) | ||
{ | ||
if (id == null) | ||
throw new ArgumentNullException(nameof(id)); | ||
|
||
Id = id; | ||
Editable = editable; | ||
ModifiedOn = modifiedOn; | ||
} | ||
|
||
/// <summary> | ||
/// ID of the zone setting. | ||
/// </summary> | ||
[JsonProperty("id")] | ||
public string Id { get; } | ||
|
||
/// <summary> | ||
/// Value of the zone setting. | ||
/// </summary> | ||
[JsonProperty("editable")] | ||
public bool Editable { get; } | ||
|
||
/// <summary> | ||
/// last time this setting was modified. | ||
/// </summary> | ||
[JsonProperty("modified_on")] | ||
[JsonConverter(typeof(IsoDateTimeOffsetConverter))] | ||
public DateTimeOffset? ModifiedOn { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
namespace CloudFlare.NET | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
/// <inheritdoc/> | ||
public partial class CloudFlareClient : IZoneSettingsClient | ||
{ | ||
/// <inheritdoc/> | ||
public Task<IEnumerable<ZoneSettingBase>> GetAllZoneSettingsAsync( | ||
IdentifierTag zoneId, | ||
CancellationToken cancellationToken, | ||
CloudFlareAuth auth = null) | ||
{ | ||
return _client.GetAllZoneSettingsAsync(zoneId, cancellationToken, auth ?? _auth); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
namespace CloudFlare.NET | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
/// <summary> | ||
/// The CloudFlare Zone Settings API Client. | ||
/// </summary> | ||
/// <seealso href="https://api.cloudflare.com/#zone-settings"/> | ||
public interface IZoneSettingsClient | ||
{ | ||
/// <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"/> | ||
Task<IEnumerable<ZoneSettingBase>> GetAllZoneSettingsAsync( | ||
IdentifierTag zoneId, | ||
CancellationToken cancellationToken, | ||
CloudFlareAuth auth = null); | ||
} | ||
} |
Oops, something went wrong.