diff --git a/Extensions/Cloudflare.Zones/Enums/OnOffCustomState.cs b/Extensions/Cloudflare.Zones/Enums/OnOffCustomState.cs new file mode 100644 index 0000000..92ebd52 --- /dev/null +++ b/Extensions/Cloudflare.Zones/Enums/OnOffCustomState.cs @@ -0,0 +1,31 @@ +using System.Runtime.Serialization; +using Newtonsoft.Json.Converters; + +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// Value states on/off/custom. + /// Source + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum OnOffCustomState + { + /// + /// On state. + /// + [EnumMember(Value = "on")] + On = 1, + + /// + /// Off state. + /// + [EnumMember(Value = "off")] + Off = 2, + + /// + /// Custom state. + /// + [EnumMember(Value = "custom")] + Custom = 3 + } +} diff --git a/Extensions/Cloudflare.Zones/Enums/OnOffOpenState.cs b/Extensions/Cloudflare.Zones/Enums/OnOffOpenState.cs new file mode 100644 index 0000000..888ac5f --- /dev/null +++ b/Extensions/Cloudflare.Zones/Enums/OnOffOpenState.cs @@ -0,0 +1,31 @@ +using System.Runtime.Serialization; +using Newtonsoft.Json.Converters; + +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// Value states on/off/open. + /// Source + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum OnOffOpenState + { + /// + /// On state. + /// + [EnumMember(Value = "on")] + On = 1, + + /// + /// Off state. + /// + [EnumMember(Value = "off")] + Off = 2, + + /// + /// Custom state. + /// + [EnumMember(Value = "open")] + Open = 4 + } +} diff --git a/Extensions/Cloudflare.Zones/Enums/OnOffState.cs b/Extensions/Cloudflare.Zones/Enums/OnOffState.cs new file mode 100644 index 0000000..c8a1e6e --- /dev/null +++ b/Extensions/Cloudflare.Zones/Enums/OnOffState.cs @@ -0,0 +1,25 @@ +using System.Runtime.Serialization; +using Newtonsoft.Json.Converters; + +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// Value states on/off. + /// Source + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum OnOffState + { + /// + /// On state. + /// + [EnumMember(Value = "on")] + On = 1, + + /// + /// Off state. + /// + [EnumMember(Value = "off")] + Off = 2 + } +} diff --git a/Extensions/Cloudflare.Zones/Enums/ZoneSettingId.cs b/Extensions/Cloudflare.Zones/Enums/ZoneSettingId.cs new file mode 100644 index 0000000..3064216 --- /dev/null +++ b/Extensions/Cloudflare.Zones/Enums/ZoneSettingId.cs @@ -0,0 +1,352 @@ +using System.Runtime.Serialization; +using Newtonsoft.Json.Converters; + +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// The zone setting ID. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum ZoneSettingId + { + /// + /// Advanced protection from Distributed Denial of Service (DDoS) attacks on your + /// website. + /// + [EnumMember(Value = "advanced_ddos")] + AdvancedDDoS = 1, + + /// + /// Aegis provides dedicated egress IPs (from Cloudflare to your origin) for your + /// layer 7 WAF and CDN services. + /// + [EnumMember(Value = "aegis")] + Aegis = 2, + + /// + /// When enabled, Cloudflare serves limited copies of web pages available from the + /// Internet Archive's Wayback Machine if your server is offline. + /// + [EnumMember(Value = "always_online")] + AlwaysOnline = 3, + + /// + /// If enabled, any http:// URL is converted to https:// through a 301 + /// redirect. + /// + [EnumMember(Value = "always_use_https")] + AlwaysUseHTTPS = 4, + + /// + /// Turn on or off Automatic HTTPS Rewrites. + /// + [EnumMember(Value = "automatic_https_rewrites")] + AutomaticHTTPSRewrites = 5, + + /// + /// Brotli Compression. + /// + [EnumMember(Value = "brotli")] + Brotli = 6, + + /// + /// Control how long resources cached by client browsers remain valid. + /// + [EnumMember(Value = "browser_cache_ttl")] + BrowserCacheTTL = 7, + + /// + /// Inspect the visitor's browser for headers commonly associated with spammers and + /// certain bots. + /// + [EnumMember(Value = "browser_check")] + BrowserCheck = 8, + + /// + /// Apply custom caching based on the option selected. + /// + [EnumMember(Value = "cache_level")] + CacheLevel = 9, + + /// + /// Specify how long a visitor is allowed access to your site after successfully completing a challenge. + /// + [EnumMember(Value = "challenge_ttl")] + ChallengeTTL = 10, + + /// + /// An allowlist of ciphers for TLS termination. + /// + [EnumMember(Value = "ciphers")] + Ciphers = 11, + + /// + /// Development Mode temporarily allows you to enter development mode for your + /// websites if you need to make changes to your site. + /// + [EnumMember(Value = "development_mode")] + DevelopmentMode = 12, + + /// + /// When enabled, Cloudflare will attempt to speed up overall page loads. + /// + [EnumMember(Value = "early_hints")] + EarlyHints = 13, + + /// + /// Email obfuscation. + /// + [EnumMember(Value = "email_obfuscation")] + EmailObfuscation = 14, + + /// + /// Enhance your website's font delivery with Cloudflare Fonts. + /// + [EnumMember(Value = "fonts")] + FontSettings = 15, + + /// + /// HTTP/2 Edge Prioritization optimises the delivery of resources served through + /// HTTP/2 to improve page load performance. + /// + [EnumMember(Value = "h2_prioritization")] + H2Prioritization = 16, + + /// + /// Hotlink Protection option ensures that other sites cannot suck + /// up your bandwidth by building pages that use images hosted on your site. + /// + [EnumMember(Value = "hotlink_protection")] + HotlinkProtection = 17, + + /// + /// HTTP/2 option. + /// + [EnumMember(Value = "http2")] + HTTP2 = 18, + + /// + /// HTTP/3 option. + /// + [EnumMember(Value = "http3")] + HTTP3 = 19, + + /// + /// Image Transformations provides on-demand resizing, conversion and optimization. + /// + [EnumMember(Value = "image_resizing")] + ImageResizing = 20, + + /// + /// Cloudflare adds a header with the visitor's country. + /// + [EnumMember(Value = "ip_geolocation")] + IPGeolocation = 21, + + /// + /// Enable IPv6 on all subdomains that are Cloudflare enabled. + /// + [EnumMember(Value = "ipv6")] + IPV6 = 22, + + /// + /// Only accepts HTTPS requests that use at least the TLS protocol version specified. + /// + [EnumMember(Value = "min_tls_version")] + MinTLSVersion = 23, + + /// + /// Cloudflare Mirage reduces bandwidth used by images in mobile browsers. + /// + [EnumMember(Value = "mirage")] + Mirage = 24, + + /// + /// Network Error Logging. + /// + [EnumMember(Value = "nel")] + NEL = 25, + + /// + /// Opportunistic Encryption allows browsers to access HTTP URIs over an encrypted TLS channel. + /// + [EnumMember(Value = "opportunistic_encryption")] + OpportunisticEncryption = 26, + + /// + /// Add an Alt-Svc header to all legitimate requests from Tor. + /// + [EnumMember(Value = "opportunistic_onion")] + OpportunisticOnion = 27, + + /// + /// Orange to Orange option. + /// + [EnumMember(Value = "orange_to_orange")] + OrangeToOrange = 28, + + /// + /// Cloudflare error pages generated from issues sent from the origin server. + /// + [EnumMember(Value = "origin_error_page_pass_thru")] + OriginErrorPagePassThru = 29, + + /// + /// Only accepts HTTP requests that use at least the HTTP protocol version specified. + /// + [EnumMember(Value = "origin_max_http_version")] + OriginMaxHTTPVersion = 30, + + /// + /// Polish feature of the Cloudflare Speed app. + /// + [EnumMember(Value = "polish")] + Polish = 31, + + /// + /// Cloudflare will prefetch any URLs that are included in the response headers. + /// + [EnumMember(Value = "prefetch_preload")] + PrefetchPreload = 32, + + /// + /// Proxy Read Timeout. + /// + [EnumMember(Value = "proxy_read_timeout")] + ProxyReadTimeout = 33, + + /// + /// Pseudo IPv4. + /// + [EnumMember(Value = "pseudo_ipv4")] + PseudoIPV4 = 34, + + /// + /// Turn on or off whether Cloudflare should wait for an entire file from the origin. + /// + [EnumMember(Value = "response_buffering")] + ResponseBuffering = 35, + + /// + /// Rocket Loader in the Cloudflare Speed app. + /// + [EnumMember(Value = "rocket_loader")] + RocketLoader = 36, + + /// + /// Security Headers. + /// + [EnumMember(Value = "security_header")] + SecurityHeaders = 37, + + /// + /// Security Level feature from the Security app. + /// + [EnumMember(Value = "security_level")] + SecurityLevel = 38, + + /// + /// Server-Side Excludes. + /// + [EnumMember(Value = "server_side_excludes")] + ServerSideExcludes = 39, + + /// + /// Sort Query String for Cache. + /// + [EnumMember(Value = "sort_query_string_for_cache")] + SortQueryStringForCache = 40, + + /// + /// SSL. + /// + [EnumMember(Value = "ssl")] + SSL = 41, + + /// + /// Enrollment value for SSL/TLS Recommender. + /// + [EnumMember(Value = "ssl_recommender")] + SSLRecommender = 42, + + /// + /// TLS 1.3. + /// + [EnumMember(Value = "tls_1_3")] + TLS1_3 = 43, + + /// + /// TLS Client Authentication. + /// + [EnumMember(Value = "tls_client_auth")] + TLSClientAuth = 44, + + /// + /// True Client IP Header. + /// + [EnumMember(Value = "true_client_ip_header")] + TrueClientIPHeader = 45, + + /// + /// Web Application Firewall. + /// + [EnumMember(Value = "waf")] + WAF = 46, + + /// + /// Cloudflare will serve a WebP version of the original image. + /// + [EnumMember(Value = "webp")] + WebP = 47, + + /// + /// WebSockets settings. + /// + [EnumMember(Value = "websockets")] + Websocket = 48, + + /// + /// 0-RTT + /// + [EnumMember(Value = "0rtt")] + ZeroRTT = 49, + + /// + /// Edge Cache TTL. + /// + [EnumMember(Value = "edge_cache_ttl")] + SchemasEdgeCacheTTL = 501, + + /// + /// Maximum size of an allowable upload. + /// + [EnumMember(Value = "max_upload")] + MaxUpload = 502, + + /// + /// Replace insecure JS. + /// + [EnumMember(Value = "replace_insecure_js")] + ReplaceInsecureJS = 503, + + /// + /// Only allows TLS1.2. + /// + [EnumMember(Value = "tls_1_2_only")] + TLS1_2Only = 504, + + /// + /// How to flatten the cname destination. + /// + [Obsolete("Please use the DNS Settings route instead.")] + [EnumMember(Value = "cname_flattening")] + CNAMEFlattening = 901, + + /// + /// Privacy Pass. + /// + [Obsolete("Privacy Pass v1 was deprecated in 2023.")] + [EnumMember(Value = "privacy_pass")] + PrivacyPass = 902, + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/AdvancedDDoS.cs b/Extensions/Cloudflare.Zones/Models/Settings/AdvancedDDoS.cs new file mode 100644 index 0000000..604b94b --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/AdvancedDDoS.cs @@ -0,0 +1,24 @@ +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// Advanced protection from Distributed Denial of Service (DDoS) attacks on your + /// website. This is an uneditable value that is in the + /// case of Business and Enterprise zones. + /// + public class AdvancedDDoS : ZoneSettingBase + { + /// + /// Initializes a new instance of the class. + /// + public AdvancedDDoS() + { + Id = ZoneSettingId.AdvancedDDoS; + } + + /// + /// Current value of the zone setting. + /// + [JsonProperty("value")] + public OnOffState Value { get; set; } + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/Aegis.cs b/Extensions/Cloudflare.Zones/Models/Settings/Aegis.cs new file mode 100644 index 0000000..a8fc417 --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/Aegis.cs @@ -0,0 +1,44 @@ +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// Aegis provides dedicated egress IPs (from Cloudflare to your origin) for your + /// layer 7 WAF and CDN services. The egress IPs are reserved exclusively for your + /// account so that you can increase your origin security by only allowing traffic + /// from a small list of IP addresses. + /// + public class Aegis : ZoneSettingBase + { + /// + /// Initializes a new instance of the class. + /// + public Aegis() + { + Id = ZoneSettingId.Aegis; + } + + /// + /// Current value of the zone setting. + /// + [JsonProperty("value")] + public AegisValue? Value { get; set; } + } + + /// + /// Value of the zone setting. + /// + public class AegisValue + { + /// + /// Whether the feature is enabled or not. + /// + [JsonProperty("enabled")] + public bool? Enabled { get; set; } + + /// + /// Egress pool id which refers to a grouping of dedicated egress IPs through which + /// Cloudflare will connect to origin. + /// + [JsonProperty("pool_id")] + public string? PoolId { get; set; } + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/AlwaysOnline.cs b/Extensions/Cloudflare.Zones/Models/Settings/AlwaysOnline.cs new file mode 100644 index 0000000..7c94759 --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/AlwaysOnline.cs @@ -0,0 +1,26 @@ +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// When enabled, Cloudflare serves limited copies of web pages available from the + /// Internet Archive's Wayback Machine + /// if your server is offline. + /// Refer to Always Online + /// for more information. + /// + public class AlwaysOnline : ZoneSettingBase + { + /// + /// Initializes a new instance of the class. + /// + public AlwaysOnline() + { + Id = ZoneSettingId.AlwaysOnline; + } + + /// + /// Current value of the zone setting. + /// + [JsonProperty("value")] + public OnOffState Value { get; set; } + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/AlwaysUseHTTPS.cs b/Extensions/Cloudflare.Zones/Models/Settings/AlwaysUseHTTPS.cs new file mode 100644 index 0000000..c4ded11 --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/AlwaysUseHTTPS.cs @@ -0,0 +1,23 @@ +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// If enabled, any http:// URL is converted to https:// through a 301 + /// redirect. + /// + public class AlwaysUseHTTPS : ZoneSettingBase + { + /// + /// Initializes a new instance of the class. + /// + public AlwaysUseHTTPS() + { + Id = ZoneSettingId.AlwaysUseHTTPS; + } + + /// + /// Current value of the zone setting. + /// + [JsonProperty("value")] + public OnOffState? Value { get; set; } + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/AutomaticHTTPSRewrites.cs b/Extensions/Cloudflare.Zones/Models/Settings/AutomaticHTTPSRewrites.cs new file mode 100644 index 0000000..f15e2df --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/AutomaticHTTPSRewrites.cs @@ -0,0 +1,22 @@ +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// Turn on or off Automatic HTTPS Rewrites. + /// + public class AutomaticHTTPSRewrites : ZoneSettingBase + { + /// + /// Initializes a new instance of the class. + /// + public AutomaticHTTPSRewrites() + { + Id = ZoneSettingId.AutomaticHTTPSRewrites; + } + + /// + /// Current value of the zone setting. + /// + [JsonProperty("value")] + public OnOffState Value { get; set; } + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/AutomaticPlatformOptimization.cs b/Extensions/Cloudflare.Zones/Models/Settings/AutomaticPlatformOptimization.cs new file mode 100644 index 0000000..a26bcab --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/AutomaticPlatformOptimization.cs @@ -0,0 +1,48 @@ +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// Apply custom caching based on the option selected. + /// + public class AutomaticPlatformOptimization + { + /// + /// Indicates whether or not + /// cache by device type + /// is enabled. + /// + [JsonProperty("cache_by_device_type")] + public bool? CacheByDeviceType { get; set; } + + /// + /// Indicates whether or not Cloudflare proxy is enabled. + /// + [JsonProperty("cf")] + public bool? CloudflareProxyEnabled { get; set; } + + /// + /// Indicates whether or not Automatic Platform Optimization is enabled. + /// + [JsonProperty("enabled")] + public bool? Enabled { get; set; } + + /// + /// An array of hostnames where Automatic Platform Optimization for WordPress is activated. + /// + [JsonProperty("hostnames")] + public IReadOnlyCollection? Hostnames { get; set; } + + /// + /// Indicates whether or not site is powered by WordPress. + /// + [JsonProperty("wordpress")] + public bool? WordPress { get; set; } + + /// + /// Indicates whether or not + /// Cloudflare for WordPress plugin + /// is installed. + /// + [JsonProperty("wp_plugin")] + public bool? WpPlugin { get; set; } + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/Brotli.cs b/Extensions/Cloudflare.Zones/Models/Settings/Brotli.cs new file mode 100644 index 0000000..ca9cef7 --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/Brotli.cs @@ -0,0 +1,23 @@ +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// When the client requesting an asset supports the Brotli compression algorithm, + /// Cloudflare will serve a Brotli compressed version of the asset. + /// + public class Brotli : ZoneSettingBase + { + /// + /// Initializes a new instance of the class. + /// + public Brotli() + { + Id = ZoneSettingId.Brotli; + } + + /// + /// Current value of the zone setting. + /// + [JsonProperty("value")] + public OnOffState Value { get; set; } + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/BrowserCacheTTL.cs b/Extensions/Cloudflare.Zones/Models/Settings/BrowserCacheTTL.cs new file mode 100644 index 0000000..7de3230 --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/BrowserCacheTTL.cs @@ -0,0 +1,23 @@ +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// Control how long resources cached by client browsers remain valid. + /// + public class BrowserCacheTTL : ZoneSettingBase + { + /// + /// Initializes a new instance of the class. + /// + public BrowserCacheTTL() + { + Id = ZoneSettingId.BrowserCacheTTL; + } + + /// + /// The number of seconds to cache resources for. + /// The API prohibits setting this to 0 for non-Enterprise domains. + /// + [JsonProperty("value")] + public int? Value { get; set; } + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/BrowserCheck.cs b/Extensions/Cloudflare.Zones/Models/Settings/BrowserCheck.cs new file mode 100644 index 0000000..ba66bc9 --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/BrowserCheck.cs @@ -0,0 +1,23 @@ +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// Inspect the visitor's browser for headers commonly associated with spammers and + /// certain bots. + /// + public class BrowserCheck : ZoneSettingBase + { + /// + /// Initializes a new instance of the class. + /// + public BrowserCheck() + { + Id = ZoneSettingId.BrowserCheck; + } + + /// + /// The status of Browser Integrity Check. + /// + [JsonProperty("value")] + public OnOffState? Value { get; set; } + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/CNAMEFlattening.cs b/Extensions/Cloudflare.Zones/Models/Settings/CNAMEFlattening.cs new file mode 100644 index 0000000..201e7d9 --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/CNAMEFlattening.cs @@ -0,0 +1,24 @@ +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// How to flatten the cname destination. + /// + [Obsolete("Please use the DNS Settings route instead.")] + public class CNAMEFlattening : ZoneSettingBase + { + /// + /// Initializes a new instance of the class. + /// + public CNAMEFlattening() + { + Id = ZoneSettingId.CNAMEFlattening; + } + + /// + /// Current value of the zone setting. + /// + [Obsolete("Please use the DNS Settings route instead.")] + [JsonProperty("value")] + public string? Value { get; set; } + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/CacheLevel.cs b/Extensions/Cloudflare.Zones/Models/Settings/CacheLevel.cs new file mode 100644 index 0000000..351a0a5 --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/CacheLevel.cs @@ -0,0 +1,64 @@ +using System.Runtime.Serialization; +using Newtonsoft.Json.Converters; + +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// Apply custom caching based on the option selected. + /// + public class CacheLevel : ZoneSettingBase + { + /// + /// Initializes a new instance of the class. + /// + public CacheLevel() + { + Id = ZoneSettingId.CacheLevel; + } + + /// + /// Current value of the zone setting. + /// + [JsonProperty("value")] + public CacheLevelOption? Value { get; set; } + } + + /// + /// Apply custom caching based on the option selected. + /// Source + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum CacheLevelOption + { + /// + /// Cloudflare does not cache. + /// + [EnumMember(Value = "bypass")] + Bypass = 1, + + /// + /// Delivers resources from cache when there is no query string. + /// + [EnumMember(Value = "basic")] + Basic = 2, + + /// + /// Delivers the same resource to everyone independent of the query string. + /// + [EnumMember(Value = "simplified")] + Simplified = 3, + + /// + /// Caches all static content that has a query string. + /// + [EnumMember(Value = "aggressive")] + Aggressive = 4, + + /// + /// Treats all content as static and caches all file types beyond the + /// Cloudflare default cached content + /// + [EnumMember(Value = "cache_everything")] + CacheEverything = 5 + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/ChallengeTTL.cs b/Extensions/Cloudflare.Zones/Models/Settings/ChallengeTTL.cs new file mode 100644 index 0000000..79277ea --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/ChallengeTTL.cs @@ -0,0 +1,103 @@ +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// Specify how long a visitor is allowed access to your site after successfully + /// completing a challenge (such as a CAPTCHA). After the TTL has expired the + /// visitor will have to complete a new challenge. We recommend a 15 - 45 minute + /// setting and will attempt to honor any setting above 45 minutes. + /// (). + /// + public class ChallengeTTL : ZoneSettingBase + { + /// + /// Initializes a new instance of the class. + /// + public ChallengeTTL() + { + Id = ZoneSettingId.ChallengeTTL; + } + + /// + /// Current value of the zone setting. + /// + [JsonProperty("value")] + public ChallengeTTLValue Value { get; set; } + } + + /// + /// The time-to-live (TTL) of the challenge. + /// Soruce + /// + public enum ChallengeTTLValue : int + { + /// + /// 5 minutes. + /// + FiveMinutes = 300, + + /// + /// 15 minutes. + /// + FifteenMinutes = 900, + + /// + /// 30 minutes. + /// + HalfHour = 1800, + + /// + /// 45 minutes. + /// + ThreeQuartersHour = 2700, + + /// + /// 1 hour. + /// + Hour = 3600, + + /// + /// 2 hours. + /// + TwoHours = 7200, + + /// + /// 3 hours. + /// + ThreeHours = 10800, + + /// + /// 4 hours. + /// + FourHours = 14400, + + /// + /// 8 hours. + /// + EightHours = 28800, + + /// + /// 16 hours. + /// + SixteenHours = 57600, + + /// + /// 1 day. + /// + Day = 86400, + + /// + /// 1 week. + /// + Week = 604800, + + /// + /// 30 days. + /// + Month = 2592000, + + /// + /// 365 days. + /// + Year = 31536000 + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/Ciphers.cs b/Extensions/Cloudflare.Zones/Models/Settings/Ciphers.cs new file mode 100644 index 0000000..b449108 --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/Ciphers.cs @@ -0,0 +1,23 @@ +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// An allowlist of ciphers for TLS termination. These ciphers must be in the + /// BoringSSL format. + /// + public class Ciphers : ZoneSettingBase + { + /// + /// Initializes a new instance of the class. + /// + public Ciphers() + { + Id = ZoneSettingId.Ciphers; + } + + /// + /// Current value of the zone setting. + /// + [JsonProperty("value")] + public IReadOnlyCollection Value { get; set; } = []; + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/DevelopmentMode.cs b/Extensions/Cloudflare.Zones/Models/Settings/DevelopmentMode.cs new file mode 100644 index 0000000..3da86a0 --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/DevelopmentMode.cs @@ -0,0 +1,35 @@ +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// 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. + /// + public class DevelopmentMode : ZoneSettingBase + { + /// + /// Initializes a new instance of the class. + /// + public DevelopmentMode() + { + Id = ZoneSettingId.DevelopmentMode; + } + + /// + /// Current state of the zone setting. + /// + [JsonProperty("value")] + public OnOffState Value { get; set; } + + /// + /// 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 zero. + /// + [JsonProperty("time_remaining")] + public int? TimeRemaining { get; set; } + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/EarlyHints.cs b/Extensions/Cloudflare.Zones/Models/Settings/EarlyHints.cs new file mode 100644 index 0000000..d0caa65 --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/EarlyHints.cs @@ -0,0 +1,25 @@ +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// When enabled, Cloudflare will attempt to speed up overall page loads by serving + /// 103 responses with Link headers from the final response. Refer to + /// Early Hints + /// for more information. + /// + public class EarlyHints : ZoneSettingBase + { + /// + /// Initializes a new instance of the class. + /// + public EarlyHints() + { + Id = ZoneSettingId.EarlyHints; + } + + /// + /// Current value of the zone setting. + /// + [JsonProperty("value")] + public OnOffState Value { get; set; } + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/EmailObfuscation.cs b/Extensions/Cloudflare.Zones/Models/Settings/EmailObfuscation.cs new file mode 100644 index 0000000..c81a6d9 --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/EmailObfuscation.cs @@ -0,0 +1,22 @@ +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// Turn on or off Email Obfuscation. + /// + public class EmailObfuscation : ZoneSettingBase + { + /// + /// Initializes a new instance of the class. + /// + public EmailObfuscation() + { + Id = ZoneSettingId.EmailObfuscation; + } + + /// + /// Current value of the zone setting. + /// + [JsonProperty("value")] + public OnOffState? Value { get; set; } + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/FontSettings.cs b/Extensions/Cloudflare.Zones/Models/Settings/FontSettings.cs new file mode 100644 index 0000000..93b7975 --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/FontSettings.cs @@ -0,0 +1,24 @@ +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// Enhance your website's font delivery with Cloudflare Fonts. Deliver Google + /// Hosted fonts from your own domain, boost performance, and enhance user privacy. + /// Refer to the Cloudflare Fonts documentation for more information. + /// + public class FontSettings : ZoneSettingBase + { + /// + /// Initializes a new instance of the class. + /// + public FontSettings() + { + Id = ZoneSettingId.FontSettings; + } + + /// + /// Current value of the zone setting. + /// + [JsonProperty("value")] + public OnOffState? Value { get; set; } + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/H2Prioritization.cs b/Extensions/Cloudflare.Zones/Models/Settings/H2Prioritization.cs new file mode 100644 index 0000000..c242163 --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/H2Prioritization.cs @@ -0,0 +1,24 @@ +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// HTTP/2 Edge Prioritization optimises the delivery of resources served through + /// HTTP/2 to improve page load performance.It also supports fine control of + /// content delivery when used in conjunction with Workers. + /// + public class H2Prioritization : ZoneSettingBase + { + /// + /// Initializes a new instance of the class. + /// + public H2Prioritization() + { + Id = ZoneSettingId.H2Prioritization; + } + + /// + /// Current value of the zone setting. + /// + [JsonProperty("value")] + public OnOffCustomState Value { get; set; } + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/HTTP2.cs b/Extensions/Cloudflare.Zones/Models/Settings/HTTP2.cs new file mode 100644 index 0000000..c0a95e3 --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/HTTP2.cs @@ -0,0 +1,22 @@ +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// HTTP/2 enabled for this zone. + /// + public class HTTP2 : ZoneSettingBase + { + /// + /// Initializes a new instance of the class. + /// + public HTTP2() + { + Id = ZoneSettingId.HTTP2; + } + + /// + /// Current value of the zone setting. + /// + [JsonProperty("value")] + public OnOffState Value { get; set; } + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/HTTP3.cs b/Extensions/Cloudflare.Zones/Models/Settings/HTTP3.cs new file mode 100644 index 0000000..1c02d20 --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/HTTP3.cs @@ -0,0 +1,22 @@ +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// HTTP/3 enabled for this zone. + /// + public class HTTP3 : ZoneSettingBase + { + /// + /// Initializes a new instance of the class. + /// + public HTTP3() + { + Id = ZoneSettingId.HTTP3; + } + + /// + /// Current value of the zone setting. + /// + [JsonProperty("value")] + public OnOffState Value { get; set; } + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/HotlinkProtection.cs b/Extensions/Cloudflare.Zones/Models/Settings/HotlinkProtection.cs new file mode 100644 index 0000000..7416f3b --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/HotlinkProtection.cs @@ -0,0 +1,28 @@ +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// When enabled, the Hotlink Protection option ensures that other sites cannot suck + /// up your bandwidth by building pages that use images hosted on your site.Anytime + /// a request for an image on your site hits Cloudflare, we check to ensure that + /// it's not another site requesting them. People will still be able to download and + /// view images from your page, but other sites won't be able to steal them for use + /// on their own pages. + /// (). + /// + public class HotlinkProtection : ZoneSettingBase + { + /// + /// Initializes a new instance of the class. + /// + public HotlinkProtection() + { + Id = ZoneSettingId.HotlinkProtection; + } + + /// + /// Current value of the zone setting. + /// + [JsonProperty("value")] + public OnOffState Value { get; set; } + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/IPGeolocation.cs b/Extensions/Cloudflare.Zones/Models/Settings/IPGeolocation.cs new file mode 100644 index 0000000..24f6091 --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/IPGeolocation.cs @@ -0,0 +1,23 @@ +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// Cloudflare adds a CF-IPCountry HTTP header containing the country code that + /// corresponds to the visitor. + /// + public class IPGeolocation : ZoneSettingBase + { + /// + /// Initializes a new instance of the class. + /// + public IPGeolocation() + { + Id = ZoneSettingId.IPGeolocation; + } + + /// + /// The status of adding the IP Geolocation Header. + /// + [JsonProperty("value")] + public OnOffState? Value { get; set; } + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/IPV6.cs b/Extensions/Cloudflare.Zones/Models/Settings/IPV6.cs new file mode 100644 index 0000000..dacef44 --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/IPV6.cs @@ -0,0 +1,23 @@ +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// Enable IPv6 on all subdomains that are Cloudflare enabled. + /// (). + /// + public class IPV6 : ZoneSettingBase + { + /// + /// Initializes a new instance of the class. + /// + public IPV6() + { + Id = ZoneSettingId.IPV6; + } + + /// + /// Current value of the zone setting. + /// + [JsonProperty("value")] + public OnOffState Value { get; set; } + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/ImageResizing.cs b/Extensions/Cloudflare.Zones/Models/Settings/ImageResizing.cs new file mode 100644 index 0000000..c472ad7 --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/ImageResizing.cs @@ -0,0 +1,25 @@ +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// Image Transformations provides on-demand resizing, conversion and optimization + /// for images served through Cloudflare's network. Refer to the + /// Image Transformations documentation + /// for more information. + /// + public class ImageResizing : ZoneSettingBase + { + /// + /// Initializes a new instance of the class. + /// + public ImageResizing() + { + Id = ZoneSettingId.ImageResizing; + } + + /// + /// Current value of the zone setting. + /// + [JsonProperty("value")] + public OnOffOpenState Value { get; set; } + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/MaxUpload.cs b/Extensions/Cloudflare.Zones/Models/Settings/MaxUpload.cs new file mode 100644 index 0000000..c8e5a1c --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/MaxUpload.cs @@ -0,0 +1,119 @@ +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// Maximum size of an allowable upload. + /// + public class MaxUpload : ZoneSettingBase + { + /// + /// Initialize a new instance of the class. + /// + public MaxUpload() + { + Id = ZoneSettingId.MaxUpload; + } + + /// + /// Current value of the zone setting. + /// + [JsonProperty("value")] + public MaxUploadSize Value { get; set; } + } + + /// + /// Maximum size of an allowable upload. + /// Soruce + /// + public enum MaxUploadSize : int + { + /// + /// 100 MB. + /// + M100 = 100, + + /// + /// 125 MB. + /// + M125 = 125, + + /// + /// 150 MB. + /// + M150 = 150, + + /// + /// 175 MB. + /// + M175 = 175, + + /// + /// 200 MB. + /// + M200 = 200, + + /// + /// 225 MB. + /// + M225 = 225, + + /// + /// 250 MB. + /// + M250 = 250, + + /// + /// 275 MB. + /// + M275 = 275, + + /// + /// 300 MB. + /// + M300 = 300, + + /// + /// 325 MB. + /// + M325 = 325, + + /// + /// 350 MB. + /// + M350 = 350, + + /// + /// 375 MB. + /// + M375 = 375, + + /// + /// 400 MB. + /// + M400 = 400, + + /// + /// 425 MB. + /// + M425 = 425, + + /// + /// 450 MB. + /// + M450 = 450, + + /// + /// 475 MB. + /// + M475 = 475, + + /// + /// 500 MB. + /// + M500 = 500, + + /// + /// 1000 MB (1 GB). + /// + G1 = 1000 + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/MinTLSVersion.cs b/Extensions/Cloudflare.Zones/Models/Settings/MinTLSVersion.cs new file mode 100644 index 0000000..830f8a5 --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/MinTLSVersion.cs @@ -0,0 +1,58 @@ +using System.Runtime.Serialization; +using Newtonsoft.Json.Converters; + +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// Only accepts HTTPS requests that use at least the TLS protocol version + /// specified. For example, if TLS 1.1 is selected, TLS 1.0 connections will be + /// rejected, while 1.1, 1.2, and 1.3 (if enabled) will be permitted. + /// + public class MinTLSVersion : ZoneSettingBase + { + /// + /// Initializes a new instance of the class. + /// + public MinTLSVersion() + { + Id = ZoneSettingId.MinTLSVersion; + } + + /// + /// Current value of the zone setting. + /// + public TlsVersion? Value { get; set; } + } + + /// + /// Available TLS versions. + /// Source + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum TlsVersion + { + /// + /// TLS 1.0 + /// + [EnumMember(Value = "1.0")] + Tls10 = 1, + + /// + /// TLS 1.1 + /// + [EnumMember(Value = "1.1")] + Tls11 = 2, + + /// + /// TLS 1.2 + /// + [EnumMember(Value = "1.2")] + Tls12 = 3, + + /// + /// TLS 1.3 + /// + [EnumMember(Value = "1.3")] + Tls13 = 4 + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/Mirage.cs b/Extensions/Cloudflare.Zones/Models/Settings/Mirage.cs new file mode 100644 index 0000000..aa64117 --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/Mirage.cs @@ -0,0 +1,24 @@ +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// Cloudflare Mirage reduces bandwidth used by images in mobile browsers. It can + /// accelerate loading of image-heavy websites on very slow mobile connections and + /// HTTP/1. + /// + public class Mirage : ZoneSettingBase + { + /// + /// Initializes a new instance of the class. + /// + public Mirage() + { + Id = ZoneSettingId.Mirage; + } + + /// + /// The status of Mirage. + /// + [JsonProperty("value")] + public OnOffState? Value { get; set; } + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/NEL.cs b/Extensions/Cloudflare.Zones/Models/Settings/NEL.cs new file mode 100644 index 0000000..1796657 --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/NEL.cs @@ -0,0 +1,34 @@ +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// Enable Network Error Logging reporting on your zone. (Beta) + /// + public class NEL : ZoneSettingBase + { + /// + /// Initializes a new instance of the class. + /// + public NEL() + { + Id = ZoneSettingId.NEL; + } + + /// + /// Current value of the zone setting. + /// + [JsonProperty("value")] + public NELValue? Value { get; set; } + } + + /// + /// Current value of the zone setting. + /// + public class NELValue + { + /// + /// Current value of the zone setting. + /// + [JsonProperty("enabled")] + public bool? Enabled { get; set; } + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/OpportunisticEncryption.cs b/Extensions/Cloudflare.Zones/Models/Settings/OpportunisticEncryption.cs new file mode 100644 index 0000000..2409a5c --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/OpportunisticEncryption.cs @@ -0,0 +1,24 @@ +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// Opportunistic Encryption allows browsers to access HTTP URIs over an encrypted + /// TLS channel. It's not a substitute for HTTPS, but provides additional security + /// for otherwise vulnerable requests. + /// + public class OpportunisticEncryption : ZoneSettingBase + { + /// + /// Initializes a new instance of the class. + /// + public OpportunisticEncryption() + { + Id = ZoneSettingId.OpportunisticEncryption; + } + + /// + /// The status of Opportunistic Encryption. + /// + [JsonProperty("value")] + public OnOffState? Value { get; set; } + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/OpportunisticOnion.cs b/Extensions/Cloudflare.Zones/Models/Settings/OpportunisticOnion.cs new file mode 100644 index 0000000..3cff09a --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/OpportunisticOnion.cs @@ -0,0 +1,23 @@ +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// Add an Alt-Svc header to all legitimate requests from Tor, allowing the + /// connection to use our onion services instead of exit nodes. + /// + public class OpportunisticOnion : ZoneSettingBase + { + /// + /// Initializes a new instance of the class. + /// + public OpportunisticOnion() + { + Id = ZoneSettingId.OpportunisticOnion; + } + + /// + /// Current value of the zone setting. + /// + [JsonProperty("value")] + public OnOffState? Value { get; set; } + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/OrangeToOrange.cs b/Extensions/Cloudflare.Zones/Models/Settings/OrangeToOrange.cs new file mode 100644 index 0000000..7bd06d1 --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/OrangeToOrange.cs @@ -0,0 +1,23 @@ +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// Orange to Orange (O2O) allows zones on Cloudflare to CNAME to other zones also + /// on Cloudflare. + /// + public class OrangeToOrange : ZoneSettingBase + { + /// + /// Initializes a new instance of the class. + /// + public OrangeToOrange() + { + Id = ZoneSettingId.OrangeToOrange; + } + + /// + /// Current value of the zone setting. + /// + [JsonProperty("value")] + public OnOffState Value { get; set; } + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/OriginErrorPagePassThru.cs b/Extensions/Cloudflare.Zones/Models/Settings/OriginErrorPagePassThru.cs new file mode 100644 index 0000000..e9dc2c2 --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/OriginErrorPagePassThru.cs @@ -0,0 +1,23 @@ +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// Turn on or off Cloudflare error pages generated from issues sent from the origin + /// server. If enabled, this setting triggers error pages issued by the origin. + /// + public class OriginErrorPagePassThru : ZoneSettingBase + { + /// + /// Initializes a new instance of the class. + /// + public OriginErrorPagePassThru() + { + Id = ZoneSettingId.OriginErrorPagePassThru; + } + + /// + /// The status of Origin Error Page Passthru. + /// + [JsonProperty("value")] + public OnOffState? Value { get; set; } + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/OriginMaxHTTPVersion.cs b/Extensions/Cloudflare.Zones/Models/Settings/OriginMaxHTTPVersion.cs new file mode 100644 index 0000000..1ec2c56 --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/OriginMaxHTTPVersion.cs @@ -0,0 +1,45 @@ +using System.Runtime.Serialization; +using Newtonsoft.Json.Converters; + +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// The maximum HTTP version supported by the origin server. + /// + public class OriginMaxHTTPVersion : ZoneSettingBase + { + /// + /// Initializes a new instance of the class. + /// + public OriginMaxHTTPVersion() + { + Id = ZoneSettingId.OriginMaxHTTPVersion; + } + + /// + /// The value of the feature. + /// + [JsonProperty("value")] + public HttpVersion Value { get; set; } + } + + /// + /// HTTP versions. + /// Source + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum HttpVersion + { + /// + /// HTTP/1 + /// + [EnumMember(Value = "1")] + HTTP1 = 1, + + /// + /// HTTP/2 + /// + [EnumMember(Value = "2")] + HTTP2 = 2 + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/Polish.cs b/Extensions/Cloudflare.Zones/Models/Settings/Polish.cs new file mode 100644 index 0000000..ef9d874 --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/Polish.cs @@ -0,0 +1,51 @@ +using System.Runtime.Serialization; +using Newtonsoft.Json.Converters; + +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// Apply options from the Polish feature of the Cloudflare Speed app. + /// + public class Polish : ZoneSettingBase + { + /// + /// Initializes a new instance of the class. + /// + public Polish() + { + Id = ZoneSettingId.Polish; + } + + /// + /// The level of Polish you want applied to your origin. + /// + [JsonProperty("value")] + public PolishLevel? Value { get; set; } + } + + /// + /// The level of Polish. + /// Source + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum PolishLevel + { + /// + /// No Polish. + /// + [EnumMember(Value = "off")] + Off = 1, + + /// + /// Basic Polish. + /// + [EnumMember(Value = "lossless")] + LossLess = 2, + + /// + /// Full Polish. + /// + [EnumMember(Value = "lossy")] + Lossy = 3 + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/PrefetchPreload.cs b/Extensions/Cloudflare.Zones/Models/Settings/PrefetchPreload.cs new file mode 100644 index 0000000..ddc7319 --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/PrefetchPreload.cs @@ -0,0 +1,23 @@ +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// Cloudflare will prefetch any URLs that are included in the response headers. + /// This is limited to Enterprise Zones. + /// + public class PrefetchPreload : ZoneSettingBase + { + /// + /// Initializes a new instance of the class. + /// + public PrefetchPreload() + { + Id = ZoneSettingId.PrefetchPreload; + } + + /// + /// Current value of the zone setting. + /// + [JsonProperty("value")] + public OnOffState Value { get; set; } + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/PrivacyPass.cs b/Extensions/Cloudflare.Zones/Models/Settings/PrivacyPass.cs new file mode 100644 index 0000000..d83c9eb --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/PrivacyPass.cs @@ -0,0 +1,23 @@ +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// Privacy Pass. + /// + [Obsolete("Privacy Pass v1 was deprecated in 2023.")] + public class PrivacyPass : ZoneSettingBase + { + /// + /// Initializes a new instance of the class. + /// + public PrivacyPass() + { + Id = ZoneSettingId.PrivacyPass; + } + + /// + /// Current value of the zone setting. + /// + [JsonProperty("value")] + public OnOffState Value { get; set; } + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/ProxyReadTimeout.cs b/Extensions/Cloudflare.Zones/Models/Settings/ProxyReadTimeout.cs new file mode 100644 index 0000000..a7f3ac8 --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/ProxyReadTimeout.cs @@ -0,0 +1,22 @@ +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// Maximum time between two read operations from origin. + /// + public class ProxyReadTimeout : ZoneSettingBase + { + /// + /// Initializes a new instance of the class. + /// + public ProxyReadTimeout() + { + Id = ZoneSettingId.ProxyReadTimeout; + } + + /// + /// Current value of the zone setting. + /// + [JsonProperty("value")] + public int Value { get; set; } + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/PseudoIPV4.cs b/Extensions/Cloudflare.Zones/Models/Settings/PseudoIPV4.cs new file mode 100644 index 0000000..97a875b --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/PseudoIPV4.cs @@ -0,0 +1,51 @@ +using System.Runtime.Serialization; +using Newtonsoft.Json.Converters; + +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// The value set for the Pseudo IPv4 setting. + /// + public class PseudoIPV4 : ZoneSettingBase + { + /// + /// Initializes a new instance of the class. + /// + public PseudoIPV4() + { + Id = ZoneSettingId.PseudoIPV4; + } + + /// + /// Current value of the zone setting. + /// + [JsonProperty("value")] + public PseudoIPV4Value Value { get; set; } + } + + /// + /// Pseudo IPv4 values. + /// Source + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum PseudoIPV4Value + { + /// + /// Off. + /// + [EnumMember(Value = "off")] + Off = 1, + + /// + /// Add a header. + /// + [EnumMember(Value = "add_header")] + AddHeader = 2, + + /// + /// Add header or overwrite if exists. + /// + [EnumMember(Value = "overwrite_header")] + OverwriteHeader = 3 + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/ReplaceInsecureJS.cs b/Extensions/Cloudflare.Zones/Models/Settings/ReplaceInsecureJS.cs new file mode 100644 index 0000000..038f048 --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/ReplaceInsecureJS.cs @@ -0,0 +1,24 @@ +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// Automatically replace insecure JavaScript libraries with safer and faster + /// alternatives provided under cdnjs and powered by Cloudflare. Currently supports + /// the following libraries: Polyfill under polyfill.io. + /// + public class ReplaceInsecureJS : ZoneSettingBase + { + /// + /// Initializes a new instance of the class. + /// + public ReplaceInsecureJS() + { + Id = ZoneSettingId.ReplaceInsecureJS; + } + + /// + /// Current value of the zone setting. + /// + [JsonProperty("value")] + public OnOffState Value { get; set; } + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/ResponseBuffering.cs b/Extensions/Cloudflare.Zones/Models/Settings/ResponseBuffering.cs new file mode 100644 index 0000000..3aa7416 --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/ResponseBuffering.cs @@ -0,0 +1,24 @@ +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// Turn on or off whether Cloudflare should wait for an entire file from the origin + /// server before forwarding it to the site visitor. By default, Cloudflare sends + /// packets to the client as they arrive from the origin server. + /// + public class ResponseBuffering : ZoneSettingBase + { + /// + /// Initializes a new instance of the class. + /// + public ResponseBuffering() + { + Id = ZoneSettingId.ResponseBuffering; + } + + /// + /// The status of Response Buffering. + /// + [JsonProperty("value")] + public OnOffState? Value { get; set; } + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/RocketLoader.cs b/Extensions/Cloudflare.Zones/Models/Settings/RocketLoader.cs new file mode 100644 index 0000000..1997cc2 --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/RocketLoader.cs @@ -0,0 +1,22 @@ +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// Turn on or off Rocket Loader in the Cloudflare Speed app. + /// + public class RocketLoader : ZoneSettingBase + { + /// + /// Initializes a new instance of the class. + /// + public RocketLoader() + { + Id = ZoneSettingId.RocketLoader; + } + + /// + /// The status of Rocket Loader. + /// + [JsonProperty("value")] + public OnOffState? Value { get; set; } + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/SSL.cs b/Extensions/Cloudflare.Zones/Models/Settings/SSL.cs new file mode 100644 index 0000000..fce1fa3 --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/SSL.cs @@ -0,0 +1,69 @@ +using System.Runtime.Serialization; +using Newtonsoft.Json.Converters; + +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// Control options for the SSL feature of the Edge Certificates tab in the + /// Cloudflare SSL/TLS app. + /// + public class SSL : ZoneSettingBase + { + /// + /// Initialize a new instance of the class. + /// + public SSL() + { + Id = ZoneSettingId.SSL; + } + + /// + /// The encryption mode that Cloudflare uses to connect to your origin server. + /// + [JsonProperty("value")] + public SslMode? Value { get; set; } + } + + /// + /// SSL encryption modes. + /// Source + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum SslMode + { + /// + /// No encryption applied. + /// Turning off SSL disables HTTPS and causes browsers to show a warning that your website is not secure. + /// + [EnumMember(Value = "off")] + Off = 1, + + /// + /// Enable encryption only between your visitors and Cloudflare. + /// This will avoid browser security warnings, but all connections between Cloudflare and your origin are made through HTTP. + /// + [EnumMember(Value = "flexible")] + Flexible = 2, + + /// + /// Enable encryption end-to-end. + /// Use this mode when your origin server supports SSL certification but does not use a valid, publicly trusted certificate. + /// + [EnumMember(Value = "full")] + Full = 3, + + /// + /// Enable encryption end-to-end and enforce validation on origin certificates. + /// Use Cloudflare’s Origin CA to generate certificates for your origin. + /// + [EnumMember(Value = "strict")] + Strict = 4, + + /// + /// Enforce encryption between Cloudflare and your origin. + /// Use this mode to guarantee connections to your origin will always be encrypted, regardless of your visitor’s request. + /// + [EnumMember(Value = "origin_pull")] + OriginPull = 5 + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/SSLRecommender.cs b/Extensions/Cloudflare.Zones/Models/Settings/SSLRecommender.cs new file mode 100644 index 0000000..8a4f600 --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/SSLRecommender.cs @@ -0,0 +1,25 @@ +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// Enrollment in the SSL/TLS Recommender service which tries to detect and + /// recommend (by sending periodic emails) the most secure SSL/TLS setting your + /// origin servers support. + /// + [Obsolete("SSL/TLS Recommender has been decommissioned in favor of Automatic SSL/TLS: ssl_automatic_mode")] + public class SSLRecommender : ZoneSettingBase + { + /// + /// Initializes a new instance of the class. + /// + public SSLRecommender() + { + Id = ZoneSettingId.SSLRecommender; + } + + /// + /// Current value of the zone setting. + /// + [JsonProperty("value")] + public string? Value { get; set; } + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/SchemasEdgeCacheTTL.cs b/Extensions/Cloudflare.Zones/Models/Settings/SchemasEdgeCacheTTL.cs new file mode 100644 index 0000000..7ea8a64 --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/SchemasEdgeCacheTTL.cs @@ -0,0 +1,135 @@ +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// Time (in seconds) that a resource will be ensured to remain on Cloudflare's + /// cache servers. + /// + public class SchemasEdgeCacheTTL : ZoneSettingBase + { + /// + /// Initializes a new instance of the class. + /// + public SchemasEdgeCacheTTL() + { + Id = ZoneSettingId.SchemasEdgeCacheTTL; + } + + /// + /// Current value of the zone setting. + /// + [JsonProperty("value")] + public EdgeCacheTTLValue Value { get; set; } + } + + /// + /// The time-to-live (TTL) of the challenge. + /// Soruce + /// + public enum EdgeCacheTTLValue : int + { + /// + /// 30 seconds. + /// + HalfMinute = 30, + + /// + /// 1 minute. + /// + Minute = 60, + + /// + /// 5 minutes. + /// + FiveMinutes = 300, + + /// + /// 20 minutes. + /// + TwentyMinutes = 1200, + + /// + /// 30 minutes. + /// + HalfHour = 1800, + + /// + /// 1 hour. + /// + Hour = 3600, + + /// + /// 2 hours. + /// + TwoHours = 7200, + + /// + /// 3 hours. + /// + ThreeHours = 10800, + + /// + /// 4 hours. + /// + FourHours = 14400, + + /// + /// 5 hours. + /// + FiveHours = 18000, + + /// + /// 8 hours. + /// + EightHours = 28800, + + /// + /// 12 hours. + /// + HalfDay = 43200, + + /// + /// 16 hours. + /// + SixteenHours = 57600, + + /// + /// 20 hours. + /// + TwentyHours = 72000, + + /// + /// 1 day. + /// + Day = 86400, + + /// + /// 2 days. + /// + TwoDays = 172800, + + /// + /// 3 days. + /// + ThreeDays = 259200, + + /// + /// 4 days. + /// + FourDays = 345600, + + /// + /// 5 days. + /// + FiveDays = 432000, + + /// + /// 6 days. + /// + SixDays = 518400, + + /// + /// 1 week. + /// + Week = 604800, + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/SecurityHeaders.cs b/Extensions/Cloudflare.Zones/Models/Settings/SecurityHeaders.cs new file mode 100644 index 0000000..07ec62b --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/SecurityHeaders.cs @@ -0,0 +1,70 @@ +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// Cloudflare security header for a zone. + /// + public class SecurityHeaders : ZoneSettingBase + { + /// + /// Initializes a new instance of the class. + /// + public SecurityHeaders() + { + Id = ZoneSettingId.SecurityHeaders; + } + + /// + /// Current value of the zone setting. + /// + [JsonProperty("value")] + public SecurityHeaderValue? Value { get; set; } + } + + /// + /// Current value of the zone setting. + /// + public class SecurityHeaderValue + { + /// + /// Strict Transport Security. + /// + [JsonProperty("strict_transport_security")] + public SecurityHeaderStrictTransportSecurity? StrictTransportSecurity { get; set; } + } + + /// + /// Strict Transport Security. + /// + public class SecurityHeaderStrictTransportSecurity + { + /// + /// Whether or not strict transport security is enabled. + /// + [JsonProperty("enabled")] + public bool? Enabled { get; set; } + + /// + /// Include all subdomains for strict transport security. + /// + [JsonProperty("include_subdomains")] + public bool? IncludeSubdomains { get; set; } + + /// + /// Max age in seconds of the strict transport security. + /// + [JsonProperty("max_age")] + public int? MaxAge { get; set; } + + /// + /// Whether or not to include X-Content-Type-Options: nosniff header. + /// + [JsonProperty("nosniff")] + public bool? NoSniff { get; set; } + + /// + /// Enable automatic preload of the HSTS configuration. + /// + [JsonProperty("preload")] + public bool? Preload { get; set; } + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/SecurityLevel.cs b/Extensions/Cloudflare.Zones/Models/Settings/SecurityLevel.cs new file mode 100644 index 0000000..d4c9cd2 --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/SecurityLevel.cs @@ -0,0 +1,69 @@ +using System.Runtime.Serialization; +using Newtonsoft.Json.Converters; + +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// Control options for the Security Level feature from the Security app. + /// + public class SecurityLevel : ZoneSettingBase + { + /// + /// Initializes a new instance of the class. + /// + public SecurityLevel() + { + Id = ZoneSettingId.SecurityLevel; + } + + /// + /// Current value of the zone setting. + /// + [JsonProperty("value")] + public SecurityLevelValue? Value { get; set; } + } + + /// + /// Security levels. + /// Source + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum SecurityLevelValue + { + /// + /// Off. + /// + [EnumMember(Value = "off")] + Off = 1, + + /// + /// Essentially off. + /// + [EnumMember(Value = "essentially_off")] + EssentiallyOff = 2, + + /// + /// Low. + /// + [EnumMember(Value = "low")] + Low = 3, + + /// + /// Medium. + /// + [EnumMember(Value = "medium")] + Medium = 4, + + /// + /// High. + /// + [EnumMember(Value = "high")] + High = 5, + + /// + /// Under Attack. + /// + [EnumMember(Value = "under_attack")] + UnderAttack = 6 + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/ServerSideExcludes.cs b/Extensions/Cloudflare.Zones/Models/Settings/ServerSideExcludes.cs new file mode 100644 index 0000000..8e2151d --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/ServerSideExcludes.cs @@ -0,0 +1,34 @@ +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// If there is sensitive content on your website that you want visible to real + /// visitors, but that you want to hide from suspicious visitors, all you have to do + /// is wrap the content with Cloudflare SSE tags. Wrap any content that you want to + /// be excluded from suspicious visitors in the following SSE tags: <!--sse--></!--sse-->. + /// + /// + /// For example: <!--sse-->Bad visitors won't see my phone number, 555-555-5555</!--sse--> + ///
+ /// Note: SSE only will work with HTML. If you have HTML minification enabled, + /// you won't see the SSE tags in your HTML source when it's served through Cloudflare. + /// SSE will still function in this case, as Cloudflare's HTML minification and SSE + /// functionality occur on-the-fly as the resource moves through our network to the visitor's computer. + /// (). + ///
+ public class ServerSideExcludes : ZoneSettingBase + { + /// + /// Initializes a new instance of the class. + /// + public ServerSideExcludes() + { + Id = ZoneSettingId.ServerSideExcludes; + } + + /// + /// Current value of the zone setting. + /// + [JsonProperty("value")] + public OnOffState Value { get; set; } + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/SortQueryStringForCache.cs b/Extensions/Cloudflare.Zones/Models/Settings/SortQueryStringForCache.cs new file mode 100644 index 0000000..bd3c340 --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/SortQueryStringForCache.cs @@ -0,0 +1,23 @@ +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// Turn on or off the reordering of query strings. When query strings have the same + /// structure, caching improves. + /// + public class SortQueryStringForCache : ZoneSettingBase + { + /// + /// Initializes a new instance of the class. + /// + public SortQueryStringForCache() + { + Id = ZoneSettingId.SortQueryStringForCache; + } + + /// + /// The status of Query String Sort. + /// + [JsonProperty("value")] + public OnOffState? Value { get; set; } + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/TLS1_2Only.cs b/Extensions/Cloudflare.Zones/Models/Settings/TLS1_2Only.cs new file mode 100644 index 0000000..ae30d3f --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/TLS1_2Only.cs @@ -0,0 +1,22 @@ +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// Only allows TLS1.2. + /// + public class TLS1_2Only : ZoneSettingBase + { + /// + /// Initializes a new instance of the class. + /// + public TLS1_2Only() + { + Id = ZoneSettingId.TLS1_2Only; + } + + /// + /// Current value of the zone setting. + /// + [JsonProperty("value")] + public OnOffState Value { get; set; } + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/TLS1_3.cs b/Extensions/Cloudflare.Zones/Models/Settings/TLS1_3.cs new file mode 100644 index 0000000..6cce8ae --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/TLS1_3.cs @@ -0,0 +1,51 @@ +using System.Runtime.Serialization; +using Newtonsoft.Json.Converters; + +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// Enables Crypto TLS 1.3 feature for a zone. + /// + public class TLS1_3 : ZoneSettingBase + { + /// + /// Enables Crypto TLS 1.3 feature for a zone. + /// + public TLS1_3() + { + Id = ZoneSettingId.TLS1_3; + } + + /// + /// Current value of the zone setting. + /// + [JsonProperty("value")] + public TlsOption Value { get; set; } + } + + /// + /// Available TLS options. + /// Source + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum TlsOption + { + /// + /// Off. + /// + [EnumMember(Value = "off")] + Off = 1, + + /// + /// On. + /// + [EnumMember(Value = "on")] + On = 2, + + /// + /// ZRT refers to Zero Round Trip Time Resumption (0-RTT). + /// + [EnumMember(Value = "zrt")] + ZeroRoundTrip = 3 + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/TLSClientAuth.cs b/Extensions/Cloudflare.Zones/Models/Settings/TLSClientAuth.cs new file mode 100644 index 0000000..ebe99cf --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/TLSClientAuth.cs @@ -0,0 +1,23 @@ +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// TLS Client Auth requires Cloudflare to connect to your origin server using a + /// client certificate (Enterprise Only). + /// + public class TLSClientAuth : ZoneSettingBase + { + /// + /// Initialize a new instance of the class. + /// + public TLSClientAuth() + { + Id = ZoneSettingId.TLSClientAuth; + } + + /// + /// Current value of the zone setting. + /// + [JsonProperty("value")] + public OnOffState Value { get; set; } + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/TrueClientIPHeader.cs b/Extensions/Cloudflare.Zones/Models/Settings/TrueClientIPHeader.cs new file mode 100644 index 0000000..9064853 --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/TrueClientIPHeader.cs @@ -0,0 +1,22 @@ +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// Turn on or off the True-Client-IP Header feature of the Cloudflare Network app. + /// + public class TrueClientIPHeader : ZoneSettingBase + { + /// + /// Initializes a new instance of the class. + /// + public TrueClientIPHeader() + { + Id = ZoneSettingId.TrueClientIPHeader; + } + + /// + /// The status of True Client IP Header. + /// + [JsonProperty("value")] + public OnOffState? Value { get; set; } + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/WAF.cs b/Extensions/Cloudflare.Zones/Models/Settings/WAF.cs new file mode 100644 index 0000000..c934f86 --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/WAF.cs @@ -0,0 +1,24 @@ +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// Turn on or off + /// WAF managed rules (previous version, deprecated). + /// You cannot enable or disable individual WAF managed rules via Page Rules. + /// + public class WAF : ZoneSettingBase + { + /// + /// Initializes a new instance of the class. + /// + public WAF() + { + Id = ZoneSettingId.WAF; + } + + /// + /// The status of WAF managed rules (previous version). + /// + [JsonProperty("value")] + public OnOffState? Value { get; set; } + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/WebP.cs b/Extensions/Cloudflare.Zones/Models/Settings/WebP.cs new file mode 100644 index 0000000..6431519 --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/WebP.cs @@ -0,0 +1,24 @@ +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// When the client requesting the image supports the WebP image codec, and WebP + /// offers a performance advantage over the original image format, Cloudflare will + /// serve a WebP version of the original image. + /// + public class WebP : ZoneSettingBase + { + /// + /// Initializes a new instance of the class. + /// + public WebP() + { + Id = ZoneSettingId.WebP; + } + + /// + /// Current value of the zone setting. + /// + [JsonProperty("value")] + public OnOffState Value { get; set; } + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/Websocket.cs b/Extensions/Cloudflare.Zones/Models/Settings/Websocket.cs new file mode 100644 index 0000000..0220b1b --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/Websocket.cs @@ -0,0 +1,27 @@ +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// WebSockets are open connections sustained between the client and the origin + /// server. Inside a WebSockets connection, the client and the origin can pass data + /// back and forth without having to reestablish sessions. This makes exchanging + /// data within a WebSockets connection fast. WebSockets are often used for real-time + /// applications such as live chat and gaming. For more information refer to + /// Can I use Cloudflare with Websockets. + /// + public class Websocket : ZoneSettingBase + { + /// + /// Initializes a new instance of the class. + /// + public Websocket() + { + Id = ZoneSettingId.Websocket; + } + + /// + /// Current value of the zone setting. + /// + [JsonProperty("value")] + public OnOffState Value { get; set; } + } +} diff --git a/Extensions/Cloudflare.Zones/Models/Settings/ZeroRTT.cs b/Extensions/Cloudflare.Zones/Models/Settings/ZeroRTT.cs new file mode 100644 index 0000000..9367a11 --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/Settings/ZeroRTT.cs @@ -0,0 +1,22 @@ +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// 0-RTT session resumption enabled for this zone. + /// + public class ZeroRTT : ZoneSettingBase + { + /// + /// Initializes a new instance of the class. + /// + public ZeroRTT() + { + Id = ZoneSettingId.ZeroRTT; + } + + /// + /// Current value of the zone setting. + /// + [JsonProperty("value")] + public OnOffState Value { get; set; } + } +} diff --git a/Extensions/Cloudflare.Zones/Models/ZoneSettingBase.cs b/Extensions/Cloudflare.Zones/Models/ZoneSettingBase.cs new file mode 100644 index 0000000..4c38085 --- /dev/null +++ b/Extensions/Cloudflare.Zones/Models/ZoneSettingBase.cs @@ -0,0 +1,26 @@ +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// A Cloudflare zone setting. + /// + public abstract class ZoneSettingBase + { + /// + /// The ID of the zone setting. + /// + [JsonProperty("id")] + public ZoneSettingId? Id { get; protected set; } + + /// + /// Whether or not this setting can be modified for this zone (based on your Cloudflare plan level). + /// + [JsonProperty("editable")] + public bool? Editable { get; set; } + + /// + /// The last time this setting was modified. + /// + [JsonProperty("modified_on")] + public DateTime? ModifiedOn { get; set; } + } +} diff --git a/Extensions/Cloudflare.Zones/README.md b/Extensions/Cloudflare.Zones/README.md index 314fc20..cf41503 100644 --- a/Extensions/Cloudflare.Zones/README.md +++ b/Extensions/Cloudflare.Zones/README.md @@ -44,6 +44,12 @@ This package contains the feature set of the _Domain/Zone Management_ section of - [List Available Rate Plans](https://developers.cloudflare.com/api/resources/zones/subresources/rate_plans/methods/get/) +##### [Settings] + +- **DEPRECATED** [Edit Multiple Zone Settings](https://developers.cloudflare.com/api/resources/zones/subresources/settings/methods/bulk_edit/) +- [Edit Zone Setting](https://developers.cloudflare.com/api/resources/zones/subresources/settings/methods/edit/) +- [Get Zone Setting](https://developers.cloudflare.com/api/resources/zones/subresources/settings/methods/get/) +- **DEPRECATED** [Get All Zone Settings](https://developers.cloudflare.com/api/resources/zones/subresources/settings/methods/list/) @@ -61,3 +67,4 @@ Published under MIT License (see [choose a license]) [Holds]: https://developers.cloudflare.com/api/resources/zones/subresources/holds/ [Plans]: https://developers.cloudflare.com/api/resources/zones/subresources/plans/ [Rate Plans]: https://developers.cloudflare.com/api/resources/zones/subresources/rate_plans/ +[Settings]: https://developers.cloudflare.com/api/resources/zones/subresources/settings/ diff --git a/Extensions/Cloudflare.Zones/Requests/EditMultipleZoneSettingsRequest.cs b/Extensions/Cloudflare.Zones/Requests/EditMultipleZoneSettingsRequest.cs new file mode 100644 index 0000000..0ab8b2a --- /dev/null +++ b/Extensions/Cloudflare.Zones/Requests/EditMultipleZoneSettingsRequest.cs @@ -0,0 +1,27 @@ +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// Represents a request to edit multiple zone settings. + /// + public class EditMultipleZoneSettingsRequest + { + /// + /// Initializes a new instance of the class. + /// + /// The zone identifier. + public EditMultipleZoneSettingsRequest(string zoneId) + { + ZoneId = zoneId; + } + + /// + /// The zone identifier. + /// + public string ZoneId { get; set; } + + /// + /// The zone settings. + /// + public IReadOnlyCollection? Settings { get; set; } + } +} diff --git a/Extensions/Cloudflare.Zones/Requests/EditZoneSettingRequest.cs b/Extensions/Cloudflare.Zones/Requests/EditZoneSettingRequest.cs new file mode 100644 index 0000000..e71a003 --- /dev/null +++ b/Extensions/Cloudflare.Zones/Requests/EditZoneSettingRequest.cs @@ -0,0 +1,39 @@ +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// Represents a request to edit a zone setting. + /// + /// + public class EditZoneSettingRequest + { + /// + /// Initializes a new instance of the class. + /// + /// The zone identifier. + /// The zone setting. + public EditZoneSettingRequest(string zoneId, T setting) + { + ZoneId = zoneId; + Setting = setting; + } + + /// + /// The zone identifier. + /// + public string ZoneId { get; set; } + + /// + /// The zone setting. + /// + public T Setting { get; set; } + + /// + /// Indicates whether the setting should be enabled or disabled. + /// + /// + /// If this property is not , + /// the value of the will not be modified. + /// + public bool? Enabled { get; set; } + } +} diff --git a/Extensions/Cloudflare.Zones/ZoneSettingsExtensions.cs b/Extensions/Cloudflare.Zones/ZoneSettingsExtensions.cs new file mode 100644 index 0000000..5c31a07 --- /dev/null +++ b/Extensions/Cloudflare.Zones/ZoneSettingsExtensions.cs @@ -0,0 +1,82 @@ +using System.Threading; +using System.Threading.Tasks; +using Newtonsoft.Json.Linq; + +namespace AMWD.Net.Api.Cloudflare.Zones +{ + /// + /// Extensions for Zone Settings. + /// + public static class ZoneSettingsExtensions + { + /// + /// Edit settings for a zone. + /// + /// The instance. + /// The request. + /// A cancellation token used to propagate notification that this operation should be canceled. + [Obsolete("This endpoint is deprecated. Zone settings should instead be managed individually.")] + public static Task>> EditMultipleZoneSettings(this ICloudflareClient client, EditMultipleZoneSettingsRequest request, CancellationToken cancellationToken = default) + { + request.ZoneId.ValidateCloudflareId(); + + return client.PatchAsync, IReadOnlyCollection>($"/zones/{request.ZoneId}/settings", request.Settings, cancellationToken); + } + + /// + /// Updates a single zone setting by the identifier. + /// + /// The type of the zone setting. + /// The instance. + /// The request. + /// A cancellation token used to propagate notification that this operation should be canceled. + public static Task> EditZoneSetting(this ICloudflareClient client, EditZoneSettingRequest request, CancellationToken cancellationToken = default) + where T : ZoneSettingBase + { + request.ZoneId.ValidateCloudflareId(); + string settingId = request.Setting.Id?.GetEnumMemberValue() + ?? throw new ArgumentException("The zone setting type is not known."); + + var req = new JObject(); + + if (request.Enabled.HasValue) + req.Add("enabled", request.Enabled.Value); + else + req.Add("value", JObject.FromObject(request.Setting)["value"]); + + return client.PatchAsync($"/zones/{request.ZoneId}/settings/{settingId}", req, cancellationToken); + } + + /// + /// Fetch a single zone setting. + /// + /// The type of the zone setting. + /// The instance. + /// The zone identifier. + /// A cancellation token used to propagate notification that this operation should be canceled. + public static Task> GetZoneSetting(this ICloudflareClient client, string zoneId, CancellationToken cancellationToken = default) + where T : ZoneSettingBase + { + zoneId.ValidateCloudflareId(); + + string settingId = ((ZoneSettingBase)Activator.CreateInstance(typeof(T))).Id?.GetEnumMemberValue() + ?? throw new ArgumentException("The zone setting type is not known."); + + return client.GetAsync($"/zones/{zoneId}/settings/{settingId}", null, cancellationToken); + } + + /// + /// Available settings for your user in relation to a zone. + /// + /// The instance. + /// The zone identifier. + /// A cancellation token used to propagate notification that this operation should be canceled. + [Obsolete("This endpoint is deprecated. Zone settings should instead be managed individually.")] + public static Task>> GetAllZoneSettings(this ICloudflareClient client, string zoneId, CancellationToken cancellationToken = default) + { + zoneId.ValidateCloudflareId(); + + return client.GetAsync>($"/zones/{zoneId}/settings", null, cancellationToken); + } + } +} diff --git a/UnitTests/Cloudflare.Zones.Tests/ZoneSettingsExtensions/EditMultipleZoneSettingsTest.cs b/UnitTests/Cloudflare.Zones.Tests/ZoneSettingsExtensions/EditMultipleZoneSettingsTest.cs new file mode 100644 index 0000000..209fa52 --- /dev/null +++ b/UnitTests/Cloudflare.Zones.Tests/ZoneSettingsExtensions/EditMultipleZoneSettingsTest.cs @@ -0,0 +1,91 @@ +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using AMWD.Net.Api.Cloudflare; +using AMWD.Net.Api.Cloudflare.Zones; +using Moq; + +namespace Cloudflare.Zones.Tests.ZoneSettingsExtensions +{ + [TestClass] + public class EditMultipleZoneSettingsTest + { + private const string ZoneId = "023e105f4ecef8ad9ca31a8372d0c353"; + + private Mock _clientMock; + + private CloudflareResponse> _response; + + private List<(string RequestPath, IReadOnlyCollection Request)> _callbacks; + + private EditMultipleZoneSettingsRequest _request; + + [TestInitialize] + public void Initialize() + { + _callbacks = []; + + _response = new CloudflareResponse> + { + Success = true, + Messages = [ + new ResponseInfo(1000, "Message 1") + ], + Errors = [ + new ResponseInfo(1000, "Error 1") + ], + Result = [ + new SSL { Value = SslMode.Flexible }, + new WebP { Value = OnOffState.Off } + ] + }; + + _request = new EditMultipleZoneSettingsRequest(ZoneId) + { + Settings = [ + new SSL { Value = SslMode.Strict }, + new WebP { Value = OnOffState.On } + ] + }; + } + + [TestMethod] + public async Task ShouldEditMultipleZoneSettings() + { + // Arrange + var client = GetClient(); + + // Act +#pragma warning disable CS0618 + var response = await client.EditMultipleZoneSettings(_request); +#pragma warning restore CS0618 + + // Assert + Assert.IsNotNull(response); + Assert.IsTrue(response.Success); + Assert.AreEqual(_response.Result, response.Result); + + Assert.AreEqual(1, _callbacks.Count); + + var callback = _callbacks.First(); + Assert.AreEqual($"/zones/{ZoneId}/settings", callback.RequestPath); + + Assert.IsNotNull(callback.Request); + Assert.AreEqual(2, callback.Request.Count); + + Assert.IsInstanceOfType(callback.Request.First()); + Assert.IsInstanceOfType(callback.Request.Last()); + } + + private ICloudflareClient GetClient() + { + _clientMock = new Mock(); + _clientMock + .Setup(m => m.PatchAsync, IReadOnlyCollection>(It.IsAny(), It.IsAny>(), It.IsAny())) + .Callback, CancellationToken>((requestPath, request, _) => _callbacks.Add((requestPath, request))) + .ReturnsAsync(() => _response); + + return _clientMock.Object; + } + } +} diff --git a/UnitTests/Cloudflare.Zones.Tests/ZoneSettingsExtensions/EditZoneSettingTest.cs b/UnitTests/Cloudflare.Zones.Tests/ZoneSettingsExtensions/EditZoneSettingTest.cs new file mode 100644 index 0000000..35ca9f9 --- /dev/null +++ b/UnitTests/Cloudflare.Zones.Tests/ZoneSettingsExtensions/EditZoneSettingTest.cs @@ -0,0 +1,127 @@ +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using AMWD.Net.Api.Cloudflare; +using AMWD.Net.Api.Cloudflare.Zones; +using Moq; +using Newtonsoft.Json.Linq; + +namespace Cloudflare.Zones.Tests.ZoneSettingsExtensions +{ + [TestClass] + public class EditZoneSettingTest + { + private const string ZoneId = "023e105f4ecef8ad9ca31a8372d0c353"; + + private Mock _clientMock; + + private CloudflareResponse _response; + + private List<(string RequestPath, JObject Request)> _callbacks; + + private EditZoneSettingRequest _request; + + [TestInitialize] + public void Initialize() + { + _callbacks = []; + + _response = new CloudflareResponse + { + Success = true, + Messages = [ + new ResponseInfo(1000, "Message 1") + ], + Errors = [ + new ResponseInfo(1000, "Error 1") + ], + Result = new SSL { Value = SslMode.Flexible } + }; + + _request = new EditZoneSettingRequest(ZoneId, null) + { + Setting = new SSL { Value = SslMode.OriginPull } + }; + } + + [TestMethod] + public async Task ShouldEditZoneSetting() + { + // Arrange + var client = GetClient(); + + // Act + var response = await client.EditZoneSetting(_request); + + // Assert + Assert.IsNotNull(response); + Assert.IsTrue(response.Success); + Assert.AreEqual(_response.Result, response.Result); + + Assert.AreEqual(1, _callbacks.Count); + + var callback = _callbacks.First(); + Assert.AreEqual($"/zones/{ZoneId}/settings/ssl", callback.RequestPath); + + Assert.IsNotNull(callback.Request); + Assert.AreEqual("origin_pull", callback.Request["value"]); + Assert.IsFalse(callback.Request.ContainsKey("enabled")); + } + + [DataTestMethod] + [DataRow(true)] + [DataRow(false)] + public async Task ShouldEditEnabledState(bool enabled) + { + // Arrange + _request.Enabled = enabled; + var client = GetClient(); + + // Act + var response = await client.EditZoneSetting(_request); + + // Assert + Assert.IsNotNull(response); + Assert.IsTrue(response.Success); + Assert.AreEqual(_response.Result, response.Result); + + Assert.AreEqual(1, _callbacks.Count); + + var callback = _callbacks.First(); + Assert.AreEqual($"/zones/{ZoneId}/settings/ssl", callback.RequestPath); + + Assert.IsNotNull(callback.Request); + Assert.AreEqual(enabled, callback.Request["enabled"]); + Assert.IsFalse(callback.Request.ContainsKey("value")); + } + + [TestMethod] + [ExpectedException(typeof(ArgumentException))] + public async Task ShouldThrowArgumentException() + { + // Arrange + var request = new EditZoneSettingRequest(ZoneId, new TestSetting()); + var client = GetClient(); + + // Act + var response = await client.EditZoneSetting(request); + + // Assert - ArgumentException + } + + private ICloudflareClient GetClient() + { + _clientMock = new Mock(); + _clientMock + .Setup(m => m.PatchAsync(It.IsAny(), It.IsAny(), It.IsAny())) + .Callback((requestPath, request, _) => _callbacks.Add((requestPath, request))) + .ReturnsAsync(() => _response); + + return _clientMock.Object; + } + + public class TestSetting : ZoneSettingBase + { + } + } +} diff --git a/UnitTests/Cloudflare.Zones.Tests/ZoneSettingsExtensions/GetAllZoneSettingsTest.cs b/UnitTests/Cloudflare.Zones.Tests/ZoneSettingsExtensions/GetAllZoneSettingsTest.cs new file mode 100644 index 0000000..e5931de --- /dev/null +++ b/UnitTests/Cloudflare.Zones.Tests/ZoneSettingsExtensions/GetAllZoneSettingsTest.cs @@ -0,0 +1,79 @@ +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using AMWD.Net.Api.Cloudflare; +using AMWD.Net.Api.Cloudflare.Zones; +using Moq; + +namespace Cloudflare.Zones.Tests.ZoneSettingsExtensions +{ + [TestClass] + public class GetAllZoneSettingsTest + { + private const string ZoneId = "023e105f4ecef8ad9ca31a8372d0c353"; + + private Mock _clientMock; + + private CloudflareResponse> _response; + + private List<(string RequestPath, IQueryParameterFilter QueryFilter)> _callbacks; + + [TestInitialize] + public void Initialize() + { + _callbacks = []; + + _response = new CloudflareResponse> + { + Success = true, + Messages = [ + new ResponseInfo(1000, "Message 1") + ], + Errors = [ + new ResponseInfo(1000, "Error 1") + ], + Result = [ + new SSL { Value = SslMode.Flexible }, + new WebP { Value = OnOffState.Off } + ] + }; + } + + [TestMethod] + public async Task ShouldReturnZoneSetting() + { + // Arrange + var client = GetClient(); + + // Act +#pragma warning disable CS0618 + var response = await client.GetAllZoneSettings(ZoneId); +#pragma warning restore CS0618 + + // Assert + Assert.IsNotNull(response); + Assert.IsTrue(response.Success); + Assert.AreEqual(_response.Result, response.Result); + + Assert.AreEqual(1, _callbacks.Count); + + var callback = _callbacks.First(); + Assert.AreEqual($"/zones/{ZoneId}/settings", callback.RequestPath); + Assert.IsNull(callback.QueryFilter); + + _clientMock.Verify(m => m.GetAsync>($"/zones/{ZoneId}/settings", null, It.IsAny()), Times.Once); + _clientMock.VerifyNoOtherCalls(); + } + + private ICloudflareClient GetClient() + { + _clientMock = new Mock(); + _clientMock + .Setup(m => m.GetAsync>(It.IsAny(), It.IsAny(), It.IsAny())) + .Callback((requestPath, queryFilter, _) => _callbacks.Add((requestPath, queryFilter))) + .ReturnsAsync(() => _response); + + return _clientMock.Object; + } + } +} diff --git a/UnitTests/Cloudflare.Zones.Tests/ZoneSettingsExtensions/GetZoneSettingTest.cs b/UnitTests/Cloudflare.Zones.Tests/ZoneSettingsExtensions/GetZoneSettingTest.cs new file mode 100644 index 0000000..05d3af6 --- /dev/null +++ b/UnitTests/Cloudflare.Zones.Tests/ZoneSettingsExtensions/GetZoneSettingTest.cs @@ -0,0 +1,91 @@ +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using AMWD.Net.Api.Cloudflare; +using AMWD.Net.Api.Cloudflare.Zones; +using Moq; + +namespace Cloudflare.Zones.Tests.ZoneSettingsExtensions +{ + [TestClass] + public class GetZoneSettingTest + { + private const string ZoneId = "023e105f4ecef8ad9ca31a8372d0c353"; + + private Mock _clientMock; + + private CloudflareResponse _response; + + private List<(string RequestPath, IQueryParameterFilter QueryFilter)> _callbacks; + + [TestInitialize] + public void Initialize() + { + _callbacks = []; + + _response = new CloudflareResponse + { + Success = true, + Messages = [ + new ResponseInfo(1000, "Message 1") + ], + Errors = [ + new ResponseInfo(1000, "Error 1") + ], + Result = new SSL { Value = SslMode.Flexible } + }; + } + + [TestMethod] + public async Task ShouldReturnZoneSetting() + { + // Arrange + var client = GetClient(); + + // Act + var response = await client.GetZoneSetting(ZoneId); + + // Assert + Assert.IsNotNull(response); + Assert.IsTrue(response.Success); + Assert.AreEqual(_response.Result, response.Result); + + Assert.AreEqual(1, _callbacks.Count); + + var callback = _callbacks.First(); + Assert.AreEqual($"/zones/{ZoneId}/settings/ssl", callback.RequestPath); + Assert.IsNull(callback.QueryFilter); + + _clientMock.Verify(m => m.GetAsync($"/zones/{ZoneId}/settings/ssl", null, It.IsAny()), Times.Once); + _clientMock.VerifyNoOtherCalls(); + } + + [TestMethod] + [ExpectedException(typeof(ArgumentException))] + public async Task ShouldThrowArgumentException() + { + // Arrange + var client = GetClient(); + + // Act + var response = await client.GetZoneSetting(ZoneId); + + // Assert - ArgumentException + } + + private ICloudflareClient GetClient() + { + _clientMock = new Mock(); + _clientMock + .Setup(m => m.GetAsync(It.IsAny(), It.IsAny(), It.IsAny())) + .Callback((requestPath, queryFilter, _) => _callbacks.Add((requestPath, queryFilter))) + .ReturnsAsync(() => _response); + + return _clientMock.Object; + } + + public class TestSetting : ZoneSettingBase + { + } + } +}