|
| 1 | +from http import HTTPStatus |
| 2 | +from typing import Any, Optional, Union |
| 3 | + |
| 4 | +import httpx |
| 5 | + |
| 6 | +from ... import errors |
| 7 | +from ...client import AuthenticatedClient, Client |
| 8 | +from ...models.get_projects_paginated_response_v2 import GetProjectsPaginatedResponseV2 |
| 9 | +from ...models.http_validation_error import HTTPValidationError |
| 10 | +from ...types import UNSET, Response, Unset |
| 11 | + |
| 12 | + |
| 13 | +def _get_kwargs( |
| 14 | + scorer_id: str, |
| 15 | + *, |
| 16 | + starting_token: Union[Unset, int] = 0, |
| 17 | + limit: Union[Unset, int] = 100, |
| 18 | +) -> dict[str, Any]: |
| 19 | + params: dict[str, Any] = {} |
| 20 | + |
| 21 | + params["starting_token"] = starting_token |
| 22 | + |
| 23 | + params["limit"] = limit |
| 24 | + |
| 25 | + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} |
| 26 | + |
| 27 | + _kwargs: dict[str, Any] = { |
| 28 | + "method": "get", |
| 29 | + "url": f"/scorers/{scorer_id}/projects", |
| 30 | + "params": params, |
| 31 | + } |
| 32 | + |
| 33 | + return _kwargs |
| 34 | + |
| 35 | + |
| 36 | +def _parse_response( |
| 37 | + *, client: Union[AuthenticatedClient, Client], response: httpx.Response |
| 38 | +) -> Optional[Union[GetProjectsPaginatedResponseV2, HTTPValidationError]]: |
| 39 | + if response.status_code == 200: |
| 40 | + response_200 = GetProjectsPaginatedResponseV2.from_dict(response.json()) |
| 41 | + |
| 42 | + return response_200 |
| 43 | + if response.status_code == 422: |
| 44 | + response_422 = HTTPValidationError.from_dict(response.json()) |
| 45 | + |
| 46 | + return response_422 |
| 47 | + if client.raise_on_unexpected_status: |
| 48 | + raise errors.UnexpectedStatus(response.status_code, response.content) |
| 49 | + else: |
| 50 | + return None |
| 51 | + |
| 52 | + |
| 53 | +def _build_response( |
| 54 | + *, client: Union[AuthenticatedClient, Client], response: httpx.Response |
| 55 | +) -> Response[Union[GetProjectsPaginatedResponseV2, HTTPValidationError]]: |
| 56 | + return Response( |
| 57 | + status_code=HTTPStatus(response.status_code), |
| 58 | + content=response.content, |
| 59 | + headers=response.headers, |
| 60 | + parsed=_parse_response(client=client, response=response), |
| 61 | + ) |
| 62 | + |
| 63 | + |
| 64 | +def sync_detailed( |
| 65 | + scorer_id: str, |
| 66 | + *, |
| 67 | + client: AuthenticatedClient, |
| 68 | + starting_token: Union[Unset, int] = 0, |
| 69 | + limit: Union[Unset, int] = 100, |
| 70 | +) -> Response[Union[GetProjectsPaginatedResponseV2, HTTPValidationError]]: |
| 71 | + """List Projects For Scorer Route |
| 72 | +
|
| 73 | + List all projects associated with a specific scorer. |
| 74 | +
|
| 75 | + Args: |
| 76 | + scorer_id (str): |
| 77 | + starting_token (Union[Unset, int]): Default: 0. |
| 78 | + limit (Union[Unset, int]): Default: 100. |
| 79 | +
|
| 80 | + Raises: |
| 81 | + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. |
| 82 | + httpx.TimeoutException: If the request takes longer than Client.timeout. |
| 83 | +
|
| 84 | + Returns: |
| 85 | + Response[Union[GetProjectsPaginatedResponseV2, HTTPValidationError]] |
| 86 | + """ |
| 87 | + |
| 88 | + kwargs = _get_kwargs( |
| 89 | + scorer_id=scorer_id, |
| 90 | + starting_token=starting_token, |
| 91 | + limit=limit, |
| 92 | + ) |
| 93 | + |
| 94 | + response = client.get_httpx_client().request( |
| 95 | + **kwargs, |
| 96 | + ) |
| 97 | + |
| 98 | + return _build_response(client=client, response=response) |
| 99 | + |
| 100 | + |
| 101 | +def sync( |
| 102 | + scorer_id: str, |
| 103 | + *, |
| 104 | + client: AuthenticatedClient, |
| 105 | + starting_token: Union[Unset, int] = 0, |
| 106 | + limit: Union[Unset, int] = 100, |
| 107 | +) -> Optional[Union[GetProjectsPaginatedResponseV2, HTTPValidationError]]: |
| 108 | + """List Projects For Scorer Route |
| 109 | +
|
| 110 | + List all projects associated with a specific scorer. |
| 111 | +
|
| 112 | + Args: |
| 113 | + scorer_id (str): |
| 114 | + starting_token (Union[Unset, int]): Default: 0. |
| 115 | + limit (Union[Unset, int]): Default: 100. |
| 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 | + Union[GetProjectsPaginatedResponseV2, HTTPValidationError] |
| 123 | + """ |
| 124 | + |
| 125 | + return sync_detailed( |
| 126 | + scorer_id=scorer_id, |
| 127 | + client=client, |
| 128 | + starting_token=starting_token, |
| 129 | + limit=limit, |
| 130 | + ).parsed |
| 131 | + |
| 132 | + |
| 133 | +async def asyncio_detailed( |
| 134 | + scorer_id: str, |
| 135 | + *, |
| 136 | + client: AuthenticatedClient, |
| 137 | + starting_token: Union[Unset, int] = 0, |
| 138 | + limit: Union[Unset, int] = 100, |
| 139 | +) -> Response[Union[GetProjectsPaginatedResponseV2, HTTPValidationError]]: |
| 140 | + """List Projects For Scorer Route |
| 141 | +
|
| 142 | + List all projects associated with a specific scorer. |
| 143 | +
|
| 144 | + Args: |
| 145 | + scorer_id (str): |
| 146 | + starting_token (Union[Unset, int]): Default: 0. |
| 147 | + limit (Union[Unset, int]): Default: 100. |
| 148 | +
|
| 149 | + Raises: |
| 150 | + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. |
| 151 | + httpx.TimeoutException: If the request takes longer than Client.timeout. |
| 152 | +
|
| 153 | + Returns: |
| 154 | + Response[Union[GetProjectsPaginatedResponseV2, HTTPValidationError]] |
| 155 | + """ |
| 156 | + |
| 157 | + kwargs = _get_kwargs( |
| 158 | + scorer_id=scorer_id, |
| 159 | + starting_token=starting_token, |
| 160 | + limit=limit, |
| 161 | + ) |
| 162 | + |
| 163 | + response = await client.get_async_httpx_client().request(**kwargs) |
| 164 | + |
| 165 | + return _build_response(client=client, response=response) |
| 166 | + |
| 167 | + |
| 168 | +async def asyncio( |
| 169 | + scorer_id: str, |
| 170 | + *, |
| 171 | + client: AuthenticatedClient, |
| 172 | + starting_token: Union[Unset, int] = 0, |
| 173 | + limit: Union[Unset, int] = 100, |
| 174 | +) -> Optional[Union[GetProjectsPaginatedResponseV2, HTTPValidationError]]: |
| 175 | + """List Projects For Scorer Route |
| 176 | +
|
| 177 | + List all projects associated with a specific scorer. |
| 178 | +
|
| 179 | + Args: |
| 180 | + scorer_id (str): |
| 181 | + starting_token (Union[Unset, int]): Default: 0. |
| 182 | + limit (Union[Unset, int]): Default: 100. |
| 183 | +
|
| 184 | + Raises: |
| 185 | + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. |
| 186 | + httpx.TimeoutException: If the request takes longer than Client.timeout. |
| 187 | +
|
| 188 | + Returns: |
| 189 | + Union[GetProjectsPaginatedResponseV2, HTTPValidationError] |
| 190 | + """ |
| 191 | + |
| 192 | + return ( |
| 193 | + await asyncio_detailed( |
| 194 | + scorer_id=scorer_id, |
| 195 | + client=client, |
| 196 | + starting_token=starting_token, |
| 197 | + limit=limit, |
| 198 | + ) |
| 199 | + ).parsed |
0 commit comments