beetkeeper-api-client 0.12.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. beetkeeper_api_client/__init__.py +112 -0
  2. beetkeeper_api_client/_scm_version.py +1 -0
  3. beetkeeper_api_client/api/__init__.py +9 -0
  4. beetkeeper_api_client/api/authentication_api.py +758 -0
  5. beetkeeper_api_client/api/events_api.py +1663 -0
  6. beetkeeper_api_client/api/imports_api.py +3134 -0
  7. beetkeeper_api_client/api/monitoring_api.py +377 -0
  8. beetkeeper_api_client/api/query_api.py +1250 -0
  9. beetkeeper_api_client/api_client.py +845 -0
  10. beetkeeper_api_client/api_response.py +21 -0
  11. beetkeeper_api_client/configuration.py +604 -0
  12. beetkeeper_api_client/exceptions.py +218 -0
  13. beetkeeper_api_client/models/__init__.py +44 -0
  14. beetkeeper_api_client/models/api_album.py +285 -0
  15. beetkeeper_api_client/models/api_track.py +528 -0
  16. beetkeeper_api_client/models/beets_event_type.py +40 -0
  17. beetkeeper_api_client/models/clean_slate_preview.py +147 -0
  18. beetkeeper_api_client/models/clean_slate_submit_request.py +116 -0
  19. beetkeeper_api_client/models/current_beets_subject_state.py +140 -0
  20. beetkeeper_api_client/models/decision_request.py +104 -0
  21. beetkeeper_api_client/models/event_search_response.py +97 -0
  22. beetkeeper_api_client/models/event_search_result.py +107 -0
  23. beetkeeper_api_client/models/event_subject_summary.py +100 -0
  24. beetkeeper_api_client/models/events_list_response.py +95 -0
  25. beetkeeper_api_client/models/find_missing_source_path_request.py +100 -0
  26. beetkeeper_api_client/models/find_missing_source_path_response.py +108 -0
  27. beetkeeper_api_client/models/health_info.py +101 -0
  28. beetkeeper_api_client/models/http_validation_error.py +95 -0
  29. beetkeeper_api_client/models/import_action.py +38 -0
  30. beetkeeper_api_client/models/import_candidate.py +171 -0
  31. beetkeeper_api_client/models/import_decision.py +96 -0
  32. beetkeeper_api_client/models/import_job.py +162 -0
  33. beetkeeper_api_client/models/import_job_status.py +41 -0
  34. beetkeeper_api_client/models/import_submit_request.py +104 -0
  35. beetkeeper_api_client/models/listener_event_details.py +121 -0
  36. beetkeeper_api_client/models/location_inner.py +138 -0
  37. beetkeeper_api_client/models/login_request_body.py +90 -0
  38. beetkeeper_api_client/models/login_response_body.py +100 -0
  39. beetkeeper_api_client/models/logout_response_body.py +88 -0
  40. beetkeeper_api_client/models/search_missing_source_path_result.py +106 -0
  41. beetkeeper_api_client/models/validation_error.py +108 -0
  42. beetkeeper_api_client/py.typed +0 -0
  43. beetkeeper_api_client/rest.py +201 -0
  44. beetkeeper_api_client/sync_helper.py +57 -0
  45. beetkeeper_api_client-0.12.0.dist-info/METADATA +34 -0
  46. beetkeeper_api_client-0.12.0.dist-info/RECORD +48 -0
  47. beetkeeper_api_client-0.12.0.dist-info/WHEEL +5 -0
  48. beetkeeper_api_client-0.12.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,107 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ beetkeeper
5
+
6
+ No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
7
+
8
+ The version of the OpenAPI document:
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+
15
+ from __future__ import annotations
16
+ import pprint
17
+ import re # noqa: F401
18
+ import json
19
+
20
+ from datetime import datetime
21
+ from pydantic import BaseModel, ConfigDict, Field, StrictInt
22
+ from typing import Any, ClassVar, Dict, List, Optional
23
+ from beetkeeper_api_client.models.beets_event_type import BeetsEventType
24
+ from beetkeeper_api_client.models.current_beets_subject_state import CurrentBeetsSubjectState
25
+ from typing import Optional, Set
26
+ from typing_extensions import Self
27
+ from pydantic_core import to_jsonable_python
28
+
29
+ class EventSearchResult(BaseModel):
30
+ """
31
+ A model with an aggregate of details for an event search match.
32
+ """ # noqa: E501
33
+ event_id: StrictInt = Field(description="The beetkeeper event ID associated with this match.")
34
+ event_type: BeetsEventType = Field(description="The type of beets event ( https://beets.readthedocs.io/en/stable/dev/plugins/events.html ).")
35
+ event_time: datetime = Field(description="The time of the event taking place.")
36
+ beets_id: StrictInt = Field(description="The beets ID of the event's subject (either beets Album ID or Item ID).")
37
+ current_beets_subject_state: Optional[CurrentBeetsSubjectState] = None
38
+ __properties: ClassVar[List[str]] = ["event_id", "event_type", "event_time", "beets_id", "current_beets_subject_state"]
39
+
40
+ model_config = ConfigDict(
41
+ validate_by_name=True,
42
+ validate_by_alias=True,
43
+ validate_assignment=True,
44
+ protected_namespaces=(),
45
+ )
46
+
47
+
48
+ def to_str(self) -> str:
49
+ """Returns the string representation of the model using alias"""
50
+ return pprint.pformat(self.model_dump(by_alias=True))
51
+
52
+ def to_json(self) -> str:
53
+ """Returns the JSON representation of the model using alias"""
54
+ return json.dumps(to_jsonable_python(self.to_dict()))
55
+
56
+ @classmethod
57
+ def from_json(cls, json_str: str) -> Optional[Self]:
58
+ """Create an instance of EventSearchResult from a JSON string"""
59
+ return cls.from_dict(json.loads(json_str))
60
+
61
+ def to_dict(self) -> Dict[str, Any]:
62
+ """Return the dictionary representation of the model using alias.
63
+
64
+ This has the following differences from calling pydantic's
65
+ `self.model_dump(by_alias=True)`:
66
+
67
+ * `None` is only added to the output dict for nullable fields that
68
+ were set at model initialization. Other fields with value `None`
69
+ are ignored.
70
+ """
71
+ excluded_fields: Set[str] = set([
72
+ ])
73
+
74
+ _dict = self.model_dump(
75
+ by_alias=True,
76
+ exclude=excluded_fields,
77
+ exclude_none=True,
78
+ )
79
+ # override the default output from pydantic by calling `to_dict()` of current_beets_subject_state
80
+ if self.current_beets_subject_state:
81
+ _dict['current_beets_subject_state'] = self.current_beets_subject_state.to_dict()
82
+ # set to None if current_beets_subject_state (nullable) is None
83
+ # and model_fields_set contains the field
84
+ if self.current_beets_subject_state is None and "current_beets_subject_state" in self.model_fields_set:
85
+ _dict['current_beets_subject_state'] = None
86
+
87
+ return _dict
88
+
89
+ @classmethod
90
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
91
+ """Create an instance of EventSearchResult from a dict"""
92
+ if obj is None:
93
+ return None
94
+
95
+ if not isinstance(obj, dict):
96
+ return cls.model_validate(obj)
97
+
98
+ _obj = cls.model_validate({
99
+ "event_id": obj.get("event_id"),
100
+ "event_type": obj.get("event_type"),
101
+ "event_time": obj.get("event_time"),
102
+ "beets_id": obj.get("beets_id"),
103
+ "current_beets_subject_state": CurrentBeetsSubjectState.from_dict(obj["current_beets_subject_state"]) if obj.get("current_beets_subject_state") is not None else None
104
+ })
105
+ return _obj
106
+
107
+
@@ -0,0 +1,100 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ beetkeeper
5
+
6
+ No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
7
+
8
+ The version of the OpenAPI document:
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+
15
+ from __future__ import annotations
16
+ import pprint
17
+ import re # noqa: F401
18
+ import json
19
+
20
+ from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr
21
+ from typing import Any, ClassVar, Dict, List, Optional
22
+ from typing import Optional, Set
23
+ from typing_extensions import Self
24
+ from pydantic_core import to_jsonable_python
25
+
26
+ class EventSubjectSummary(BaseModel):
27
+ """
28
+ One beets album or track referenced by a listener event: its beets id plus the name recorded at push time (the album/release name, or the track title). Either part can be missing: rows ingested before names were recorded have no name, and a singleton's release name has no beets album id.
29
+ """ # noqa: E501
30
+ beets_id: Optional[StrictInt] = None
31
+ name: Optional[StrictStr] = None
32
+ __properties: ClassVar[List[str]] = ["beets_id", "name"]
33
+
34
+ model_config = ConfigDict(
35
+ validate_by_name=True,
36
+ validate_by_alias=True,
37
+ validate_assignment=True,
38
+ protected_namespaces=(),
39
+ )
40
+
41
+
42
+ def to_str(self) -> str:
43
+ """Returns the string representation of the model using alias"""
44
+ return pprint.pformat(self.model_dump(by_alias=True))
45
+
46
+ def to_json(self) -> str:
47
+ """Returns the JSON representation of the model using alias"""
48
+ return json.dumps(to_jsonable_python(self.to_dict()))
49
+
50
+ @classmethod
51
+ def from_json(cls, json_str: str) -> Optional[Self]:
52
+ """Create an instance of EventSubjectSummary from a JSON string"""
53
+ return cls.from_dict(json.loads(json_str))
54
+
55
+ def to_dict(self) -> Dict[str, Any]:
56
+ """Return the dictionary representation of the model using alias.
57
+
58
+ This has the following differences from calling pydantic's
59
+ `self.model_dump(by_alias=True)`:
60
+
61
+ * `None` is only added to the output dict for nullable fields that
62
+ were set at model initialization. Other fields with value `None`
63
+ are ignored.
64
+ """
65
+ excluded_fields: Set[str] = set([
66
+ ])
67
+
68
+ _dict = self.model_dump(
69
+ by_alias=True,
70
+ exclude=excluded_fields,
71
+ exclude_none=True,
72
+ )
73
+ # set to None if beets_id (nullable) is None
74
+ # and model_fields_set contains the field
75
+ if self.beets_id is None and "beets_id" in self.model_fields_set:
76
+ _dict['beets_id'] = None
77
+
78
+ # set to None if name (nullable) is None
79
+ # and model_fields_set contains the field
80
+ if self.name is None and "name" in self.model_fields_set:
81
+ _dict['name'] = None
82
+
83
+ return _dict
84
+
85
+ @classmethod
86
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
87
+ """Create an instance of EventSubjectSummary from a dict"""
88
+ if obj is None:
89
+ return None
90
+
91
+ if not isinstance(obj, dict):
92
+ return cls.model_validate(obj)
93
+
94
+ _obj = cls.model_validate({
95
+ "beets_id": obj.get("beets_id"),
96
+ "name": obj.get("name")
97
+ })
98
+ return _obj
99
+
100
+
@@ -0,0 +1,95 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ beetkeeper
5
+
6
+ No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
7
+
8
+ The version of the OpenAPI document:
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+
15
+ from __future__ import annotations
16
+ import pprint
17
+ import re # noqa: F401
18
+ import json
19
+
20
+ from pydantic import BaseModel, ConfigDict
21
+ from typing import Any, ClassVar, Dict, List, Optional
22
+ from beetkeeper_api_client.models.listener_event_details import ListenerEventDetails
23
+ from typing import Optional, Set
24
+ from typing_extensions import Self
25
+ from pydantic_core import to_jsonable_python
26
+
27
+ class EventsListResponse(BaseModel):
28
+ """
29
+ Response payload for the events listing: recently ingested listener events, newest first.
30
+ """ # noqa: E501
31
+ events: Optional[List[ListenerEventDetails]] = None
32
+ __properties: ClassVar[List[str]] = ["events"]
33
+
34
+ model_config = ConfigDict(
35
+ validate_by_name=True,
36
+ validate_by_alias=True,
37
+ validate_assignment=True,
38
+ protected_namespaces=(),
39
+ )
40
+
41
+
42
+ def to_str(self) -> str:
43
+ """Returns the string representation of the model using alias"""
44
+ return pprint.pformat(self.model_dump(by_alias=True))
45
+
46
+ def to_json(self) -> str:
47
+ """Returns the JSON representation of the model using alias"""
48
+ return json.dumps(to_jsonable_python(self.to_dict()))
49
+
50
+ @classmethod
51
+ def from_json(cls, json_str: str) -> Optional[Self]:
52
+ """Create an instance of EventsListResponse from a JSON string"""
53
+ return cls.from_dict(json.loads(json_str))
54
+
55
+ def to_dict(self) -> Dict[str, Any]:
56
+ """Return the dictionary representation of the model using alias.
57
+
58
+ This has the following differences from calling pydantic's
59
+ `self.model_dump(by_alias=True)`:
60
+
61
+ * `None` is only added to the output dict for nullable fields that
62
+ were set at model initialization. Other fields with value `None`
63
+ are ignored.
64
+ """
65
+ excluded_fields: Set[str] = set([
66
+ ])
67
+
68
+ _dict = self.model_dump(
69
+ by_alias=True,
70
+ exclude=excluded_fields,
71
+ exclude_none=True,
72
+ )
73
+ # override the default output from pydantic by calling `to_dict()` of each item in events (list)
74
+ _items = []
75
+ if self.events:
76
+ for _item_events in self.events:
77
+ _items.append(_item_events.to_dict() if _item_events is not None else None)
78
+ _dict['events'] = _items
79
+ return _dict
80
+
81
+ @classmethod
82
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
83
+ """Create an instance of EventsListResponse from a dict"""
84
+ if obj is None:
85
+ return None
86
+
87
+ if not isinstance(obj, dict):
88
+ return cls.model_validate(obj)
89
+
90
+ _obj = cls.model_validate({
91
+ "events": [ListenerEventDetails.from_dict(_item) for _item in obj["events"]] if obj.get("events") is not None else None
92
+ })
93
+ return _obj
94
+
95
+
@@ -0,0 +1,100 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ beetkeeper
5
+
6
+ No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
7
+
8
+ The version of the OpenAPI document:
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+
15
+ from __future__ import annotations
16
+ import pprint
17
+ import re # noqa: F401
18
+ import json
19
+
20
+ from pydantic import BaseModel, ConfigDict, Field, StrictInt
21
+ from typing import Any, ClassVar, Dict, List, Optional
22
+ from typing import Optional, Set
23
+ from typing_extensions import Self
24
+ from pydantic_core import to_jsonable_python
25
+
26
+ class FindMissingSourcePathRequest(BaseModel):
27
+ """
28
+ Body of `POST /api/import/find_missing_source_path`: the entry to ask the downloader about.
29
+ """ # noqa: E501
30
+ beets_album_id: Optional[StrictInt] = Field(default=None, description="The beets library id of an album. Mutually exclusive with `beets_item_id`.")
31
+ beets_item_id: Optional[StrictInt] = Field(default=None, description="The beets library id of an item (track). Mutually exclusive with `beets_album_id`.")
32
+ __properties: ClassVar[List[str]] = ["beets_album_id", "beets_item_id"]
33
+
34
+ model_config = ConfigDict(
35
+ validate_by_name=True,
36
+ validate_by_alias=True,
37
+ validate_assignment=True,
38
+ protected_namespaces=(),
39
+ )
40
+
41
+
42
+ def to_str(self) -> str:
43
+ """Returns the string representation of the model using alias"""
44
+ return pprint.pformat(self.model_dump(by_alias=True))
45
+
46
+ def to_json(self) -> str:
47
+ """Returns the JSON representation of the model using alias"""
48
+ return json.dumps(to_jsonable_python(self.to_dict()))
49
+
50
+ @classmethod
51
+ def from_json(cls, json_str: str) -> Optional[Self]:
52
+ """Create an instance of FindMissingSourcePathRequest from a JSON string"""
53
+ return cls.from_dict(json.loads(json_str))
54
+
55
+ def to_dict(self) -> Dict[str, Any]:
56
+ """Return the dictionary representation of the model using alias.
57
+
58
+ This has the following differences from calling pydantic's
59
+ `self.model_dump(by_alias=True)`:
60
+
61
+ * `None` is only added to the output dict for nullable fields that
62
+ were set at model initialization. Other fields with value `None`
63
+ are ignored.
64
+ """
65
+ excluded_fields: Set[str] = set([
66
+ ])
67
+
68
+ _dict = self.model_dump(
69
+ by_alias=True,
70
+ exclude=excluded_fields,
71
+ exclude_none=True,
72
+ )
73
+ # set to None if beets_album_id (nullable) is None
74
+ # and model_fields_set contains the field
75
+ if self.beets_album_id is None and "beets_album_id" in self.model_fields_set:
76
+ _dict['beets_album_id'] = None
77
+
78
+ # set to None if beets_item_id (nullable) is None
79
+ # and model_fields_set contains the field
80
+ if self.beets_item_id is None and "beets_item_id" in self.model_fields_set:
81
+ _dict['beets_item_id'] = None
82
+
83
+ return _dict
84
+
85
+ @classmethod
86
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
87
+ """Create an instance of FindMissingSourcePathRequest from a dict"""
88
+ if obj is None:
89
+ return None
90
+
91
+ if not isinstance(obj, dict):
92
+ return cls.model_validate(obj)
93
+
94
+ _obj = cls.model_validate({
95
+ "beets_album_id": obj.get("beets_album_id"),
96
+ "beets_item_id": obj.get("beets_item_id")
97
+ })
98
+ return _obj
99
+
100
+
@@ -0,0 +1,108 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ beetkeeper
5
+
6
+ No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
7
+
8
+ The version of the OpenAPI document:
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+
15
+ from __future__ import annotations
16
+ import pprint
17
+ import re # noqa: F401
18
+ import json
19
+
20
+ from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr
21
+ from typing import Any, ClassVar, Dict, List, Optional
22
+ from typing import Optional, Set
23
+ from typing_extensions import Self
24
+ from pydantic_core import to_jsonable_python
25
+
26
+ class FindMissingSourcePathResponse(BaseModel):
27
+ """
28
+ Response model for the `/find_missing_source_path` endpoint.
29
+ """ # noqa: E501
30
+ found_match: StrictBool = Field(description="True if the missing source path search returned a matching result.")
31
+ search_status_code: Optional[StrictInt] = Field(default=None, description="The HTTP status code of the downloader API search, when one was made.")
32
+ source_directory: Optional[StrictStr] = Field(default=None, description="The source directory (as mounted on the app container) from the matched search, if any.")
33
+ var_query_params: Optional[Dict[str, StrictStr]] = Field(default=None, description="The query params the search was made with (the renamed beets fields).", alias="query_params")
34
+ detail: Optional[StrictStr] = Field(default='', description="Why no match was found, when `found_match` is false.")
35
+ recorded_inference: Optional[StrictBool] = Field(default=False, description="True when the match was stored as the entry's *inferred* source path (shown as such on the search page; kept apart from source paths recorded from the beetkeeper plugin's events).")
36
+ __properties: ClassVar[List[str]] = ["found_match", "search_status_code", "source_directory", "query_params", "detail", "recorded_inference"]
37
+
38
+ model_config = ConfigDict(
39
+ validate_by_name=True,
40
+ validate_by_alias=True,
41
+ validate_assignment=True,
42
+ protected_namespaces=(),
43
+ )
44
+
45
+
46
+ def to_str(self) -> str:
47
+ """Returns the string representation of the model using alias"""
48
+ return pprint.pformat(self.model_dump(by_alias=True))
49
+
50
+ def to_json(self) -> str:
51
+ """Returns the JSON representation of the model using alias"""
52
+ return json.dumps(to_jsonable_python(self.to_dict()))
53
+
54
+ @classmethod
55
+ def from_json(cls, json_str: str) -> Optional[Self]:
56
+ """Create an instance of FindMissingSourcePathResponse from a JSON string"""
57
+ return cls.from_dict(json.loads(json_str))
58
+
59
+ def to_dict(self) -> Dict[str, Any]:
60
+ """Return the dictionary representation of the model using alias.
61
+
62
+ This has the following differences from calling pydantic's
63
+ `self.model_dump(by_alias=True)`:
64
+
65
+ * `None` is only added to the output dict for nullable fields that
66
+ were set at model initialization. Other fields with value `None`
67
+ are ignored.
68
+ """
69
+ excluded_fields: Set[str] = set([
70
+ ])
71
+
72
+ _dict = self.model_dump(
73
+ by_alias=True,
74
+ exclude=excluded_fields,
75
+ exclude_none=True,
76
+ )
77
+ # set to None if search_status_code (nullable) is None
78
+ # and model_fields_set contains the field
79
+ if self.search_status_code is None and "search_status_code" in self.model_fields_set:
80
+ _dict['search_status_code'] = None
81
+
82
+ # set to None if source_directory (nullable) is None
83
+ # and model_fields_set contains the field
84
+ if self.source_directory is None and "source_directory" in self.model_fields_set:
85
+ _dict['source_directory'] = None
86
+
87
+ return _dict
88
+
89
+ @classmethod
90
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
91
+ """Create an instance of FindMissingSourcePathResponse from a dict"""
92
+ if obj is None:
93
+ return None
94
+
95
+ if not isinstance(obj, dict):
96
+ return cls.model_validate(obj)
97
+
98
+ _obj = cls.model_validate({
99
+ "found_match": obj.get("found_match"),
100
+ "search_status_code": obj.get("search_status_code"),
101
+ "source_directory": obj.get("source_directory"),
102
+ "query_params": obj.get("query_params"),
103
+ "detail": obj.get("detail") if obj.get("detail") is not None else '',
104
+ "recorded_inference": obj.get("recorded_inference") if obj.get("recorded_inference") is not None else False
105
+ })
106
+ return _obj
107
+
108
+
@@ -0,0 +1,101 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ beetkeeper
5
+
6
+ No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
7
+
8
+ The version of the OpenAPI document:
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+
15
+ from __future__ import annotations
16
+ import pprint
17
+ import re # noqa: F401
18
+ import json
19
+
20
+ from pydantic import BaseModel, ConfigDict, StrictBool, StrictInt, StrictStr
21
+ from typing import Any, ClassVar, Dict, List, Optional
22
+ from typing import Optional, Set
23
+ from typing_extensions import Self
24
+ from pydantic_core import to_jsonable_python
25
+
26
+ class HealthInfo(BaseModel):
27
+ """
28
+ Per-process health snapshot.
29
+ """ # noqa: E501
30
+ process_pid: StrictInt
31
+ hostname: StrictStr
32
+ import_lock_holder: Optional[StrictStr]
33
+ is_import_leader: StrictBool
34
+ job_count: StrictInt
35
+ __properties: ClassVar[List[str]] = ["process_pid", "hostname", "import_lock_holder", "is_import_leader", "job_count"]
36
+
37
+ model_config = ConfigDict(
38
+ validate_by_name=True,
39
+ validate_by_alias=True,
40
+ validate_assignment=True,
41
+ protected_namespaces=(),
42
+ )
43
+
44
+
45
+ def to_str(self) -> str:
46
+ """Returns the string representation of the model using alias"""
47
+ return pprint.pformat(self.model_dump(by_alias=True))
48
+
49
+ def to_json(self) -> str:
50
+ """Returns the JSON representation of the model using alias"""
51
+ return json.dumps(to_jsonable_python(self.to_dict()))
52
+
53
+ @classmethod
54
+ def from_json(cls, json_str: str) -> Optional[Self]:
55
+ """Create an instance of HealthInfo from a JSON string"""
56
+ return cls.from_dict(json.loads(json_str))
57
+
58
+ def to_dict(self) -> Dict[str, Any]:
59
+ """Return the dictionary representation of the model using alias.
60
+
61
+ This has the following differences from calling pydantic's
62
+ `self.model_dump(by_alias=True)`:
63
+
64
+ * `None` is only added to the output dict for nullable fields that
65
+ were set at model initialization. Other fields with value `None`
66
+ are ignored.
67
+ """
68
+ excluded_fields: Set[str] = set([
69
+ ])
70
+
71
+ _dict = self.model_dump(
72
+ by_alias=True,
73
+ exclude=excluded_fields,
74
+ exclude_none=True,
75
+ )
76
+ # set to None if import_lock_holder (nullable) is None
77
+ # and model_fields_set contains the field
78
+ if self.import_lock_holder is None and "import_lock_holder" in self.model_fields_set:
79
+ _dict['import_lock_holder'] = None
80
+
81
+ return _dict
82
+
83
+ @classmethod
84
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
85
+ """Create an instance of HealthInfo from a dict"""
86
+ if obj is None:
87
+ return None
88
+
89
+ if not isinstance(obj, dict):
90
+ return cls.model_validate(obj)
91
+
92
+ _obj = cls.model_validate({
93
+ "process_pid": obj.get("process_pid"),
94
+ "hostname": obj.get("hostname"),
95
+ "import_lock_holder": obj.get("import_lock_holder"),
96
+ "is_import_leader": obj.get("is_import_leader"),
97
+ "job_count": obj.get("job_count")
98
+ })
99
+ return _obj
100
+
101
+