opencode-python-sdk 0.0.1.dev1__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 (62) hide show
  1. opencode/.generated.json +39 -0
  2. opencode/__init__.py +221 -0
  3. opencode/_base_client.py +539 -0
  4. opencode/_client.py +255 -0
  5. opencode/_constants.py +27 -0
  6. opencode/_errors.py +547 -0
  7. opencode/_events.py +732 -0
  8. opencode/_exceptions.py +271 -0
  9. opencode/_models.py +54 -0
  10. opencode/_pagination.py +192 -0
  11. opencode/_pty.py +586 -0
  12. opencode/_qs.py +95 -0
  13. opencode/_resource.py +42 -0
  14. opencode/_rpc.py +489 -0
  15. opencode/_server.py +335 -0
  16. opencode/_streaming.py +248 -0
  17. opencode/_types.py +77 -0
  18. opencode/_unions.py +46 -0
  19. opencode/_version.py +8 -0
  20. opencode/lib/__init__.py +5 -0
  21. opencode/lib/_ready.py +91 -0
  22. opencode/lib/_session.py +231 -0
  23. opencode/py.typed +0 -0
  24. opencode/resources/__init__.py +364 -0
  25. opencode/resources/agent.py +179 -0
  26. opencode/resources/command.py +100 -0
  27. opencode/resources/config.py +240 -0
  28. opencode/resources/credential.py +384 -0
  29. opencode/resources/debug.py +178 -0
  30. opencode/resources/event.py +88 -0
  31. opencode/resources/experimental.py +765 -0
  32. opencode/resources/file.py +355 -0
  33. opencode/resources/form.py +100 -0
  34. opencode/resources/generate.py +110 -0
  35. opencode/resources/integration.py +1033 -0
  36. opencode/resources/location.py +162 -0
  37. opencode/resources/mcp.py +492 -0
  38. opencode/resources/message.py +152 -0
  39. opencode/resources/migration.py +118 -0
  40. opencode/resources/model.py +177 -0
  41. opencode/resources/permission.py +704 -0
  42. opencode/resources/plugin.py +250 -0
  43. opencode/resources/project.py +187 -0
  44. opencode/resources/provider.py +183 -0
  45. opencode/resources/pty.py +522 -0
  46. opencode/resources/reference.py +100 -0
  47. opencode/resources/rpc.py +113 -0
  48. opencode/resources/server.py +230 -0
  49. opencode/resources/session.py +3567 -0
  50. opencode/resources/shell.py +412 -0
  51. opencode/resources/skill.py +100 -0
  52. opencode/resources/vcs.py +500 -0
  53. opencode/resources/voice.py +113 -0
  54. opencode/resources/websearch.py +184 -0
  55. opencode/resources/worktree.py +336 -0
  56. opencode/testing.py +508 -0
  57. opencode/types/__init__.py +1462 -0
  58. opencode/types/_generated.py +8540 -0
  59. opencode_python_sdk-0.0.1.dev1.dist-info/METADATA +468 -0
  60. opencode_python_sdk-0.0.1.dev1.dist-info/RECORD +62 -0
  61. opencode_python_sdk-0.0.1.dev1.dist-info/WHEEL +4 -0
  62. opencode_python_sdk-0.0.1.dev1.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,1033 @@
1
+ # This file is generated by `python -m codegen` from spec/contract.json. Do not edit it by hand.
2
+ # OpenCode 2.1.2
3
+
4
+ """The ``integration`` resource."""
5
+
6
+ from __future__ import annotations
7
+
8
+ from functools import cached_property
9
+ from typing import TYPE_CHECKING, cast
10
+
11
+ from .._base_client import RequestOptions
12
+ from .._qs import encode_path_segment
13
+ from .._resource import AsyncAPIResource, SyncAPIResource
14
+ from .._types import NOT_GIVEN, Body, Headers, NotGiven, Query, Timeout
15
+
16
+ if TYPE_CHECKING:
17
+ from ..types import (
18
+ FormAnswer,
19
+ IntegrationAttemptID,
20
+ IntegrationCommandConnectResponse,
21
+ IntegrationCommandStatusResponse,
22
+ IntegrationGetResponse,
23
+ IntegrationID,
24
+ IntegrationListResponse,
25
+ IntegrationMethodID,
26
+ IntegrationOauthConnectResponse,
27
+ IntegrationOauthStatusResponse,
28
+ Location,
29
+ )
30
+
31
+ __all__ = ["IntegrationResource", "AsyncIntegrationResource"]
32
+
33
+
34
+ class IntegrationWellknownResource(SyncAPIResource):
35
+ """Operations under ``client.integration.wellknown`` (OpenCode ``integration.wellknown``)."""
36
+
37
+ def add(
38
+ self,
39
+ *,
40
+ url: str,
41
+ location: Location | NotGiven | None = NOT_GIVEN,
42
+ extra_headers: Headers | None = None,
43
+ extra_query: Query | None = None,
44
+ extra_body: Body | None = None,
45
+ timeout: Timeout | NotGiven = NOT_GIVEN,
46
+ ) -> None:
47
+ """Add wellknown integration.
48
+
49
+ Discover and persist an experimental wellknown integration source.
50
+
51
+ This endpoint is experimental in OpenCode and may change without notice.
52
+
53
+ Raises:
54
+ InvalidRequestError: The server answered 400.
55
+ UnauthorizedError: The server answered 401.
56
+ LocationNotFoundError: The server answered 404.
57
+
58
+ ``POST /api/experimental/integration/wellknown``
59
+ """
60
+ self._client.request(
61
+ RequestOptions(
62
+ method="POST",
63
+ path="/api/experimental/integration/wellknown",
64
+ query={"location": self._location(location)},
65
+ body={"url": url},
66
+ extra_headers=extra_headers,
67
+ extra_query=extra_query,
68
+ extra_body=extra_body,
69
+ timeout=timeout,
70
+ ),
71
+ kind="void",
72
+ )
73
+
74
+
75
+ class IntegrationConnectResource(SyncAPIResource):
76
+ """Operations under ``client.integration.connect`` (OpenCode ``integration.connect``)."""
77
+
78
+ def key(
79
+ self,
80
+ integration_id: IntegrationID,
81
+ *,
82
+ key: str,
83
+ location: Location | NotGiven | None = NOT_GIVEN,
84
+ answer: FormAnswer | NotGiven | None = NOT_GIVEN,
85
+ label: str | NotGiven | None = NOT_GIVEN,
86
+ extra_headers: Headers | None = None,
87
+ extra_query: Query | None = None,
88
+ extra_body: Body | None = None,
89
+ timeout: Timeout | NotGiven = NOT_GIVEN,
90
+ ) -> None:
91
+ """Connect with key.
92
+
93
+ Run a key authentication method and store the resulting credential.
94
+
95
+ Raises:
96
+ InvalidRequestError: The server answered 400.
97
+ UnauthorizedError: The server answered 401.
98
+ IntegrationNotFoundError: The server answered 404.
99
+ LocationNotFoundError: The server answered 404.
100
+
101
+ ``POST /api/integration/:integrationID/connect/key``
102
+ """
103
+ self._client.request(
104
+ RequestOptions(
105
+ method="POST",
106
+ path=f"/api/integration/{encode_path_segment(integration_id)}/connect/key",
107
+ query={"location": self._location(location)},
108
+ body={"key": key, "answer": answer, "label": label},
109
+ extra_headers=extra_headers,
110
+ extra_query=extra_query,
111
+ extra_body=extra_body,
112
+ timeout=timeout,
113
+ ),
114
+ kind="void",
115
+ )
116
+
117
+ def external(
118
+ self,
119
+ integration_id: IntegrationID,
120
+ *,
121
+ method_id: IntegrationMethodID,
122
+ location: Location | NotGiven | None = NOT_GIVEN,
123
+ answer: FormAnswer | NotGiven | None = NOT_GIVEN,
124
+ label: str | NotGiven | None = NOT_GIVEN,
125
+ extra_headers: Headers | None = None,
126
+ extra_query: Query | None = None,
127
+ extra_body: Body | None = None,
128
+ timeout: Timeout | NotGiven = NOT_GIVEN,
129
+ ) -> None:
130
+ """Connect with external credentials.
131
+
132
+ Run an external authentication method and store a reference to its credential source.
133
+
134
+ Raises:
135
+ InvalidRequestError: The server answered 400.
136
+ UnauthorizedError: The server answered 401.
137
+ IntegrationNotFoundError: The server answered 404.
138
+ LocationNotFoundError: The server answered 404.
139
+
140
+ ``POST /api/integration/:integrationID/connect/external``
141
+ """
142
+ self._client.request(
143
+ RequestOptions(
144
+ method="POST",
145
+ path=f"/api/integration/{encode_path_segment(integration_id)}/connect/external",
146
+ query={"location": self._location(location)},
147
+ body={"methodID": method_id, "answer": answer, "label": label},
148
+ extra_headers=extra_headers,
149
+ extra_query=extra_query,
150
+ extra_body=extra_body,
151
+ timeout=timeout,
152
+ ),
153
+ kind="void",
154
+ )
155
+
156
+
157
+ class IntegrationOauthResource(SyncAPIResource):
158
+ """Operations under ``client.integration.oauth`` (OpenCode ``integration.oauth``)."""
159
+
160
+ def connect(
161
+ self,
162
+ integration_id: IntegrationID,
163
+ *,
164
+ method_id: IntegrationMethodID,
165
+ location: Location | NotGiven | None = NOT_GIVEN,
166
+ answer: FormAnswer | NotGiven | None = NOT_GIVEN,
167
+ label: str | NotGiven | None = NOT_GIVEN,
168
+ extra_headers: Headers | None = None,
169
+ extra_query: Query | None = None,
170
+ extra_body: Body | None = None,
171
+ timeout: Timeout | NotGiven = NOT_GIVEN,
172
+ ) -> IntegrationOauthConnectResponse:
173
+ """Begin OAuth connection.
174
+
175
+ Start an OAuth attempt and return the authorization details.
176
+
177
+ Raises:
178
+ InvalidRequestError: The server answered 400.
179
+ UnauthorizedError: The server answered 401.
180
+ LocationNotFoundError: The server answered 404.
181
+
182
+ ``POST /api/integration/:integrationID/connect/oauth``
183
+ """
184
+ return cast(
185
+ "IntegrationOauthConnectResponse",
186
+ self._client.request(
187
+ RequestOptions(
188
+ method="POST",
189
+ path=f"/api/integration/{encode_path_segment(integration_id)}/connect/oauth",
190
+ query={"location": self._location(location)},
191
+ body={"methodID": method_id, "answer": answer, "label": label},
192
+ extra_headers=extra_headers,
193
+ extra_query=extra_query,
194
+ extra_body=extra_body,
195
+ timeout=timeout,
196
+ ),
197
+ response_type="IntegrationOauthConnectResponse",
198
+ ),
199
+ )
200
+
201
+ def status(
202
+ self,
203
+ integration_id: IntegrationID,
204
+ attempt_id: IntegrationAttemptID,
205
+ *,
206
+ location: Location | NotGiven | None = NOT_GIVEN,
207
+ extra_headers: Headers | None = None,
208
+ extra_query: Query | None = None,
209
+ extra_body: Body | None = None,
210
+ timeout: Timeout | NotGiven = NOT_GIVEN,
211
+ ) -> IntegrationOauthStatusResponse:
212
+ """Get OAuth attempt status.
213
+
214
+ Poll the current status of an OAuth attempt.
215
+
216
+ Raises:
217
+ InvalidRequestError: The server answered 400.
218
+ UnauthorizedError: The server answered 401.
219
+ IntegrationNotFoundError: The server answered 404.
220
+ IntegrationAttemptNotFoundError: The server answered 404.
221
+ LocationNotFoundError: The server answered 404.
222
+
223
+ ``GET /api/integration/:integrationID/connect/oauth/:attemptID``
224
+ """
225
+ return cast(
226
+ "IntegrationOauthStatusResponse",
227
+ self._client.request(
228
+ RequestOptions(
229
+ method="GET",
230
+ path=f"/api/integration/{encode_path_segment(integration_id)}/connect/oauth/{encode_path_segment(attempt_id)}",
231
+ query={"location": self._location(location)},
232
+ extra_headers=extra_headers,
233
+ extra_query=extra_query,
234
+ extra_body=extra_body,
235
+ timeout=timeout,
236
+ ),
237
+ response_type="IntegrationOauthStatusResponse",
238
+ ),
239
+ )
240
+
241
+ def complete(
242
+ self,
243
+ integration_id: IntegrationID,
244
+ attempt_id: IntegrationAttemptID,
245
+ *,
246
+ location: Location | NotGiven | None = NOT_GIVEN,
247
+ code: str | NotGiven | None = NOT_GIVEN,
248
+ extra_headers: Headers | None = None,
249
+ extra_query: Query | None = None,
250
+ extra_body: Body | None = None,
251
+ timeout: Timeout | NotGiven = NOT_GIVEN,
252
+ ) -> None:
253
+ """Complete OAuth connection.
254
+
255
+ Complete a code-based OAuth attempt and store the resulting credential.
256
+
257
+ Raises:
258
+ InvalidRequestError: The server answered 400.
259
+ UnauthorizedError: The server answered 401.
260
+ IntegrationNotFoundError: The server answered 404.
261
+ IntegrationAttemptNotFoundError: The server answered 404.
262
+ LocationNotFoundError: The server answered 404.
263
+
264
+ ``POST /api/integration/:integrationID/connect/oauth/:attemptID/complete``
265
+ """
266
+ self._client.request(
267
+ RequestOptions(
268
+ method="POST",
269
+ path=f"/api/integration/{encode_path_segment(integration_id)}/connect/oauth/{encode_path_segment(attempt_id)}/complete",
270
+ query={"location": self._location(location)},
271
+ body={"code": code},
272
+ extra_headers=extra_headers,
273
+ extra_query=extra_query,
274
+ extra_body=extra_body,
275
+ timeout=timeout,
276
+ ),
277
+ kind="void",
278
+ )
279
+
280
+ def cancel(
281
+ self,
282
+ integration_id: IntegrationID,
283
+ attempt_id: IntegrationAttemptID,
284
+ *,
285
+ location: Location | NotGiven | None = NOT_GIVEN,
286
+ extra_headers: Headers | None = None,
287
+ extra_query: Query | None = None,
288
+ extra_body: Body | None = None,
289
+ timeout: Timeout | NotGiven = NOT_GIVEN,
290
+ ) -> None:
291
+ """Cancel OAuth connection.
292
+
293
+ Cancel an OAuth attempt and release its resources.
294
+
295
+ Raises:
296
+ InvalidRequestError: The server answered 400.
297
+ UnauthorizedError: The server answered 401.
298
+ LocationNotFoundError: The server answered 404.
299
+
300
+ ``DELETE /api/integration/:integrationID/connect/oauth/:attemptID``
301
+ """
302
+ self._client.request(
303
+ RequestOptions(
304
+ method="DELETE",
305
+ path=f"/api/integration/{encode_path_segment(integration_id)}/connect/oauth/{encode_path_segment(attempt_id)}",
306
+ query={"location": self._location(location)},
307
+ extra_headers=extra_headers,
308
+ extra_query=extra_query,
309
+ extra_body=extra_body,
310
+ timeout=timeout,
311
+ ),
312
+ kind="void",
313
+ )
314
+
315
+
316
+ class IntegrationCommandResource(SyncAPIResource):
317
+ """Operations under ``client.integration.command`` (OpenCode ``integration.command``)."""
318
+
319
+ def connect(
320
+ self,
321
+ integration_id: IntegrationID,
322
+ *,
323
+ method_id: IntegrationMethodID,
324
+ location: Location | NotGiven | None = NOT_GIVEN,
325
+ label: str | NotGiven | None = NOT_GIVEN,
326
+ extra_headers: Headers | None = None,
327
+ extra_query: Query | None = None,
328
+ extra_body: Body | None = None,
329
+ timeout: Timeout | NotGiven = NOT_GIVEN,
330
+ ) -> IntegrationCommandConnectResponse:
331
+ """Begin command connection.
332
+
333
+ Start a command authentication attempt.
334
+
335
+ Raises:
336
+ InvalidRequestError: The server answered 400.
337
+ UnauthorizedError: The server answered 401.
338
+ IntegrationNotFoundError: The server answered 404.
339
+ IntegrationMethodNotFoundError: The server answered 404.
340
+ LocationNotFoundError: The server answered 404.
341
+
342
+ ``POST /api/integration/:integrationID/connect/command``
343
+ """
344
+ return cast(
345
+ "IntegrationCommandConnectResponse",
346
+ self._client.request(
347
+ RequestOptions(
348
+ method="POST",
349
+ path=f"/api/integration/{encode_path_segment(integration_id)}/connect/command",
350
+ query={"location": self._location(location)},
351
+ body={"methodID": method_id, "label": label},
352
+ extra_headers=extra_headers,
353
+ extra_query=extra_query,
354
+ extra_body=extra_body,
355
+ timeout=timeout,
356
+ ),
357
+ response_type="IntegrationCommandConnectResponse",
358
+ ),
359
+ )
360
+
361
+ def status(
362
+ self,
363
+ integration_id: IntegrationID,
364
+ attempt_id: IntegrationAttemptID,
365
+ *,
366
+ location: Location | NotGiven | None = NOT_GIVEN,
367
+ extra_headers: Headers | None = None,
368
+ extra_query: Query | None = None,
369
+ extra_body: Body | None = None,
370
+ timeout: Timeout | NotGiven = NOT_GIVEN,
371
+ ) -> IntegrationCommandStatusResponse:
372
+ """Get command attempt status.
373
+
374
+ Poll the current status and output of a command authentication attempt.
375
+
376
+ Raises:
377
+ InvalidRequestError: The server answered 400.
378
+ UnauthorizedError: The server answered 401.
379
+ IntegrationNotFoundError: The server answered 404.
380
+ IntegrationAttemptNotFoundError: The server answered 404.
381
+ LocationNotFoundError: The server answered 404.
382
+
383
+ ``GET /api/integration/:integrationID/connect/command/:attemptID``
384
+ """
385
+ return cast(
386
+ "IntegrationCommandStatusResponse",
387
+ self._client.request(
388
+ RequestOptions(
389
+ method="GET",
390
+ path=f"/api/integration/{encode_path_segment(integration_id)}/connect/command/{encode_path_segment(attempt_id)}",
391
+ query={"location": self._location(location)},
392
+ extra_headers=extra_headers,
393
+ extra_query=extra_query,
394
+ extra_body=extra_body,
395
+ timeout=timeout,
396
+ ),
397
+ response_type="IntegrationCommandStatusResponse",
398
+ ),
399
+ )
400
+
401
+ def cancel(
402
+ self,
403
+ integration_id: IntegrationID,
404
+ attempt_id: IntegrationAttemptID,
405
+ *,
406
+ location: Location | NotGiven | None = NOT_GIVEN,
407
+ extra_headers: Headers | None = None,
408
+ extra_query: Query | None = None,
409
+ extra_body: Body | None = None,
410
+ timeout: Timeout | NotGiven = NOT_GIVEN,
411
+ ) -> None:
412
+ """Cancel command connection.
413
+
414
+ Cancel a command authentication attempt and terminate its process.
415
+
416
+ Raises:
417
+ InvalidRequestError: The server answered 400.
418
+ UnauthorizedError: The server answered 401.
419
+ LocationNotFoundError: The server answered 404.
420
+
421
+ ``DELETE /api/integration/:integrationID/connect/command/:attemptID``
422
+ """
423
+ self._client.request(
424
+ RequestOptions(
425
+ method="DELETE",
426
+ path=f"/api/integration/{encode_path_segment(integration_id)}/connect/command/{encode_path_segment(attempt_id)}",
427
+ query={"location": self._location(location)},
428
+ extra_headers=extra_headers,
429
+ extra_query=extra_query,
430
+ extra_body=extra_body,
431
+ timeout=timeout,
432
+ ),
433
+ kind="void",
434
+ )
435
+
436
+
437
+ class IntegrationResource(SyncAPIResource):
438
+ """Operations under ``client.integration`` (OpenCode ``integration``)."""
439
+
440
+ @cached_property
441
+ def wellknown(self) -> IntegrationWellknownResource:
442
+ """Operations under ``client.integration.wellknown``."""
443
+ return IntegrationWellknownResource(self._client)
444
+
445
+ @cached_property
446
+ def connect(self) -> IntegrationConnectResource:
447
+ """Operations under ``client.integration.connect``."""
448
+ return IntegrationConnectResource(self._client)
449
+
450
+ @cached_property
451
+ def oauth(self) -> IntegrationOauthResource:
452
+ """Operations under ``client.integration.oauth``."""
453
+ return IntegrationOauthResource(self._client)
454
+
455
+ @cached_property
456
+ def command(self) -> IntegrationCommandResource:
457
+ """Operations under ``client.integration.command``."""
458
+ return IntegrationCommandResource(self._client)
459
+
460
+ def list(
461
+ self,
462
+ *,
463
+ location: Location | NotGiven | None = NOT_GIVEN,
464
+ extra_headers: Headers | None = None,
465
+ extra_query: Query | None = None,
466
+ extra_body: Body | None = None,
467
+ timeout: Timeout | NotGiven = NOT_GIVEN,
468
+ ) -> IntegrationListResponse:
469
+ """List integrations.
470
+
471
+ Retrieve available integrations and their authentication methods.
472
+
473
+ Raises:
474
+ InvalidRequestError: The server answered 400.
475
+ UnauthorizedError: The server answered 401.
476
+ LocationNotFoundError: The server answered 404.
477
+
478
+ ``GET /api/integration``
479
+ """
480
+ return cast(
481
+ "IntegrationListResponse",
482
+ self._client.request(
483
+ RequestOptions(
484
+ method="GET",
485
+ path="/api/integration",
486
+ query={"location": self._location(location)},
487
+ extra_headers=extra_headers,
488
+ extra_query=extra_query,
489
+ extra_body=extra_body,
490
+ timeout=timeout,
491
+ ),
492
+ response_type="IntegrationListResponse",
493
+ ),
494
+ )
495
+
496
+ def get(
497
+ self,
498
+ integration_id: IntegrationID,
499
+ *,
500
+ location: Location | NotGiven | None = NOT_GIVEN,
501
+ extra_headers: Headers | None = None,
502
+ extra_query: Query | None = None,
503
+ extra_body: Body | None = None,
504
+ timeout: Timeout | NotGiven = NOT_GIVEN,
505
+ ) -> IntegrationGetResponse:
506
+ """Get integration.
507
+
508
+ Retrieve one integration and its authentication methods.
509
+
510
+ Raises:
511
+ InvalidRequestError: The server answered 400.
512
+ UnauthorizedError: The server answered 401.
513
+ IntegrationNotFoundError: The server answered 404.
514
+ LocationNotFoundError: The server answered 404.
515
+
516
+ ``GET /api/integration/:integrationID``
517
+ """
518
+ return cast(
519
+ "IntegrationGetResponse",
520
+ self._client.request(
521
+ RequestOptions(
522
+ method="GET",
523
+ path=f"/api/integration/{encode_path_segment(integration_id)}",
524
+ query={"location": self._location(location)},
525
+ extra_headers=extra_headers,
526
+ extra_query=extra_query,
527
+ extra_body=extra_body,
528
+ timeout=timeout,
529
+ ),
530
+ response_type="IntegrationGetResponse",
531
+ ),
532
+ )
533
+
534
+
535
+ class AsyncIntegrationWellknownResource(AsyncAPIResource):
536
+ """Operations under ``client.integration.wellknown`` (OpenCode ``integration.wellknown``)."""
537
+
538
+ async def add(
539
+ self,
540
+ *,
541
+ url: str,
542
+ location: Location | NotGiven | None = NOT_GIVEN,
543
+ extra_headers: Headers | None = None,
544
+ extra_query: Query | None = None,
545
+ extra_body: Body | None = None,
546
+ timeout: Timeout | NotGiven = NOT_GIVEN,
547
+ ) -> None:
548
+ """Add wellknown integration.
549
+
550
+ Discover and persist an experimental wellknown integration source.
551
+
552
+ This endpoint is experimental in OpenCode and may change without notice.
553
+
554
+ Raises:
555
+ InvalidRequestError: The server answered 400.
556
+ UnauthorizedError: The server answered 401.
557
+ LocationNotFoundError: The server answered 404.
558
+
559
+ ``POST /api/experimental/integration/wellknown``
560
+ """
561
+ await self._client.request(
562
+ RequestOptions(
563
+ method="POST",
564
+ path="/api/experimental/integration/wellknown",
565
+ query={"location": self._location(location)},
566
+ body={"url": url},
567
+ extra_headers=extra_headers,
568
+ extra_query=extra_query,
569
+ extra_body=extra_body,
570
+ timeout=timeout,
571
+ ),
572
+ kind="void",
573
+ )
574
+
575
+
576
+ class AsyncIntegrationConnectResource(AsyncAPIResource):
577
+ """Operations under ``client.integration.connect`` (OpenCode ``integration.connect``)."""
578
+
579
+ async def key(
580
+ self,
581
+ integration_id: IntegrationID,
582
+ *,
583
+ key: str,
584
+ location: Location | NotGiven | None = NOT_GIVEN,
585
+ answer: FormAnswer | NotGiven | None = NOT_GIVEN,
586
+ label: str | NotGiven | None = NOT_GIVEN,
587
+ extra_headers: Headers | None = None,
588
+ extra_query: Query | None = None,
589
+ extra_body: Body | None = None,
590
+ timeout: Timeout | NotGiven = NOT_GIVEN,
591
+ ) -> None:
592
+ """Connect with key.
593
+
594
+ Run a key authentication method and store the resulting credential.
595
+
596
+ Raises:
597
+ InvalidRequestError: The server answered 400.
598
+ UnauthorizedError: The server answered 401.
599
+ IntegrationNotFoundError: The server answered 404.
600
+ LocationNotFoundError: The server answered 404.
601
+
602
+ ``POST /api/integration/:integrationID/connect/key``
603
+ """
604
+ await self._client.request(
605
+ RequestOptions(
606
+ method="POST",
607
+ path=f"/api/integration/{encode_path_segment(integration_id)}/connect/key",
608
+ query={"location": self._location(location)},
609
+ body={"key": key, "answer": answer, "label": label},
610
+ extra_headers=extra_headers,
611
+ extra_query=extra_query,
612
+ extra_body=extra_body,
613
+ timeout=timeout,
614
+ ),
615
+ kind="void",
616
+ )
617
+
618
+ async def external(
619
+ self,
620
+ integration_id: IntegrationID,
621
+ *,
622
+ method_id: IntegrationMethodID,
623
+ location: Location | NotGiven | None = NOT_GIVEN,
624
+ answer: FormAnswer | NotGiven | None = NOT_GIVEN,
625
+ label: str | NotGiven | None = NOT_GIVEN,
626
+ extra_headers: Headers | None = None,
627
+ extra_query: Query | None = None,
628
+ extra_body: Body | None = None,
629
+ timeout: Timeout | NotGiven = NOT_GIVEN,
630
+ ) -> None:
631
+ """Connect with external credentials.
632
+
633
+ Run an external authentication method and store a reference to its credential source.
634
+
635
+ Raises:
636
+ InvalidRequestError: The server answered 400.
637
+ UnauthorizedError: The server answered 401.
638
+ IntegrationNotFoundError: The server answered 404.
639
+ LocationNotFoundError: The server answered 404.
640
+
641
+ ``POST /api/integration/:integrationID/connect/external``
642
+ """
643
+ await self._client.request(
644
+ RequestOptions(
645
+ method="POST",
646
+ path=f"/api/integration/{encode_path_segment(integration_id)}/connect/external",
647
+ query={"location": self._location(location)},
648
+ body={"methodID": method_id, "answer": answer, "label": label},
649
+ extra_headers=extra_headers,
650
+ extra_query=extra_query,
651
+ extra_body=extra_body,
652
+ timeout=timeout,
653
+ ),
654
+ kind="void",
655
+ )
656
+
657
+
658
+ class AsyncIntegrationOauthResource(AsyncAPIResource):
659
+ """Operations under ``client.integration.oauth`` (OpenCode ``integration.oauth``)."""
660
+
661
+ async def connect(
662
+ self,
663
+ integration_id: IntegrationID,
664
+ *,
665
+ method_id: IntegrationMethodID,
666
+ location: Location | NotGiven | None = NOT_GIVEN,
667
+ answer: FormAnswer | NotGiven | None = NOT_GIVEN,
668
+ label: str | NotGiven | None = NOT_GIVEN,
669
+ extra_headers: Headers | None = None,
670
+ extra_query: Query | None = None,
671
+ extra_body: Body | None = None,
672
+ timeout: Timeout | NotGiven = NOT_GIVEN,
673
+ ) -> IntegrationOauthConnectResponse:
674
+ """Begin OAuth connection.
675
+
676
+ Start an OAuth attempt and return the authorization details.
677
+
678
+ Raises:
679
+ InvalidRequestError: The server answered 400.
680
+ UnauthorizedError: The server answered 401.
681
+ LocationNotFoundError: The server answered 404.
682
+
683
+ ``POST /api/integration/:integrationID/connect/oauth``
684
+ """
685
+ return cast(
686
+ "IntegrationOauthConnectResponse",
687
+ await self._client.request(
688
+ RequestOptions(
689
+ method="POST",
690
+ path=f"/api/integration/{encode_path_segment(integration_id)}/connect/oauth",
691
+ query={"location": self._location(location)},
692
+ body={"methodID": method_id, "answer": answer, "label": label},
693
+ extra_headers=extra_headers,
694
+ extra_query=extra_query,
695
+ extra_body=extra_body,
696
+ timeout=timeout,
697
+ ),
698
+ response_type="IntegrationOauthConnectResponse",
699
+ ),
700
+ )
701
+
702
+ async def status(
703
+ self,
704
+ integration_id: IntegrationID,
705
+ attempt_id: IntegrationAttemptID,
706
+ *,
707
+ location: Location | NotGiven | None = NOT_GIVEN,
708
+ extra_headers: Headers | None = None,
709
+ extra_query: Query | None = None,
710
+ extra_body: Body | None = None,
711
+ timeout: Timeout | NotGiven = NOT_GIVEN,
712
+ ) -> IntegrationOauthStatusResponse:
713
+ """Get OAuth attempt status.
714
+
715
+ Poll the current status of an OAuth attempt.
716
+
717
+ Raises:
718
+ InvalidRequestError: The server answered 400.
719
+ UnauthorizedError: The server answered 401.
720
+ IntegrationNotFoundError: The server answered 404.
721
+ IntegrationAttemptNotFoundError: The server answered 404.
722
+ LocationNotFoundError: The server answered 404.
723
+
724
+ ``GET /api/integration/:integrationID/connect/oauth/:attemptID``
725
+ """
726
+ return cast(
727
+ "IntegrationOauthStatusResponse",
728
+ await self._client.request(
729
+ RequestOptions(
730
+ method="GET",
731
+ path=f"/api/integration/{encode_path_segment(integration_id)}/connect/oauth/{encode_path_segment(attempt_id)}",
732
+ query={"location": self._location(location)},
733
+ extra_headers=extra_headers,
734
+ extra_query=extra_query,
735
+ extra_body=extra_body,
736
+ timeout=timeout,
737
+ ),
738
+ response_type="IntegrationOauthStatusResponse",
739
+ ),
740
+ )
741
+
742
+ async def complete(
743
+ self,
744
+ integration_id: IntegrationID,
745
+ attempt_id: IntegrationAttemptID,
746
+ *,
747
+ location: Location | NotGiven | None = NOT_GIVEN,
748
+ code: str | NotGiven | None = NOT_GIVEN,
749
+ extra_headers: Headers | None = None,
750
+ extra_query: Query | None = None,
751
+ extra_body: Body | None = None,
752
+ timeout: Timeout | NotGiven = NOT_GIVEN,
753
+ ) -> None:
754
+ """Complete OAuth connection.
755
+
756
+ Complete a code-based OAuth attempt and store the resulting credential.
757
+
758
+ Raises:
759
+ InvalidRequestError: The server answered 400.
760
+ UnauthorizedError: The server answered 401.
761
+ IntegrationNotFoundError: The server answered 404.
762
+ IntegrationAttemptNotFoundError: The server answered 404.
763
+ LocationNotFoundError: The server answered 404.
764
+
765
+ ``POST /api/integration/:integrationID/connect/oauth/:attemptID/complete``
766
+ """
767
+ await self._client.request(
768
+ RequestOptions(
769
+ method="POST",
770
+ path=f"/api/integration/{encode_path_segment(integration_id)}/connect/oauth/{encode_path_segment(attempt_id)}/complete",
771
+ query={"location": self._location(location)},
772
+ body={"code": code},
773
+ extra_headers=extra_headers,
774
+ extra_query=extra_query,
775
+ extra_body=extra_body,
776
+ timeout=timeout,
777
+ ),
778
+ kind="void",
779
+ )
780
+
781
+ async def cancel(
782
+ self,
783
+ integration_id: IntegrationID,
784
+ attempt_id: IntegrationAttemptID,
785
+ *,
786
+ location: Location | NotGiven | None = NOT_GIVEN,
787
+ extra_headers: Headers | None = None,
788
+ extra_query: Query | None = None,
789
+ extra_body: Body | None = None,
790
+ timeout: Timeout | NotGiven = NOT_GIVEN,
791
+ ) -> None:
792
+ """Cancel OAuth connection.
793
+
794
+ Cancel an OAuth attempt and release its resources.
795
+
796
+ Raises:
797
+ InvalidRequestError: The server answered 400.
798
+ UnauthorizedError: The server answered 401.
799
+ LocationNotFoundError: The server answered 404.
800
+
801
+ ``DELETE /api/integration/:integrationID/connect/oauth/:attemptID``
802
+ """
803
+ await self._client.request(
804
+ RequestOptions(
805
+ method="DELETE",
806
+ path=f"/api/integration/{encode_path_segment(integration_id)}/connect/oauth/{encode_path_segment(attempt_id)}",
807
+ query={"location": self._location(location)},
808
+ extra_headers=extra_headers,
809
+ extra_query=extra_query,
810
+ extra_body=extra_body,
811
+ timeout=timeout,
812
+ ),
813
+ kind="void",
814
+ )
815
+
816
+
817
+ class AsyncIntegrationCommandResource(AsyncAPIResource):
818
+ """Operations under ``client.integration.command`` (OpenCode ``integration.command``)."""
819
+
820
+ async def connect(
821
+ self,
822
+ integration_id: IntegrationID,
823
+ *,
824
+ method_id: IntegrationMethodID,
825
+ location: Location | NotGiven | None = NOT_GIVEN,
826
+ label: str | NotGiven | None = NOT_GIVEN,
827
+ extra_headers: Headers | None = None,
828
+ extra_query: Query | None = None,
829
+ extra_body: Body | None = None,
830
+ timeout: Timeout | NotGiven = NOT_GIVEN,
831
+ ) -> IntegrationCommandConnectResponse:
832
+ """Begin command connection.
833
+
834
+ Start a command authentication attempt.
835
+
836
+ Raises:
837
+ InvalidRequestError: The server answered 400.
838
+ UnauthorizedError: The server answered 401.
839
+ IntegrationNotFoundError: The server answered 404.
840
+ IntegrationMethodNotFoundError: The server answered 404.
841
+ LocationNotFoundError: The server answered 404.
842
+
843
+ ``POST /api/integration/:integrationID/connect/command``
844
+ """
845
+ return cast(
846
+ "IntegrationCommandConnectResponse",
847
+ await self._client.request(
848
+ RequestOptions(
849
+ method="POST",
850
+ path=f"/api/integration/{encode_path_segment(integration_id)}/connect/command",
851
+ query={"location": self._location(location)},
852
+ body={"methodID": method_id, "label": label},
853
+ extra_headers=extra_headers,
854
+ extra_query=extra_query,
855
+ extra_body=extra_body,
856
+ timeout=timeout,
857
+ ),
858
+ response_type="IntegrationCommandConnectResponse",
859
+ ),
860
+ )
861
+
862
+ async def status(
863
+ self,
864
+ integration_id: IntegrationID,
865
+ attempt_id: IntegrationAttemptID,
866
+ *,
867
+ location: Location | NotGiven | None = NOT_GIVEN,
868
+ extra_headers: Headers | None = None,
869
+ extra_query: Query | None = None,
870
+ extra_body: Body | None = None,
871
+ timeout: Timeout | NotGiven = NOT_GIVEN,
872
+ ) -> IntegrationCommandStatusResponse:
873
+ """Get command attempt status.
874
+
875
+ Poll the current status and output of a command authentication attempt.
876
+
877
+ Raises:
878
+ InvalidRequestError: The server answered 400.
879
+ UnauthorizedError: The server answered 401.
880
+ IntegrationNotFoundError: The server answered 404.
881
+ IntegrationAttemptNotFoundError: The server answered 404.
882
+ LocationNotFoundError: The server answered 404.
883
+
884
+ ``GET /api/integration/:integrationID/connect/command/:attemptID``
885
+ """
886
+ return cast(
887
+ "IntegrationCommandStatusResponse",
888
+ await self._client.request(
889
+ RequestOptions(
890
+ method="GET",
891
+ path=f"/api/integration/{encode_path_segment(integration_id)}/connect/command/{encode_path_segment(attempt_id)}",
892
+ query={"location": self._location(location)},
893
+ extra_headers=extra_headers,
894
+ extra_query=extra_query,
895
+ extra_body=extra_body,
896
+ timeout=timeout,
897
+ ),
898
+ response_type="IntegrationCommandStatusResponse",
899
+ ),
900
+ )
901
+
902
+ async def cancel(
903
+ self,
904
+ integration_id: IntegrationID,
905
+ attempt_id: IntegrationAttemptID,
906
+ *,
907
+ location: Location | NotGiven | None = NOT_GIVEN,
908
+ extra_headers: Headers | None = None,
909
+ extra_query: Query | None = None,
910
+ extra_body: Body | None = None,
911
+ timeout: Timeout | NotGiven = NOT_GIVEN,
912
+ ) -> None:
913
+ """Cancel command connection.
914
+
915
+ Cancel a command authentication attempt and terminate its process.
916
+
917
+ Raises:
918
+ InvalidRequestError: The server answered 400.
919
+ UnauthorizedError: The server answered 401.
920
+ LocationNotFoundError: The server answered 404.
921
+
922
+ ``DELETE /api/integration/:integrationID/connect/command/:attemptID``
923
+ """
924
+ await self._client.request(
925
+ RequestOptions(
926
+ method="DELETE",
927
+ path=f"/api/integration/{encode_path_segment(integration_id)}/connect/command/{encode_path_segment(attempt_id)}",
928
+ query={"location": self._location(location)},
929
+ extra_headers=extra_headers,
930
+ extra_query=extra_query,
931
+ extra_body=extra_body,
932
+ timeout=timeout,
933
+ ),
934
+ kind="void",
935
+ )
936
+
937
+
938
+ class AsyncIntegrationResource(AsyncAPIResource):
939
+ """Operations under ``client.integration`` (OpenCode ``integration``)."""
940
+
941
+ @cached_property
942
+ def wellknown(self) -> AsyncIntegrationWellknownResource:
943
+ """Operations under ``client.integration.wellknown``."""
944
+ return AsyncIntegrationWellknownResource(self._client)
945
+
946
+ @cached_property
947
+ def connect(self) -> AsyncIntegrationConnectResource:
948
+ """Operations under ``client.integration.connect``."""
949
+ return AsyncIntegrationConnectResource(self._client)
950
+
951
+ @cached_property
952
+ def oauth(self) -> AsyncIntegrationOauthResource:
953
+ """Operations under ``client.integration.oauth``."""
954
+ return AsyncIntegrationOauthResource(self._client)
955
+
956
+ @cached_property
957
+ def command(self) -> AsyncIntegrationCommandResource:
958
+ """Operations under ``client.integration.command``."""
959
+ return AsyncIntegrationCommandResource(self._client)
960
+
961
+ async def list(
962
+ self,
963
+ *,
964
+ location: Location | NotGiven | None = NOT_GIVEN,
965
+ extra_headers: Headers | None = None,
966
+ extra_query: Query | None = None,
967
+ extra_body: Body | None = None,
968
+ timeout: Timeout | NotGiven = NOT_GIVEN,
969
+ ) -> IntegrationListResponse:
970
+ """List integrations.
971
+
972
+ Retrieve available integrations and their authentication methods.
973
+
974
+ Raises:
975
+ InvalidRequestError: The server answered 400.
976
+ UnauthorizedError: The server answered 401.
977
+ LocationNotFoundError: The server answered 404.
978
+
979
+ ``GET /api/integration``
980
+ """
981
+ return cast(
982
+ "IntegrationListResponse",
983
+ await self._client.request(
984
+ RequestOptions(
985
+ method="GET",
986
+ path="/api/integration",
987
+ query={"location": self._location(location)},
988
+ extra_headers=extra_headers,
989
+ extra_query=extra_query,
990
+ extra_body=extra_body,
991
+ timeout=timeout,
992
+ ),
993
+ response_type="IntegrationListResponse",
994
+ ),
995
+ )
996
+
997
+ async def get(
998
+ self,
999
+ integration_id: IntegrationID,
1000
+ *,
1001
+ location: Location | NotGiven | None = NOT_GIVEN,
1002
+ extra_headers: Headers | None = None,
1003
+ extra_query: Query | None = None,
1004
+ extra_body: Body | None = None,
1005
+ timeout: Timeout | NotGiven = NOT_GIVEN,
1006
+ ) -> IntegrationGetResponse:
1007
+ """Get integration.
1008
+
1009
+ Retrieve one integration and its authentication methods.
1010
+
1011
+ Raises:
1012
+ InvalidRequestError: The server answered 400.
1013
+ UnauthorizedError: The server answered 401.
1014
+ IntegrationNotFoundError: The server answered 404.
1015
+ LocationNotFoundError: The server answered 404.
1016
+
1017
+ ``GET /api/integration/:integrationID``
1018
+ """
1019
+ return cast(
1020
+ "IntegrationGetResponse",
1021
+ await self._client.request(
1022
+ RequestOptions(
1023
+ method="GET",
1024
+ path=f"/api/integration/{encode_path_segment(integration_id)}",
1025
+ query={"location": self._location(location)},
1026
+ extra_headers=extra_headers,
1027
+ extra_query=extra_query,
1028
+ extra_body=extra_body,
1029
+ timeout=timeout,
1030
+ ),
1031
+ response_type="IntegrationGetResponse",
1032
+ ),
1033
+ )