# coding: utf-8 """ Jungfraujoch Jungfraujoch Broker Web API The version of the OpenAPI document: 1.0.0-rc.15 Contact: filip.leonarski@psi.ch 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 from typing import Any, ClassVar, Dict, List, Optional, Union from typing_extensions import Annotated from typing import Optional, Set from typing_extensions import Self class PreviewSettings(BaseModel): """ Settings for JPEG rendering of preview images """ # noqa: E501 saturation: Annotated[int, Field(le=65535, strict=True, ge=0)] = Field(description="Saturation value to set contrast in the preview image") show_spots: Optional[StrictBool] = Field(default=True, description="Show spot finding results on the image") show_roi: Optional[StrictBool] = Field(default=False, description="Show ROI areas on the image") jpeg_quality: Optional[Annotated[int, Field(le=100, strict=True, ge=0)]] = Field(default=100, description="Quality of JPEG image (100 - highest; 0 - lowest)") show_indexed: Optional[StrictBool] = Field(default=False, description="Preview indexed images only") show_user_mask: Optional[StrictBool] = Field(default=False, description="Show user mask") resolution_ring: Optional[Union[Annotated[float, Field(le=100.0, strict=True, ge=0.1)], Annotated[int, Field(le=100, strict=True, ge=1)]]] = 0.1 __properties: ClassVar[List[str]] = ["saturation", "show_spots", "show_roi", "jpeg_quality", "show_indexed", "show_user_mask", "resolution_ring"] 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 PreviewSettings 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 PreviewSettings from a dict""" if obj is None: return None if not isinstance(obj, dict): return cls.model_validate(obj) _obj = cls.model_validate({ "saturation": obj.get("saturation"), "show_spots": obj.get("show_spots") if obj.get("show_spots") is not None else True, "show_roi": obj.get("show_roi") if obj.get("show_roi") is not None else False, "jpeg_quality": obj.get("jpeg_quality") if obj.get("jpeg_quality") is not None else 100, "show_indexed": obj.get("show_indexed") if obj.get("show_indexed") is not None else False, "show_user_mask": obj.get("show_user_mask") if obj.get("show_user_mask") is not None else False, "resolution_ring": obj.get("resolution_ring") if obj.get("resolution_ring") is not None else 0.1 }) return _obj