Class: Nylas::Workspaces

Inherits:
Resource show all
Includes:
ApiOperations::Delete, ApiOperations::Get, ApiOperations::Patch, ApiOperations::Post
Defined in:
lib/nylas/resources/workspaces.rb

Overview

Nylas Workspaces API

A workspace groups grants in a Nylas application by email domain. Grants can be auto-grouped (by matching email domain) or manually assigned/removed.

Instance Method Summary collapse

Methods inherited from Resource

#initialize

Constructor Details

This class inherits a constructor from Nylas::Resource

Instance Method Details

#auto_group(request_body: nil) ⇒ Array(Hash, String, Hash)

Auto-group grants into workspaces by matching email domain.

Runs as a background job and returns immediately with a job ID. Rate limited to one call per minute per application.

Parameters:

  • request_body (Hash) (defaults to: nil)

    Optional filters to scope which grants are grouped, including after_created_at, invalid_also, and specific_domain.

Returns:

  • (Array(Hash, String, Hash))

    The job info, API Request ID, and response headers.



89
90
91
92
93
94
# File 'lib/nylas/resources/workspaces.rb', line 89

def auto_group(request_body: nil)
  post(
    path: "#{api_uri}/v3/workspaces/auto-group",
    request_body: request_body
  )
end

#create(request_body:) ⇒ Array(Hash, String, Hash)

Create a workspace.

Parameters:

  • request_body (Hash)

    The values to create the workspace with. Only name is required.

Returns:

  • (Array(Hash, String, Hash))

    The created workspace, API Request ID, and response headers.



46
47
48
49
50
51
# File 'lib/nylas/resources/workspaces.rb', line 46

def create(request_body:)
  post(
    path: "#{api_uri}/v3/workspaces",
    request_body: request_body
  )
end

#destroy(workspace_id:) ⇒ Array(TrueClass, String)

Delete a workspace.

Parameters:

  • workspace_id (String)

    The id of the workspace to delete. Accepts a workspace UUID or an email domain.

Returns:

  • (Array(TrueClass, String))

    True and the API Request ID for the delete operation.



73
74
75
76
77
78
79
# File 'lib/nylas/resources/workspaces.rb', line 73

def destroy(workspace_id:)
  _, request_id = delete(
    path: "#{api_uri}/v3/workspaces/#{workspace_id}"
  )

  [true, request_id]
end

#find(workspace_id:) ⇒ Array(Hash, String, Hash)

Return a workspace.

Parameters:

  • workspace_id (String)

    The id of the workspace to return. Accepts a workspace UUID or an email domain.

Returns:

  • (Array(Hash, String, Hash))

    The workspace, API Request ID, and response headers.



34
35
36
37
38
# File 'lib/nylas/resources/workspaces.rb', line 34

def find(workspace_id:)
  get(
    path: "#{api_uri}/v3/workspaces/#{workspace_id}"
  )
end

#listArray(Array(Hash), String, Hash)

Return all workspaces for the application.

The list endpoint is not paginated; data is a flat array of workspaces.

Returns:

  • (Array(Array(Hash), String, Hash))

    The list of workspaces, API Request ID, and response headers.



23
24
25
26
27
# File 'lib/nylas/resources/workspaces.rb', line 23

def list
  get(
    path: "#{api_uri}/v3/workspaces"
  )
end

#manual_assign(workspace_id:, request_body:) ⇒ Array(Hash, String, Hash)

Manually assign grants to or remove grants from a workspace.

Parameters:

  • workspace_id (String)

    The id of the workspace to update. Accepts a workspace UUID or an email domain.

  • request_body (Hash)

    The grants to assign and/or remove (+assign_grants+, remove_grants).

Returns:

  • (Array(Hash, String, Hash))

    The assignment result, API Request ID, and response headers.



104
105
106
107
108
109
# File 'lib/nylas/resources/workspaces.rb', line 104

def manual_assign(workspace_id:, request_body:)
  post(
    path: "#{api_uri}/v3/workspaces/#{workspace_id}/manual-assign",
    request_body: request_body
  )
end

#update(workspace_id:, request_body:) ⇒ Array(Hash, String)

Update a workspace.

The API exposes update via PATCH only (there is no PUT route). The workspace must be addressed by its UUID; a domain path param is not accepted on update.

Parameters:

  • workspace_id (String)

    The UUID of the workspace to update.

  • request_body (Hash)

    The values to update the workspace with.

Returns:

  • (Array(Hash, String))

    The updated workspace and API Request ID.



61
62
63
64
65
66
# File 'lib/nylas/resources/workspaces.rb', line 61

def update(workspace_id:, request_body:)
  patch(
    path: "#{api_uri}/v3/workspaces/#{workspace_id}",
    request_body: request_body
  )
end