Source code for annofabapi.pydantic_models.annotation_query

"""


No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
"""

from __future__ import annotations

import json
import pprint
import re  # noqa: F401
from typing import Any, ClassVar, Dict, List, Set

from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr
from typing_extensions import Annotated, Self

from annofabapi.pydantic_models.additional_data_v1 import AdditionalDataV1


[docs] class AnnotationQuery(BaseModel): """ アノテーションの絞り込み条件 """ task_id: Annotated[str, Field(strict=True, max_length=300)] | None = Field(default=None, description="タスクIDで絞り込みます。 ") exact_match_task_id: StrictBool | None = Field( default=True, description="タスクIDの検索方法を指定します。 `true`の場合は完全一致検索、`false`の場合は部分一致検索です。 " ) input_data_id: Annotated[str, Field(strict=True, max_length=300)] | None = Field(default=None, description="入力データID絞り込みます。 ") exact_match_input_data_id: StrictBool | None = Field( default=True, description="入力データIDの検索方法を指定します。 `true`の場合は完全一致検索、`false`の場合は部分一致検索です。 " ) label_id: StrictStr | None = Field(default=None, description="ラベルID。[値の制約についてはこちら。](#section/API-Convention/APIID) ") attributes: List[AdditionalDataV1] | None = Field( default=None, description="属性情報。 アノテーション属性の種類(`additional_data_definition`の`type`)によって、属性値を格納するプロパティは変わります。 | 属性の種類 | `additional_data_definition`の`type` | 属性値を格納するプロパティ | |------------|-------------------------|----------------------| | ON/OFF | flag | flag | | 整数 | integer | integer | | 自由記述(1行)| text | comment | | 自由記述(複数行)| comment | comment | | トラッキングID | tracking | comment | | アノテーションリンク | link | comment | | 排他選択(ラジオボタン) |choice | choice | | 排他選択(ドロップダウン) | select | choice | ", ) updated_from: str | None = Field( default=None, description="開始日・終了日を含む区間[updated_from, updated_to]でアノテーションの更新日を絞り込むときに使用する、開始日(ISO 8601 拡張形式または基本形式)。 `updated_to` より後の日付が指定された場合、期間指定は開始日・終了日を含む区間[updated_to, updated_from]となる。未指定の場合、API実行日(JST)の日付が指定されたものとして扱われる。 ", ) updated_to: str | None = Field( default=None, description="開始日・終了日を含む区間[updated_from, updated_to]でアノテーションの更新日を絞り込むときに使用する、終了日(ISO 8601 拡張形式または基本形式)。 未指定の場合、API実行日(JST)の日付が指定されたものとして扱われる。 ", ) __properties: ClassVar[List[str]] = [ "task_id", "exact_match_task_id", "input_data_id", "exact_match_input_data_id", "label_id", "attributes", "updated_from", "updated_to", ] model_config = ConfigDict( populate_by_name=True, validate_assignment=True, protected_namespaces=(), )
[docs] def to_str(self) -> str: """Returns the string representation of the model using alias""" return pprint.pformat(self.model_dump(by_alias=True))
[docs] 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())
[docs] @classmethod def from_json(cls, json_str: str) -> Self | None: """Create an instance of AnnotationQuery from a JSON string""" return cls.from_dict(json.loads(json_str))
[docs] 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 each item in attributes (list) _items = [] if self.attributes: for _item_attributes in self.attributes: if _item_attributes: _items.append(_item_attributes.to_dict()) _dict["attributes"] = _items return _dict
[docs] @classmethod def from_dict(cls, obj: Dict[str, Any] | None) -> Self | None: """Create an instance of AnnotationQuery from a dict""" if obj is None: return None if not isinstance(obj, dict): return cls.model_validate(obj) _obj = cls.model_validate( { "task_id": obj.get("task_id"), "exact_match_task_id": obj.get("exact_match_task_id") if obj.get("exact_match_task_id") is not None else True, "input_data_id": obj.get("input_data_id"), "exact_match_input_data_id": obj.get("exact_match_input_data_id") if obj.get("exact_match_input_data_id") is not None else True, "label_id": obj.get("label_id"), "attributes": [AdditionalDataV1.from_dict(_item) for _item in obj["attributes"]] if obj.get("attributes") is not None else None, "updated_from": obj.get("updated_from"), "updated_to": obj.get("updated_to"), } ) return _obj