noderings 0.1.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.
- noderings/__init__.py +66 -0
- noderings/_base.py +418 -0
- noderings/_client.py +217 -0
- noderings/_errors.py +203 -0
- noderings/_services.py +29765 -0
- noderings/_types.py +94 -0
- noderings/_version.py +1 -0
- noderings/models.py +10699 -0
- noderings/py.typed +0 -0
- noderings-0.1.0.dist-info/METADATA +211 -0
- noderings-0.1.0.dist-info/RECORD +13 -0
- noderings-0.1.0.dist-info/WHEEL +4 -0
- noderings-0.1.0.dist-info/licenses/LICENSE +201 -0
noderings/_types.py
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"""Base types shared by the generated models."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import base64
|
|
6
|
+
from enum import Enum
|
|
7
|
+
from typing import Annotated, Any
|
|
8
|
+
|
|
9
|
+
from pydantic import BaseModel, BeforeValidator, ConfigDict, PlainSerializer, model_validator
|
|
10
|
+
|
|
11
|
+
__all__ = ["Base64Bytes", "Int64", "Model", "OpenEnum"]
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def _int64_in(v: Any) -> Any:
|
|
15
|
+
# The API sends 64-bit integers as JSON strings; accept numbers too.
|
|
16
|
+
if isinstance(v, str):
|
|
17
|
+
return int(v)
|
|
18
|
+
return v
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
Int64 = Annotated[
|
|
22
|
+
int,
|
|
23
|
+
BeforeValidator(_int64_in),
|
|
24
|
+
PlainSerializer(lambda v: str(v), return_type=str, when_used="json"),
|
|
25
|
+
]
|
|
26
|
+
"""A 64-bit integer. The API sends it as a JSON string; in Python it is an int."""
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def _bytes_in(v: Any) -> Any:
|
|
30
|
+
if isinstance(v, str):
|
|
31
|
+
s = v.strip()
|
|
32
|
+
s += "=" * (-len(s) % 4)
|
|
33
|
+
return base64.urlsafe_b64decode(s.replace("+", "-").replace("/", "_"))
|
|
34
|
+
return v
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
Base64Bytes = Annotated[
|
|
38
|
+
bytes,
|
|
39
|
+
BeforeValidator(_bytes_in),
|
|
40
|
+
PlainSerializer(lambda v: base64.b64encode(v).decode("ascii"), return_type=str, when_used="json"),
|
|
41
|
+
]
|
|
42
|
+
"""Bytes, sent by the API as standard base64."""
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class OpenEnum(str, Enum):
|
|
46
|
+
"""An API enum that keeps values this SDK version does not know yet.
|
|
47
|
+
|
|
48
|
+
Members compare equal to their string values, so
|
|
49
|
+
``vm.operation_status == "OPERATION_STATUS_STARTED"`` works too.
|
|
50
|
+
"""
|
|
51
|
+
|
|
52
|
+
@classmethod
|
|
53
|
+
def _missing_(cls, value: object) -> Any:
|
|
54
|
+
if not isinstance(value, str):
|
|
55
|
+
return None
|
|
56
|
+
member = str.__new__(cls, value)
|
|
57
|
+
member._name_ = value
|
|
58
|
+
member._value_ = value
|
|
59
|
+
return member
|
|
60
|
+
|
|
61
|
+
def __str__(self) -> str:
|
|
62
|
+
return str(self.value)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
class Model(BaseModel):
|
|
66
|
+
"""Base class of every API object.
|
|
67
|
+
|
|
68
|
+
Fields are snake_case attributes; the API's camelCase names work as well
|
|
69
|
+
when creating a model (``Model.model_validate({"planId": ...})``).
|
|
70
|
+
"""
|
|
71
|
+
|
|
72
|
+
model_config = ConfigDict(
|
|
73
|
+
populate_by_name=True,
|
|
74
|
+
extra="allow",
|
|
75
|
+
defer_build=True,
|
|
76
|
+
protected_namespaces=(),
|
|
77
|
+
arbitrary_types_allowed=False,
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
@model_validator(mode="before")
|
|
81
|
+
@classmethod
|
|
82
|
+
def _null_is_unset(cls, data: Any) -> Any:
|
|
83
|
+
# In the API's JSON a null field means "not set", the same as a missing one.
|
|
84
|
+
if isinstance(data, dict) and None in data.values():
|
|
85
|
+
return {k: v for k, v in data.items() if v is not None}
|
|
86
|
+
return data
|
|
87
|
+
|
|
88
|
+
def to_dict(self) -> dict[str, Any]:
|
|
89
|
+
"""The object as the API's JSON, with camelCase keys, leaving out fields that were never set."""
|
|
90
|
+
return self.model_dump(mode="json", by_alias=True, exclude_unset=True)
|
|
91
|
+
|
|
92
|
+
def to_json(self, indent: int | None = None) -> str:
|
|
93
|
+
"""The object as a JSON string, with camelCase keys."""
|
|
94
|
+
return self.model_dump_json(by_alias=True, exclude_unset=True, indent=indent)
|
noderings/_version.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.0"
|