# coding: utf-8

"""
    Cochl.Sense API

    Cochl.Sense API allows to detect what is contained inside sound data. Send audio data over the internet to discover what it contains. 

    The version of the OpenAPI document: v1.7.11
    Contact: support@cochl.ai
    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, StrictFloat, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional, Union
from typing_extensions import Annotated
from cochl_sense_api.models.session_type import SessionType
from typing import Optional, Set
from typing_extensions import Self

class CreateSession(BaseModel):
    """
    Options to create a new session. 
    """ # noqa: E501
    type: SessionType
    content_type: StrictStr = Field(description="Type of audio to send.  There are three options for file format audio: `audio/mp3`, `audio/wav`, `audio/ogg`.  For raw PCM data, you can use this foramt: `audio/x-raw; rate={sample_rate}; format={sample_format}` For example, when sample rate is 22,050Hz and sample format is signed 24-bit little-endian, `content_type` should be `audio/x-raw; rate=22050; format=s24le`.  Supported sample formats are:   - `s16le`, `s24le`, `s32le`, `s16be`, `s24be`, `s32be`   - `u16le`, `u24le`, `u32le`, `u16be`, `u24be`, `u32be`   - `f16le`, `f24le`, `f32le`, `f16be`, `f24be`, `f32be` ")
    tags_sensitivity: Optional[Dict[str, Annotated[int, Field(le=2, strict=True, ge=-2)]]] = Field(default=None, description="If set, it allows to adjust the sensitivity of a given tag [in this list](https://docs.cochl.ai/sense/tags/)  The sensitivity adjustment ranges in [-2,2]  A value of 0 preserves the default sensitivity  Positive value reduces tag appearance, negative value increases it ")
    default_sensitivity: Optional[Annotated[int, Field(le=2, strict=True, ge=-2)]] = Field(default=0, description="If set, it allows to provide a default adjusted sensitivity for all tags  The sensitivity adjustment ranges in [-2,2]  0 is used if not set  Positive value reduces tag appearance, negative value increases it ")
    total_size: Optional[StrictInt] = Field(default=None, description="(for File Session only)  The byte size of the file to be uploaded to this Session. Cochl.Sense determines if all file chunks are uploaded baased on the value set here. ")
    file_name: Optional[StrictStr] = Field(default=None, description="(for File Session only)  The name of the file to be uploaded to this Session. ")
    file_length: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="(for File Session only)  The float length (second unit) of the file to be uploaded to this Session. ")
    window_hop: Optional[StrictStr] = Field(default=None, description="(deprecated)  ~If set, it allows to adjust the sensitivity of a given tag [in this list]~  ~The window hop adjustment can be set eith to 0.5s or 1s~  ~By default, this value is set to 0.5s~ ")
    __properties: ClassVar[List[str]] = ["type", "content_type", "tags_sensitivity", "default_sensitivity", "total_size", "file_name", "file_length", "window_hop"]

    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 CreateSession 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 CreateSession 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"),
            "content_type": obj.get("content_type"),
            "tags_sensitivity": obj.get("tags_sensitivity"),
            "default_sensitivity": obj.get("default_sensitivity") if obj.get("default_sensitivity") is not None else 0,
            "total_size": obj.get("total_size"),
            "file_name": obj.get("file_name"),
            "file_length": obj.get("file_length"),
            "window_hop": obj.get("window_hop")
        })
        return _obj


