|
| 1 | +from http import HTTPStatus |
| 2 | +from typing import Any |
| 3 | +from urllib.parse import quote |
| 4 | + |
| 5 | +import httpx |
| 6 | + |
| 7 | +from ... import errors |
| 8 | +from ...client import AuthenticatedClient, Client |
| 9 | +from ...models.consolidation_worksheet_request import ConsolidationWorksheetRequest |
| 10 | +from ...models.error_response import ErrorResponse |
| 11 | +from ...models.operation_envelope_consolidation_worksheet_response import ( |
| 12 | + OperationEnvelopeConsolidationWorksheetResponse, |
| 13 | +) |
| 14 | +from ...types import UNSET, Response, Unset |
| 15 | + |
| 16 | + |
| 17 | +def _get_kwargs( |
| 18 | + graph_id: str, |
| 19 | + *, |
| 20 | + body: ConsolidationWorksheetRequest, |
| 21 | + idempotency_key: None | str | Unset = UNSET, |
| 22 | +) -> dict[str, Any]: |
| 23 | + headers: dict[str, Any] = {} |
| 24 | + if not isinstance(idempotency_key, Unset): |
| 25 | + headers["Idempotency-Key"] = idempotency_key |
| 26 | + |
| 27 | + _kwargs: dict[str, Any] = { |
| 28 | + "method": "post", |
| 29 | + "url": "/extensions/roboledger/{graph_id}/operations/consolidation-worksheet".format( |
| 30 | + graph_id=quote(str(graph_id), safe=""), |
| 31 | + ), |
| 32 | + } |
| 33 | + |
| 34 | + _kwargs["json"] = body.to_dict() |
| 35 | + |
| 36 | + headers["Content-Type"] = "application/json" |
| 37 | + |
| 38 | + _kwargs["headers"] = headers |
| 39 | + return _kwargs |
| 40 | + |
| 41 | + |
| 42 | +def _parse_response( |
| 43 | + *, client: AuthenticatedClient | Client, response: httpx.Response |
| 44 | +) -> ErrorResponse | OperationEnvelopeConsolidationWorksheetResponse | None: |
| 45 | + if response.status_code == 200: |
| 46 | + response_200 = OperationEnvelopeConsolidationWorksheetResponse.from_dict( |
| 47 | + response.json() |
| 48 | + ) |
| 49 | + |
| 50 | + return response_200 |
| 51 | + |
| 52 | + if response.status_code == 400: |
| 53 | + response_400 = ErrorResponse.from_dict(response.json()) |
| 54 | + |
| 55 | + return response_400 |
| 56 | + |
| 57 | + if response.status_code == 401: |
| 58 | + response_401 = ErrorResponse.from_dict(response.json()) |
| 59 | + |
| 60 | + return response_401 |
| 61 | + |
| 62 | + if response.status_code == 403: |
| 63 | + response_403 = ErrorResponse.from_dict(response.json()) |
| 64 | + |
| 65 | + return response_403 |
| 66 | + |
| 67 | + if response.status_code == 404: |
| 68 | + response_404 = ErrorResponse.from_dict(response.json()) |
| 69 | + |
| 70 | + return response_404 |
| 71 | + |
| 72 | + if response.status_code == 409: |
| 73 | + response_409 = ErrorResponse.from_dict(response.json()) |
| 74 | + |
| 75 | + return response_409 |
| 76 | + |
| 77 | + if response.status_code == 422: |
| 78 | + response_422 = ErrorResponse.from_dict(response.json()) |
| 79 | + |
| 80 | + return response_422 |
| 81 | + |
| 82 | + if response.status_code == 429: |
| 83 | + response_429 = ErrorResponse.from_dict(response.json()) |
| 84 | + |
| 85 | + return response_429 |
| 86 | + |
| 87 | + if response.status_code == 500: |
| 88 | + response_500 = ErrorResponse.from_dict(response.json()) |
| 89 | + |
| 90 | + return response_500 |
| 91 | + |
| 92 | + if client.raise_on_unexpected_status: |
| 93 | + raise errors.UnexpectedStatus(response.status_code, response.content) |
| 94 | + else: |
| 95 | + return None |
| 96 | + |
| 97 | + |
| 98 | +def _build_response( |
| 99 | + *, client: AuthenticatedClient | Client, response: httpx.Response |
| 100 | +) -> Response[ErrorResponse | OperationEnvelopeConsolidationWorksheetResponse]: |
| 101 | + return Response( |
| 102 | + status_code=HTTPStatus(response.status_code), |
| 103 | + content=response.content, |
| 104 | + headers=response.headers, |
| 105 | + parsed=_parse_response(client=client, response=response), |
| 106 | + ) |
| 107 | + |
| 108 | + |
| 109 | +def sync_detailed( |
| 110 | + graph_id: str, |
| 111 | + *, |
| 112 | + client: AuthenticatedClient, |
| 113 | + body: ConsolidationWorksheetRequest, |
| 114 | + idempotency_key: None | str | Unset = UNSET, |
| 115 | +) -> Response[ErrorResponse | OperationEnvelopeConsolidationWorksheetResponse]: |
| 116 | + """Consolidation Worksheet |
| 117 | +
|
| 118 | + The group's statement for one window with the entity as the column, read live from the tenant's OLTP |
| 119 | + ledger: the parent and each member consolidated in full, their combined sum, the consolidation |
| 120 | + entity's adjustments, the consolidated total, and each equity-method or cost member beside the sum, |
| 121 | + never in it. Every column renders under the group parent's Reporting Style. Rejected on shared- |
| 122 | + repository graphs. |
| 123 | +
|
| 124 | + **Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours |
| 125 | + return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict. |
| 126 | +
|
| 127 | + Args: |
| 128 | + graph_id (str): |
| 129 | + idempotency_key (None | str | Unset): |
| 130 | + body (ConsolidationWorksheetRequest): Request for consolidation-worksheet (OLTP, entity |
| 131 | + graphs only). |
| 132 | +
|
| 133 | + Raises: |
| 134 | + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. |
| 135 | + httpx.TimeoutException: If the request takes longer than Client.timeout. |
| 136 | +
|
| 137 | + Returns: |
| 138 | + Response[ErrorResponse | OperationEnvelopeConsolidationWorksheetResponse] |
| 139 | + """ |
| 140 | + |
| 141 | + kwargs = _get_kwargs( |
| 142 | + graph_id=graph_id, |
| 143 | + body=body, |
| 144 | + idempotency_key=idempotency_key, |
| 145 | + ) |
| 146 | + |
| 147 | + response = client.get_httpx_client().request( |
| 148 | + **kwargs, |
| 149 | + ) |
| 150 | + |
| 151 | + return _build_response(client=client, response=response) |
| 152 | + |
| 153 | + |
| 154 | +def sync( |
| 155 | + graph_id: str, |
| 156 | + *, |
| 157 | + client: AuthenticatedClient, |
| 158 | + body: ConsolidationWorksheetRequest, |
| 159 | + idempotency_key: None | str | Unset = UNSET, |
| 160 | +) -> ErrorResponse | OperationEnvelopeConsolidationWorksheetResponse | None: |
| 161 | + """Consolidation Worksheet |
| 162 | +
|
| 163 | + The group's statement for one window with the entity as the column, read live from the tenant's OLTP |
| 164 | + ledger: the parent and each member consolidated in full, their combined sum, the consolidation |
| 165 | + entity's adjustments, the consolidated total, and each equity-method or cost member beside the sum, |
| 166 | + never in it. Every column renders under the group parent's Reporting Style. Rejected on shared- |
| 167 | + repository graphs. |
| 168 | +
|
| 169 | + **Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours |
| 170 | + return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict. |
| 171 | +
|
| 172 | + Args: |
| 173 | + graph_id (str): |
| 174 | + idempotency_key (None | str | Unset): |
| 175 | + body (ConsolidationWorksheetRequest): Request for consolidation-worksheet (OLTP, entity |
| 176 | + graphs only). |
| 177 | +
|
| 178 | + Raises: |
| 179 | + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. |
| 180 | + httpx.TimeoutException: If the request takes longer than Client.timeout. |
| 181 | +
|
| 182 | + Returns: |
| 183 | + ErrorResponse | OperationEnvelopeConsolidationWorksheetResponse |
| 184 | + """ |
| 185 | + |
| 186 | + return sync_detailed( |
| 187 | + graph_id=graph_id, |
| 188 | + client=client, |
| 189 | + body=body, |
| 190 | + idempotency_key=idempotency_key, |
| 191 | + ).parsed |
| 192 | + |
| 193 | + |
| 194 | +async def asyncio_detailed( |
| 195 | + graph_id: str, |
| 196 | + *, |
| 197 | + client: AuthenticatedClient, |
| 198 | + body: ConsolidationWorksheetRequest, |
| 199 | + idempotency_key: None | str | Unset = UNSET, |
| 200 | +) -> Response[ErrorResponse | OperationEnvelopeConsolidationWorksheetResponse]: |
| 201 | + """Consolidation Worksheet |
| 202 | +
|
| 203 | + The group's statement for one window with the entity as the column, read live from the tenant's OLTP |
| 204 | + ledger: the parent and each member consolidated in full, their combined sum, the consolidation |
| 205 | + entity's adjustments, the consolidated total, and each equity-method or cost member beside the sum, |
| 206 | + never in it. Every column renders under the group parent's Reporting Style. Rejected on shared- |
| 207 | + repository graphs. |
| 208 | +
|
| 209 | + **Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours |
| 210 | + return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict. |
| 211 | +
|
| 212 | + Args: |
| 213 | + graph_id (str): |
| 214 | + idempotency_key (None | str | Unset): |
| 215 | + body (ConsolidationWorksheetRequest): Request for consolidation-worksheet (OLTP, entity |
| 216 | + graphs only). |
| 217 | +
|
| 218 | + Raises: |
| 219 | + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. |
| 220 | + httpx.TimeoutException: If the request takes longer than Client.timeout. |
| 221 | +
|
| 222 | + Returns: |
| 223 | + Response[ErrorResponse | OperationEnvelopeConsolidationWorksheetResponse] |
| 224 | + """ |
| 225 | + |
| 226 | + kwargs = _get_kwargs( |
| 227 | + graph_id=graph_id, |
| 228 | + body=body, |
| 229 | + idempotency_key=idempotency_key, |
| 230 | + ) |
| 231 | + |
| 232 | + response = await client.get_async_httpx_client().request(**kwargs) |
| 233 | + |
| 234 | + return _build_response(client=client, response=response) |
| 235 | + |
| 236 | + |
| 237 | +async def asyncio( |
| 238 | + graph_id: str, |
| 239 | + *, |
| 240 | + client: AuthenticatedClient, |
| 241 | + body: ConsolidationWorksheetRequest, |
| 242 | + idempotency_key: None | str | Unset = UNSET, |
| 243 | +) -> ErrorResponse | OperationEnvelopeConsolidationWorksheetResponse | None: |
| 244 | + """Consolidation Worksheet |
| 245 | +
|
| 246 | + The group's statement for one window with the entity as the column, read live from the tenant's OLTP |
| 247 | + ledger: the parent and each member consolidated in full, their combined sum, the consolidation |
| 248 | + entity's adjustments, the consolidated total, and each equity-method or cost member beside the sum, |
| 249 | + never in it. Every column renders under the group parent's Reporting Style. Rejected on shared- |
| 250 | + repository graphs. |
| 251 | +
|
| 252 | + **Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours |
| 253 | + return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict. |
| 254 | +
|
| 255 | + Args: |
| 256 | + graph_id (str): |
| 257 | + idempotency_key (None | str | Unset): |
| 258 | + body (ConsolidationWorksheetRequest): Request for consolidation-worksheet (OLTP, entity |
| 259 | + graphs only). |
| 260 | +
|
| 261 | + Raises: |
| 262 | + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. |
| 263 | + httpx.TimeoutException: If the request takes longer than Client.timeout. |
| 264 | +
|
| 265 | + Returns: |
| 266 | + ErrorResponse | OperationEnvelopeConsolidationWorksheetResponse |
| 267 | + """ |
| 268 | + |
| 269 | + return ( |
| 270 | + await asyncio_detailed( |
| 271 | + graph_id=graph_id, |
| 272 | + client=client, |
| 273 | + body=body, |
| 274 | + idempotency_key=idempotency_key, |
| 275 | + ) |
| 276 | + ).parsed |
0 commit comments