22
33from __future__ import annotations
44
5+ from typing import Optional
6+
57import httpx
68
79from .slack import (
1214 SlackResourceWithStreamingResponse ,
1315 AsyncSlackResourceWithStreamingResponse ,
1416)
15- from ..._types import Body , Query , Headers , NotGiven , not_given
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
1620from ..._compat import cached_property
1721from ..._resource import SyncAPIResource , AsyncAPIResource
1822from ..._response import (
3842 GoogleCalendarResourceWithStreamingResponse ,
3943 AsyncGoogleCalendarResourceWithStreamingResponse ,
4044)
45+ from ...types .integration_list_response import IntegrationListResponse
4146from ...types .integration_revoke_response import IntegrationRevokeResponse
47+ from ...types .integration_connect_response import IntegrationConnectResponse
4248
4349__all__ = ["IntegrationsResource" , "AsyncIntegrationsResource" ]
4450
@@ -75,9 +81,68 @@ def with_streaming_response(self) -> IntegrationsResourceWithStreamingResponse:
7581 """
7682 return IntegrationsResourceWithStreamingResponse (self )
7783
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+
78143 def revoke (
79144 self ,
80- provider : str ,
145+ integration_id : str ,
81146 * ,
82147 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
83148 # The extra values given here take precedence over values defined on the client or passed to this method.
@@ -99,10 +164,10 @@ def revoke(
99164
100165 timeout: Override the client-level default timeout for this request, in seconds
101166 """
102- if not provider :
103- raise ValueError (f"Expected a non-empty value for `provider ` but received { provider !r} " )
167+ if not integration_id :
168+ raise ValueError (f"Expected a non-empty value for `integration_id ` but received { integration_id !r} " )
104169 return self ._get (
105- f"/integrations/{ provider } /revoke" ,
170+ f"/integrations/{ integration_id } /revoke" ,
106171 options = make_request_options (
107172 extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
108173 ),
@@ -142,9 +207,68 @@ def with_streaming_response(self) -> AsyncIntegrationsResourceWithStreamingRespo
142207 """
143208 return AsyncIntegrationsResourceWithStreamingResponse (self )
144209
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+
145269 async def revoke (
146270 self ,
147- provider : str ,
271+ integration_id : str ,
148272 * ,
149273 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
150274 # The extra values given here take precedence over values defined on the client or passed to this method.
@@ -166,10 +290,10 @@ async def revoke(
166290
167291 timeout: Override the client-level default timeout for this request, in seconds
168292 """
169- if not provider :
170- raise ValueError (f"Expected a non-empty value for `provider ` but received { provider !r} " )
293+ if not integration_id :
294+ raise ValueError (f"Expected a non-empty value for `integration_id ` but received { integration_id !r} " )
171295 return await self ._get (
172- f"/integrations/{ provider } /revoke" ,
296+ f"/integrations/{ integration_id } /revoke" ,
173297 options = make_request_options (
174298 extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
175299 ),
@@ -181,6 +305,12 @@ class IntegrationsResourceWithRawResponse:
181305 def __init__ (self , integrations : IntegrationsResource ) -> None :
182306 self ._integrations = integrations
183307
308+ self .list = to_raw_response_wrapper (
309+ integrations .list ,
310+ )
311+ self .connect = to_raw_response_wrapper (
312+ integrations .connect ,
313+ )
184314 self .revoke = to_raw_response_wrapper (
185315 integrations .revoke ,
186316 )
@@ -202,6 +332,12 @@ class AsyncIntegrationsResourceWithRawResponse:
202332 def __init__ (self , integrations : AsyncIntegrationsResource ) -> None :
203333 self ._integrations = integrations
204334
335+ self .list = async_to_raw_response_wrapper (
336+ integrations .list ,
337+ )
338+ self .connect = async_to_raw_response_wrapper (
339+ integrations .connect ,
340+ )
205341 self .revoke = async_to_raw_response_wrapper (
206342 integrations .revoke ,
207343 )
@@ -223,6 +359,12 @@ class IntegrationsResourceWithStreamingResponse:
223359 def __init__ (self , integrations : IntegrationsResource ) -> None :
224360 self ._integrations = integrations
225361
362+ self .list = to_streamed_response_wrapper (
363+ integrations .list ,
364+ )
365+ self .connect = to_streamed_response_wrapper (
366+ integrations .connect ,
367+ )
226368 self .revoke = to_streamed_response_wrapper (
227369 integrations .revoke ,
228370 )
@@ -244,6 +386,12 @@ class AsyncIntegrationsResourceWithStreamingResponse:
244386 def __init__ (self , integrations : AsyncIntegrationsResource ) -> None :
245387 self ._integrations = integrations
246388
389+ self .list = async_to_streamed_response_wrapper (
390+ integrations .list ,
391+ )
392+ self .connect = async_to_streamed_response_wrapper (
393+ integrations .connect ,
394+ )
247395 self .revoke = async_to_streamed_response_wrapper (
248396 integrations .revoke ,
249397 )
0 commit comments