22
33from __future__ import annotations
44
5+ from typing import Optional
6+
7+ import httpx
8+
59from .slack import (
610 SlackResource ,
711 AsyncSlackResource ,
1014 SlackResourceWithStreamingResponse ,
1115 AsyncSlackResourceWithStreamingResponse ,
1216)
17+ from ...types import integration_connect_params
18+ from ..._types import Body , Omit , Query , Headers , NotGiven , omit , not_given
19+ from ..._utils import maybe_transform , async_maybe_transform
1320from ..._compat import cached_property
1421from ..._resource import SyncAPIResource , AsyncAPIResource
22+ from ..._response import (
23+ to_raw_response_wrapper ,
24+ to_streamed_response_wrapper ,
25+ async_to_raw_response_wrapper ,
26+ async_to_streamed_response_wrapper ,
27+ )
1528from .web_crawler import (
1629 WebCrawlerResource ,
1730 AsyncWebCrawlerResource ,
2033 WebCrawlerResourceWithStreamingResponse ,
2134 AsyncWebCrawlerResourceWithStreamingResponse ,
2235)
36+ from ..._base_client import make_request_options
2337from .google_calendar import (
2438 GoogleCalendarResource ,
2539 AsyncGoogleCalendarResource ,
2842 GoogleCalendarResourceWithStreamingResponse ,
2943 AsyncGoogleCalendarResourceWithStreamingResponse ,
3044)
45+ from ...types .integration_list_response import IntegrationListResponse
46+ from ...types .integration_revoke_response import IntegrationRevokeResponse
47+ from ...types .integration_connect_response import IntegrationConnectResponse
3148
3249__all__ = ["IntegrationsResource" , "AsyncIntegrationsResource" ]
3350
@@ -64,6 +81,99 @@ def with_streaming_response(self) -> IntegrationsResourceWithStreamingResponse:
6481 """
6582 return IntegrationsResourceWithStreamingResponse (self )
6683
84+ def list (
85+ self ,
86+ * ,
87+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
88+ # The extra values given here take precedence over values defined on the client or passed to this method.
89+ extra_headers : Headers | None = None ,
90+ extra_query : Query | None = None ,
91+ extra_body : Body | None = None ,
92+ timeout : float | httpx .Timeout | None | NotGiven = not_given ,
93+ ) -> IntegrationListResponse :
94+ """List all integrations for the user."""
95+ return self ._get (
96+ "/integrations/list" ,
97+ options = make_request_options (
98+ extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
99+ ),
100+ cast_to = IntegrationListResponse ,
101+ )
102+
103+ def connect (
104+ self ,
105+ integration_id : str ,
106+ * ,
107+ redirect_url : Optional [str ] | Omit = omit ,
108+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
109+ # The extra values given here take precedence over values defined on the client or passed to this method.
110+ extra_headers : Headers | None = None ,
111+ extra_query : Query | None = None ,
112+ extra_body : Body | None = None ,
113+ timeout : float | httpx .Timeout | None | NotGiven = not_given ,
114+ ) -> IntegrationConnectResponse :
115+ """
116+ Redirects to the connect URL to link an integration.
117+
118+ Args:
119+ extra_headers: Send extra headers
120+
121+ extra_query: Add additional query parameters to the request
122+
123+ extra_body: Add additional JSON properties to the request
124+
125+ timeout: Override the client-level default timeout for this request, in seconds
126+ """
127+ if not integration_id :
128+ raise ValueError (f"Expected a non-empty value for `integration_id` but received { integration_id !r} " )
129+ return self ._get (
130+ f"/integrations/{ integration_id } /connect" ,
131+ options = make_request_options (
132+ extra_headers = extra_headers ,
133+ extra_query = extra_query ,
134+ extra_body = extra_body ,
135+ timeout = timeout ,
136+ query = maybe_transform (
137+ {"redirect_url" : redirect_url }, integration_connect_params .IntegrationConnectParams
138+ ),
139+ ),
140+ cast_to = IntegrationConnectResponse ,
141+ )
142+
143+ def revoke (
144+ self ,
145+ integration_id : str ,
146+ * ,
147+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
148+ # The extra values given here take precedence over values defined on the client or passed to this method.
149+ extra_headers : Headers | None = None ,
150+ extra_query : Query | None = None ,
151+ extra_body : Body | None = None ,
152+ timeout : float | httpx .Timeout | None | NotGiven = not_given ,
153+ ) -> IntegrationRevokeResponse :
154+ """
155+ Revokes Hyperspell's access the given provider and deletes all stored
156+ credentials and indexed data.
157+
158+ Args:
159+ extra_headers: Send extra headers
160+
161+ extra_query: Add additional query parameters to the request
162+
163+ extra_body: Add additional JSON properties to the request
164+
165+ timeout: Override the client-level default timeout for this request, in seconds
166+ """
167+ if not integration_id :
168+ raise ValueError (f"Expected a non-empty value for `integration_id` but received { integration_id !r} " )
169+ return self ._get (
170+ f"/integrations/{ integration_id } /revoke" ,
171+ options = make_request_options (
172+ extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
173+ ),
174+ cast_to = IntegrationRevokeResponse ,
175+ )
176+
67177
68178class AsyncIntegrationsResource (AsyncAPIResource ):
69179 @cached_property
@@ -97,11 +207,114 @@ def with_streaming_response(self) -> AsyncIntegrationsResourceWithStreamingRespo
97207 """
98208 return AsyncIntegrationsResourceWithStreamingResponse (self )
99209
210+ async def list (
211+ self ,
212+ * ,
213+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
214+ # The extra values given here take precedence over values defined on the client or passed to this method.
215+ extra_headers : Headers | None = None ,
216+ extra_query : Query | None = None ,
217+ extra_body : Body | None = None ,
218+ timeout : float | httpx .Timeout | None | NotGiven = not_given ,
219+ ) -> IntegrationListResponse :
220+ """List all integrations for the user."""
221+ return await self ._get (
222+ "/integrations/list" ,
223+ options = make_request_options (
224+ extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
225+ ),
226+ cast_to = IntegrationListResponse ,
227+ )
228+
229+ async def connect (
230+ self ,
231+ integration_id : str ,
232+ * ,
233+ redirect_url : Optional [str ] | Omit = omit ,
234+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
235+ # The extra values given here take precedence over values defined on the client or passed to this method.
236+ extra_headers : Headers | None = None ,
237+ extra_query : Query | None = None ,
238+ extra_body : Body | None = None ,
239+ timeout : float | httpx .Timeout | None | NotGiven = not_given ,
240+ ) -> IntegrationConnectResponse :
241+ """
242+ Redirects to the connect URL to link an integration.
243+
244+ Args:
245+ extra_headers: Send extra headers
246+
247+ extra_query: Add additional query parameters to the request
248+
249+ extra_body: Add additional JSON properties to the request
250+
251+ timeout: Override the client-level default timeout for this request, in seconds
252+ """
253+ if not integration_id :
254+ raise ValueError (f"Expected a non-empty value for `integration_id` but received { integration_id !r} " )
255+ return await self ._get (
256+ f"/integrations/{ integration_id } /connect" ,
257+ options = make_request_options (
258+ extra_headers = extra_headers ,
259+ extra_query = extra_query ,
260+ extra_body = extra_body ,
261+ timeout = timeout ,
262+ query = await async_maybe_transform (
263+ {"redirect_url" : redirect_url }, integration_connect_params .IntegrationConnectParams
264+ ),
265+ ),
266+ cast_to = IntegrationConnectResponse ,
267+ )
268+
269+ async def revoke (
270+ self ,
271+ integration_id : str ,
272+ * ,
273+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
274+ # The extra values given here take precedence over values defined on the client or passed to this method.
275+ extra_headers : Headers | None = None ,
276+ extra_query : Query | None = None ,
277+ extra_body : Body | None = None ,
278+ timeout : float | httpx .Timeout | None | NotGiven = not_given ,
279+ ) -> IntegrationRevokeResponse :
280+ """
281+ Revokes Hyperspell's access the given provider and deletes all stored
282+ credentials and indexed data.
283+
284+ Args:
285+ extra_headers: Send extra headers
286+
287+ extra_query: Add additional query parameters to the request
288+
289+ extra_body: Add additional JSON properties to the request
290+
291+ timeout: Override the client-level default timeout for this request, in seconds
292+ """
293+ if not integration_id :
294+ raise ValueError (f"Expected a non-empty value for `integration_id` but received { integration_id !r} " )
295+ return await self ._get (
296+ f"/integrations/{ integration_id } /revoke" ,
297+ options = make_request_options (
298+ extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
299+ ),
300+ cast_to = IntegrationRevokeResponse ,
301+ )
302+
100303
101304class IntegrationsResourceWithRawResponse :
102305 def __init__ (self , integrations : IntegrationsResource ) -> None :
103306 self ._integrations = integrations
104307
308+ self .list = to_raw_response_wrapper (
309+ integrations .list ,
310+ )
311+ self .connect = to_raw_response_wrapper (
312+ integrations .connect ,
313+ )
314+ self .revoke = to_raw_response_wrapper (
315+ integrations .revoke ,
316+ )
317+
105318 @cached_property
106319 def google_calendar (self ) -> GoogleCalendarResourceWithRawResponse :
107320 return GoogleCalendarResourceWithRawResponse (self ._integrations .google_calendar )
@@ -119,6 +332,16 @@ class AsyncIntegrationsResourceWithRawResponse:
119332 def __init__ (self , integrations : AsyncIntegrationsResource ) -> None :
120333 self ._integrations = integrations
121334
335+ self .list = async_to_raw_response_wrapper (
336+ integrations .list ,
337+ )
338+ self .connect = async_to_raw_response_wrapper (
339+ integrations .connect ,
340+ )
341+ self .revoke = async_to_raw_response_wrapper (
342+ integrations .revoke ,
343+ )
344+
122345 @cached_property
123346 def google_calendar (self ) -> AsyncGoogleCalendarResourceWithRawResponse :
124347 return AsyncGoogleCalendarResourceWithRawResponse (self ._integrations .google_calendar )
@@ -136,6 +359,16 @@ class IntegrationsResourceWithStreamingResponse:
136359 def __init__ (self , integrations : IntegrationsResource ) -> None :
137360 self ._integrations = integrations
138361
362+ self .list = to_streamed_response_wrapper (
363+ integrations .list ,
364+ )
365+ self .connect = to_streamed_response_wrapper (
366+ integrations .connect ,
367+ )
368+ self .revoke = to_streamed_response_wrapper (
369+ integrations .revoke ,
370+ )
371+
139372 @cached_property
140373 def google_calendar (self ) -> GoogleCalendarResourceWithStreamingResponse :
141374 return GoogleCalendarResourceWithStreamingResponse (self ._integrations .google_calendar )
@@ -153,6 +386,16 @@ class AsyncIntegrationsResourceWithStreamingResponse:
153386 def __init__ (self , integrations : AsyncIntegrationsResource ) -> None :
154387 self ._integrations = integrations
155388
389+ self .list = async_to_streamed_response_wrapper (
390+ integrations .list ,
391+ )
392+ self .connect = async_to_streamed_response_wrapper (
393+ integrations .connect ,
394+ )
395+ self .revoke = async_to_streamed_response_wrapper (
396+ integrations .revoke ,
397+ )
398+
156399 @cached_property
157400 def google_calendar (self ) -> AsyncGoogleCalendarResourceWithStreamingResponse :
158401 return AsyncGoogleCalendarResourceWithStreamingResponse (self ._integrations .google_calendar )
0 commit comments