Coverage for src/hush_hush/_generated/api/credentials/rename_credential.py: 0%

51 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 

5from urllib.parse import quote 

6 

7import httpx 

8 

9from ... import errors 

10from ...client import AuthenticatedClient, Client 

11from ...models.credential import Credential 

12from ...models.credential_rename_request import CredentialRenameRequest 

13from ...models.error import Error 

14from ...types import Response 

15 

16 

17def _get_kwargs( 

18 id: str, 

19 *, 

20 body: CredentialRenameRequest, 

21 x_csrf_token: str, 

22) -> dict[str, Any]: 

23 headers: dict[str, Any] = {} 

24 headers["X-CSRF-Token"] = x_csrf_token 

25 

26 _kwargs: dict[str, Any] = { 

27 "method": "patch", 

28 "url": "/credentials/{id}".format( 

29 id=quote(str(id), safe=""), 

30 ), 

31 } 

32 

33 _kwargs["json"] = body.to_dict() 

34 

35 headers["Content-Type"] = "application/json" 

36 

37 _kwargs["headers"] = headers 

38 return _kwargs 

39 

40 

41def _parse_response( 

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

43) -> Credential | Error | None: 

44 if response.status_code == 200: 

45 response_200 = Credential.from_dict(response.json()) 

46 

47 return response_200 

48 

49 if response.status_code == 401: 

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

51 

52 return response_401 

53 

54 if response.status_code == 404: 

55 response_404 = Error.from_dict(response.json()) 

56 

57 return response_404 

58 

59 if response.status_code == 413: 

60 response_413 = Error.from_dict(response.json()) 

61 

62 return response_413 

63 

64 if response.status_code == 422: 

65 response_422 = Error.from_dict(response.json()) 

66 

67 return response_422 

68 

69 if client.raise_on_unexpected_status: 

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

71 else: 

72 return None 

73 

74 

75def _build_response( 

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

77) -> Response[Credential | Error]: 

78 return Response( 

79 status_code=HTTPStatus(response.status_code), 

80 content=response.content, 

81 headers=response.headers, 

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

83 ) 

84 

85 

86def sync_detailed( 

87 id: str, 

88 *, 

89 client: AuthenticatedClient, 

90 body: CredentialRenameRequest, 

91 x_csrf_token: str, 

92) -> Response[Credential | Error]: 

93 """Rename a passkey 

94 

95 Args: 

96 id (str): 

97 x_csrf_token (str): 

98 body (CredentialRenameRequest): 

99 

100 Raises: 

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

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

103 

104 Returns: 

105 Response[Credential | Error] 

106 """ 

107 

108 kwargs = _get_kwargs( 

109 id=id, 

110 body=body, 

111 x_csrf_token=x_csrf_token, 

112 ) 

113 

114 response = client.get_httpx_client().request( 

115 **kwargs, 

116 ) 

117 

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

119 

120 

121def sync( 

122 id: str, 

123 *, 

124 client: AuthenticatedClient, 

125 body: CredentialRenameRequest, 

126 x_csrf_token: str, 

127) -> Credential | Error | None: 

128 """Rename a passkey 

129 

130 Args: 

131 id (str): 

132 x_csrf_token (str): 

133 body (CredentialRenameRequest): 

134 

135 Raises: 

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

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

138 

139 Returns: 

140 Credential | Error 

141 """ 

142 

143 return sync_detailed( 

144 id=id, 

145 client=client, 

146 body=body, 

147 x_csrf_token=x_csrf_token, 

148 ).parsed 

149 

150 

151async def asyncio_detailed( 

152 id: str, 

153 *, 

154 client: AuthenticatedClient, 

155 body: CredentialRenameRequest, 

156 x_csrf_token: str, 

157) -> Response[Credential | Error]: 

158 """Rename a passkey 

159 

160 Args: 

161 id (str): 

162 x_csrf_token (str): 

163 body (CredentialRenameRequest): 

164 

165 Raises: 

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

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

168 

169 Returns: 

170 Response[Credential | Error] 

171 """ 

172 

173 kwargs = _get_kwargs( 

174 id=id, 

175 body=body, 

176 x_csrf_token=x_csrf_token, 

177 ) 

178 

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

180 

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

182 

183 

184async def asyncio( 

185 id: str, 

186 *, 

187 client: AuthenticatedClient, 

188 body: CredentialRenameRequest, 

189 x_csrf_token: str, 

190) -> Credential | Error | None: 

191 """Rename a passkey 

192 

193 Args: 

194 id (str): 

195 x_csrf_token (str): 

196 body (CredentialRenameRequest): 

197 

198 Raises: 

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

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

201 

202 Returns: 

203 Credential | Error 

204 """ 

205 

206 return ( 

207 await asyncio_detailed( 

208 id=id, 

209 client=client, 

210 body=body, 

211 x_csrf_token=x_csrf_token, 

212 ) 

213 ).parsed