Class: Cadenya::Resources::WorkspaceAdmin::Members

Inherits:
Object
  • Object
show all
Defined in:
lib/cadenya/resources/workspace_admin/members.rb

Overview

Administer workspaces across the account: create and archive workspaces and manage their membership. These operations are account-scoped and require the admin role (a token whose profile holds the WorkOS admin role); they live under /v1/account/workspaces rather than the workspace-scoped /v1/workspaces tree so an admin can manage any workspace in the account, including ones they are not themselves a member of.

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Members

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Members.

Parameters:



101
102
103
# File 'lib/cadenya/resources/workspace_admin/members.rb', line 101

def initialize(client:)
  @client = client
end

Instance Method Details

#add(workspace_id, email: nil, profile_id: nil, request_options: {}) ⇒ Cadenya::Models::WorkspaceMember

Grants a profile access to the workspace by creating (or reactivating) the actor that links the profile to the workspace. Accepts either an existing profile_id or an email to resolve-or-invite. Idempotent for an already-active member. Admin only.

Parameters:

  • workspace_id (String)

    The workspace to add the member to (path).

  • email (String)

    Email address to add (resolve-or-invite). Mutually exclusive with profile_id.

  • profile_id (String)

    An existing account profile to add. Mutually exclusive with email.

  • request_options (Cadenya::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



59
60
61
62
63
64
65
66
67
68
# File 'lib/cadenya/resources/workspace_admin/members.rb', line 59

def add(workspace_id, params = {})
  parsed, options = Cadenya::WorkspaceAdmin::MemberAddParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["v1/account/workspaces/%1$s/members", workspace_id],
    body: parsed,
    model: Cadenya::WorkspaceMember,
    options: options
  )
end

#list(workspace_id, cursor: nil, limit: nil, request_options: {}) ⇒ Cadenya::Internal::CursorPagination<Cadenya::Models::WorkspaceMember>

Lists the members of a workspace. Admin only.

Parameters:

  • workspace_id (String)

    The workspace whose members will be listed (path).

  • cursor (String)

    Pagination cursor from previous response

  • limit (Integer)

    Maximum number of results to return

  • request_options (Cadenya::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/cadenya/resources/workspace_admin/members.rb', line 28

def list(workspace_id, params = {})
  parsed, options = Cadenya::WorkspaceAdmin::MemberListParams.dump_request(params)
  query = Cadenya::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["v1/account/workspaces/%1$s/members", workspace_id],
    query: query,
    page: Cadenya::Internal::CursorPagination,
    model: Cadenya::WorkspaceMember,
    options: options
  )
end

#remove(profile_id, workspace_id:, request_options: {}) ⇒ nil

Revokes a member’s access by deactivating their actor; the member is immediately cut off. The underlying profile is not deleted. Admin only.

Parameters:

  • profile_id (String)

    The profile to remove from the workspace (path).

  • workspace_id (String)

    The workspace to remove the member from (path).

  • request_options (Cadenya::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

  • (nil)

See Also:



84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/cadenya/resources/workspace_admin/members.rb', line 84

def remove(profile_id, params)
  parsed, options = Cadenya::WorkspaceAdmin::MemberRemoveParams.dump_request(params)
  workspace_id =
    parsed.delete(:workspace_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :delete,
    path: ["v1/account/workspaces/%1$s/members/%2$s", workspace_id, profile_id],
    model: NilClass,
    options: options
  )
end