# generated by datamodel-codegen:
#   timestamp: 2024-04-28T19:06:26+00:00
#   k8s version: v1.30.0

from __future__ import annotations

from typing import List, Optional

from pydantic import BaseModel, Field

from ...apimachinery.pkg.apis.meta import v1


class PolicyRule(BaseModel):
    apiGroups: Optional[List[str]] = Field(
        default=None,
        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. "" represents'
            ' the core API group and "*" represents all API groups.'
        ),
    )
    nonResourceURLs: Optional[List[str]] = Field(
        default=None,
        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 Since"
            " non-resource URLs are not namespaced, this field is only applicable for"
            " ClusterRoles referenced from a ClusterRoleBinding. Rules can either apply"
            ' to API resources (such as "pods" or "secrets") or non-resource URL paths'
            ' (such as "/api"),  but not both.'
        ),
    )
    resourceNames: Optional[List[str]] = Field(
        default=None,
        description=(
            "ResourceNames is an optional white list of names that the rule applies to."
            "  An empty set means that everything is allowed."
        ),
    )
    resources: Optional[List[str]] = Field(
        default=None,
        description=(
            "Resources is a list of resources this rule applies to. '*' represents all"
            " resources."
        ),
    )
    verbs: List[str] = Field(
        ...,
        description=(
            "Verbs is a list of Verbs that apply to ALL the ResourceKinds contained in"
            " this rule. '*' represents all verbs."
        ),
    )


class RoleRef(BaseModel):
    apiGroup: str = Field(
        ..., description="APIGroup is the group for the resource being referenced"
    )
    kind: str = Field(..., description="Kind is the type of resource being referenced")
    name: str = Field(..., description="Name is the name of resource being referenced")


class Subject(BaseModel):
    apiGroup: Optional[str] = Field(
        default=None,
        description=(
            'APIGroup holds the API group of the referenced subject. Defaults to "" for'
            ' ServiceAccount subjects. Defaults to "rbac.authorization.k8s.io" for User'
            " and Group subjects."
        ),
    )
    kind: str = Field(
        ...,
        description=(
            "Kind of object being referenced. Values defined by this API group are"
            ' "User", "Group", and "ServiceAccount". If the Authorizer does not'
            " recognized the kind value, the Authorizer should report an error."
        ),
    )
    name: str = Field(..., description="Name of the object being referenced.")
    namespace: Optional[str] = Field(
        default=None,
        description=(
            "Namespace of the referenced object.  If the object kind is non-namespace,"
            ' such as "User" or "Group", and this value is not empty the Authorizer'
            " should report an error."
        ),
    )


class AggregationRule(BaseModel):
    clusterRoleSelectors: Optional[List[v1.LabelSelector]] = Field(
        default=None,
        description=(
            "ClusterRoleSelectors holds a list of selectors which will be used to find"
            " ClusterRoles and create the rules. If any of the selectors match, then"
            " the ClusterRole's permissions will be added"
        ),
    )


class ClusterRole(BaseModel):
    aggregationRule: Optional[AggregationRule] = Field(
        default=None,
        description=(
            "AggregationRule is an optional field that describes how to build the Rules"
            " for this ClusterRole. If AggregationRule is set, then the Rules are"
            " controller managed and direct changes to Rules will be stomped by the"
            " controller."
        ),
    )
    apiVersion: Optional[str] = Field(
        default="rbac.authorization.k8s.io/v1",
        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"
        ),
    )
    kind: Optional[str] = Field(
        default="ClusterRole",
        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"
        ),
    )
    metadata: Optional[v1.ObjectMeta] = Field(
        default=None, description="Standard object's metadata."
    )
    rules: Optional[List[PolicyRule]] = Field(
        default=None, description="Rules holds all the PolicyRules for this ClusterRole"
    )


class ClusterRoleBinding(BaseModel):
    apiVersion: Optional[str] = Field(
        default="rbac.authorization.k8s.io/v1",
        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"
        ),
    )
    kind: Optional[str] = Field(
        default="ClusterRoleBinding",
        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"
        ),
    )
    metadata: Optional[v1.ObjectMeta] = Field(
        default=None, description="Standard object's metadata."
    )
    roleRef: RoleRef = Field(
        ...,
        description=(
            "RoleRef can only reference a ClusterRole in the global namespace. If the"
            " RoleRef cannot be resolved, the Authorizer must return an error. This"
            " field is immutable."
        ),
    )
    subjects: Optional[List[Subject]] = Field(
        default=None,
        description="Subjects holds references to the objects the role applies to.",
    )


class ClusterRoleBindingList(BaseModel):
    apiVersion: Optional[str] = Field(
        default="rbac.authorization.k8s.io/v1",
        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"
        ),
    )
    items: List[ClusterRoleBinding] = Field(
        ..., description="Items is a list of ClusterRoleBindings"
    )
    kind: Optional[str] = Field(
        default="ClusterRoleBindingList",
        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"
        ),
    )
    metadata: Optional[v1.ListMeta] = Field(
        default=None, description="Standard object's metadata."
    )


class ClusterRoleList(BaseModel):
    apiVersion: Optional[str] = Field(
        default="rbac.authorization.k8s.io/v1",
        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"
        ),
    )
    items: List[ClusterRole] = Field(..., description="Items is a list of ClusterRoles")
    kind: Optional[str] = Field(
        default="ClusterRoleList",
        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"
        ),
    )
    metadata: Optional[v1.ListMeta] = Field(
        default=None, description="Standard object's metadata."
    )


class Role(BaseModel):
    apiVersion: Optional[str] = Field(
        default="rbac.authorization.k8s.io/v1",
        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"
        ),
    )
    kind: Optional[str] = Field(
        default="Role",
        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"
        ),
    )
    metadata: Optional[v1.ObjectMeta] = Field(
        default=None, description="Standard object's metadata."
    )
    rules: Optional[List[PolicyRule]] = Field(
        default=None, description="Rules holds all the PolicyRules for this Role"
    )


class RoleBinding(BaseModel):
    apiVersion: Optional[str] = Field(
        default="rbac.authorization.k8s.io/v1",
        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"
        ),
    )
    kind: Optional[str] = Field(
        default="RoleBinding",
        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"
        ),
    )
    metadata: Optional[v1.ObjectMeta] = Field(
        default=None, description="Standard object's metadata."
    )
    roleRef: RoleRef = Field(
        ...,
        description=(
            "RoleRef can reference a Role in the current namespace or a ClusterRole in"
            " the global namespace. If the RoleRef cannot be resolved, the Authorizer"
            " must return an error. This field is immutable."
        ),
    )
    subjects: Optional[List[Subject]] = Field(
        default=None,
        description="Subjects holds references to the objects the role applies to.",
    )


class RoleBindingList(BaseModel):
    apiVersion: Optional[str] = Field(
        default="rbac.authorization.k8s.io/v1",
        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"
        ),
    )
    items: List[RoleBinding] = Field(..., description="Items is a list of RoleBindings")
    kind: Optional[str] = Field(
        default="RoleBindingList",
        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"
        ),
    )
    metadata: Optional[v1.ListMeta] = Field(
        default=None, description="Standard object's metadata."
    )


class RoleList(BaseModel):
    apiVersion: Optional[str] = Field(
        default="rbac.authorization.k8s.io/v1",
        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"
        ),
    )
    items: List[Role] = Field(..., description="Items is a list of Roles")
    kind: Optional[str] = Field(
        default="RoleList",
        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"
        ),
    )
    metadata: Optional[v1.ListMeta] = Field(
        default=None, description="Standard object's metadata."
    )
