Coverage for src/hush_hush/_generated/api/tokens/list_tokens.py: 0%

46 statements  

« prev     ^ index     » next       coverage.py v7.16.0, created at 2026-10-16 16:01 +0000

1# Code generated by openapi-python-client from hush-hush/api/openapi.yaml; DO NOT EDIT. 

2 

3from http import HTTPStatus 

4from typing import Any 

5 

6import httpx 

7 

8from ... import errors 

9from ...client import AuthenticatedClient, Client 

10from ...models.error import Error 

11from ...models.token_metadata import TokenMetadata 

12from ...types import UNSET, Response, Unset 

13 

14 

15def _get_kwargs( 

16 *, 

17 limit: int | Unset = 50, 

18 offset: int | Unset = UNSET, 

19) -> dict[str, Any]: 

20 

21 params: dict[str, Any] = {} 

22 

23 params["limit"] = limit 

24 

25 params["offset"] = offset 

26 

27 params = {k: v for k, v in params.items() if v is not UNSET and v is not None} 

28 

29 _kwargs: dict[str, Any] = { 

30 "method": "get", 

31 "url": "/tokens", 

32 "params": params, 

33 } 

34 

35 return _kwargs 

36 

37 

38def _parse_response( 

39 *, client: AuthenticatedClient | Client, response: httpx.Response 

40) -> Error | list[TokenMetadata] | None: 

41 if response.status_code == 200: 

42 response_200 = [] 

43 _response_200 = response.json() 

44 for response_200_item_data in _response_200: 

45 response_200_item = TokenMetadata.from_dict(response_200_item_data) 

46 

47 response_200.append(response_200_item) 

48 

49 return response_200 

50 

51 if response.status_code == 400: 

52 response_400 = Error.from_dict(response.json()) 

53 

54 return response_400 

55 

56 if response.status_code == 401: 

57 response_401 = Error.from_dict(response.json()) 

58 

59 return response_401 

60 

61 if client.raise_on_unexpected_status: 

62 raise errors.UnexpectedStatus(response.status_code, response.content) 

63 else: 

64 return None 

65 

66 

67def _build_response( 

68 *, client: AuthenticatedClient | Client, response: httpx.Response 

69) -> Response[Error | list[TokenMetadata]]: 

70 return Response( 

71 status_code=HTTPStatus(response.status_code), 

72 content=response.content, 

73 headers=response.headers, 

74 parsed=_parse_response(client=client, response=response), 

75 ) 

76 

77 

78def sync_detailed( 

79 *, 

80 client: AuthenticatedClient, 

81 limit: int | Unset = 50, 

82 offset: int | Unset = UNSET, 

83) -> Response[Error | list[TokenMetadata]]: 

84 """List write bearer tokens 

85 

86 Returns every issued token's metadata - never a raw value, which 

87 by design no longer exists anywhere to return once a token is 

88 created. Includes tokens issued via the `token` CLI command 

89 alongside ones created here; a CLI-issued token has no owner. 

90 

91 Args: 

92 limit (int | Unset): Default: 50. 

93 offset (int | Unset): 

94 

95 Raises: 

96 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. 

97 httpx.TimeoutException: If the request takes longer than Client.timeout. 

98 

99 Returns: 

100 Response[Error | list[TokenMetadata]] 

101 """ 

102 

103 kwargs = _get_kwargs( 

104 limit=limit, 

105 offset=offset, 

106 ) 

107 

108 response = client.get_httpx_client().request( 

109 **kwargs, 

110 ) 

111 

112 return _build_response(client=client, response=response) 

113 

114 

115def sync( 

116 *, 

117 client: AuthenticatedClient, 

118 limit: int | Unset = 50, 

119 offset: int | Unset = UNSET, 

120) -> Error | list[TokenMetadata] | None: 

121 """List write bearer tokens 

122 

123 Returns every issued token's metadata - never a raw value, which 

124 by design no longer exists anywhere to return once a token is 

125 created. Includes tokens issued via the `token` CLI command 

126 alongside ones created here; a CLI-issued token has no owner. 

127 

128 Args: 

129 limit (int | Unset): Default: 50. 

130 offset (int | Unset): 

131 

132 Raises: 

133 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. 

134 httpx.TimeoutException: If the request takes longer than Client.timeout. 

135 

136 Returns: 

137 Error | list[TokenMetadata] 

138 """ 

139 

140 return sync_detailed( 

141 client=client, 

142 limit=limit, 

143 offset=offset, 

144 ).parsed 

145 

146 

147async def asyncio_detailed( 

148 *, 

149 client: AuthenticatedClient, 

150 limit: int | Unset = 50, 

151 offset: int | Unset = UNSET, 

152) -> Response[Error | list[TokenMetadata]]: 

153 """List write bearer tokens 

154 

155 Returns every issued token's metadata - never a raw value, which 

156 by design no longer exists anywhere to return once a token is 

157 created. Includes tokens issued via the `token` CLI command 

158 alongside ones created here; a CLI-issued token has no owner. 

159 

160 Args: 

161 limit (int | Unset): Default: 50. 

162 offset (int | Unset): 

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 Response[Error | list[TokenMetadata]] 

170 """ 

171 

172 kwargs = _get_kwargs( 

173 limit=limit, 

174 offset=offset, 

175 ) 

176 

177 response = await client.get_async_httpx_client().request(**kwargs) 

178 

179 return _build_response(client=client, response=response) 

180 

181 

182async def asyncio( 

183 *, 

184 client: AuthenticatedClient, 

185 limit: int | Unset = 50, 

186 offset: int | Unset = UNSET, 

187) -> Error | list[TokenMetadata] | None: 

188 """List write bearer tokens 

189 

190 Returns every issued token's metadata - never a raw value, which 

191 by design no longer exists anywhere to return once a token is 

192 created. Includes tokens issued via the `token` CLI command 

193 alongside ones created here; a CLI-issued token has no owner. 

194 

195 Args: 

196 limit (int | Unset): Default: 50. 

197 offset (int | Unset): 

198 

199 Raises: 

200 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. 

201 httpx.TimeoutException: If the request takes longer than Client.timeout. 

202 

203 Returns: 

204 Error | list[TokenMetadata] 

205 """ 

206 

207 return ( 

208 await asyncio_detailed( 

209 client=client, 

210 limit=limit, 

211 offset=offset, 

212 ) 

213 ).parsed