# coding: utf-8

"""
    HashiCorp Vault API

    HTTP API that gives you full access to Vault. All API routes are prefixed with `/v1/`.

    The version of the OpenAPI document: 1.15.0
    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 pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from typing import Optional, Set
from typing_extensions import Self

class AwsWriteRoleTagRequest(BaseModel):
    """
    AwsWriteRoleTagRequest
    """ # noqa: E501
    allow_instance_migration: Optional[StrictBool] = Field(default=False, description="If set, allows migration of the underlying instance where the client resides. This keys off of pendingTime in the metadata document, so essentially, this disables the client nonce check whenever the instance is migrated to a new host and pendingTime is newer than the previously-remembered time. Use with caution.")
    disallow_reauthentication: Optional[StrictBool] = Field(default=False, description="If set, only allows a single token to be granted per instance ID. In order to perform a fresh login, the entry in access list for the instance ID needs to be cleared using the 'auth/aws-ec2/identity-accesslist/<instance_id>' endpoint.")
    instance_id: Optional[StrictStr] = Field(default=None, description="Instance ID for which this tag is intended for. If set, the created tag can only be used by the instance with the given ID.")
    max_ttl: Optional[StrictStr] = Field(default='0', description="If set, specifies the maximum allowed token lifetime.")
    policies: Optional[List[StrictStr]] = Field(default=None, description="Policies to be associated with the tag. If set, must be a subset of the role's policies. If set, but set to an empty value, only the 'default' policy will be given to issued tokens.")
    __properties: ClassVar[List[str]] = ["allow_instance_migration", "disallow_reauthentication", "instance_id", "max_ttl", "policies"]

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
    )


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

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
        return json.dumps(self.to_dict())

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

    def to_dict(self) -> Dict[str, Any]:
        """Return the dictionary representation of the model using alias.

        This has the following differences from calling pydantic's
        `self.model_dump(by_alias=True)`:

        * `None` is only added to the output dict for nullable fields that
          were set at model initialization. Other fields with value `None`
          are ignored.
        """
        excluded_fields: Set[str] = set([
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of AwsWriteRoleTagRequest from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return cls.model_validate(obj)

        _obj = cls.model_validate({
            "allow_instance_migration": obj.get("allow_instance_migration") if obj.get("allow_instance_migration") is not None else False,
            "disallow_reauthentication": obj.get("disallow_reauthentication") if obj.get("disallow_reauthentication") is not None else False,
            "instance_id": obj.get("instance_id"),
            "max_ttl": obj.get("max_ttl") if obj.get("max_ttl") is not None else '0',
            "policies": obj.get("policies")
        })
        return _obj


