Class: WorkOS::Pipes

Inherits:
Object
  • Object
show all
Defined in:
lib/workos/pipes.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Pipes

Returns a new instance of Pipes.



9
10
11
# File 'lib/workos/pipes.rb', line 9

def initialize(client)
  @client = client
end

Instance Method Details

#authorize_data_integration(slug:, user_id:, organization_id: nil, connection_owner: nil, return_to: nil, config: nil, request_options: {}) ⇒ WorkOS::DataIntegrationAuthorizeUrlResponse

Get authorization URL

Parameters:

  • slug (String)

    The slug identifier of the provider (e.g., github, slack, notion).

  • user_id (String)

    The ID of the user to authorize. When connection_owner is organization, this is the user authorizing on behalf of the organization; they must be an active member of the organization and do not become the owner of the resulting connected account.

  • organization_id (String, nil) (defaults to: nil)

    An organization ID to scope the authorization to a specific organization. Required when connection_owner is organization.

  • connection_owner (WorkOS::Types::DataIntegrationsGetDataIntegrationAuthorizeUrlRequestConnectionOwner, nil) (defaults to: nil)

    Who will own the connected account. user (the default) connects the user's own account. organization connects the organization's shared account and requires organization_id.

  • return_to (String, nil) (defaults to: nil)

    The URL to redirect the user to after authorization.

  • config (Hash{String => String}, nil) (defaults to: nil)

    Connect-time config values for the provider-declared installation-scope fields (e.g. a Zendesk subdomain), keyed by the config field. Only fields the provider declares may be supplied, and required fields must be provided unless already pinned on the integration.

  • request_options (Hash) (defaults to: {})

    (see WorkOS::Types::RequestOptions)

Returns:



233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
# File 'lib/workos/pipes.rb', line 233

def authorize_data_integration(
  slug:,
  user_id:,
  organization_id: nil,
  connection_owner: nil,
  return_to: nil,
  config: nil,
  request_options: {}
)
  body = {
    "user_id" => user_id,
    "organization_id" => organization_id,
    "connection_owner" => connection_owner,
    "return_to" => return_to,
    "config" => config
  }.compact
  response = @client.request(
    method: :post,
    path: "/data-integrations/#{WorkOS::Util.encode_path(slug)}/authorize",
    auth: true,
    body: body,
    request_options: request_options
  )
  result = WorkOS::DataIntegrationAuthorizeUrlResponse.new(response.body)
  result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#create_data_integration(provider:, ownership: nil, description: WorkOS::OMIT, enabled: nil, scopes: WorkOS::OMIT, auth_methods: nil, config: nil, credentials: nil, api_key: nil, custom_provider: nil, request_options: {}) ⇒ WorkOS::DataIntegration

Create a data integration

Parameters:

  • provider (String)

    The provider to create a Data Integration for. For a built-in provider use its slug (e.g. github, slack). For a custom provider, this is the new provider slug and custom_provider must be supplied. A custom provider slug cannot shadow an existing global provider slug.

  • ownership (WorkOS::Types::CreateDataIntegrationOwnership, nil) (defaults to: nil)

    Who owns the Data Integration. user (the default) creates the integration users connect their own accounts to; organization creates the root organizations connect to. Ownership is fixed at creation, and one integration of each ownership may exist per provider. Independent of credentials.type.

  • description (String, nil) (defaults to: WorkOS::OMIT)

    An optional description of the Data Integration.

  • enabled (Boolean, nil) (defaults to: nil)

    Whether the Data Integration is enabled. Defaults to false.

  • scopes (Array<String>, nil) (defaults to: WorkOS::OMIT)

    The OAuth scopes to request for the Data Integration. Defaults to the provider's configured scopes when omitted.

  • auth_methods (Array<WorkOS::Types::CreateDataIntegrationAuthMethods>, nil) (defaults to: nil)

    How accounts authenticate with the provider. Defaults to ["oauth"]. Use ["api_key"] to declare an API key integration; credentials is then not required and keys are supplied per-tenant (optionally via api_key on this request). Use ["client_credentials"] to declare a client-credentials integration; credentials is likewise not required and client credentials are supplied per-tenant.

  • config (Hash{String => String}, nil) (defaults to: nil)

    Provider-specific config values (e.g. a Snowflake account), keyed by the config field. Only fields the built-in provider declares are accepted.

  • credentials (WorkOS::DataIntegrationCredentialsInput, nil) (defaults to: nil)

    The OAuth credentials to configure for the Data Integration. Required for OAuth integrations; omit when auth_methods is ["api_key"].

  • api_key (WorkOS::ApiKeyInstallation, nil) (defaults to: nil)

    An optional API key to install for the first tenant on an api_key integration. Omit to declare a keyless integration; tenants can be added later via the per-installation API key path.

  • custom_provider (WorkOS::CustomProviderDefinition, nil) (defaults to: nil)

    The OAuth definition for a custom provider. Supply this to define a custom provider; omit it to create an integration for a built-in provider.

  • request_options (Hash) (defaults to: {})

    (see WorkOS::Types::RequestOptions)

Returns:



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/workos/pipes.rb', line 74

def create_data_integration(
  provider:,
  ownership: nil,
  description: WorkOS::OMIT,
  enabled: nil,
  scopes: WorkOS::OMIT,
  auth_methods: nil,
  config: nil,
  credentials: nil,
  api_key: nil,
  custom_provider: nil,
  request_options: {}
)
  body = {
    "provider" => provider,
    "ownership" => ownership,
    "enabled" => enabled,
    "auth_methods" => auth_methods,
    "config" => config,
    "credentials" => credentials,
    "api_key" => api_key,
    "custom_provider" => custom_provider
  }.compact
  body["description"] = description unless description.equal?(WorkOS::OMIT)
  body["scopes"] = scopes unless scopes.equal?(WorkOS::OMIT)
  response = @client.request(
    method: :post,
    path: "/data-integrations",
    auth: true,
    body: body,
    request_options: request_options
  )
  result = WorkOS::DataIntegration.new(response.body)
  result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#create_data_integration_credential(slug:, user_id:, organization_id: nil, connected_account_id: nil, connection_owner: nil, supports_multiple_connections: nil, request_options: {}) ⇒ WorkOS::DataIntegrationCredentialsResponse

Vend credentials for a connected account

Parameters:

  • slug (String)

    The identifier of the integration.

  • user_id (String)

    A User identifier. When connection_owner is organization, this is the user the credentials are vended on behalf of; they must be an active member of the organization.

  • organization_id (String, nil) (defaults to: nil)

    An Organization identifier. Optional parameter to scope the connection to a specific organization. Required when connection_owner is organization.

  • connected_account_id (String, nil) (defaults to: nil)

    A connected account identifier. Use this to select a specific connection when the user has several for this provider.

  • connection_owner (WorkOS::Types::DataIntegrationsVendCredentialsRequestConnectionOwner, nil) (defaults to: nil)

    Which connection to vend from. user (the default) vends the user's own connection and requires user_id. organization vends the organization's shared connection and requires organization_id.

  • supports_multiple_connections (Boolean, nil) (defaults to: nil)

    Set to true to use the plural connection contract. If no connected_account_id is supplied and several connections match, the request returns account_selection_required. When omitted or false, only the compatibility connection is considered.

  • request_options (Hash) (defaults to: {})

    (see WorkOS::Types::RequestOptions)

Returns:



313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
# File 'lib/workos/pipes.rb', line 313

def create_data_integration_credential(
  slug:,
  user_id:,
  organization_id: nil,
  connected_account_id: nil,
  connection_owner: nil,
  supports_multiple_connections: nil,
  request_options: {}
)
  body = {
    "user_id" => user_id,
    "organization_id" => organization_id,
    "connected_account_id" => ,
    "connection_owner" => connection_owner,
    "supports_multiple_connections" => supports_multiple_connections
  }.compact
  response = @client.request(
    method: :post,
    path: "/data-integrations/#{WorkOS::Util.encode_path(slug)}/credentials",
    auth: true,
    body: body,
    request_options: request_options
  )
  result = WorkOS::DataIntegrationCredentialsResponse.new(response.body)
  result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#create_organization_connected_account(organization_id:, slug:, access_token: nil, refresh_token: nil, expires_at: nil, scopes: nil, state: nil, request_options: {}) ⇒ WorkOS::ConnectedAccount

Import an organization connected account

Parameters:

  • organization_id (String)

    An Organization identifier.

  • slug (String)

    The slug identifier of the provider (e.g., github, slack, notion).

  • access_token (String, nil) (defaults to: nil)

    The OAuth access token for the connected account.

  • refresh_token (String, nil) (defaults to: nil)

    The OAuth refresh token for the connected account.

  • expires_at (String, nil) (defaults to: nil)

    The ISO-8601 timestamp when the access token expires. Required when access_token is provided for tokens that expire.

  • scopes (Array<String>, nil) (defaults to: nil)

    The OAuth scopes granted for this connection.

  • state (WorkOS::Types::ConnectedAccountInputState, nil) (defaults to: nil)

    Explicitly set the state of the connected account. When omitted, the state is derived from the token combination provided.

  • request_options (Hash) (defaults to: {})

    (see WorkOS::Types::RequestOptions)

Returns:



494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
# File 'lib/workos/pipes.rb', line 494

def (
  organization_id:,
  slug:,
  access_token: nil,
  refresh_token: nil,
  expires_at: nil,
  scopes: nil,
  state: nil,
  request_options: {}
)
  body = {
    "access_token" => access_token,
    "refresh_token" => refresh_token,
    "expires_at" => expires_at,
    "scopes" => scopes,
    "state" => state
  }.compact
  response = @client.request(
    method: :post,
    path: "/organizations/#{WorkOS::Util.encode_path(organization_id)}/connected_accounts/#{WorkOS::Util.encode_path(slug)}",
    auth: true,
    body: body,
    request_options: request_options
  )
  result = WorkOS::ConnectedAccount.new(response.body)
  result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#create_user_connected_account(user_id:, slug:, access_token: nil, refresh_token: nil, expires_at: nil, scopes: nil, state: nil, organization_id: nil, request_options: {}) ⇒ WorkOS::ConnectedAccount

Import a connected account

Parameters:

  • user_id (String)

    A User identifier.

  • slug (String)

    The slug identifier of the provider (e.g., github, slack, notion).

  • access_token (String, nil) (defaults to: nil)

    The OAuth access token for the connected account.

  • refresh_token (String, nil) (defaults to: nil)

    The OAuth refresh token for the connected account.

  • expires_at (String, nil) (defaults to: nil)

    The ISO-8601 timestamp when the access token expires. Required when access_token is provided for tokens that expire.

  • scopes (Array<String>, nil) (defaults to: nil)

    The OAuth scopes granted for this connection.

  • state (WorkOS::Types::ConnectedAccountInputState, nil) (defaults to: nil)

    Explicitly set the state of the connected account. When omitted, the state is derived from the token combination provided.

  • organization_id (String, nil) (defaults to: nil)

    An Organization identifier. Optional parameter if the connection is scoped to an organization.

  • request_options (Hash) (defaults to: {})

    (see WorkOS::Types::RequestOptions)

Returns:



668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
# File 'lib/workos/pipes.rb', line 668

def (
  user_id:,
  slug:,
  access_token: nil,
  refresh_token: nil,
  expires_at: nil,
  scopes: nil,
  state: nil,
  organization_id: nil,
  request_options: {}
)
  params = {
    "organization_id" => organization_id
  }.compact
  body = {
    "access_token" => access_token,
    "refresh_token" => refresh_token,
    "expires_at" => expires_at,
    "scopes" => scopes,
    "state" => state
  }.compact
  response = @client.request(
    method: :post,
    path: "/user_management/users/#{WorkOS::Util.encode_path(user_id)}/connected_accounts/#{WorkOS::Util.encode_path(slug)}",
    auth: true,
    params: params,
    body: body,
    request_options: request_options
  )
  result = WorkOS::ConnectedAccount.new(response.body)
  result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#delete_data_integration(slug:, request_options: {}) ⇒ void

This method returns an undefined value.

Delete a data integration

Parameters:

  • slug (String)

    The slug identifier of the data integration.

  • request_options (Hash) (defaults to: {})

    (see WorkOS::Types::RequestOptions)



174
175
176
177
178
179
180
181
182
183
184
185
# File 'lib/workos/pipes.rb', line 174

def delete_data_integration(
  slug:,
  request_options: {}
)
  @client.request(
    method: :delete,
    path: "/data-integrations/#{WorkOS::Util.encode_path(slug)}",
    auth: true,
    request_options: request_options
  )
  nil
end

#delete_data_integration_organization(slug:, request_options: {}) ⇒ void

This method returns an undefined value.

Delete an organization-owned data integration

Parameters:

  • slug (String)

    The slug identifier of the data integration.

  • request_options (Hash) (defaults to: {})

    (see WorkOS::Types::RequestOptions)



404
405
406
407
408
409
410
411
412
413
414
415
# File 'lib/workos/pipes.rb', line 404

def delete_data_integration_organization(
  slug:,
  request_options: {}
)
  @client.request(
    method: :delete,
    path: "/data-integrations/#{WorkOS::Util.encode_path(slug)}/organization",
    auth: true,
    request_options: request_options
  )
  nil
end

#delete_organization_connected_account(organization_id:, slug:, supports_multiple_connections: nil, connected_account_id: nil, request_options: {}) ⇒ void

This method returns an undefined value.

Delete an organization connected account

Parameters:

  • organization_id (String)

    An Organization identifier.

  • slug (String)

    The slug identifier of the provider (e.g., github, slack, notion).

  • supports_multiple_connections (Boolean, nil) (defaults to: nil)

    Set to true to use the plural connection contract. When omitted or false, only the compatibility connection is considered.

  • connected_account_id (String, nil) (defaults to: nil)

    A connected account identifier. Use this to select the connection to delete.

  • request_options (Hash) (defaults to: {})

    (see WorkOS::Types::RequestOptions)



578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
# File 'lib/workos/pipes.rb', line 578

def (
  organization_id:,
  slug:,
  supports_multiple_connections: nil,
  connected_account_id: nil,
  request_options: {}
)
  params = {
    "supports_multiple_connections" => supports_multiple_connections,
    "connected_account_id" => 
  }.compact
  @client.request(
    method: :delete,
    path: "/organizations/#{WorkOS::Util.encode_path(organization_id)}/connected_accounts/#{WorkOS::Util.encode_path(slug)}",
    auth: true,
    params: params,
    request_options: request_options
  )
  nil
end

#delete_user_connected_account(user_id:, slug:, organization_id: nil, supports_multiple_connections: nil, connected_account_id: nil, request_options: {}) ⇒ void

This method returns an undefined value.

Delete a connected account

Parameters:

  • user_id (String)

    A User identifier.

  • slug (String)

    The slug identifier of the provider (e.g., github, slack, notion).

  • organization_id (String, nil) (defaults to: nil)

    An Organization identifier. Optional parameter if the connection is scoped to an organization.

  • supports_multiple_connections (Boolean, nil) (defaults to: nil)

    Set to true to use the plural connection contract. When omitted or false, only the compatibility connection is considered.

  • connected_account_id (String, nil) (defaults to: nil)

    A connected account identifier. Use this to select the connection to delete.

  • request_options (Hash) (defaults to: {})

    (see WorkOS::Types::RequestOptions)



761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
# File 'lib/workos/pipes.rb', line 761

def (
  user_id:,
  slug:,
  organization_id: nil,
  supports_multiple_connections: nil,
  connected_account_id: nil,
  request_options: {}
)
  params = {
    "organization_id" => organization_id,
    "supports_multiple_connections" => supports_multiple_connections,
    "connected_account_id" => 
  }.compact
  @client.request(
    method: :delete,
    path: "/user_management/users/#{WorkOS::Util.encode_path(user_id)}/connected_accounts/#{WorkOS::Util.encode_path(slug)}",
    auth: true,
    params: params,
    request_options: request_options
  )
  nil
end

#get_access_token(provider:, user_id:, organization_id: WorkOS::OMIT, connected_account_id: nil, connection_owner: nil, supports_multiple_connections: nil, request_options: {}) ⇒ WorkOS::DataIntegrationAccessTokenResponse

Get an access token for a connected account

Parameters:

  • provider (String)

    The identifier of the integration.

  • user_id (String)

    A User identifier. When connection_owner is organization, this is the user the credentials are vended on behalf of; they must be an active member of the organization.

  • organization_id (String, nil) (defaults to: WorkOS::OMIT)

    An Organization identifier. Optional parameter to scope the connection to a specific organization. Required when connection_owner is organization.

  • connected_account_id (String, nil) (defaults to: nil)

    A connected account identifier. Use this to select a specific connection when the user has several for this provider.

  • connection_owner (WorkOS::Types::DataIntegrationsGetUserTokenRequestConnectionOwner, nil) (defaults to: nil)

    Which connection to vend from. user (the default) vends the user's own connection and requires user_id. organization vends the organization's shared connection and requires organization_id.

  • supports_multiple_connections (Boolean, nil) (defaults to: nil)

    Set to true to use the plural connection contract. If no connected_account_id is supplied and several connections match, the request returns account_selection_required. When omitted or false, only the compatibility connection is considered.

  • request_options (Hash) (defaults to: {})

    (see WorkOS::Types::RequestOptions)

Returns:



426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
# File 'lib/workos/pipes.rb', line 426

def get_access_token(
  provider:,
  user_id:,
  organization_id: WorkOS::OMIT,
  connected_account_id: nil,
  connection_owner: nil,
  supports_multiple_connections: nil,
  request_options: {}
)
  body = {
    "user_id" => user_id,
    "connected_account_id" => ,
    "connection_owner" => connection_owner,
    "supports_multiple_connections" => supports_multiple_connections
  }.compact
  body["organization_id"] = organization_id unless organization_id.equal?(WorkOS::OMIT)
  response = @client.request(
    method: :post,
    path: "/data-integrations/#{WorkOS::Util.encode_path(provider)}/token",
    auth: true,
    body: body,
    request_options: request_options
  )
  result = WorkOS::DataIntegrationAccessTokenResponse.new(response.body)
  result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#get_data_integration(slug:, request_options: {}) ⇒ WorkOS::DataIntegration

Get a data integration

Parameters:

  • slug (String)

    The slug identifier of the data integration.

  • request_options (Hash) (defaults to: {})

    (see WorkOS::Types::RequestOptions)

Returns:



115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/workos/pipes.rb', line 115

def get_data_integration(
  slug:,
  request_options: {}
)
  response = @client.request(
    method: :get,
    path: "/data-integrations/#{WorkOS::Util.encode_path(slug)}",
    auth: true,
    request_options: request_options
  )
  result = WorkOS::DataIntegration.new(response.body)
  result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#get_organization_connected_account(organization_id:, slug:, supports_multiple_connections: nil, connected_account_id: nil, request_options: {}) ⇒ WorkOS::ConnectedAccount

Get an organization connected account

Parameters:

  • organization_id (String)

    An Organization identifier.

  • slug (String)

    The slug identifier of the provider (e.g., github, slack, notion).

  • supports_multiple_connections (Boolean, nil) (defaults to: nil)

    Set to true to use the plural connection contract. When omitted or false, only the compatibility connection is considered.

  • connected_account_id (String, nil) (defaults to: nil)

    A connected account identifier. Use this to select a specific connection when the organization has several for this provider.

  • request_options (Hash) (defaults to: {})

    (see WorkOS::Types::RequestOptions)

Returns:



461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
# File 'lib/workos/pipes.rb', line 461

def (
  organization_id:,
  slug:,
  supports_multiple_connections: nil,
  connected_account_id: nil,
  request_options: {}
)
  params = {
    "supports_multiple_connections" => supports_multiple_connections,
    "connected_account_id" => 
  }.compact
  response = @client.request(
    method: :get,
    path: "/organizations/#{WorkOS::Util.encode_path(organization_id)}/connected_accounts/#{WorkOS::Util.encode_path(slug)}",
    auth: true,
    params: params,
    request_options: request_options
  )
  result = WorkOS::ConnectedAccount.new(response.body)
  result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#get_user_connected_account(user_id:, slug:, organization_id: nil, supports_multiple_connections: nil, connected_account_id: nil, request_options: {}) ⇒ WorkOS::ConnectedAccount

Get a connected account

Parameters:

  • user_id (String)

    A User identifier.

  • slug (String)

    The slug identifier of the provider (e.g., github, slack, notion).

  • organization_id (String, nil) (defaults to: nil)

    An Organization identifier. Optional parameter if the connection is scoped to an organization.

  • supports_multiple_connections (Boolean, nil) (defaults to: nil)

    Set to true to use the plural connection contract. When omitted or false, only the compatibility connection is considered.

  • connected_account_id (String, nil) (defaults to: nil)

    A connected account identifier. Use this to select a specific connection when the user has several for this provider.

  • request_options (Hash) (defaults to: {})

    (see WorkOS::Types::RequestOptions)

Returns:



632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
# File 'lib/workos/pipes.rb', line 632

def (
  user_id:,
  slug:,
  organization_id: nil,
  supports_multiple_connections: nil,
  connected_account_id: nil,
  request_options: {}
)
  params = {
    "organization_id" => organization_id,
    "supports_multiple_connections" => supports_multiple_connections,
    "connected_account_id" => 
  }.compact
  response = @client.request(
    method: :get,
    path: "/user_management/users/#{WorkOS::Util.encode_path(user_id)}/connected_accounts/#{WorkOS::Util.encode_path(slug)}",
    auth: true,
    params: params,
    request_options: request_options
  )
  result = WorkOS::ConnectedAccount.new(response.body)
  result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#list_data_integration_organization(slug:, request_options: {}) ⇒ WorkOS::DataIntegration

Get an organization-owned data integration

Parameters:

  • slug (String)

    The slug identifier of the data integration.

  • request_options (Hash) (defaults to: {})

    (see WorkOS::Types::RequestOptions)

Returns:



345
346
347
348
349
350
351
352
353
354
355
356
357
358
# File 'lib/workos/pipes.rb', line 345

def list_data_integration_organization(
  slug:,
  request_options: {}
)
  response = @client.request(
    method: :get,
    path: "/data-integrations/#{WorkOS::Util.encode_path(slug)}/organization",
    auth: true,
    request_options: request_options
  )
  result = WorkOS::DataIntegration.new(response.body)
  result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#list_data_integrations(before: nil, after: nil, limit: 10, order: "desc", ownership: nil, request_options: {}) ⇒ WorkOS::Types::ListStruct<WorkOS::DataIntegration>

List data integrations

Parameters:

  • before (String, nil) (defaults to: nil)

    An object ID that defines your place in the list. When the ID is not present, you are at the end of the list. For example, if you make a list request and receive 100 objects, ending with "obj_123", your subsequent call can include before="obj_123" to fetch a new batch of objects before "obj_123".

  • after (String, nil) (defaults to: nil)

    An object ID that defines your place in the list. When the ID is not present, you are at the end of the list. For example, if you make a list request and receive 100 objects, ending with "obj_123", your subsequent call can include after="obj_123" to fetch a new batch of objects after "obj_123".

  • limit (Integer, nil) (defaults to: 10)

    Upper limit on the number of objects to return, between 1 and 100.

  • order (WorkOS::Types::PaginationOrder, nil) (defaults to: "desc")

    Order the results by the creation time. Supported values are "asc" (ascending), "desc" (descending), and "normal" (descending with reversed cursor semantics where before fetches older records and after fetches newer records).

  • ownership (WorkOS::Types::PipesOwnership, nil) (defaults to: nil)

    Only return Data Integrations with this ownership: user for the integrations users connect their own accounts to, or organization for the roots organizations connect to. Omit to return both.

  • request_options (Hash) (defaults to: {})

    (see WorkOS::Types::RequestOptions)

Returns:



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/workos/pipes.rb', line 21

def list_data_integrations(
  before: nil,
  after: nil,
  limit: 10,
  order: "desc",
  ownership: nil,
  request_options: {}
)
  params = {
    "before" => before,
    "after" => after,
    "limit" => limit,
    "order" => order,
    "ownership" => ownership
  }.compact
  response = @client.request(
    method: :get,
    path: "/data-integrations",
    auth: true,
    params: params,
    request_options: request_options
  )
  fetch_next = ->(cursor) {
    list_data_integrations(
      before: before,
      after: cursor,
      limit: limit,
      order: order,
      ownership: ownership,
      request_options: request_options
    )
  }
  WorkOS::Types::ListStruct.from_response(
    response,
    model: WorkOS::DataIntegration,
    filters: {before: before, limit: limit, order: order, ownership: ownership},
    fetch_next: fetch_next
  )
end

#list_organization_data_providers(organization_id:, supports_multiple_connections: nil, request_options: {}) ⇒ WorkOS::DataIntegrationsListResponse

List providers for an organization

Parameters:

  • organization_id (String)

    An Organization identifier to list providers and connected accounts for.

  • supports_multiple_connections (Boolean, nil) (defaults to: nil)

    Set to true to use the plural connection contract. When omitted or false, only the compatibility connection is considered.

  • request_options (Hash) (defaults to: {})

    (see WorkOS::Types::RequestOptions)

Returns:



604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
# File 'lib/workos/pipes.rb', line 604

def list_organization_data_providers(
  organization_id:,
  supports_multiple_connections: nil,
  request_options: {}
)
  params = {
    "supports_multiple_connections" => supports_multiple_connections
  }.compact
  response = @client.request(
    method: :get,
    path: "/organizations/#{WorkOS::Util.encode_path(organization_id)}/data_providers",
    auth: true,
    params: params,
    request_options: request_options
  )
  result = WorkOS::DataIntegrationsListResponse.new(response.body)
  result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#list_user_data_providers(user_id:, organization_id: nil, supports_multiple_connections: nil, request_options: {}) ⇒ WorkOS::DataIntegrationsListResponse

List providers for a user

Parameters:

  • user_id (String)

    A User identifier to list providers and connected accounts for.

  • organization_id (String, nil) (defaults to: nil)

    An Organization identifier. Optional parameter to filter connections for a specific organization.

  • supports_multiple_connections (Boolean, nil) (defaults to: nil)

    Set to true to use the plural connection contract. When omitted or false, only the compatibility connection is considered.

  • request_options (Hash) (defaults to: {})

    (see WorkOS::Types::RequestOptions)

Returns:



790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
# File 'lib/workos/pipes.rb', line 790

def list_user_data_providers(
  user_id:,
  organization_id: nil,
  supports_multiple_connections: nil,
  request_options: {}
)
  params = {
    "organization_id" => organization_id,
    "supports_multiple_connections" => supports_multiple_connections
  }.compact
  response = @client.request(
    method: :get,
    path: "/user_management/users/#{WorkOS::Util.encode_path(user_id)}/data_providers",
    auth: true,
    params: params,
    request_options: request_options
  )
  result = WorkOS::DataIntegrationsListResponse.new(response.body)
  result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#update_data_integration(slug:, description: WorkOS::OMIT, enabled: nil, scopes: WorkOS::OMIT, credentials: nil, api_key: nil, custom_provider: nil, request_options: {}) ⇒ WorkOS::DataIntegration

Update a data integration

Parameters:

  • slug (String)

    The slug identifier of the data integration.

  • description (String, nil) (defaults to: WorkOS::OMIT)

    An optional description of the Data Integration.

  • enabled (Boolean, nil) (defaults to: nil)

    Whether the Data Integration is enabled.

  • scopes (Array<String>, nil) (defaults to: WorkOS::OMIT)

    The OAuth scopes to request for the Data Integration. Pass null to reset to the provider's configured scopes.

  • credentials (WorkOS::DataIntegrationCredentialsInput, nil) (defaults to: nil)

    New OAuth credentials for the Data Integration. When provided, rotates the stored client secret. Mutually exclusive with api_key.

  • api_key (WorkOS::ApiKeyInstallation, nil) (defaults to: nil)

    An API key to install or rotate for a tenant on an api_key integration. Upserts the tenant installation identified by user_id (and optional organization_id).

  • custom_provider (WorkOS::UpdateCustomProviderDefinition, nil) (defaults to: nil)

    Updates to a custom provider's OAuth definition. Only valid for custom-provider integrations.

  • request_options (Hash) (defaults to: {})

    (see WorkOS::Types::RequestOptions)

Returns:



140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# File 'lib/workos/pipes.rb', line 140

def update_data_integration(
  slug:,
  description: WorkOS::OMIT,
  enabled: nil,
  scopes: WorkOS::OMIT,
  credentials: nil,
  api_key: nil,
  custom_provider: nil,
  request_options: {}
)
  body = {
    "enabled" => enabled,
    "credentials" => credentials,
    "api_key" => api_key,
    "custom_provider" => custom_provider
  }.compact
  body["description"] = description unless description.equal?(WorkOS::OMIT)
  body["scopes"] = scopes unless scopes.equal?(WorkOS::OMIT)
  response = @client.request(
    method: :put,
    path: "/data-integrations/#{WorkOS::Util.encode_path(slug)}",
    auth: true,
    body: body,
    request_options: request_options
  )
  result = WorkOS::DataIntegration.new(response.body)
  result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#update_data_integration_api_key(slug:, user_id:, secret:, organization_id: nil, connected_account_id: nil, connection_owner: nil, request_options: {}) ⇒ WorkOS::ConnectedAccount

Upsert an API key for a connected account

Parameters:

  • slug (String)

    The identifier of the integration.

  • user_id (String)

    A User identifier.

  • organization_id (String, nil) (defaults to: nil)

    An Organization identifier. Optional parameter to scope the connection to a specific organization. Required when connection_owner is organization.

  • connected_account_id (String, nil) (defaults to: nil)

    A connected account identifier. Use this to rotate a specific existing connection.

  • connection_owner (WorkOS::Types::DataIntegrationsUpsertApiKeyRequestConnectionOwner, nil) (defaults to: nil)

    Whose connection to create or rotate. user (the default) addresses the connection owned by user_id. organization addresses the connection shared by every member of organization_id; user_id then identifies the member performing the request and must be an active member of the organization.

  • secret (String)

    The API key secret to store for this integration.

  • request_options (Hash) (defaults to: {})

    (see WorkOS::Types::RequestOptions)

Returns:



196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
# File 'lib/workos/pipes.rb', line 196

def update_data_integration_api_key(
  slug:,
  user_id:,
  secret:,
  organization_id: nil,
  connected_account_id: nil,
  connection_owner: nil,
  request_options: {}
)
  body = {
    "user_id" => user_id,
    "organization_id" => organization_id,
    "connected_account_id" => ,
    "connection_owner" => connection_owner,
    "secret" => secret
  }.compact
  response = @client.request(
    method: :put,
    path: "/data-integrations/#{WorkOS::Util.encode_path(slug)}/api-key",
    auth: true,
    body: body,
    request_options: request_options
  )
  result = WorkOS::ConnectedAccount.new(response.body)
  result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#update_data_integration_client_credentials(slug:, user_id:, client_id:, client_secret:, organization_id: nil, connected_account_id: nil, connection_owner: nil, config: nil, request_options: {}) ⇒ WorkOS::ConnectedAccount

Upsert client credentials for a connected account

Parameters:

  • slug (String)

    The identifier of the integration.

  • user_id (String)

    A User identifier.

  • organization_id (String, nil) (defaults to: nil)

    An Organization identifier. Optional parameter to scope the connection to a specific organization. Required when connection_owner is organization.

  • connected_account_id (String, nil) (defaults to: nil)

    A connected account identifier. Use this to rotate a specific existing connection.

  • connection_owner (WorkOS::Types::DataIntegrationsUpsertClientCredentialsRequestConnectionOwner, nil) (defaults to: nil)

    Whose connection to create or rotate. user (the default) addresses the connection owned by user_id. organization addresses the connection shared by every member of organization_id; user_id then identifies the member performing the request and must be an active member of the organization.

  • client_id (String)

    The OAuth client ID to store for this integration.

  • client_secret (String)

    The OAuth client secret to store for this integration.

  • config (Hash{String => String}, nil) (defaults to: nil)

    Provider-specific configuration values collected for this installation, keyed by the provider's config field descriptors.

  • request_options (Hash) (defaults to: {})

    (see WorkOS::Types::RequestOptions)

Returns:



272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
# File 'lib/workos/pipes.rb', line 272

def update_data_integration_client_credentials(
  slug:,
  user_id:,
  client_id:,
  client_secret:,
  organization_id: nil,
  connected_account_id: nil,
  connection_owner: nil,
  config: nil,
  request_options: {}
)
  body = {
    "user_id" => user_id,
    "organization_id" => organization_id,
    "connected_account_id" => ,
    "connection_owner" => connection_owner,
    "client_id" => client_id,
    "client_secret" => client_secret,
    "config" => config
  }.compact
  response = @client.request(
    method: :put,
    path: "/data-integrations/#{WorkOS::Util.encode_path(slug)}/client-credentials",
    auth: true,
    body: body,
    request_options: request_options
  )
  result = WorkOS::ConnectedAccount.new(response.body)
  result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#update_data_integration_organization(slug:, description: WorkOS::OMIT, enabled: nil, scopes: WorkOS::OMIT, credentials: nil, api_key: nil, custom_provider: nil, request_options: {}) ⇒ WorkOS::DataIntegration

Update an organization-owned data integration

Parameters:

  • slug (String)

    The slug identifier of the data integration.

  • description (String, nil) (defaults to: WorkOS::OMIT)

    An optional description of the Data Integration.

  • enabled (Boolean, nil) (defaults to: nil)

    Whether the Data Integration is enabled.

  • scopes (Array<String>, nil) (defaults to: WorkOS::OMIT)

    The OAuth scopes to request for the Data Integration. Pass null to reset to the provider's configured scopes.

  • credentials (WorkOS::DataIntegrationCredentialsInput, nil) (defaults to: nil)

    New OAuth credentials for the Data Integration. When provided, rotates the stored client secret. Mutually exclusive with api_key.

  • api_key (WorkOS::ApiKeyInstallation, nil) (defaults to: nil)

    An API key to install or rotate for a tenant on an api_key integration. Upserts the tenant installation identified by user_id (and optional organization_id).

  • custom_provider (WorkOS::UpdateCustomProviderDefinition, nil) (defaults to: nil)

    Updates to a custom provider's OAuth definition. Only valid for custom-provider integrations.

  • request_options (Hash) (defaults to: {})

    (see WorkOS::Types::RequestOptions)

Returns:



370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
# File 'lib/workos/pipes.rb', line 370

def update_data_integration_organization(
  slug:,
  description: WorkOS::OMIT,
  enabled: nil,
  scopes: WorkOS::OMIT,
  credentials: nil,
  api_key: nil,
  custom_provider: nil,
  request_options: {}
)
  body = {
    "enabled" => enabled,
    "credentials" => credentials,
    "api_key" => api_key,
    "custom_provider" => custom_provider
  }.compact
  body["description"] = description unless description.equal?(WorkOS::OMIT)
  body["scopes"] = scopes unless scopes.equal?(WorkOS::OMIT)
  response = @client.request(
    method: :put,
    path: "/data-integrations/#{WorkOS::Util.encode_path(slug)}/organization",
    auth: true,
    body: body,
    request_options: request_options
  )
  result = WorkOS::DataIntegration.new(response.body)
  result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#update_organization_connected_account(organization_id:, slug:, access_token: nil, refresh_token: nil, expires_at: nil, scopes: nil, state: nil, supports_multiple_connections: nil, connected_account_id: nil, request_options: {}) ⇒ WorkOS::ConnectedAccount

Update an organization connected account

Parameters:

  • organization_id (String)

    An Organization identifier.

  • slug (String)

    The slug identifier of the provider (e.g., github, slack, notion).

  • access_token (String, nil) (defaults to: nil)

    The OAuth access token for the connected account.

  • refresh_token (String, nil) (defaults to: nil)

    The OAuth refresh token for the connected account.

  • expires_at (String, nil) (defaults to: nil)

    The ISO-8601 timestamp when the access token expires. Required when access_token is provided for tokens that expire.

  • scopes (Array<String>, nil) (defaults to: nil)

    The OAuth scopes granted for this connection.

  • state (WorkOS::Types::ConnectedAccountInputState, nil) (defaults to: nil)

    Explicitly set the state of the connected account. When omitted, the state is derived from the token combination provided.

  • supports_multiple_connections (Boolean, nil) (defaults to: nil)

    Set to true to use the plural connection contract. When omitted or false, only the compatibility connection is considered.

  • connected_account_id (String, nil) (defaults to: nil)

    A connected account identifier. Use this to select the connection to update.

  • request_options (Hash) (defaults to: {})

    (see WorkOS::Types::RequestOptions)

Returns:



535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
# File 'lib/workos/pipes.rb', line 535

def (
  organization_id:,
  slug:,
  access_token: nil,
  refresh_token: nil,
  expires_at: nil,
  scopes: nil,
  state: nil,
  supports_multiple_connections: nil,
  connected_account_id: nil,
  request_options: {}
)
  params = {
    "supports_multiple_connections" => supports_multiple_connections,
    "connected_account_id" => 
  }.compact
  body = {
    "access_token" => access_token,
    "refresh_token" => refresh_token,
    "expires_at" => expires_at,
    "scopes" => scopes,
    "state" => state
  }.compact
  response = @client.request(
    method: :put,
    path: "/organizations/#{WorkOS::Util.encode_path(organization_id)}/connected_accounts/#{WorkOS::Util.encode_path(slug)}",
    auth: true,
    params: params,
    body: body,
    request_options: request_options
  )
  result = WorkOS::ConnectedAccount.new(response.body)
  result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#update_user_connected_account(user_id:, slug:, access_token: nil, refresh_token: nil, expires_at: nil, scopes: nil, state: nil, organization_id: nil, supports_multiple_connections: nil, connected_account_id: nil, request_options: {}) ⇒ WorkOS::ConnectedAccount

Update a connected account

Parameters:

  • user_id (String)

    A User identifier.

  • slug (String)

    The slug identifier of the provider (e.g., github, slack, notion).

  • access_token (String, nil) (defaults to: nil)

    The OAuth access token for the connected account.

  • refresh_token (String, nil) (defaults to: nil)

    The OAuth refresh token for the connected account.

  • expires_at (String, nil) (defaults to: nil)

    The ISO-8601 timestamp when the access token expires. Required when access_token is provided for tokens that expire.

  • scopes (Array<String>, nil) (defaults to: nil)

    The OAuth scopes granted for this connection.

  • state (WorkOS::Types::ConnectedAccountInputState, nil) (defaults to: nil)

    Explicitly set the state of the connected account. When omitted, the state is derived from the token combination provided.

  • organization_id (String, nil) (defaults to: nil)

    An Organization identifier. Optional parameter if the connection is scoped to an organization.

  • supports_multiple_connections (Boolean, nil) (defaults to: nil)

    Set to true to use the plural connection contract. When omitted or false, only the compatibility connection is considered.

  • connected_account_id (String, nil) (defaults to: nil)

    A connected account identifier. Use this to select the connection to update.

  • request_options (Hash) (defaults to: {})

    (see WorkOS::Types::RequestOptions)

Returns:



715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
# File 'lib/workos/pipes.rb', line 715

def (
  user_id:,
  slug:,
  access_token: nil,
  refresh_token: nil,
  expires_at: nil,
  scopes: nil,
  state: nil,
  organization_id: nil,
  supports_multiple_connections: nil,
  connected_account_id: nil,
  request_options: {}
)
  params = {
    "organization_id" => organization_id,
    "supports_multiple_connections" => supports_multiple_connections,
    "connected_account_id" => 
  }.compact
  body = {
    "access_token" => access_token,
    "refresh_token" => refresh_token,
    "expires_at" => expires_at,
    "scopes" => scopes,
    "state" => state
  }.compact
  response = @client.request(
    method: :put,
    path: "/user_management/users/#{WorkOS::Util.encode_path(user_id)}/connected_accounts/#{WorkOS::Util.encode_path(slug)}",
    auth: true,
    params: params,
    body: body,
    request_options: request_options
  )
  result = WorkOS::ConnectedAccount.new(response.body)
  result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end