# Generated by cloudcoil-model-codegen v0.0.17
# DO NOT EDIT

from __future__ import annotations

from typing import Annotated, Dict, List, Literal, Optional

from pydantic import Field

from cloudcoil import apimachinery
from cloudcoil._pydantic import BaseModel
from cloudcoil.resources import Resource


class NonResourceAttributes(BaseModel):
    path: Annotated[Optional[str], Field(description="Path is the URL path of the request")] = None
    verb: Annotated[Optional[str], Field(description="Verb is the standard HTTP verb")] = None


class NonResourceRule(BaseModel):
    non_resource_ur_ls: Annotated[
        Optional[List[str]],
        Field(
            alias="nonResourceURLs",
            description='NonResourceURLs is a set of partial urls that a user should have access to.  *s are allowed, but only as the full, final step in the path.  "*" means all.',
        ),
    ] = None
    verbs: Annotated[
        List[str],
        Field(
            description='Verb is a list of kubernetes non-resource API verbs, like: get, post, put, delete, patch, head, options.  "*" means all.'
        ),
    ]


class ResourceRule(BaseModel):
    api_groups: Annotated[
        Optional[List[str]],
        Field(
            alias="apiGroups",
            description='APIGroups is the name of the APIGroup that contains the resources.  If multiple API groups are specified, any action requested against one of the enumerated resources in any API group will be allowed.  "*" means all.',
        ),
    ] = None
    resource_names: Annotated[
        Optional[List[str]],
        Field(
            alias="resourceNames",
            description='ResourceNames is an optional white list of names that the rule applies to.  An empty set means that everything is allowed.  "*" means all.',
        ),
    ] = None
    resources: Annotated[
        Optional[List[str]],
        Field(
            description='Resources is a list of resources this rule applies to.  "*" means all in the specified apiGroups.\n "*/foo" represents the subresource \'foo\' for all resources in the specified apiGroups.'
        ),
    ] = None
    verbs: Annotated[
        List[str],
        Field(
            description='Verb is a list of kubernetes resource API verbs, like: get, list, watch, create, update, delete, proxy.  "*" means all.'
        ),
    ]


class SelfSubjectRulesReviewSpec(BaseModel):
    namespace: Annotated[
        Optional[str], Field(description="Namespace to evaluate rules for. Required.")
    ] = None


class SubjectAccessReviewStatus(BaseModel):
    allowed: Annotated[
        bool,
        Field(
            description="Allowed is required. True if the action would be allowed, false otherwise."
        ),
    ]
    denied: Annotated[
        Optional[bool],
        Field(
            description="Denied is optional. True if the action would be denied, otherwise false. If both allowed is false and denied is false, then the authorizer has no opinion on whether to authorize the action. Denied may not be true if Allowed is true."
        ),
    ] = None
    evaluation_error: Annotated[
        Optional[str],
        Field(
            alias="evaluationError",
            description="EvaluationError is an indication that some error occurred during the authorization check. It is entirely possible to get an error and be able to continue determine authorization status in spite of it. For instance, RBAC can be missing a role, but enough roles are still present and bound to reason about the request.",
        ),
    ] = None
    reason: Annotated[
        Optional[str],
        Field(description="Reason is optional.  It indicates why a request was allowed or denied."),
    ] = None


class SubjectRulesReviewStatus(BaseModel):
    evaluation_error: Annotated[
        Optional[str],
        Field(
            alias="evaluationError",
            description="EvaluationError can appear in combination with Rules. It indicates an error occurred during rule evaluation, such as an authorizer that doesn't support rule evaluation, and that ResourceRules and/or NonResourceRules may be incomplete.",
        ),
    ] = None
    incomplete: Annotated[
        bool,
        Field(
            description="Incomplete is true when the rules returned by this call are incomplete. This is most commonly encountered when an authorizer, such as an external authorizer, doesn't support rules evaluation."
        ),
    ]
    non_resource_rules: Annotated[
        List[NonResourceRule],
        Field(
            alias="nonResourceRules",
            description="NonResourceRules is the list of actions the subject is allowed to perform on non-resources. The list ordering isn't significant, may contain duplicates, and possibly be incomplete.",
        ),
    ]
    resource_rules: Annotated[
        List[ResourceRule],
        Field(
            alias="resourceRules",
            description="ResourceRules is the list of actions the subject is allowed to perform on resources. The list ordering isn't significant, may contain duplicates, and possibly be incomplete.",
        ),
    ]


class FieldSelectorAttributes(BaseModel):
    raw_selector: Annotated[
        Optional[str],
        Field(
            alias="rawSelector",
            description="rawSelector is the serialization of a field selector that would be included in a query parameter. Webhook implementations are encouraged to ignore rawSelector. The kube-apiserver's *SubjectAccessReview will parse the rawSelector as long as the requirements are not present.",
        ),
    ] = None
    requirements: Annotated[
        Optional[List[apimachinery.FieldSelectorRequirement]],
        Field(
            description="requirements is the parsed interpretation of a field selector. All requirements must be met for a resource instance to match the selector. Webhook implementations should handle requirements, but how to handle them is up to the webhook. Since requirements can only limit the request, it is safe to authorize as unlimited request if the requirements are not understood."
        ),
    ] = None


class LabelSelectorAttributes(BaseModel):
    raw_selector: Annotated[
        Optional[str],
        Field(
            alias="rawSelector",
            description="rawSelector is the serialization of a field selector that would be included in a query parameter. Webhook implementations are encouraged to ignore rawSelector. The kube-apiserver's *SubjectAccessReview will parse the rawSelector as long as the requirements are not present.",
        ),
    ] = None
    requirements: Annotated[
        Optional[List[apimachinery.LabelSelectorRequirement]],
        Field(
            description="requirements is the parsed interpretation of a label selector. All requirements must be met for a resource instance to match the selector. Webhook implementations should handle requirements, but how to handle them is up to the webhook. Since requirements can only limit the request, it is safe to authorize as unlimited request if the requirements are not understood."
        ),
    ] = None


class ResourceAttributes(BaseModel):
    field_selector: Annotated[
        Optional[FieldSelectorAttributes],
        Field(
            alias="fieldSelector",
            description="fieldSelector describes the limitation on access based on field.  It can only limit access, not broaden it.\n\nThis field  is alpha-level. To use this field, you must enable the `AuthorizeWithSelectors` feature gate (disabled by default).",
        ),
    ] = None
    group: Annotated[
        Optional[str],
        Field(description='Group is the API Group of the Resource.  "*" means all.'),
    ] = None
    label_selector: Annotated[
        Optional[LabelSelectorAttributes],
        Field(
            alias="labelSelector",
            description="labelSelector describes the limitation on access based on labels.  It can only limit access, not broaden it.\n\nThis field  is alpha-level. To use this field, you must enable the `AuthorizeWithSelectors` feature gate (disabled by default).",
        ),
    ] = None
    name: Annotated[
        Optional[str],
        Field(
            description='Name is the name of the resource being requested for a "get" or deleted for a "delete". "" (empty) means all.'
        ),
    ] = None
    namespace: Annotated[
        Optional[str],
        Field(
            description='Namespace is the namespace of the action being requested.  Currently, there is no distinction between no namespace and all namespaces "" (empty) is defaulted for LocalSubjectAccessReviews "" (empty) is empty for cluster-scoped resources "" (empty) means "all" for namespace scoped resources from a SubjectAccessReview or SelfSubjectAccessReview'
        ),
    ] = None
    resource: Annotated[
        Optional[str],
        Field(description='Resource is one of the existing resource types.  "*" means all.'),
    ] = None
    subresource: Annotated[
        Optional[str],
        Field(description='Subresource is one of the existing resource types.  "" means none.'),
    ] = None
    verb: Annotated[
        Optional[str],
        Field(
            description='Verb is a kubernetes resource API verb, like: get, list, watch, create, update, delete, proxy.  "*" means all.'
        ),
    ] = None
    version: Annotated[
        Optional[str],
        Field(description='Version is the API Version of the Resource.  "*" means all.'),
    ] = None


class SelfSubjectAccessReviewSpec(BaseModel):
    non_resource_attributes: Annotated[
        Optional[NonResourceAttributes],
        Field(
            alias="nonResourceAttributes",
            description="NonResourceAttributes describes information for a non-resource access request",
        ),
    ] = None
    resource_attributes: Annotated[
        Optional[ResourceAttributes],
        Field(
            alias="resourceAttributes",
            description="ResourceAuthorizationAttributes describes information for a resource access request",
        ),
    ] = None


class SubjectAccessReviewSpec(BaseModel):
    extra: Annotated[
        Optional[Dict[str, List[str]]],
        Field(
            description="Extra corresponds to the user.Info.GetExtra() method from the authenticator.  Since that is input to the authorizer it needs a reflection here."
        ),
    ] = None
    groups: Annotated[
        Optional[List[str]],
        Field(description="Groups is the groups you're testing for."),
    ] = None
    non_resource_attributes: Annotated[
        Optional[NonResourceAttributes],
        Field(
            alias="nonResourceAttributes",
            description="NonResourceAttributes describes information for a non-resource access request",
        ),
    ] = None
    resource_attributes: Annotated[
        Optional[ResourceAttributes],
        Field(
            alias="resourceAttributes",
            description="ResourceAuthorizationAttributes describes information for a resource access request",
        ),
    ] = None
    uid: Annotated[
        Optional[str], Field(description="UID information about the requesting user.")
    ] = None
    user: Annotated[
        Optional[str],
        Field(
            description='User is the user you\'re testing for. If you specify "User" but not "Groups", then is it interpreted as "What if User were not a member of any groups'
        ),
    ] = None


class LocalSubjectAccessReview(Resource):
    api_version: Annotated[
        Optional[Literal["authorization.k8s.io/v1"]],
        Field(
            alias="apiVersion",
            description="APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources",
        ),
    ] = "authorization.k8s.io/v1"
    kind: Annotated[
        Optional[Literal["LocalSubjectAccessReview"]],
        Field(
            description="Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds"
        ),
    ] = "LocalSubjectAccessReview"
    metadata: Annotated[
        Optional[apimachinery.ObjectMeta],
        Field(
            description="Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata"
        ),
    ] = None
    spec: Annotated[
        SubjectAccessReviewSpec,
        Field(
            description="Spec holds information about the request being evaluated.  spec.namespace must be equal to the namespace you made the request against.  If empty, it is defaulted."
        ),
    ]
    status: Annotated[
        Optional[SubjectAccessReviewStatus],
        Field(
            description="Status is filled in by the server and indicates whether the request is allowed or not"
        ),
    ] = None


class SelfSubjectAccessReview(Resource):
    api_version: Annotated[
        Optional[Literal["authorization.k8s.io/v1"]],
        Field(
            alias="apiVersion",
            description="APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources",
        ),
    ] = "authorization.k8s.io/v1"
    kind: Annotated[
        Optional[Literal["SelfSubjectAccessReview"]],
        Field(
            description="Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds"
        ),
    ] = "SelfSubjectAccessReview"
    metadata: Annotated[
        Optional[apimachinery.ObjectMeta],
        Field(
            description="Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata"
        ),
    ] = None
    spec: Annotated[
        SelfSubjectAccessReviewSpec,
        Field(
            description="Spec holds information about the request being evaluated.  user and groups must be empty"
        ),
    ]
    status: Annotated[
        Optional[SubjectAccessReviewStatus],
        Field(
            description="Status is filled in by the server and indicates whether the request is allowed or not"
        ),
    ] = None


class SelfSubjectRulesReview(Resource):
    api_version: Annotated[
        Optional[Literal["authorization.k8s.io/v1"]],
        Field(
            alias="apiVersion",
            description="APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources",
        ),
    ] = "authorization.k8s.io/v1"
    kind: Annotated[
        Optional[Literal["SelfSubjectRulesReview"]],
        Field(
            description="Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds"
        ),
    ] = "SelfSubjectRulesReview"
    metadata: Annotated[
        Optional[apimachinery.ObjectMeta],
        Field(
            description="Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata"
        ),
    ] = None
    spec: Annotated[
        SelfSubjectRulesReviewSpec,
        Field(description="Spec holds information about the request being evaluated."),
    ]
    status: Annotated[
        Optional[SubjectRulesReviewStatus],
        Field(
            description="Status is filled in by the server and indicates the set of actions a user can perform."
        ),
    ] = None


class SubjectAccessReview(Resource):
    api_version: Annotated[
        Optional[Literal["authorization.k8s.io/v1"]],
        Field(
            alias="apiVersion",
            description="APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources",
        ),
    ] = "authorization.k8s.io/v1"
    kind: Annotated[
        Optional[Literal["SubjectAccessReview"]],
        Field(
            description="Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds"
        ),
    ] = "SubjectAccessReview"
    metadata: Annotated[
        Optional[apimachinery.ObjectMeta],
        Field(
            description="Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata"
        ),
    ] = None
    spec: Annotated[
        SubjectAccessReviewSpec,
        Field(description="Spec holds information about the request being evaluated"),
    ]
    status: Annotated[
        Optional[SubjectAccessReviewStatus],
        Field(
            description="Status is filled in by the server and indicates whether the request is allowed or not"
        ),
    ] = None
