# coding: utf-8

"""
    Kubernetes

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

    The version of the OpenAPI document: release-1.29
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501


from __future__ import annotations
import pprint
import re  # noqa: F401
import json


from typing import List, Optional
from pydantic import BaseModel, Field, StrictBool, StrictStr, conlist
from .v1_user_info import V1UserInfo

class V1TokenReviewStatus(BaseModel):
    """
    TokenReviewStatus is the result of the token authentication request.  # noqa: E501
    """
    audiences: Optional[conlist(StrictStr)] = Field(None, description="Audiences are audience identifiers chosen by the authenticator that are compatible with both the TokenReview and token. An identifier is any identifier in the intersection of the TokenReviewSpec audiences and the token's audiences. A client of the TokenReview API that sets the spec.audiences field should validate that a compatible audience identifier is returned in the status.audiences field to ensure that the TokenReview server is audience aware. If a TokenReview returns an empty status.audience field where status.authenticated is \"true\", the token is valid against the audience of the Kubernetes API server.")
    authenticated: Optional[StrictBool] = Field(None, description="Authenticated indicates that the token was associated with a known user.")
    error: Optional[StrictStr] = Field(None, description="Error indicates that the token couldn't be checked")
    user: Optional[V1UserInfo] = None
    __properties = ["audiences", "authenticated", "error", "user"]

    class Config:
        """Pydantic configuration"""
        allow_population_by_field_name = True
        validate_assignment = True

    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.dict(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> V1TokenReviewStatus:
        """Create an instance of V1TokenReviewStatus from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self):
        """Returns the dictionary representation of the model using alias"""
        _dict = self.dict(by_alias=True,
                          exclude={
                          },
                          exclude_none=True)
        # override the default output from pydantic by calling `to_dict()` of user
        if self.user:
            _dict['user'] = self.user.to_dict()
        return _dict

    @classmethod
    def from_dict(cls, obj: dict) -> V1TokenReviewStatus:
        """Create an instance of V1TokenReviewStatus from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return V1TokenReviewStatus.parse_obj(obj)

        _obj = V1TokenReviewStatus.parse_obj({
            "audiences": obj.get("audiences"),
            "authenticated": obj.get("authenticated"),
            "error": obj.get("error"),
            "user": V1UserInfo.from_dict(obj.get("user")) if obj.get("user") is not None else None
        })
        return _obj


