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