using System.Runtime.Serialization; using Newtonsoft.Json.Converters; namespace AMWD.Net.Api.Cloudflare { /// /// A token policy. /// Source /// public class TokenPolicy { /// /// Initializes a new instance of the class. /// /// Policy identifier. /// Allow or deny operations against the resources. public TokenPolicy(string id, TokenPolicyEffect effect) { Id = id; Effect = effect; } /// /// Policy identifier. /// [JsonProperty("id")] public string Id { get; set; } /// /// Allow or deny operations against the resources. /// [JsonProperty("effect")] public TokenPolicyEffect Effect { get; set; } /// /// A set of permission groups that are specified to the policy. /// [JsonProperty("permission_groups")] public IReadOnlyCollection PermissionGroups { get; set; } = []; /// /// A list of resource names that the policy applies to. /// [JsonProperty("resources")] public IDictionary Resources { get; set; } = new Dictionary(); } /// /// Allow or deny operations against the resources. /// Source /// [JsonConverter(typeof(StringEnumConverter))] public enum TokenPolicyEffect { /// /// Allow operations against the resources. /// [EnumMember(Value = "allow")] Allow = 1, /// /// Deny operations against the resources. /// [EnumMember(Value = "deny")] Deny = 2 } /// /// A named group of permissions that map to a group of operations against resources. /// Source /// public class TokenPolicyPermissionGroup { /// /// Initializes a new instance of the class. /// /// Identifier of the permission group. public TokenPolicyPermissionGroup(string id) { Id = id; } /// /// Identifier of the permission group. /// [JsonProperty("id")] public string Id { get; set; } /// /// Attributes associated to the permission group. /// [JsonProperty("meta")] public TokenPolicyPermissionGroupMeta? Meta { get; set; } /// /// Name of the permission group. /// [JsonProperty("name")] public string? Name { get; set; } } /// /// Attributes associated to the permission group. /// Source /// public class TokenPolicyPermissionGroupMeta { /// /// Key. /// [JsonProperty("key")] public string? Key { get; set; } /// /// Value. /// [JsonProperty("value")] public string? Value { get; set; } } }