sinatra-dev 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. sinatra_dev/__init__.py +71 -0
  2. sinatra_dev/_client.py +391 -0
  3. sinatra_dev/_errors.py +53 -0
  4. sinatra_dev/_generated/__init__.py +8 -0
  5. sinatra_dev/_generated/api/__init__.py +1 -0
  6. sinatra_dev/_generated/api/me/__init__.py +1 -0
  7. sinatra_dev/_generated/api/me/me_get.py +156 -0
  8. sinatra_dev/_generated/api/me/me_revoke_token.py +173 -0
  9. sinatra_dev/_generated/api/messages/__init__.py +1 -0
  10. sinatra_dev/_generated/api/messages/messages_create.py +323 -0
  11. sinatra_dev/_generated/api/messages/messages_list.py +332 -0
  12. sinatra_dev/_generated/api/tasks/__init__.py +1 -0
  13. sinatra_dev/_generated/api/tasks/tasks_create.py +337 -0
  14. sinatra_dev/_generated/api/tasks/tasks_get.py +202 -0
  15. sinatra_dev/_generated/api/tasks/tasks_list.py +252 -0
  16. sinatra_dev/_generated/api/tasks/tasks_stop.py +231 -0
  17. sinatra_dev/_generated/api/tickets/__init__.py +1 -0
  18. sinatra_dev/_generated/api/tickets/tickets_delegate.py +273 -0
  19. sinatra_dev/_generated/api/tickets/tickets_search.py +265 -0
  20. sinatra_dev/_generated/client.py +280 -0
  21. sinatra_dev/_generated/errors.py +16 -0
  22. sinatra_dev/_generated/models/__init__.py +47 -0
  23. sinatra_dev/_generated/models/create_message_request.py +62 -0
  24. sinatra_dev/_generated/models/create_message_response.py +62 -0
  25. sinatra_dev/_generated/models/create_task_request.py +106 -0
  26. sinatra_dev/_generated/models/create_task_response.py +76 -0
  27. sinatra_dev/_generated/models/delegate_github_ticket.py +86 -0
  28. sinatra_dev/_generated/models/delegate_linear_ticket.py +78 -0
  29. sinatra_dev/_generated/models/delegate_ticket_response.py +62 -0
  30. sinatra_dev/_generated/models/error.py +168 -0
  31. sinatra_dev/_generated/models/me.py +86 -0
  32. sinatra_dev/_generated/models/me_user.py +98 -0
  33. sinatra_dev/_generated/models/message.py +113 -0
  34. sinatra_dev/_generated/models/message_list.py +91 -0
  35. sinatra_dev/_generated/models/pull_request.py +70 -0
  36. sinatra_dev/_generated/models/stop_task_response.py +62 -0
  37. sinatra_dev/_generated/models/task.py +201 -0
  38. sinatra_dev/_generated/models/task_list.py +91 -0
  39. sinatra_dev/_generated/models/ticket.py +147 -0
  40. sinatra_dev/_generated/models/ticket_search_result.py +97 -0
  41. sinatra_dev/_generated/models/ticket_search_result_github.py +77 -0
  42. sinatra_dev/_generated/models/ticket_search_result_linear.py +79 -0
  43. sinatra_dev/_generated/models/workspace.py +78 -0
  44. sinatra_dev/_generated/types.py +54 -0
  45. sinatra_dev/_retry.py +72 -0
  46. sinatra_dev/py.typed +0 -0
  47. sinatra_dev-0.1.0.dist-info/METADATA +184 -0
  48. sinatra_dev-0.1.0.dist-info/RECORD +50 -0
  49. sinatra_dev-0.1.0.dist-info/WHEEL +4 -0
  50. sinatra_dev-0.1.0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,273 @@
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.delegate_github_ticket import DelegateGithubTicket
10
+ from ...models.delegate_linear_ticket import DelegateLinearTicket
11
+ from ...models.delegate_ticket_response import DelegateTicketResponse
12
+ from ...models.error import Error
13
+ from ...types import Response
14
+
15
+
16
+ def _get_kwargs(
17
+ workspace_id: str,
18
+ *,
19
+ body: DelegateGithubTicket | DelegateLinearTicket,
20
+ ) -> dict[str, Any]:
21
+ headers: dict[str, Any] = {}
22
+
23
+ _kwargs: dict[str, Any] = {
24
+ "method": "post",
25
+ "url": "/v1/workspaces/{workspace_id}/tickets/delegate".format(
26
+ workspace_id=quote(str(workspace_id), safe=""),
27
+ ),
28
+ }
29
+
30
+ if isinstance(body, DelegateLinearTicket):
31
+ _kwargs["json"] = body.to_dict()
32
+ else:
33
+ _kwargs["json"] = body.to_dict()
34
+
35
+ headers["Content-Type"] = "application/json"
36
+
37
+ _kwargs["headers"] = headers
38
+ return _kwargs
39
+
40
+
41
+ def _parse_response(
42
+ *, client: AuthenticatedClient | Client, response: httpx.Response
43
+ ) -> DelegateTicketResponse | Error | None:
44
+ if response.status_code == 202:
45
+ response_202 = DelegateTicketResponse.from_dict(response.json())
46
+
47
+ return response_202
48
+
49
+ if response.status_code == 400:
50
+ response_400 = Error.from_dict(response.json())
51
+
52
+ return response_400
53
+
54
+ if response.status_code == 401:
55
+ response_401 = Error.from_dict(response.json())
56
+
57
+ return response_401
58
+
59
+ if response.status_code == 404:
60
+ response_404 = Error.from_dict(response.json())
61
+
62
+ return response_404
63
+
64
+ if response.status_code == 409:
65
+ response_409 = Error.from_dict(response.json())
66
+
67
+ return response_409
68
+
69
+ if response.status_code == 413:
70
+ response_413 = Error.from_dict(response.json())
71
+
72
+ return response_413
73
+
74
+ if response.status_code == 415:
75
+ response_415 = Error.from_dict(response.json())
76
+
77
+ return response_415
78
+
79
+ if response.status_code == 429:
80
+ response_429 = Error.from_dict(response.json())
81
+
82
+ return response_429
83
+
84
+ if response.status_code == 500:
85
+ response_500 = Error.from_dict(response.json())
86
+
87
+ return response_500
88
+
89
+ if client.raise_on_unexpected_status:
90
+ raise errors.UnexpectedStatus(response.status_code, response.content)
91
+ else:
92
+ return None
93
+
94
+
95
+ def _build_response(
96
+ *, client: AuthenticatedClient | Client, response: httpx.Response
97
+ ) -> Response[DelegateTicketResponse | Error]:
98
+ return Response(
99
+ status_code=HTTPStatus(response.status_code),
100
+ content=response.content,
101
+ headers=response.headers,
102
+ parsed=_parse_response(client=client, response=response),
103
+ )
104
+
105
+
106
+ def sync_detailed(
107
+ workspace_id: str,
108
+ *,
109
+ client: AuthenticatedClient | Client,
110
+ body: DelegateGithubTicket | DelegateLinearTicket,
111
+ ) -> Response[DelegateTicketResponse | Error]:
112
+ """Delegate an issue
113
+
114
+ Hands Sinatra an existing Linear or GitHub issue as you, as if you'd assigned it to Sinatra
115
+ yourself, and returns `202` with `{"ok": true}`. The task then runs on the issue. Its conversation
116
+ is there, not under Read the conversation, and it appears in List tasks once Sinatra picks it up.
117
+
118
+ The rules match delegating from the dashboard. Sinatra reads a Linear issue as your linked Linear
119
+ account, so you can only delegate issues you can see. Closed issues, pull requests and issues
120
+ assigned to someone else are refused. If the workspace's queue is full, the request is refused
121
+ before the issue is touched.
122
+
123
+ A refusal returns an `error` code and a `reason` that says what to fix, for example `{"error":
124
+ "linear_identity_unlinked", "reason": "Link your Linear identity in Settings first."}`.
125
+
126
+ Args:
127
+ workspace_id (str):
128
+ body (DelegateGithubTicket | DelegateLinearTicket): An issue to delegate: a Linear issue
129
+ by `id`, or a GitHub issue by `repo` and `number`.
130
+
131
+ Raises:
132
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
133
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
134
+
135
+ Returns:
136
+ Response[DelegateTicketResponse | Error]
137
+ """
138
+
139
+ kwargs = _get_kwargs(
140
+ workspace_id=workspace_id,
141
+ body=body,
142
+ )
143
+
144
+ response = client.get_httpx_client().request(
145
+ **kwargs,
146
+ )
147
+
148
+ return _build_response(client=client, response=response)
149
+
150
+
151
+ def sync(
152
+ workspace_id: str,
153
+ *,
154
+ client: AuthenticatedClient | Client,
155
+ body: DelegateGithubTicket | DelegateLinearTicket,
156
+ ) -> DelegateTicketResponse | Error | None:
157
+ """Delegate an issue
158
+
159
+ Hands Sinatra an existing Linear or GitHub issue as you, as if you'd assigned it to Sinatra
160
+ yourself, and returns `202` with `{"ok": true}`. The task then runs on the issue. Its conversation
161
+ is there, not under Read the conversation, and it appears in List tasks once Sinatra picks it up.
162
+
163
+ The rules match delegating from the dashboard. Sinatra reads a Linear issue as your linked Linear
164
+ account, so you can only delegate issues you can see. Closed issues, pull requests and issues
165
+ assigned to someone else are refused. If the workspace's queue is full, the request is refused
166
+ before the issue is touched.
167
+
168
+ A refusal returns an `error` code and a `reason` that says what to fix, for example `{"error":
169
+ "linear_identity_unlinked", "reason": "Link your Linear identity in Settings first."}`.
170
+
171
+ Args:
172
+ workspace_id (str):
173
+ body (DelegateGithubTicket | DelegateLinearTicket): An issue to delegate: a Linear issue
174
+ by `id`, or a GitHub issue by `repo` and `number`.
175
+
176
+ Raises:
177
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
178
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
179
+
180
+ Returns:
181
+ DelegateTicketResponse | Error
182
+ """
183
+
184
+ return sync_detailed(
185
+ workspace_id=workspace_id,
186
+ client=client,
187
+ body=body,
188
+ ).parsed
189
+
190
+
191
+ async def asyncio_detailed(
192
+ workspace_id: str,
193
+ *,
194
+ client: AuthenticatedClient | Client,
195
+ body: DelegateGithubTicket | DelegateLinearTicket,
196
+ ) -> Response[DelegateTicketResponse | Error]:
197
+ """Delegate an issue
198
+
199
+ Hands Sinatra an existing Linear or GitHub issue as you, as if you'd assigned it to Sinatra
200
+ yourself, and returns `202` with `{"ok": true}`. The task then runs on the issue. Its conversation
201
+ is there, not under Read the conversation, and it appears in List tasks once Sinatra picks it up.
202
+
203
+ The rules match delegating from the dashboard. Sinatra reads a Linear issue as your linked Linear
204
+ account, so you can only delegate issues you can see. Closed issues, pull requests and issues
205
+ assigned to someone else are refused. If the workspace's queue is full, the request is refused
206
+ before the issue is touched.
207
+
208
+ A refusal returns an `error` code and a `reason` that says what to fix, for example `{"error":
209
+ "linear_identity_unlinked", "reason": "Link your Linear identity in Settings first."}`.
210
+
211
+ Args:
212
+ workspace_id (str):
213
+ body (DelegateGithubTicket | DelegateLinearTicket): An issue to delegate: a Linear issue
214
+ by `id`, or a GitHub issue by `repo` and `number`.
215
+
216
+ Raises:
217
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
218
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
219
+
220
+ Returns:
221
+ Response[DelegateTicketResponse | Error]
222
+ """
223
+
224
+ kwargs = _get_kwargs(
225
+ workspace_id=workspace_id,
226
+ body=body,
227
+ )
228
+
229
+ response = await client.get_async_httpx_client().request(**kwargs)
230
+
231
+ return _build_response(client=client, response=response)
232
+
233
+
234
+ async def asyncio(
235
+ workspace_id: str,
236
+ *,
237
+ client: AuthenticatedClient | Client,
238
+ body: DelegateGithubTicket | DelegateLinearTicket,
239
+ ) -> DelegateTicketResponse | Error | None:
240
+ """Delegate an issue
241
+
242
+ Hands Sinatra an existing Linear or GitHub issue as you, as if you'd assigned it to Sinatra
243
+ yourself, and returns `202` with `{"ok": true}`. The task then runs on the issue. Its conversation
244
+ is there, not under Read the conversation, and it appears in List tasks once Sinatra picks it up.
245
+
246
+ The rules match delegating from the dashboard. Sinatra reads a Linear issue as your linked Linear
247
+ account, so you can only delegate issues you can see. Closed issues, pull requests and issues
248
+ assigned to someone else are refused. If the workspace's queue is full, the request is refused
249
+ before the issue is touched.
250
+
251
+ A refusal returns an `error` code and a `reason` that says what to fix, for example `{"error":
252
+ "linear_identity_unlinked", "reason": "Link your Linear identity in Settings first."}`.
253
+
254
+ Args:
255
+ workspace_id (str):
256
+ body (DelegateGithubTicket | DelegateLinearTicket): An issue to delegate: a Linear issue
257
+ by `id`, or a GitHub issue by `repo` and `number`.
258
+
259
+ Raises:
260
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
261
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
262
+
263
+ Returns:
264
+ DelegateTicketResponse | Error
265
+ """
266
+
267
+ return (
268
+ await asyncio_detailed(
269
+ workspace_id=workspace_id,
270
+ client=client,
271
+ body=body,
272
+ )
273
+ ).parsed
@@ -0,0 +1,265 @@
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.error import Error
10
+ from ...models.ticket_search_result import TicketSearchResult
11
+ from ...types import UNSET, Response, Unset
12
+
13
+
14
+ def _get_kwargs(
15
+ workspace_id: str,
16
+ *,
17
+ q: str | Unset = UNSET,
18
+ repo: str | Unset = UNSET,
19
+ ) -> dict[str, Any]:
20
+
21
+ params: dict[str, Any] = {}
22
+
23
+ params["q"] = q
24
+
25
+ params["repo"] = repo
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": "/v1/workspaces/{workspace_id}/tickets".format(
32
+ workspace_id=quote(str(workspace_id), safe=""),
33
+ ),
34
+ "params": params,
35
+ }
36
+
37
+ return _kwargs
38
+
39
+
40
+ def _parse_response(
41
+ *, client: AuthenticatedClient | Client, response: httpx.Response
42
+ ) -> Error | TicketSearchResult | None:
43
+ if response.status_code == 200:
44
+ response_200 = TicketSearchResult.from_dict(response.json())
45
+
46
+ return response_200
47
+
48
+ if response.status_code == 401:
49
+ response_401 = Error.from_dict(response.json())
50
+
51
+ return response_401
52
+
53
+ if response.status_code == 404:
54
+ response_404 = Error.from_dict(response.json())
55
+
56
+ return response_404
57
+
58
+ if response.status_code == 429:
59
+ response_429 = Error.from_dict(response.json())
60
+
61
+ return response_429
62
+
63
+ if response.status_code == 500:
64
+ response_500 = Error.from_dict(response.json())
65
+
66
+ return response_500
67
+
68
+ if response.status_code == 503:
69
+ response_503 = Error.from_dict(response.json())
70
+
71
+ return response_503
72
+
73
+ if client.raise_on_unexpected_status:
74
+ raise errors.UnexpectedStatus(response.status_code, response.content)
75
+ else:
76
+ return None
77
+
78
+
79
+ def _build_response(
80
+ *, client: AuthenticatedClient | Client, response: httpx.Response
81
+ ) -> Response[Error | TicketSearchResult]:
82
+ return Response(
83
+ status_code=HTTPStatus(response.status_code),
84
+ content=response.content,
85
+ headers=response.headers,
86
+ parsed=_parse_response(client=client, response=response),
87
+ )
88
+
89
+
90
+ def sync_detailed(
91
+ workspace_id: str,
92
+ *,
93
+ client: AuthenticatedClient | Client,
94
+ q: str | Unset = UNSET,
95
+ repo: str | Unset = UNSET,
96
+ ) -> Response[Error | TicketSearchResult]:
97
+ """Search issues
98
+
99
+ Lists the open Linear and GitHub issues you could delegate. It is the same list as the dashboard's
100
+ ticket picker: yours first, then your team's unassigned ones, Linear's before GitHub's, at most 10
101
+ from each tracker.
102
+
103
+ Issues assigned to someone else, closed, or already being worked on are left out, and so are pull
104
+ requests. Linear issues appear only when your Linear account is linked, and are read as you. GitHub
105
+ issues appear only if you have a GitHub account, and only from the repositories enabled in the
106
+ workspace.
107
+
108
+ To delegate one, pass a Linear issue's `identifier` as `id`, or a GitHub issue's `identifier` split
109
+ into `repo` and `number`.
110
+
111
+ Args:
112
+ workspace_id (str):
113
+ q (str | Unset):
114
+ repo (str | Unset):
115
+
116
+ Raises:
117
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
118
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
119
+
120
+ Returns:
121
+ Response[Error | TicketSearchResult]
122
+ """
123
+
124
+ kwargs = _get_kwargs(
125
+ workspace_id=workspace_id,
126
+ q=q,
127
+ repo=repo,
128
+ )
129
+
130
+ response = client.get_httpx_client().request(
131
+ **kwargs,
132
+ )
133
+
134
+ return _build_response(client=client, response=response)
135
+
136
+
137
+ def sync(
138
+ workspace_id: str,
139
+ *,
140
+ client: AuthenticatedClient | Client,
141
+ q: str | Unset = UNSET,
142
+ repo: str | Unset = UNSET,
143
+ ) -> Error | TicketSearchResult | None:
144
+ """Search issues
145
+
146
+ Lists the open Linear and GitHub issues you could delegate. It is the same list as the dashboard's
147
+ ticket picker: yours first, then your team's unassigned ones, Linear's before GitHub's, at most 10
148
+ from each tracker.
149
+
150
+ Issues assigned to someone else, closed, or already being worked on are left out, and so are pull
151
+ requests. Linear issues appear only when your Linear account is linked, and are read as you. GitHub
152
+ issues appear only if you have a GitHub account, and only from the repositories enabled in the
153
+ workspace.
154
+
155
+ To delegate one, pass a Linear issue's `identifier` as `id`, or a GitHub issue's `identifier` split
156
+ into `repo` and `number`.
157
+
158
+ Args:
159
+ workspace_id (str):
160
+ q (str | Unset):
161
+ repo (str | Unset):
162
+
163
+ Raises:
164
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
165
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
166
+
167
+ Returns:
168
+ Error | TicketSearchResult
169
+ """
170
+
171
+ return sync_detailed(
172
+ workspace_id=workspace_id,
173
+ client=client,
174
+ q=q,
175
+ repo=repo,
176
+ ).parsed
177
+
178
+
179
+ async def asyncio_detailed(
180
+ workspace_id: str,
181
+ *,
182
+ client: AuthenticatedClient | Client,
183
+ q: str | Unset = UNSET,
184
+ repo: str | Unset = UNSET,
185
+ ) -> Response[Error | TicketSearchResult]:
186
+ """Search issues
187
+
188
+ Lists the open Linear and GitHub issues you could delegate. It is the same list as the dashboard's
189
+ ticket picker: yours first, then your team's unassigned ones, Linear's before GitHub's, at most 10
190
+ from each tracker.
191
+
192
+ Issues assigned to someone else, closed, or already being worked on are left out, and so are pull
193
+ requests. Linear issues appear only when your Linear account is linked, and are read as you. GitHub
194
+ issues appear only if you have a GitHub account, and only from the repositories enabled in the
195
+ workspace.
196
+
197
+ To delegate one, pass a Linear issue's `identifier` as `id`, or a GitHub issue's `identifier` split
198
+ into `repo` and `number`.
199
+
200
+ Args:
201
+ workspace_id (str):
202
+ q (str | Unset):
203
+ repo (str | Unset):
204
+
205
+ Raises:
206
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
207
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
208
+
209
+ Returns:
210
+ Response[Error | TicketSearchResult]
211
+ """
212
+
213
+ kwargs = _get_kwargs(
214
+ workspace_id=workspace_id,
215
+ q=q,
216
+ repo=repo,
217
+ )
218
+
219
+ response = await client.get_async_httpx_client().request(**kwargs)
220
+
221
+ return _build_response(client=client, response=response)
222
+
223
+
224
+ async def asyncio(
225
+ workspace_id: str,
226
+ *,
227
+ client: AuthenticatedClient | Client,
228
+ q: str | Unset = UNSET,
229
+ repo: str | Unset = UNSET,
230
+ ) -> Error | TicketSearchResult | None:
231
+ """Search issues
232
+
233
+ Lists the open Linear and GitHub issues you could delegate. It is the same list as the dashboard's
234
+ ticket picker: yours first, then your team's unassigned ones, Linear's before GitHub's, at most 10
235
+ from each tracker.
236
+
237
+ Issues assigned to someone else, closed, or already being worked on are left out, and so are pull
238
+ requests. Linear issues appear only when your Linear account is linked, and are read as you. GitHub
239
+ issues appear only if you have a GitHub account, and only from the repositories enabled in the
240
+ workspace.
241
+
242
+ To delegate one, pass a Linear issue's `identifier` as `id`, or a GitHub issue's `identifier` split
243
+ into `repo` and `number`.
244
+
245
+ Args:
246
+ workspace_id (str):
247
+ q (str | Unset):
248
+ repo (str | Unset):
249
+
250
+ Raises:
251
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
252
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
253
+
254
+ Returns:
255
+ Error | TicketSearchResult
256
+ """
257
+
258
+ return (
259
+ await asyncio_detailed(
260
+ workspace_id=workspace_id,
261
+ client=client,
262
+ q=q,
263
+ repo=repo,
264
+ )
265
+ ).parsed