|
| 1 | +from http import HTTPStatus |
| 2 | +from typing import Any |
| 3 | +from urllib.parse import quote |
| 4 | +from uuid import UUID |
| 5 | + |
| 6 | +import httpx |
| 7 | + |
| 8 | +from ... import errors |
| 9 | +from ...client import AuthenticatedClient, Client |
| 10 | +from ...models.application_release_diff import ApplicationReleaseDiff |
| 11 | +from ...models.error import Error |
| 12 | +from ...types import UNSET, Response, Unset |
| 13 | + |
| 14 | + |
| 15 | +def _get_kwargs( |
| 16 | + id: UUID, |
| 17 | + application_id: int, |
| 18 | + *, |
| 19 | + from_release_id: str | Unset = UNSET, |
| 20 | + to_release_id: str | Unset = UNSET, |
| 21 | + limit: int | Unset = 100, |
| 22 | + offset: int | Unset = 0, |
| 23 | +) -> dict[str, Any]: |
| 24 | + |
| 25 | + params: dict[str, Any] = {} |
| 26 | + |
| 27 | + params["fromReleaseId"] = from_release_id |
| 28 | + |
| 29 | + params["toReleaseId"] = to_release_id |
| 30 | + |
| 31 | + params["limit"] = limit |
| 32 | + |
| 33 | + params["offset"] = offset |
| 34 | + |
| 35 | + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} |
| 36 | + |
| 37 | + _kwargs: dict[str, Any] = { |
| 38 | + "method": "get", |
| 39 | + "url": "/organisation/id/{id}/applications/{application_id}/diffs".format( |
| 40 | + id=quote(str(id), safe=""), |
| 41 | + application_id=quote(str(application_id), safe=""), |
| 42 | + ), |
| 43 | + "params": params, |
| 44 | + } |
| 45 | + |
| 46 | + return _kwargs |
| 47 | + |
| 48 | + |
| 49 | +def _parse_response( |
| 50 | + *, client: AuthenticatedClient | Client, response: httpx.Response |
| 51 | +) -> Error | list[ApplicationReleaseDiff] | None: |
| 52 | + if response.status_code == 200: |
| 53 | + response_200 = [] |
| 54 | + _response_200 = response.json() |
| 55 | + for response_200_item_data in _response_200: |
| 56 | + response_200_item = ApplicationReleaseDiff.from_dict(response_200_item_data) |
| 57 | + |
| 58 | + response_200.append(response_200_item) |
| 59 | + |
| 60 | + return response_200 |
| 61 | + |
| 62 | + if response.status_code == 400: |
| 63 | + response_400 = Error.from_dict(response.json()) |
| 64 | + |
| 65 | + return response_400 |
| 66 | + |
| 67 | + if response.status_code == 403: |
| 68 | + response_403 = Error.from_dict(response.json()) |
| 69 | + |
| 70 | + return response_403 |
| 71 | + |
| 72 | + if response.status_code == 404: |
| 73 | + response_404 = Error.from_dict(response.json()) |
| 74 | + |
| 75 | + return response_404 |
| 76 | + |
| 77 | + if client.raise_on_unexpected_status: |
| 78 | + raise errors.UnexpectedStatus(response.status_code, response.content) |
| 79 | + else: |
| 80 | + return None |
| 81 | + |
| 82 | + |
| 83 | +def _build_response( |
| 84 | + *, client: AuthenticatedClient | Client, response: httpx.Response |
| 85 | +) -> Response[Error | list[ApplicationReleaseDiff]]: |
| 86 | + return Response( |
| 87 | + status_code=HTTPStatus(response.status_code), |
| 88 | + content=response.content, |
| 89 | + headers=response.headers, |
| 90 | + parsed=_parse_response(client=client, response=response), |
| 91 | + ) |
| 92 | + |
| 93 | + |
| 94 | +def sync_detailed( |
| 95 | + id: UUID, |
| 96 | + application_id: int, |
| 97 | + *, |
| 98 | + client: AuthenticatedClient | Client, |
| 99 | + from_release_id: str | Unset = UNSET, |
| 100 | + to_release_id: str | Unset = UNSET, |
| 101 | + limit: int | Unset = 100, |
| 102 | + offset: int | Unset = 0, |
| 103 | +) -> Response[Error | list[ApplicationReleaseDiff]]: |
| 104 | + """Get release diffs for an application |
| 105 | +
|
| 106 | + Get release diffs for an application. Filter by fromReleaseId, toReleaseId, or both. If both are |
| 107 | + provided, returns the matching diff between those releases. |
| 108 | +
|
| 109 | + Args: |
| 110 | + id (UUID): |
| 111 | + application_id (int): |
| 112 | + from_release_id (str | Unset): |
| 113 | + to_release_id (str | Unset): |
| 114 | + limit (int | Unset): Default: 100. |
| 115 | + offset (int | Unset): Default: 0. |
| 116 | +
|
| 117 | + Raises: |
| 118 | + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. |
| 119 | + httpx.TimeoutException: If the request takes longer than Client.timeout. |
| 120 | +
|
| 121 | + Returns: |
| 122 | + Response[Error | list[ApplicationReleaseDiff]] |
| 123 | + """ |
| 124 | + |
| 125 | + kwargs = _get_kwargs( |
| 126 | + id=id, |
| 127 | + application_id=application_id, |
| 128 | + from_release_id=from_release_id, |
| 129 | + to_release_id=to_release_id, |
| 130 | + limit=limit, |
| 131 | + offset=offset, |
| 132 | + ) |
| 133 | + |
| 134 | + response = client.get_httpx_client().request( |
| 135 | + **kwargs, |
| 136 | + ) |
| 137 | + |
| 138 | + return _build_response(client=client, response=response) |
| 139 | + |
| 140 | + |
| 141 | +def sync( |
| 142 | + id: UUID, |
| 143 | + application_id: int, |
| 144 | + *, |
| 145 | + client: AuthenticatedClient | Client, |
| 146 | + from_release_id: str | Unset = UNSET, |
| 147 | + to_release_id: str | Unset = UNSET, |
| 148 | + limit: int | Unset = 100, |
| 149 | + offset: int | Unset = 0, |
| 150 | +) -> Error | list[ApplicationReleaseDiff] | None: |
| 151 | + """Get release diffs for an application |
| 152 | +
|
| 153 | + Get release diffs for an application. Filter by fromReleaseId, toReleaseId, or both. If both are |
| 154 | + provided, returns the matching diff between those releases. |
| 155 | +
|
| 156 | + Args: |
| 157 | + id (UUID): |
| 158 | + application_id (int): |
| 159 | + from_release_id (str | Unset): |
| 160 | + to_release_id (str | Unset): |
| 161 | + limit (int | Unset): Default: 100. |
| 162 | + offset (int | Unset): Default: 0. |
| 163 | +
|
| 164 | + Raises: |
| 165 | + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. |
| 166 | + httpx.TimeoutException: If the request takes longer than Client.timeout. |
| 167 | +
|
| 168 | + Returns: |
| 169 | + Error | list[ApplicationReleaseDiff] |
| 170 | + """ |
| 171 | + |
| 172 | + return sync_detailed( |
| 173 | + id=id, |
| 174 | + application_id=application_id, |
| 175 | + client=client, |
| 176 | + from_release_id=from_release_id, |
| 177 | + to_release_id=to_release_id, |
| 178 | + limit=limit, |
| 179 | + offset=offset, |
| 180 | + ).parsed |
| 181 | + |
| 182 | + |
| 183 | +async def asyncio_detailed( |
| 184 | + id: UUID, |
| 185 | + application_id: int, |
| 186 | + *, |
| 187 | + client: AuthenticatedClient | Client, |
| 188 | + from_release_id: str | Unset = UNSET, |
| 189 | + to_release_id: str | Unset = UNSET, |
| 190 | + limit: int | Unset = 100, |
| 191 | + offset: int | Unset = 0, |
| 192 | +) -> Response[Error | list[ApplicationReleaseDiff]]: |
| 193 | + """Get release diffs for an application |
| 194 | +
|
| 195 | + Get release diffs for an application. Filter by fromReleaseId, toReleaseId, or both. If both are |
| 196 | + provided, returns the matching diff between those releases. |
| 197 | +
|
| 198 | + Args: |
| 199 | + id (UUID): |
| 200 | + application_id (int): |
| 201 | + from_release_id (str | Unset): |
| 202 | + to_release_id (str | Unset): |
| 203 | + limit (int | Unset): Default: 100. |
| 204 | + offset (int | Unset): Default: 0. |
| 205 | +
|
| 206 | + Raises: |
| 207 | + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. |
| 208 | + httpx.TimeoutException: If the request takes longer than Client.timeout. |
| 209 | +
|
| 210 | + Returns: |
| 211 | + Response[Error | list[ApplicationReleaseDiff]] |
| 212 | + """ |
| 213 | + |
| 214 | + kwargs = _get_kwargs( |
| 215 | + id=id, |
| 216 | + application_id=application_id, |
| 217 | + from_release_id=from_release_id, |
| 218 | + to_release_id=to_release_id, |
| 219 | + limit=limit, |
| 220 | + offset=offset, |
| 221 | + ) |
| 222 | + |
| 223 | + response = await client.get_async_httpx_client().request(**kwargs) |
| 224 | + |
| 225 | + return _build_response(client=client, response=response) |
| 226 | + |
| 227 | + |
| 228 | +async def asyncio( |
| 229 | + id: UUID, |
| 230 | + application_id: int, |
| 231 | + *, |
| 232 | + client: AuthenticatedClient | Client, |
| 233 | + from_release_id: str | Unset = UNSET, |
| 234 | + to_release_id: str | Unset = UNSET, |
| 235 | + limit: int | Unset = 100, |
| 236 | + offset: int | Unset = 0, |
| 237 | +) -> Error | list[ApplicationReleaseDiff] | None: |
| 238 | + """Get release diffs for an application |
| 239 | +
|
| 240 | + Get release diffs for an application. Filter by fromReleaseId, toReleaseId, or both. If both are |
| 241 | + provided, returns the matching diff between those releases. |
| 242 | +
|
| 243 | + Args: |
| 244 | + id (UUID): |
| 245 | + application_id (int): |
| 246 | + from_release_id (str | Unset): |
| 247 | + to_release_id (str | Unset): |
| 248 | + limit (int | Unset): Default: 100. |
| 249 | + offset (int | Unset): Default: 0. |
| 250 | +
|
| 251 | + Raises: |
| 252 | + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. |
| 253 | + httpx.TimeoutException: If the request takes longer than Client.timeout. |
| 254 | +
|
| 255 | + Returns: |
| 256 | + Error | list[ApplicationReleaseDiff] |
| 257 | + """ |
| 258 | + |
| 259 | + return ( |
| 260 | + await asyncio_detailed( |
| 261 | + id=id, |
| 262 | + application_id=application_id, |
| 263 | + client=client, |
| 264 | + from_release_id=from_release_id, |
| 265 | + to_release_id=to_release_id, |
| 266 | + limit=limit, |
| 267 | + offset=offset, |
| 268 | + ) |
| 269 | + ).parsed |
0 commit comments