# coding: utf-8

"""
    Infisical API

    List of all available APIs that can be consumed

    The version of the OpenAPI document: 0.0.1
    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 datetime import datetime
from typing import Optional
from pydantic import BaseModel, Field, StrictBool, StrictStr

class ApiV1WorkspaceWorkspaceIdUsersGet200ResponseUsersInnerRolesInner(BaseModel):
    """
    ApiV1WorkspaceWorkspaceIdUsersGet200ResponseUsersInnerRolesInner
    """
    id: StrictStr = Field(...)
    role: StrictStr = Field(...)
    custom_role_id: Optional[StrictStr] = Field(default=None, alias="customRoleId")
    custom_role_name: Optional[StrictStr] = Field(default=None, alias="customRoleName")
    custom_role_slug: Optional[StrictStr] = Field(default=None, alias="customRoleSlug")
    is_temporary: StrictBool = Field(default=..., alias="isTemporary")
    temporary_mode: Optional[StrictStr] = Field(default=None, alias="temporaryMode")
    temporary_range: Optional[StrictStr] = Field(default=None, alias="temporaryRange")
    temporary_access_start_time: Optional[datetime] = Field(default=None, alias="temporaryAccessStartTime")
    temporary_access_end_time: Optional[datetime] = Field(default=None, alias="temporaryAccessEndTime")
    __properties = ["id", "role", "customRoleId", "customRoleName", "customRoleSlug", "isTemporary", "temporaryMode", "temporaryRange", "temporaryAccessStartTime", "temporaryAccessEndTime"]

    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) -> ApiV1WorkspaceWorkspaceIdUsersGet200ResponseUsersInnerRolesInner:
        """Create an instance of ApiV1WorkspaceWorkspaceIdUsersGet200ResponseUsersInnerRolesInner 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)
        # set to None if custom_role_id (nullable) is None
        # and __fields_set__ contains the field
        if self.custom_role_id is None and "custom_role_id" in self.__fields_set__:
            _dict['customRoleId'] = None

        # set to None if custom_role_name (nullable) is None
        # and __fields_set__ contains the field
        if self.custom_role_name is None and "custom_role_name" in self.__fields_set__:
            _dict['customRoleName'] = None

        # set to None if custom_role_slug (nullable) is None
        # and __fields_set__ contains the field
        if self.custom_role_slug is None and "custom_role_slug" in self.__fields_set__:
            _dict['customRoleSlug'] = None

        # set to None if temporary_mode (nullable) is None
        # and __fields_set__ contains the field
        if self.temporary_mode is None and "temporary_mode" in self.__fields_set__:
            _dict['temporaryMode'] = None

        # set to None if temporary_range (nullable) is None
        # and __fields_set__ contains the field
        if self.temporary_range is None and "temporary_range" in self.__fields_set__:
            _dict['temporaryRange'] = None

        # set to None if temporary_access_start_time (nullable) is None
        # and __fields_set__ contains the field
        if self.temporary_access_start_time is None and "temporary_access_start_time" in self.__fields_set__:
            _dict['temporaryAccessStartTime'] = None

        # set to None if temporary_access_end_time (nullable) is None
        # and __fields_set__ contains the field
        if self.temporary_access_end_time is None and "temporary_access_end_time" in self.__fields_set__:
            _dict['temporaryAccessEndTime'] = None

        return _dict

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

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

        _obj = ApiV1WorkspaceWorkspaceIdUsersGet200ResponseUsersInnerRolesInner.parse_obj({
            "id": obj.get("id"),
            "role": obj.get("role"),
            "custom_role_id": obj.get("customRoleId"),
            "custom_role_name": obj.get("customRoleName"),
            "custom_role_slug": obj.get("customRoleSlug"),
            "is_temporary": obj.get("isTemporary"),
            "temporary_mode": obj.get("temporaryMode"),
            "temporary_range": obj.get("temporaryRange"),
            "temporary_access_start_time": obj.get("temporaryAccessStartTime"),
            "temporary_access_end_time": obj.get("temporaryAccessEndTime")
        })
        return _obj


