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

[Feature] Add additional zone settings #122

Open
bjammin opened this issue Jan 13, 2025 · 1 comment
Open

[Feature] Add additional zone settings #122

bjammin opened this issue Jan 13, 2025 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@bjammin
Copy link

bjammin commented Jan 13, 2025

Thanks for the great library.

I am happy to submit a PR for this, but wanted to check if it's likely to get merged first.

There are a lot of zone settings missing from the Zones.Settings namespace.

Since so many of them are boolean (feature on/off), it would be handy to add a custom method to cover them without having to implement specifically.

Task<CloudFlareResult<ZoneSetting<FeatureStatus>>> GetFeatureSettingAsync(string zoneId, string settingId, CancellationToken cancellationToken = default);

Task<CloudFlareResult<ZoneSetting<FeatureStatus>>> UpdateFeatureSettingAsync(string zoneId, string settingId, FeatureStatus status, CancellationToken cancellationToken = default);

Or would you prefer they are each implemented individually?

@bjammin bjammin added the enhancement New feature or request label Jan 13, 2025
@zingz0r
Copy link
Owner

zingz0r commented Feb 12, 2025

Hey @bjammin,
I really like your idea and believe this approach is better than implementing each one individually.

However, I’d prefer not to allow developers to use free text strings as setting IDs. With this library, they shouldn't have to browse Cloudflare documentation for IDs and endpoints. While this does create a minor limitation when Cloudflare introduces new features, it ensures a safer and more efficient experience in most cases.

So, what do you think about using an enum with attributes? I'm open to other suggestions as well!

    public enum Feature
    {
        [EnumMember(Value = "aegis")]
        ZonesCacheRulesAegis,
    }
    
    public async Task<CloudFlareResult<ZoneSetting<FeatureStatus>>> GetFeatureStatusAsync(string zoneId, Feature feature, CancellationToken cancellationToken = default)
    {
        var settingId = setting.GetEnumMemberValue();
        var requestUri = $"{ZoneEndpoints.Base}/{zoneId}/{SettingsEndpoints.Base}/{settingId}";
        return await Connection.GetAsync<ZoneSetting<FeatureStatus>>(requestUri, cancellationToken).ConfigureAwait(false);
    }

Also those endpoints which are already there like GetAlwaysUseHttpsSettingAsync should be marked as obsolete with a comment stating the new api should be used and it will be removed in the next version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants