Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for Get All Settings for a Zone #20

Merged
merged 10 commits into from
Sep 7, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ build:
verbosity: minimal

before_build:
- nuget restore src\cloudflare.net.sln
- appveyor DownloadFile https://raw.githubusercontent.com/appveyor/ci/master/scripts/nuget-restore.cmd
- nuget-restore src\cloudflare.net.sln
- ps: gitversion /l console /output buildserver /updateAssemblyInfo

after_build:
Expand All @@ -78,6 +79,27 @@ after_test: |
%coveralls_exe% --opencover src\TestResults\Test.Coverage.xml
appveyor PushArtifact src\TestResults\Specifications.html -FileName "Specifications_%GitVersion_FullSemVer%.html"

#---------------------------------#
# deployment configuration #
#---------------------------------#

deploy:
# Deploy to NuGet when tags are applied to the master branch.
- provider: NuGet
api_key:
secure: YE/e/aOqNtjXWWk+IKzSl+HtDzrSE1tkaUPGQtzg6mA5chWEz53GJ9WNF/qdXgX1
on:
branch: master
appveyor_repo_tag: true

# Deploy to GitHub when tags are applied to the master branch.
- provider: GitHub
auth_token:
secure: HsYB0bln/Vj2trBco3Z3y9tG8sN8kguyXMogs9wSV65e0qRLl+BABxBxt3Q+CX9y
on:
branch: master
appveyor_repo_tag: true

#---------------------------------#
# global handlers #
#---------------------------------#
Expand All @@ -98,5 +120,5 @@ notifications:
auth_token:
secure: AkSNuuHmfzAFp2+Oq00NRQFOfrXl4ue08SHx0FC2WTeXSiZv8uVKI3ZBWns7HTcV
channel: cloudflare_net
on_build_success: false
on_build_status_changed: true

11 changes: 11 additions & 0 deletions src/CloudFlare.NET/CloudFlare.NET.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,24 @@
<Compile Include="PagedParametersOrderType.cs" />
<Compile Include="Serialization\IsoDateTimeOffsetConverter.cs" />
<Compile Include="Serialization\ToStringJsonConverter.cs" />
<Compile Include="SettingCacheLevelTypes.cs" />
<Compile Include="SettingOnOffTypes.cs" />
<Compile Include="SettingSecurityLevelTypes.cs" />
<Compile Include="SettingSslTypes.cs" />
<Compile Include="Zone.cs" />
<Compile Include="ZoneClient.Implementation.cs" />
<Compile Include="ZoneClient.Interface.cs" />
<Compile Include="ZoneClientExtensions.cs" />
<Compile Include="ZoneDevelopmentModeSetting.cs" />
<Compile Include="ZoneGetParameters.cs" />
<Compile Include="ZoneHttpClientExtensions.cs" />
<Compile Include="ZoneOrderTypes.cs" />
<Compile Include="ZoneSetting.cs" />
<Compile Include="ZoneSettingBase.cs" />
<Compile Include="ZoneSettingsClient.Implementation.cs" />
<Compile Include="ZoneSettingsClient.Interface.cs" />
<Compile Include="ZoneSettingsClientExtensions.cs" />
<Compile Include="ZoneSettingsHttpClientExtensions.cs" />
<Compile Include="ZoneStatusType.cs" />
<None Include="app.config" />
<None Include="CloudFlare.NET.nuspec" />
Expand Down
2 changes: 1 addition & 1 deletion src/CloudFlare.NET/DnsRecordClient.Interface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using System.Threading.Tasks;

/// <summary>
/// The CloudFlare DNS records for a zone API Client.
/// The CloudFlare DNS record API Client.
/// </summary>
/// <seealso href="https://api.cloudflare.com/#dns-records-for-a-zone"/>
public interface IDnsRecordClient
Expand Down
2 changes: 1 addition & 1 deletion src/CloudFlare.NET/DnsRecordHttpClientExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
public static class DnsRecordHttpClientExtensions
{
/// <summary>
/// Gets the zones for the account specified by the <paramref name="auth"/> details.
/// 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(
Expand Down
2 changes: 1 addition & 1 deletion src/CloudFlare.NET/HttpClientExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public static async Task<T> GetCloudFlareResultAsync<T>(
where T : class
{
CloudFlareResponse<T> cloudFlareResponse =
await client.GetCloudFlareResponseAsync<T>(uri, auth, cancellationToken);
await client.GetCloudFlareResponseAsync<T>(uri, auth, cancellationToken).ConfigureAwait(false);

return cloudFlareResponse.Result;
}
Expand Down
24 changes: 24 additions & 0 deletions src/CloudFlare.NET/SettingCacheLevelTypes.cs
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,
}
}
23 changes: 23 additions & 0 deletions src/CloudFlare.NET/SettingOnOffTypes.cs
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,
}
}
26 changes: 26 additions & 0 deletions src/CloudFlare.NET/SettingSecurityLevelTypes.cs
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,
}
}
25 changes: 25 additions & 0 deletions src/CloudFlare.NET/SettingSslTypes.cs
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,
}
}
2 changes: 1 addition & 1 deletion src/CloudFlare.NET/ZoneClient.Interface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using System.Threading.Tasks;

/// <summary>
/// The CloudFlare API Client.
/// The CloudFlare Zone API Client.
/// </summary>
/// <seealso href="https://api.cloudflare.com/#zone"/>
public interface IZoneClient
Expand Down
38 changes: 38 additions & 0 deletions src/CloudFlare.NET/ZoneDevelopmentModeSetting.cs
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; }
}
}
30 changes: 30 additions & 0 deletions src/CloudFlare.NET/ZoneSetting.cs
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; }
}
}
47 changes: 47 additions & 0 deletions src/CloudFlare.NET/ZoneSettingBase.cs
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; }
}
}
21 changes: 21 additions & 0 deletions src/CloudFlare.NET/ZoneSettingsClient.Implementation.cs
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);
}
}
}
24 changes: 24 additions & 0 deletions src/CloudFlare.NET/ZoneSettingsClient.Interface.cs
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);
}
}
Loading