# 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, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from typing import Optional, Set
from typing_extensions import Self

class AwsWriteRoleRequest(BaseModel):
    """
    AwsWriteRoleRequest
    """ # noqa: E501
    arn: Optional[StrictStr] = Field(default=None, description="Use role_arns or policy_arns instead.")
    credential_type: Optional[StrictStr] = Field(default=None, description="Type of credential to retrieve. Must be one of assumed_role, iam_user, or federation_token")
    default_sts_ttl: Optional[StrictStr] = Field(default=None, description="Default TTL for assumed_role and federation_token credential types when no TTL is explicitly requested with the credentials")
    iam_groups: Optional[List[StrictStr]] = Field(default=None, description="Names of IAM groups that generated IAM users will be added to. For a credential type of assumed_role or federation_token, the policies sent to the corresponding AWS call (sts:AssumeRole or sts:GetFederation) will be the policies from each group in iam_groups combined with the policy_document and policy_arns parameters.")
    iam_tags: Optional[Dict[str, Any]] = Field(default=None, description="IAM tags to be set for any users created by this role. These must be presented as Key-Value pairs. This can be represented as a map or a list of equal sign delimited key pairs.")
    max_sts_ttl: Optional[StrictStr] = Field(default=None, description="Max allowed TTL for assumed_role and federation_token credential types")
    permissions_boundary_arn: Optional[StrictStr] = Field(default=None, description="ARN of an IAM policy to attach as a permissions boundary on IAM user credentials; only valid when credential_type isiam_user")
    policy: Optional[StrictStr] = Field(default=None, description="Use policy_document instead.")
    policy_arns: Optional[List[StrictStr]] = Field(default=None, description="ARNs of AWS policies. Behavior varies by credential_type. When credential_type is iam_user, then it will attach the specified policies to the generated IAM user. When credential_type is assumed_role or federation_token, the policies will be passed as the PolicyArns parameter, acting as a filter on permissions available.")
    policy_document: Optional[StrictStr] = Field(default=None, description="JSON-encoded IAM policy document. Behavior varies by credential_type. When credential_type is iam_user, then it will attach the contents of the policy_document to the IAM user generated. When credential_type is assumed_role or federation_token, this will be passed in as the Policy parameter to the AssumeRole or GetFederationToken API call, acting as a filter on permissions available.")
    role_arns: Optional[List[StrictStr]] = Field(default=None, description="ARNs of AWS roles allowed to be assumed. Only valid when credential_type is assumed_role")
    user_path: Optional[StrictStr] = Field(default='/', description="Path for IAM User. Only valid when credential_type is iam_user")
    __properties: ClassVar[List[str]] = ["arn", "credential_type", "default_sts_ttl", "iam_groups", "iam_tags", "max_sts_ttl", "permissions_boundary_arn", "policy", "policy_arns", "policy_document", "role_arns", "user_path"]

    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 AwsWriteRoleRequest 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 AwsWriteRoleRequest from a dict"""
        if obj is None:
            return None

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

        _obj = cls.model_validate({
            "arn": obj.get("arn"),
            "credential_type": obj.get("credential_type"),
            "default_sts_ttl": obj.get("default_sts_ttl"),
            "iam_groups": obj.get("iam_groups"),
            "iam_tags": obj.get("iam_tags"),
            "max_sts_ttl": obj.get("max_sts_ttl"),
            "permissions_boundary_arn": obj.get("permissions_boundary_arn"),
            "policy": obj.get("policy"),
            "policy_arns": obj.get("policy_arns"),
            "policy_document": obj.get("policy_document"),
            "role_arns": obj.get("role_arns"),
            "user_path": obj.get("user_path") if obj.get("user_path") is not None else '/'
        })
        return _obj


