# coding: utf-8

"""
    Google Drive API

    The Google Drive API allows clients to access resources from Google Drive.

    The version of the OpenAPI document: v3
    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, StrictFloat, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional, Union
from google_drive_ti.models.file_image_media_metadata_location import FileImageMediaMetadataLocation
from typing import Optional, Set
from typing_extensions import Self

class FileImageMediaMetadata(BaseModel):
    """
    Output only. Additional metadata about image media, if available.
    """ # noqa: E501
    aperture: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Output only. The aperture used to create the photo (f-number).")
    camera_make: Optional[StrictStr] = Field(default=None, description="Output only. The make of the camera used to create the photo.", alias="cameraMake")
    camera_model: Optional[StrictStr] = Field(default=None, description="Output only. The model of the camera used to create the photo.", alias="cameraModel")
    color_space: Optional[StrictStr] = Field(default=None, description="Output only. The color space of the photo.", alias="colorSpace")
    exposure_bias: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Output only. The exposure bias of the photo (APEX value).", alias="exposureBias")
    exposure_mode: Optional[StrictStr] = Field(default=None, description="Output only. The exposure mode used to create the photo.", alias="exposureMode")
    exposure_time: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Output only. The length of the exposure, in seconds.", alias="exposureTime")
    flash_used: Optional[StrictBool] = Field(default=None, description="Output only. Whether a flash was used to create the photo.", alias="flashUsed")
    focal_length: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Output only. The focal length used to create the photo, in millimeters.", alias="focalLength")
    height: Optional[StrictInt] = Field(default=None, description="Output only. The height of the image in pixels.")
    iso_speed: Optional[StrictInt] = Field(default=None, description="Output only. The ISO speed used to create the photo.", alias="isoSpeed")
    lens: Optional[StrictStr] = Field(default=None, description="Output only. The lens used to create the photo.")
    location: Optional[FileImageMediaMetadataLocation] = None
    max_aperture_value: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Output only. The smallest f-number of the lens at the focal length used to create the photo (APEX value).", alias="maxApertureValue")
    metering_mode: Optional[StrictStr] = Field(default=None, description="Output only. The metering mode used to create the photo.", alias="meteringMode")
    rotation: Optional[StrictInt] = Field(default=None, description="Output only. The number of clockwise 90 degree rotations applied from the image's original orientation.")
    sensor: Optional[StrictStr] = Field(default=None, description="Output only. The type of sensor used to create the photo.")
    subject_distance: Optional[StrictInt] = Field(default=None, description="Output only. The distance to the subject of the photo, in meters.", alias="subjectDistance")
    time: Optional[StrictStr] = Field(default=None, description="Output only. The date and time the photo was taken (EXIF DateTime).")
    white_balance: Optional[StrictStr] = Field(default=None, description="Output only. The white balance mode used to create the photo.", alias="whiteBalance")
    width: Optional[StrictInt] = Field(default=None, description="Output only. The width of the image in pixels.")
    __properties: ClassVar[List[str]] = ["aperture", "cameraMake", "cameraModel", "colorSpace", "exposureBias", "exposureMode", "exposureTime", "flashUsed", "focalLength", "height", "isoSpeed", "lens", "location", "maxApertureValue", "meteringMode", "rotation", "sensor", "subjectDistance", "time", "whiteBalance", "width"]

    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 FileImageMediaMetadata 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,
        )
        # override the default output from pydantic by calling `to_dict()` of location
        if self.location:
            _dict['location'] = self.location.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "aperture": obj.get("aperture"),
            "cameraMake": obj.get("cameraMake"),
            "cameraModel": obj.get("cameraModel"),
            "colorSpace": obj.get("colorSpace"),
            "exposureBias": obj.get("exposureBias"),
            "exposureMode": obj.get("exposureMode"),
            "exposureTime": obj.get("exposureTime"),
            "flashUsed": obj.get("flashUsed"),
            "focalLength": obj.get("focalLength"),
            "height": obj.get("height"),
            "isoSpeed": obj.get("isoSpeed"),
            "lens": obj.get("lens"),
            "location": FileImageMediaMetadataLocation.from_dict(obj["location"]) if obj.get("location") is not None else None,
            "maxApertureValue": obj.get("maxApertureValue"),
            "meteringMode": obj.get("meteringMode"),
            "rotation": obj.get("rotation"),
            "sensor": obj.get("sensor"),
            "subjectDistance": obj.get("subjectDistance"),
            "time": obj.get("time"),
            "whiteBalance": obj.get("whiteBalance"),
            "width": obj.get("width")
        })
        return _obj


