# coding: utf-8

"""
    Mender API

    Combined API specification for the features of the different Mender backend services, suitable for code generation applications 

    The version of the OpenAPI document: 1
    Contact: support@mender.io
    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, field_validator
from typing import Any, ClassVar, Dict, List, Optional
from typing import Optional, Set
from typing_extensions import Self

class StorageSettings(BaseModel):
    """
    Per tenant storage settings.
    """ # noqa: E501
    type: Optional[StrictStr] = Field(default=None, description="The storage provider type 'azure' Blob storage or AWS 's3' (defaults to s3).")
    region: Optional[StrictStr] = Field(default=None, description="AWS region (S3 only: required).")
    bucket: StrictStr = Field(description="S3 Bucket (Azure: container) name.")
    uri: Optional[StrictStr] = Field(default=None, description="Bucket/container endpoint URI.")
    external_uri: Optional[StrictStr] = Field(default=None, description="Public Endpoint URI for presigning URLs (S3 only).")
    key: StrictStr = Field(description="Access key identifier (Azure: account name).")
    secret: StrictStr = Field(description="Secret access key (Azure: access key).")
    token: Optional[StrictStr] = Field(default=None, description="AWS S3 session token (S3 only).")
    force_path_style: Optional[StrictBool] = Field(default=None, description="Force S3 path-style instead of virtual-hosted style (S3 only).")
    use_accelerate: Optional[StrictBool] = Field(default=None, description="Enable S3 Transfer acceleration (S3 only).")
    connection_string: Optional[StrictStr] = Field(default=None, description="Shared access key connection string (Azure only).")
    container_name: Optional[StrictStr] = Field(default=None, description="Alias for 'bucket' (Azure only).")
    account_name: Optional[StrictStr] = Field(default=None, description="Alias for 'key' (Azure only).")
    account_key: Optional[StrictStr] = Field(default=None, description="Alias for 'secret' (Azure only).")
    __properties: ClassVar[List[str]] = ["type", "region", "bucket", "uri", "external_uri", "key", "secret", "token", "force_path_style", "use_accelerate", "connection_string", "container_name", "account_name", "account_key"]

    @field_validator('type')
    def type_validate_enum(cls, value):
        """Validates the enum"""
        if value is None:
            return value

        if value not in set(['s3', 'azure']):
            raise ValueError("must be one of enum values ('s3', 'azure')")
        return value

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

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

        _obj = cls.model_validate({
            "type": obj.get("type"),
            "region": obj.get("region"),
            "bucket": obj.get("bucket"),
            "uri": obj.get("uri"),
            "external_uri": obj.get("external_uri"),
            "key": obj.get("key"),
            "secret": obj.get("secret"),
            "token": obj.get("token"),
            "force_path_style": obj.get("force_path_style"),
            "use_accelerate": obj.get("use_accelerate"),
            "connection_string": obj.get("connection_string"),
            "container_name": obj.get("container_name"),
            "account_name": obj.get("account_name"),
            "account_key": obj.get("account_key")
        })
        return _obj


