# coding: utf-8
"""
    Snowflake Role API

    The Snowflake Role API is a REST API that you can use to access, update, and perform certain action on Roles in a Snowflake database.  # noqa: E501

    The version of the OpenAPI document: 0.0.1
    Contact: support@snowflake.com
    Generated by: https://openapi-generator.tech

    Do not edit this file manually.
"""

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

from typing import Union

from datetime import datetime

from pydantic import BaseModel, ConfigDict, StrictBool, StrictInt, StrictStr

from typing import Any, ClassVar, Dict, List, Optional


class Role(BaseModel):

    name: StrictStr

    comment: Optional[StrictStr] = None

    created_on: Optional[datetime] = None

    is_default: Optional[StrictBool] = None

    is_current: Optional[StrictBool] = None

    is_inherited: Optional[StrictBool] = None

    assigned_to_users: Optional[StrictInt] = None

    granted_to_roles: Optional[StrictInt] = None

    granted_roles: Optional[StrictInt] = None

    owner: Optional[StrictStr] = None

    __properties = [
        "name", "comment", "created_on", "is_default", "is_current",
        "is_inherited", "assigned_to_users", "granted_to_roles",
        "granted_roles", "owner"
    ]

    class Config:
        populate_by_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) -> Role:
        """Create an instance of Role 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 = dict(
            self._iter(to_dict=True,
                       by_alias=True,
                       exclude={
                           "created_on",
                           "is_default",
                           "is_current",
                           "is_inherited",
                           "assigned_to_users",
                           "granted_to_roles",
                           "granted_roles",
                           "owner",
                       },
                       exclude_none=True))

        return _dict

    @classmethod
    def from_dict(cls, obj: dict) -> Role:
        """Create an instance of Role from a dict"""

        if obj is None:
            return None

        if type(obj) is not dict:
            return Role.parse_obj(obj)

        _obj = Role.parse_obj({
            "name": obj.get("name"),
            "comment": obj.get("comment"),
            "created_on": obj.get("created_on"),
            "is_default": obj.get("is_default"),
            "is_current": obj.get("is_current"),
            "is_inherited": obj.get("is_inherited"),
            "assigned_to_users": obj.get("assigned_to_users"),
            "granted_to_roles": obj.get("granted_to_roles"),
            "granted_roles": obj.get("granted_roles"),
            "owner": obj.get("owner"),
        })

        return _obj


from typing import Optional, List, Dict


class RoleModel():

    def __init__(
        self,
        name: str,
        # optional properties
        comment: Optional[str] = None,
        created_on: Optional[datetime] = None,
        is_default: Optional[bool] = None,
        is_current: Optional[bool] = None,
        is_inherited: Optional[bool] = None,
        assigned_to_users: Optional[int] = None,
        granted_to_roles: Optional[int] = None,
        granted_roles: Optional[int] = None,
        owner: Optional[str] = None,
    ):

        self.name = name
        self.comment = comment
        self.created_on = created_on
        self.is_default = is_default
        self.is_current = is_current
        self.is_inherited = is_inherited
        self.assigned_to_users = assigned_to_users
        self.granted_to_roles = granted_to_roles
        self.granted_roles = granted_roles
        self.owner = owner

    __properties = [
        "name", "comment", "created_on", "is_default", "is_current",
        "is_inherited", "assigned_to_users", "granted_to_roles",
        "granted_roles", "owner"
    ]

    def _to_model(self):
        return Role(
            name=self.name,
            comment=self.comment,
            created_on=self.created_on,
            is_default=self.is_default,
            is_current=self.is_current,
            is_inherited=self.is_inherited,
            assigned_to_users=self.assigned_to_users,
            granted_to_roles=self.granted_to_roles,
            granted_roles=self.granted_roles,
            owner=self.owner,
        )

    @classmethod
    def _from_model(cls, model) -> RoleModel:
        return RoleModel(
            name=model.name,
            comment=model.comment,
            created_on=model.created_on,
            is_default=model.is_default,
            is_current=model.is_current,
            is_inherited=model.is_inherited,
            assigned_to_users=model.assigned_to_users,
            granted_to_roles=model.granted_to_roles,
            granted_roles=model.granted_roles,
            owner=model.owner,
        )

    def to_dict(self):
        """Returns the dictionary representation of the model using alias"""
        return self._to_model().to_dict()

    @classmethod
    def from_dict(cls, obj: dict) -> RoleModel:
        """Create an instance of Role from a dict"""
        return cls._from_model(Role.from_dict(obj))


Role._model_class = RoleModel
