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.
- sinatra_dev/__init__.py +71 -0
- sinatra_dev/_client.py +391 -0
- sinatra_dev/_errors.py +53 -0
- sinatra_dev/_generated/__init__.py +8 -0
- sinatra_dev/_generated/api/__init__.py +1 -0
- sinatra_dev/_generated/api/me/__init__.py +1 -0
- sinatra_dev/_generated/api/me/me_get.py +156 -0
- sinatra_dev/_generated/api/me/me_revoke_token.py +173 -0
- sinatra_dev/_generated/api/messages/__init__.py +1 -0
- sinatra_dev/_generated/api/messages/messages_create.py +323 -0
- sinatra_dev/_generated/api/messages/messages_list.py +332 -0
- sinatra_dev/_generated/api/tasks/__init__.py +1 -0
- sinatra_dev/_generated/api/tasks/tasks_create.py +337 -0
- sinatra_dev/_generated/api/tasks/tasks_get.py +202 -0
- sinatra_dev/_generated/api/tasks/tasks_list.py +252 -0
- sinatra_dev/_generated/api/tasks/tasks_stop.py +231 -0
- sinatra_dev/_generated/api/tickets/__init__.py +1 -0
- sinatra_dev/_generated/api/tickets/tickets_delegate.py +273 -0
- sinatra_dev/_generated/api/tickets/tickets_search.py +265 -0
- sinatra_dev/_generated/client.py +280 -0
- sinatra_dev/_generated/errors.py +16 -0
- sinatra_dev/_generated/models/__init__.py +47 -0
- sinatra_dev/_generated/models/create_message_request.py +62 -0
- sinatra_dev/_generated/models/create_message_response.py +62 -0
- sinatra_dev/_generated/models/create_task_request.py +106 -0
- sinatra_dev/_generated/models/create_task_response.py +76 -0
- sinatra_dev/_generated/models/delegate_github_ticket.py +86 -0
- sinatra_dev/_generated/models/delegate_linear_ticket.py +78 -0
- sinatra_dev/_generated/models/delegate_ticket_response.py +62 -0
- sinatra_dev/_generated/models/error.py +168 -0
- sinatra_dev/_generated/models/me.py +86 -0
- sinatra_dev/_generated/models/me_user.py +98 -0
- sinatra_dev/_generated/models/message.py +113 -0
- sinatra_dev/_generated/models/message_list.py +91 -0
- sinatra_dev/_generated/models/pull_request.py +70 -0
- sinatra_dev/_generated/models/stop_task_response.py +62 -0
- sinatra_dev/_generated/models/task.py +201 -0
- sinatra_dev/_generated/models/task_list.py +91 -0
- sinatra_dev/_generated/models/ticket.py +147 -0
- sinatra_dev/_generated/models/ticket_search_result.py +97 -0
- sinatra_dev/_generated/models/ticket_search_result_github.py +77 -0
- sinatra_dev/_generated/models/ticket_search_result_linear.py +79 -0
- sinatra_dev/_generated/models/workspace.py +78 -0
- sinatra_dev/_generated/types.py +54 -0
- sinatra_dev/_retry.py +72 -0
- sinatra_dev/py.typed +0 -0
- sinatra_dev-0.1.0.dist-info/METADATA +184 -0
- sinatra_dev-0.1.0.dist-info/RECORD +50 -0
- sinatra_dev-0.1.0.dist-info/WHEEL +4 -0
- sinatra_dev-0.1.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import ssl
|
|
2
|
+
from typing import Any, Self
|
|
3
|
+
|
|
4
|
+
import httpx
|
|
5
|
+
from attrs import define, evolve, field
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@define
|
|
9
|
+
class Client:
|
|
10
|
+
"""A class for keeping track of data related to the API
|
|
11
|
+
|
|
12
|
+
The following are accepted as keyword arguments and will be used to construct httpx Clients internally:
|
|
13
|
+
|
|
14
|
+
``base_url``: The base URL for the API, all requests are made to a relative path to this URL
|
|
15
|
+
|
|
16
|
+
``cookies``: A dictionary of cookies to be sent with every request
|
|
17
|
+
|
|
18
|
+
``headers``: A dictionary of headers to be sent with every request
|
|
19
|
+
|
|
20
|
+
``timeout``: The maximum amount of a time a request can take. API functions will raise
|
|
21
|
+
httpx.TimeoutException if this is exceeded.
|
|
22
|
+
|
|
23
|
+
``verify_ssl``: Whether or not to verify the SSL certificate of the API server. This should be True in production,
|
|
24
|
+
but can be set to False for testing purposes.
|
|
25
|
+
|
|
26
|
+
``follow_redirects``: Whether or not to follow redirects. Default value is False.
|
|
27
|
+
|
|
28
|
+
``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor.
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
Attributes:
|
|
32
|
+
raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a
|
|
33
|
+
status code that was not documented in the source OpenAPI document. Can also be provided as a keyword
|
|
34
|
+
argument to the constructor.
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
raise_on_unexpected_status: bool = field(default=False, kw_only=True)
|
|
38
|
+
_base_url: str = field(alias="base_url")
|
|
39
|
+
_cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies")
|
|
40
|
+
_headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers")
|
|
41
|
+
_timeout: httpx.Timeout | None = field(default=None, kw_only=True, alias="timeout")
|
|
42
|
+
_verify_ssl: str | bool | ssl.SSLContext = field(
|
|
43
|
+
default=True, kw_only=True, alias="verify_ssl"
|
|
44
|
+
)
|
|
45
|
+
_follow_redirects: bool = field(
|
|
46
|
+
default=False, kw_only=True, alias="follow_redirects"
|
|
47
|
+
)
|
|
48
|
+
_httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args")
|
|
49
|
+
_client: httpx.Client | None = field(default=None, init=False)
|
|
50
|
+
_async_client: httpx.AsyncClient | None = field(default=None, init=False)
|
|
51
|
+
|
|
52
|
+
def with_headers(self, headers: dict[str, str]) -> "Client":
|
|
53
|
+
"""Get a new client matching this one with additional headers"""
|
|
54
|
+
if self._client is not None:
|
|
55
|
+
self._client.headers.update(headers)
|
|
56
|
+
if self._async_client is not None:
|
|
57
|
+
self._async_client.headers.update(headers)
|
|
58
|
+
return evolve(self, headers={**self._headers, **headers})
|
|
59
|
+
|
|
60
|
+
def with_cookies(self, cookies: dict[str, str]) -> "Client":
|
|
61
|
+
"""Get a new client matching this one with additional cookies"""
|
|
62
|
+
if self._client is not None:
|
|
63
|
+
self._client.cookies.update(cookies)
|
|
64
|
+
if self._async_client is not None:
|
|
65
|
+
self._async_client.cookies.update(cookies)
|
|
66
|
+
return evolve(self, cookies={**self._cookies, **cookies})
|
|
67
|
+
|
|
68
|
+
def with_timeout(self, timeout: httpx.Timeout) -> "Client":
|
|
69
|
+
"""Get a new client matching this one with a new timeout configuration"""
|
|
70
|
+
if self._client is not None:
|
|
71
|
+
self._client.timeout = timeout
|
|
72
|
+
if self._async_client is not None:
|
|
73
|
+
self._async_client.timeout = timeout
|
|
74
|
+
return evolve(self, timeout=timeout)
|
|
75
|
+
|
|
76
|
+
def set_httpx_client(self, client: httpx.Client) -> Self:
|
|
77
|
+
"""Manually set the underlying httpx.Client
|
|
78
|
+
|
|
79
|
+
**NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
|
|
80
|
+
"""
|
|
81
|
+
self._client = client
|
|
82
|
+
return self
|
|
83
|
+
|
|
84
|
+
def get_httpx_client(self) -> httpx.Client:
|
|
85
|
+
"""Get the underlying httpx.Client, constructing a new one if not previously set"""
|
|
86
|
+
if self._client is None:
|
|
87
|
+
self._client = httpx.Client(
|
|
88
|
+
base_url=self._base_url,
|
|
89
|
+
cookies=self._cookies,
|
|
90
|
+
headers=self._headers,
|
|
91
|
+
timeout=self._timeout,
|
|
92
|
+
verify=self._verify_ssl,
|
|
93
|
+
follow_redirects=self._follow_redirects,
|
|
94
|
+
**self._httpx_args,
|
|
95
|
+
)
|
|
96
|
+
return self._client
|
|
97
|
+
|
|
98
|
+
def __enter__(self) -> Self:
|
|
99
|
+
"""Enter a context manager for self.client—you cannot enter twice (see httpx docs)"""
|
|
100
|
+
self.get_httpx_client().__enter__()
|
|
101
|
+
return self
|
|
102
|
+
|
|
103
|
+
def __exit__(self, *args: object, **kwargs: Any) -> None:
|
|
104
|
+
"""Exit a context manager for internal httpx.Client (see httpx docs)"""
|
|
105
|
+
self.get_httpx_client().__exit__(*args, **kwargs)
|
|
106
|
+
|
|
107
|
+
def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> Self:
|
|
108
|
+
"""Manually set the underlying httpx.AsyncClient
|
|
109
|
+
|
|
110
|
+
**NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
|
|
111
|
+
"""
|
|
112
|
+
self._async_client = async_client
|
|
113
|
+
return self
|
|
114
|
+
|
|
115
|
+
def get_async_httpx_client(self) -> httpx.AsyncClient:
|
|
116
|
+
"""Get the underlying httpx.AsyncClient, constructing a new one if not previously set"""
|
|
117
|
+
if self._async_client is None:
|
|
118
|
+
self._async_client = httpx.AsyncClient(
|
|
119
|
+
base_url=self._base_url,
|
|
120
|
+
cookies=self._cookies,
|
|
121
|
+
headers=self._headers,
|
|
122
|
+
timeout=self._timeout,
|
|
123
|
+
verify=self._verify_ssl,
|
|
124
|
+
follow_redirects=self._follow_redirects,
|
|
125
|
+
**self._httpx_args,
|
|
126
|
+
)
|
|
127
|
+
return self._async_client
|
|
128
|
+
|
|
129
|
+
async def __aenter__(self) -> Self:
|
|
130
|
+
"""Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)"""
|
|
131
|
+
await self.get_async_httpx_client().__aenter__()
|
|
132
|
+
return self
|
|
133
|
+
|
|
134
|
+
async def __aexit__(self, *args: object, **kwargs: Any) -> None:
|
|
135
|
+
"""Exit a context manager for underlying httpx.AsyncClient (see httpx docs)"""
|
|
136
|
+
await self.get_async_httpx_client().__aexit__(*args, **kwargs)
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
@define
|
|
140
|
+
class AuthenticatedClient:
|
|
141
|
+
"""A Client which has been authenticated for use on secured endpoints
|
|
142
|
+
|
|
143
|
+
The following are accepted as keyword arguments and will be used to construct httpx Clients internally:
|
|
144
|
+
|
|
145
|
+
``base_url``: The base URL for the API, all requests are made to a relative path to this URL
|
|
146
|
+
|
|
147
|
+
``cookies``: A dictionary of cookies to be sent with every request
|
|
148
|
+
|
|
149
|
+
``headers``: A dictionary of headers to be sent with every request
|
|
150
|
+
|
|
151
|
+
``timeout``: The maximum amount of a time a request can take. API functions will raise
|
|
152
|
+
httpx.TimeoutException if this is exceeded.
|
|
153
|
+
|
|
154
|
+
``verify_ssl``: Whether or not to verify the SSL certificate of the API server. This should be True in production,
|
|
155
|
+
but can be set to False for testing purposes.
|
|
156
|
+
|
|
157
|
+
``follow_redirects``: Whether or not to follow redirects. Default value is False.
|
|
158
|
+
|
|
159
|
+
``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor.
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
Attributes:
|
|
163
|
+
raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a
|
|
164
|
+
status code that was not documented in the source OpenAPI document. Can also be provided as a keyword
|
|
165
|
+
argument to the constructor.
|
|
166
|
+
token: The token to use for authentication
|
|
167
|
+
prefix: The prefix to use for the Authorization header
|
|
168
|
+
auth_header_name: The name of the Authorization header
|
|
169
|
+
"""
|
|
170
|
+
|
|
171
|
+
raise_on_unexpected_status: bool = field(default=False, kw_only=True)
|
|
172
|
+
_base_url: str = field(alias="base_url")
|
|
173
|
+
_cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies")
|
|
174
|
+
_headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers")
|
|
175
|
+
_timeout: httpx.Timeout | None = field(default=None, kw_only=True, alias="timeout")
|
|
176
|
+
_verify_ssl: str | bool | ssl.SSLContext = field(
|
|
177
|
+
default=True, kw_only=True, alias="verify_ssl"
|
|
178
|
+
)
|
|
179
|
+
_follow_redirects: bool = field(
|
|
180
|
+
default=False, kw_only=True, alias="follow_redirects"
|
|
181
|
+
)
|
|
182
|
+
_httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args")
|
|
183
|
+
_client: httpx.Client | None = field(default=None, init=False)
|
|
184
|
+
_async_client: httpx.AsyncClient | None = field(default=None, init=False)
|
|
185
|
+
|
|
186
|
+
token: str
|
|
187
|
+
prefix: str = "Bearer"
|
|
188
|
+
auth_header_name: str = "Authorization"
|
|
189
|
+
|
|
190
|
+
def with_headers(self, headers: dict[str, str]) -> "AuthenticatedClient":
|
|
191
|
+
"""Get a new client matching this one with additional headers"""
|
|
192
|
+
if self._client is not None:
|
|
193
|
+
self._client.headers.update(headers)
|
|
194
|
+
if self._async_client is not None:
|
|
195
|
+
self._async_client.headers.update(headers)
|
|
196
|
+
return evolve(self, headers={**self._headers, **headers})
|
|
197
|
+
|
|
198
|
+
def with_cookies(self, cookies: dict[str, str]) -> "AuthenticatedClient":
|
|
199
|
+
"""Get a new client matching this one with additional cookies"""
|
|
200
|
+
if self._client is not None:
|
|
201
|
+
self._client.cookies.update(cookies)
|
|
202
|
+
if self._async_client is not None:
|
|
203
|
+
self._async_client.cookies.update(cookies)
|
|
204
|
+
return evolve(self, cookies={**self._cookies, **cookies})
|
|
205
|
+
|
|
206
|
+
def with_timeout(self, timeout: httpx.Timeout) -> "AuthenticatedClient":
|
|
207
|
+
"""Get a new client matching this one with a new timeout configuration"""
|
|
208
|
+
if self._client is not None:
|
|
209
|
+
self._client.timeout = timeout
|
|
210
|
+
if self._async_client is not None:
|
|
211
|
+
self._async_client.timeout = timeout
|
|
212
|
+
return evolve(self, timeout=timeout)
|
|
213
|
+
|
|
214
|
+
def set_httpx_client(self, client: httpx.Client) -> Self:
|
|
215
|
+
"""Manually set the underlying httpx.Client
|
|
216
|
+
|
|
217
|
+
**NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
|
|
218
|
+
"""
|
|
219
|
+
self._client = client
|
|
220
|
+
return self
|
|
221
|
+
|
|
222
|
+
def get_httpx_client(self) -> httpx.Client:
|
|
223
|
+
"""Get the underlying httpx.Client, constructing a new one if not previously set"""
|
|
224
|
+
if self._client is None:
|
|
225
|
+
self._headers[self.auth_header_name] = (
|
|
226
|
+
f"{self.prefix} {self.token}" if self.prefix else self.token
|
|
227
|
+
)
|
|
228
|
+
self._client = httpx.Client(
|
|
229
|
+
base_url=self._base_url,
|
|
230
|
+
cookies=self._cookies,
|
|
231
|
+
headers=self._headers,
|
|
232
|
+
timeout=self._timeout,
|
|
233
|
+
verify=self._verify_ssl,
|
|
234
|
+
follow_redirects=self._follow_redirects,
|
|
235
|
+
**self._httpx_args,
|
|
236
|
+
)
|
|
237
|
+
return self._client
|
|
238
|
+
|
|
239
|
+
def __enter__(self) -> Self:
|
|
240
|
+
"""Enter a context manager for self.client—you cannot enter twice (see httpx docs)"""
|
|
241
|
+
self.get_httpx_client().__enter__()
|
|
242
|
+
return self
|
|
243
|
+
|
|
244
|
+
def __exit__(self, *args: object, **kwargs: Any) -> None:
|
|
245
|
+
"""Exit a context manager for internal httpx.Client (see httpx docs)"""
|
|
246
|
+
self.get_httpx_client().__exit__(*args, **kwargs)
|
|
247
|
+
|
|
248
|
+
def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> Self:
|
|
249
|
+
"""Manually set the underlying httpx.AsyncClient
|
|
250
|
+
|
|
251
|
+
**NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
|
|
252
|
+
"""
|
|
253
|
+
self._async_client = async_client
|
|
254
|
+
return self
|
|
255
|
+
|
|
256
|
+
def get_async_httpx_client(self) -> httpx.AsyncClient:
|
|
257
|
+
"""Get the underlying httpx.AsyncClient, constructing a new one if not previously set"""
|
|
258
|
+
if self._async_client is None:
|
|
259
|
+
self._headers[self.auth_header_name] = (
|
|
260
|
+
f"{self.prefix} {self.token}" if self.prefix else self.token
|
|
261
|
+
)
|
|
262
|
+
self._async_client = httpx.AsyncClient(
|
|
263
|
+
base_url=self._base_url,
|
|
264
|
+
cookies=self._cookies,
|
|
265
|
+
headers=self._headers,
|
|
266
|
+
timeout=self._timeout,
|
|
267
|
+
verify=self._verify_ssl,
|
|
268
|
+
follow_redirects=self._follow_redirects,
|
|
269
|
+
**self._httpx_args,
|
|
270
|
+
)
|
|
271
|
+
return self._async_client
|
|
272
|
+
|
|
273
|
+
async def __aenter__(self) -> Self:
|
|
274
|
+
"""Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)"""
|
|
275
|
+
await self.get_async_httpx_client().__aenter__()
|
|
276
|
+
return self
|
|
277
|
+
|
|
278
|
+
async def __aexit__(self, *args: object, **kwargs: Any) -> None:
|
|
279
|
+
"""Exit a context manager for underlying httpx.AsyncClient (see httpx docs)"""
|
|
280
|
+
await self.get_async_httpx_client().__aexit__(*args, **kwargs)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"""Contains shared errors types that can be raised from API functions"""
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class UnexpectedStatus(Exception):
|
|
5
|
+
"""Raised by api functions when the response status an undocumented status and Client.raise_on_unexpected_status is True"""
|
|
6
|
+
|
|
7
|
+
def __init__(self, status_code: int, content: bytes):
|
|
8
|
+
self.status_code = status_code
|
|
9
|
+
self.content = content
|
|
10
|
+
|
|
11
|
+
super().__init__(
|
|
12
|
+
f"Unexpected status code: {status_code}\n\nResponse content:\n{content.decode(errors='ignore')}"
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
__all__ = ["UnexpectedStatus"]
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"""Contains all the data models used in inputs/outputs"""
|
|
2
|
+
|
|
3
|
+
from .create_message_request import CreateMessageRequest
|
|
4
|
+
from .create_message_response import CreateMessageResponse
|
|
5
|
+
from .create_task_request import CreateTaskRequest
|
|
6
|
+
from .create_task_response import CreateTaskResponse
|
|
7
|
+
from .delegate_github_ticket import DelegateGithubTicket
|
|
8
|
+
from .delegate_linear_ticket import DelegateLinearTicket
|
|
9
|
+
from .delegate_ticket_response import DelegateTicketResponse
|
|
10
|
+
from .error import Error
|
|
11
|
+
from .me import Me
|
|
12
|
+
from .me_user import MeUser
|
|
13
|
+
from .message import Message
|
|
14
|
+
from .message_list import MessageList
|
|
15
|
+
from .pull_request import PullRequest
|
|
16
|
+
from .stop_task_response import StopTaskResponse
|
|
17
|
+
from .task import Task
|
|
18
|
+
from .task_list import TaskList
|
|
19
|
+
from .ticket import Ticket
|
|
20
|
+
from .ticket_search_result import TicketSearchResult
|
|
21
|
+
from .ticket_search_result_github import TicketSearchResultGithub
|
|
22
|
+
from .ticket_search_result_linear import TicketSearchResultLinear
|
|
23
|
+
from .workspace import Workspace
|
|
24
|
+
|
|
25
|
+
__all__ = (
|
|
26
|
+
"CreateMessageRequest",
|
|
27
|
+
"CreateMessageResponse",
|
|
28
|
+
"CreateTaskRequest",
|
|
29
|
+
"CreateTaskResponse",
|
|
30
|
+
"DelegateGithubTicket",
|
|
31
|
+
"DelegateLinearTicket",
|
|
32
|
+
"DelegateTicketResponse",
|
|
33
|
+
"Error",
|
|
34
|
+
"Me",
|
|
35
|
+
"MeUser",
|
|
36
|
+
"Message",
|
|
37
|
+
"MessageList",
|
|
38
|
+
"PullRequest",
|
|
39
|
+
"StopTaskResponse",
|
|
40
|
+
"Task",
|
|
41
|
+
"TaskList",
|
|
42
|
+
"Ticket",
|
|
43
|
+
"TicketSearchResult",
|
|
44
|
+
"TicketSearchResultGithub",
|
|
45
|
+
"TicketSearchResultLinear",
|
|
46
|
+
"Workspace",
|
|
47
|
+
)
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from collections.abc import Mapping
|
|
4
|
+
from typing import Any, Self, TypeVar
|
|
5
|
+
|
|
6
|
+
from attrs import define as _attrs_define
|
|
7
|
+
from attrs import field as _attrs_field
|
|
8
|
+
|
|
9
|
+
T = TypeVar("T", bound="CreateMessageRequest")
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@_attrs_define
|
|
13
|
+
class CreateMessageRequest:
|
|
14
|
+
"""A message to send on a task.
|
|
15
|
+
|
|
16
|
+
Attributes:
|
|
17
|
+
text (str): The message, up to 100,000 characters after trimming.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
text: str
|
|
21
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
22
|
+
|
|
23
|
+
def to_dict(self) -> dict[str, Any]:
|
|
24
|
+
text = self.text
|
|
25
|
+
|
|
26
|
+
field_dict: dict[str, Any] = {}
|
|
27
|
+
field_dict.update(self.additional_properties)
|
|
28
|
+
field_dict.update(
|
|
29
|
+
{
|
|
30
|
+
"text": text,
|
|
31
|
+
}
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
return field_dict
|
|
35
|
+
|
|
36
|
+
@classmethod
|
|
37
|
+
def from_dict(cls, src_dict: Mapping[str, Any]) -> Self:
|
|
38
|
+
d = dict(src_dict)
|
|
39
|
+
text = d.pop("text")
|
|
40
|
+
|
|
41
|
+
create_message_request = cls(
|
|
42
|
+
text=text,
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
create_message_request.additional_properties = d
|
|
46
|
+
return create_message_request
|
|
47
|
+
|
|
48
|
+
@property
|
|
49
|
+
def additional_keys(self) -> list[str]:
|
|
50
|
+
return list(self.additional_properties.keys())
|
|
51
|
+
|
|
52
|
+
def __getitem__(self, key: str) -> Any:
|
|
53
|
+
return self.additional_properties[key]
|
|
54
|
+
|
|
55
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
56
|
+
self.additional_properties[key] = value
|
|
57
|
+
|
|
58
|
+
def __delitem__(self, key: str) -> None:
|
|
59
|
+
del self.additional_properties[key]
|
|
60
|
+
|
|
61
|
+
def __contains__(self, key: str) -> bool:
|
|
62
|
+
return key in self.additional_properties
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from collections.abc import Mapping
|
|
4
|
+
from typing import Any, Self, TypeVar
|
|
5
|
+
|
|
6
|
+
from attrs import define as _attrs_define
|
|
7
|
+
from attrs import field as _attrs_field
|
|
8
|
+
|
|
9
|
+
T = TypeVar("T", bound="CreateMessageResponse")
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@_attrs_define
|
|
13
|
+
class CreateMessageResponse:
|
|
14
|
+
"""The message that was sent.
|
|
15
|
+
|
|
16
|
+
Attributes:
|
|
17
|
+
message_id (str): The message's id: the `Idempotency-Key` you sent, or a generated id.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
message_id: str
|
|
21
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
22
|
+
|
|
23
|
+
def to_dict(self) -> dict[str, Any]:
|
|
24
|
+
message_id = self.message_id
|
|
25
|
+
|
|
26
|
+
field_dict: dict[str, Any] = {}
|
|
27
|
+
field_dict.update(self.additional_properties)
|
|
28
|
+
field_dict.update(
|
|
29
|
+
{
|
|
30
|
+
"messageId": message_id,
|
|
31
|
+
}
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
return field_dict
|
|
35
|
+
|
|
36
|
+
@classmethod
|
|
37
|
+
def from_dict(cls, src_dict: Mapping[str, Any]) -> Self:
|
|
38
|
+
d = dict(src_dict)
|
|
39
|
+
message_id = d.pop("messageId")
|
|
40
|
+
|
|
41
|
+
create_message_response = cls(
|
|
42
|
+
message_id=message_id,
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
create_message_response.additional_properties = d
|
|
46
|
+
return create_message_response
|
|
47
|
+
|
|
48
|
+
@property
|
|
49
|
+
def additional_keys(self) -> list[str]:
|
|
50
|
+
return list(self.additional_properties.keys())
|
|
51
|
+
|
|
52
|
+
def __getitem__(self, key: str) -> Any:
|
|
53
|
+
return self.additional_properties[key]
|
|
54
|
+
|
|
55
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
56
|
+
self.additional_properties[key] = value
|
|
57
|
+
|
|
58
|
+
def __delitem__(self, key: str) -> None:
|
|
59
|
+
del self.additional_properties[key]
|
|
60
|
+
|
|
61
|
+
def __contains__(self, key: str) -> bool:
|
|
62
|
+
return key in self.additional_properties
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from collections.abc import Mapping
|
|
4
|
+
from typing import Any, Self, TypeVar, cast
|
|
5
|
+
|
|
6
|
+
from attrs import define as _attrs_define
|
|
7
|
+
from attrs import field as _attrs_field
|
|
8
|
+
|
|
9
|
+
from ..types import UNSET, Unset
|
|
10
|
+
|
|
11
|
+
T = TypeVar("T", bound="CreateTaskRequest")
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@_attrs_define
|
|
15
|
+
class CreateTaskRequest:
|
|
16
|
+
"""A task to start.
|
|
17
|
+
|
|
18
|
+
Attributes:
|
|
19
|
+
prompt (str): What to do, as you'd ask a teammate. Up to 100,000 characters, after trimming.
|
|
20
|
+
title (None | str | Unset): The task's title, up to 200 characters. Defaults to the prompt's first line, cut to
|
|
21
|
+
80 characters.
|
|
22
|
+
repo (None | str | Unset): `owner/name` of a repository connected to the workspace. Omit it to let the agent
|
|
23
|
+
choose.
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
prompt: str
|
|
27
|
+
title: None | str | Unset = UNSET
|
|
28
|
+
repo: None | str | Unset = UNSET
|
|
29
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
30
|
+
|
|
31
|
+
def to_dict(self) -> dict[str, Any]:
|
|
32
|
+
prompt = self.prompt
|
|
33
|
+
|
|
34
|
+
title: None | str | Unset
|
|
35
|
+
if isinstance(self.title, Unset):
|
|
36
|
+
title = UNSET
|
|
37
|
+
else:
|
|
38
|
+
title = self.title
|
|
39
|
+
|
|
40
|
+
repo: None | str | Unset
|
|
41
|
+
if isinstance(self.repo, Unset):
|
|
42
|
+
repo = UNSET
|
|
43
|
+
else:
|
|
44
|
+
repo = self.repo
|
|
45
|
+
|
|
46
|
+
field_dict: dict[str, Any] = {}
|
|
47
|
+
field_dict.update(self.additional_properties)
|
|
48
|
+
field_dict.update(
|
|
49
|
+
{
|
|
50
|
+
"prompt": prompt,
|
|
51
|
+
}
|
|
52
|
+
)
|
|
53
|
+
if title is not UNSET:
|
|
54
|
+
field_dict["title"] = title
|
|
55
|
+
if repo is not UNSET:
|
|
56
|
+
field_dict["repo"] = repo
|
|
57
|
+
|
|
58
|
+
return field_dict
|
|
59
|
+
|
|
60
|
+
@classmethod
|
|
61
|
+
def from_dict(cls, src_dict: Mapping[str, Any]) -> Self:
|
|
62
|
+
d = dict(src_dict)
|
|
63
|
+
prompt = d.pop("prompt")
|
|
64
|
+
|
|
65
|
+
def _parse_title(data: object) -> None | str | Unset:
|
|
66
|
+
if data is None:
|
|
67
|
+
return data
|
|
68
|
+
if isinstance(data, Unset):
|
|
69
|
+
return data
|
|
70
|
+
return cast(None | str | Unset, data)
|
|
71
|
+
|
|
72
|
+
title = _parse_title(d.pop("title", UNSET))
|
|
73
|
+
|
|
74
|
+
def _parse_repo(data: object) -> None | str | Unset:
|
|
75
|
+
if data is None:
|
|
76
|
+
return data
|
|
77
|
+
if isinstance(data, Unset):
|
|
78
|
+
return data
|
|
79
|
+
return cast(None | str | Unset, data)
|
|
80
|
+
|
|
81
|
+
repo = _parse_repo(d.pop("repo", UNSET))
|
|
82
|
+
|
|
83
|
+
create_task_request = cls(
|
|
84
|
+
prompt=prompt,
|
|
85
|
+
title=title,
|
|
86
|
+
repo=repo,
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
create_task_request.additional_properties = d
|
|
90
|
+
return create_task_request
|
|
91
|
+
|
|
92
|
+
@property
|
|
93
|
+
def additional_keys(self) -> list[str]:
|
|
94
|
+
return list(self.additional_properties.keys())
|
|
95
|
+
|
|
96
|
+
def __getitem__(self, key: str) -> Any:
|
|
97
|
+
return self.additional_properties[key]
|
|
98
|
+
|
|
99
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
100
|
+
self.additional_properties[key] = value
|
|
101
|
+
|
|
102
|
+
def __delitem__(self, key: str) -> None:
|
|
103
|
+
del self.additional_properties[key]
|
|
104
|
+
|
|
105
|
+
def __contains__(self, key: str) -> bool:
|
|
106
|
+
return key in self.additional_properties
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from collections.abc import Mapping
|
|
4
|
+
from typing import TYPE_CHECKING, Any, Self, TypeVar
|
|
5
|
+
|
|
6
|
+
from attrs import define as _attrs_define
|
|
7
|
+
from attrs import field as _attrs_field
|
|
8
|
+
|
|
9
|
+
if TYPE_CHECKING:
|
|
10
|
+
from ..models.task import Task
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
T = TypeVar("T", bound="CreateTaskResponse")
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@_attrs_define
|
|
17
|
+
class CreateTaskResponse:
|
|
18
|
+
"""The task that started, and the id of your first message.
|
|
19
|
+
|
|
20
|
+
Attributes:
|
|
21
|
+
task (Task): A task: one piece of work Sinatra does, from any source.
|
|
22
|
+
message_id (str): The id of your first message: the `Idempotency-Key` you sent, or a generated id.
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
task: Task
|
|
26
|
+
message_id: str
|
|
27
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
28
|
+
|
|
29
|
+
def to_dict(self) -> dict[str, Any]:
|
|
30
|
+
task = self.task.to_dict()
|
|
31
|
+
|
|
32
|
+
message_id = self.message_id
|
|
33
|
+
|
|
34
|
+
field_dict: dict[str, Any] = {}
|
|
35
|
+
field_dict.update(self.additional_properties)
|
|
36
|
+
field_dict.update(
|
|
37
|
+
{
|
|
38
|
+
"task": task,
|
|
39
|
+
"messageId": message_id,
|
|
40
|
+
}
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
return field_dict
|
|
44
|
+
|
|
45
|
+
@classmethod
|
|
46
|
+
def from_dict(cls, src_dict: Mapping[str, Any]) -> Self:
|
|
47
|
+
from ..models.task import Task
|
|
48
|
+
|
|
49
|
+
d = dict(src_dict)
|
|
50
|
+
task = Task.from_dict(d.pop("task"))
|
|
51
|
+
|
|
52
|
+
message_id = d.pop("messageId")
|
|
53
|
+
|
|
54
|
+
create_task_response = cls(
|
|
55
|
+
task=task,
|
|
56
|
+
message_id=message_id,
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
create_task_response.additional_properties = d
|
|
60
|
+
return create_task_response
|
|
61
|
+
|
|
62
|
+
@property
|
|
63
|
+
def additional_keys(self) -> list[str]:
|
|
64
|
+
return list(self.additional_properties.keys())
|
|
65
|
+
|
|
66
|
+
def __getitem__(self, key: str) -> Any:
|
|
67
|
+
return self.additional_properties[key]
|
|
68
|
+
|
|
69
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
70
|
+
self.additional_properties[key] = value
|
|
71
|
+
|
|
72
|
+
def __delitem__(self, key: str) -> None:
|
|
73
|
+
del self.additional_properties[key]
|
|
74
|
+
|
|
75
|
+
def __contains__(self, key: str) -> bool:
|
|
76
|
+
return key in self.additional_properties
|