Skip to content

Commit fbcd732

Browse files
committed
more methods
1 parent 5577edf commit fbcd732

3 files changed

Lines changed: 285 additions & 0 deletions

File tree

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
from http import HTTPStatus
2+
from typing import Any
3+
4+
import httpx
5+
6+
from ...client import AuthenticatedClient, Client
7+
from ...models.v0043_openapi_assocs_resp import V0043OpenapiAssocsResp
8+
from ...models.v0043_openapi_resp import V0043OpenapiResp
9+
from ...types import UNSET, Response, Unset
10+
11+
12+
def _get_kwargs(
13+
*,
14+
body: V0043OpenapiAssocsResp | Unset = UNSET,
15+
) -> dict[str, Any]:
16+
headers: dict[str, Any] = {}
17+
18+
_kwargs: dict[str, Any] = {
19+
"method": "post",
20+
"url": "/slurmdb/v0.0.43/associations/",
21+
}
22+
23+
if not isinstance(body, Unset):
24+
_kwargs["json"] = body.to_dict()
25+
26+
headers["Content-Type"] = "application/json"
27+
28+
_kwargs["headers"] = headers
29+
return _kwargs
30+
31+
32+
def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> V0043OpenapiResp:
33+
if response.status_code == 200:
34+
response_200 = V0043OpenapiResp.from_dict(response.json())
35+
36+
return response_200
37+
38+
response_default = V0043OpenapiResp.from_dict(response.json())
39+
40+
return response_default
41+
42+
43+
def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[V0043OpenapiResp]:
44+
return Response(
45+
status_code=HTTPStatus(response.status_code),
46+
content=response.content,
47+
headers=response.headers,
48+
parsed=_parse_response(client=client, response=response),
49+
)
50+
51+
52+
def sync_detailed(
53+
*,
54+
client: AuthenticatedClient | Client,
55+
body: V0043OpenapiAssocsResp | Unset = UNSET,
56+
) -> Response[V0043OpenapiResp]:
57+
"""Set associations info
58+
59+
Args:
60+
body (V0043OpenapiAssocsResp | Unset):
61+
62+
Raises:
63+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
64+
httpx.TimeoutException: If the request takes longer than Client.timeout.
65+
66+
Returns:
67+
Response[V0043OpenapiResp]
68+
"""
69+
70+
kwargs = _get_kwargs(
71+
body=body,
72+
)
73+
74+
response = client.get_httpx_client().request(
75+
**kwargs,
76+
)
77+
78+
return _build_response(client=client, response=response)
79+
80+
81+
def sync(
82+
*,
83+
client: AuthenticatedClient | Client,
84+
body: V0043OpenapiAssocsResp | Unset = UNSET,
85+
) -> V0043OpenapiResp | None:
86+
"""Set associations info
87+
88+
Args:
89+
body (V0043OpenapiAssocsResp | Unset):
90+
91+
Raises:
92+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
93+
httpx.TimeoutException: If the request takes longer than Client.timeout.
94+
95+
Returns:
96+
V0043OpenapiResp
97+
"""
98+
99+
return sync_detailed(
100+
client=client,
101+
body=body,
102+
).parsed
103+
104+
105+
async def asyncio_detailed(
106+
*,
107+
client: AuthenticatedClient | Client,
108+
body: V0043OpenapiAssocsResp | Unset = UNSET,
109+
) -> Response[V0043OpenapiResp]:
110+
"""Set associations info
111+
112+
Args:
113+
body (V0043OpenapiAssocsResp | Unset):
114+
115+
Raises:
116+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
117+
httpx.TimeoutException: If the request takes longer than Client.timeout.
118+
119+
Returns:
120+
Response[V0043OpenapiResp]
121+
"""
122+
123+
kwargs = _get_kwargs(
124+
body=body,
125+
)
126+
127+
response = await client.get_async_httpx_client().request(**kwargs)
128+
129+
return _build_response(client=client, response=response)
130+
131+
132+
async def asyncio(
133+
*,
134+
client: AuthenticatedClient | Client,
135+
body: V0043OpenapiAssocsResp | Unset = UNSET,
136+
) -> V0043OpenapiResp | None:
137+
"""Set associations info
138+
139+
Args:
140+
body (V0043OpenapiAssocsResp | Unset):
141+
142+
Raises:
143+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
144+
httpx.TimeoutException: If the request takes longer than Client.timeout.
145+
146+
Returns:
147+
V0043OpenapiResp
148+
"""
149+
150+
return (
151+
await asyncio_detailed(
152+
client=client,
153+
body=body,
154+
)
155+
).parsed

slurm_rest_api_client/models/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
from .v0043_openapi_meta_plugin import V0043OpenapiMetaPlugin
3838
from .v0043_openapi_meta_slurm import V0043OpenapiMetaSlurm
3939
from .v0043_openapi_meta_slurm_version import V0043OpenapiMetaSlurmVersion
40+
from .v0043_openapi_resp import V0043OpenapiResp
4041
from .v0043_openapi_warning import V0043OpenapiWarning
4142
from .v0043_tres import V0043Tres
4243
from .v0043_uint_32_no_val_struct import V0043Uint32NoValStruct
@@ -79,6 +80,7 @@
7980
"V0043OpenapiMetaPlugin",
8081
"V0043OpenapiMetaSlurm",
8182
"V0043OpenapiMetaSlurmVersion",
83+
"V0043OpenapiResp",
8284
"V0043OpenapiWarning",
8385
"V0043Tres",
8486
"V0043Uint32NoValStruct",
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
from __future__ import annotations
2+
3+
from collections.abc import Mapping
4+
from typing import TYPE_CHECKING, Any, TypeVar
5+
6+
from attrs import define as _attrs_define
7+
from attrs import field as _attrs_field
8+
9+
from ..types import UNSET, Unset
10+
11+
if TYPE_CHECKING:
12+
from ..models.v0043_openapi_error import V0043OpenapiError
13+
from ..models.v0043_openapi_meta import V0043OpenapiMeta
14+
from ..models.v0043_openapi_warning import V0043OpenapiWarning
15+
16+
17+
T = TypeVar("T", bound="V0043OpenapiResp")
18+
19+
20+
@_attrs_define
21+
class V0043OpenapiResp:
22+
"""
23+
Attributes:
24+
meta (V0043OpenapiMeta | Unset):
25+
errors (list[V0043OpenapiError] | Unset):
26+
warnings (list[V0043OpenapiWarning] | Unset):
27+
"""
28+
29+
meta: V0043OpenapiMeta | Unset = UNSET
30+
errors: list[V0043OpenapiError] | Unset = UNSET
31+
warnings: list[V0043OpenapiWarning] | Unset = UNSET
32+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
33+
34+
def to_dict(self) -> dict[str, Any]:
35+
meta: dict[str, Any] | Unset = UNSET
36+
if not isinstance(self.meta, Unset):
37+
meta = self.meta.to_dict()
38+
39+
errors: list[dict[str, Any]] | Unset = UNSET
40+
if not isinstance(self.errors, Unset):
41+
errors = []
42+
for componentsschemasv0_0_43_openapi_errors_item_data in self.errors:
43+
componentsschemasv0_0_43_openapi_errors_item = (
44+
componentsschemasv0_0_43_openapi_errors_item_data.to_dict()
45+
)
46+
errors.append(componentsschemasv0_0_43_openapi_errors_item)
47+
48+
warnings: list[dict[str, Any]] | Unset = UNSET
49+
if not isinstance(self.warnings, Unset):
50+
warnings = []
51+
for componentsschemasv0_0_43_openapi_warnings_item_data in self.warnings:
52+
componentsschemasv0_0_43_openapi_warnings_item = (
53+
componentsschemasv0_0_43_openapi_warnings_item_data.to_dict()
54+
)
55+
warnings.append(componentsschemasv0_0_43_openapi_warnings_item)
56+
57+
field_dict: dict[str, Any] = {}
58+
field_dict.update(self.additional_properties)
59+
field_dict.update({})
60+
if meta is not UNSET:
61+
field_dict["meta"] = meta
62+
if errors is not UNSET:
63+
field_dict["errors"] = errors
64+
if warnings is not UNSET:
65+
field_dict["warnings"] = warnings
66+
67+
return field_dict
68+
69+
@classmethod
70+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
71+
from ..models.v0043_openapi_error import V0043OpenapiError
72+
from ..models.v0043_openapi_meta import V0043OpenapiMeta
73+
from ..models.v0043_openapi_warning import V0043OpenapiWarning
74+
75+
d = dict(src_dict)
76+
_meta = d.pop("meta", UNSET)
77+
meta: V0043OpenapiMeta | Unset
78+
if isinstance(_meta, Unset):
79+
meta = UNSET
80+
else:
81+
meta = V0043OpenapiMeta.from_dict(_meta)
82+
83+
_errors = d.pop("errors", UNSET)
84+
errors: list[V0043OpenapiError] | Unset = UNSET
85+
if _errors is not UNSET:
86+
errors = []
87+
for componentsschemasv0_0_43_openapi_errors_item_data in _errors:
88+
componentsschemasv0_0_43_openapi_errors_item = V0043OpenapiError.from_dict(
89+
componentsschemasv0_0_43_openapi_errors_item_data
90+
)
91+
92+
errors.append(componentsschemasv0_0_43_openapi_errors_item)
93+
94+
_warnings = d.pop("warnings", UNSET)
95+
warnings: list[V0043OpenapiWarning] | Unset = UNSET
96+
if _warnings is not UNSET:
97+
warnings = []
98+
for componentsschemasv0_0_43_openapi_warnings_item_data in _warnings:
99+
componentsschemasv0_0_43_openapi_warnings_item = V0043OpenapiWarning.from_dict(
100+
componentsschemasv0_0_43_openapi_warnings_item_data
101+
)
102+
103+
warnings.append(componentsschemasv0_0_43_openapi_warnings_item)
104+
105+
v0043_openapi_resp = cls(
106+
meta=meta,
107+
errors=errors,
108+
warnings=warnings,
109+
)
110+
111+
v0043_openapi_resp.additional_properties = d
112+
return v0043_openapi_resp
113+
114+
@property
115+
def additional_keys(self) -> list[str]:
116+
return list(self.additional_properties.keys())
117+
118+
def __getitem__(self, key: str) -> Any:
119+
return self.additional_properties[key]
120+
121+
def __setitem__(self, key: str, value: Any) -> None:
122+
self.additional_properties[key] = value
123+
124+
def __delitem__(self, key: str) -> None:
125+
del self.additional_properties[key]
126+
127+
def __contains__(self, key: str) -> bool:
128+
return key in self.additional_properties

0 commit comments

Comments
 (0)