Class: Cadenya::Resources::WorkspaceAdmin

Inherits:
Object
  • Object
show all
Defined in:
lib/cadenya/resources/workspace_admin.rb,
lib/cadenya/resources/workspace_admin/members.rb,
lib/cadenya/resources/workspace_admin/profiles.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.

Defined Under Namespace

Classes: Members, Profiles

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ WorkspaceAdmin

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 WorkspaceAdmin.

Parameters:



166
167
168
169
170
# File 'lib/cadenya/resources/workspace_admin.rb', line 166

def initialize(client:)
  @client = client
  @members = Cadenya::Resources::WorkspaceAdmin::Members.new(client: client)
  @profiles = Cadenya::Resources::WorkspaceAdmin::Profiles.new(client: client)
end

Instance Attribute Details

#membersCadenya::Resources::WorkspaceAdmin::Members (readonly)

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.



19
20
21
# File 'lib/cadenya/resources/workspace_admin.rb', line 19

def members
  @members
end

#profilesCadenya::Resources::WorkspaceAdmin::Profiles (readonly)

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.



28
29
30
# File 'lib/cadenya/resources/workspace_admin.rb', line 28

def profiles
  @profiles
end

Instance Method Details

#archive(workspace_id, request_options: {}) ⇒ nil

Archives a workspace (soft delete). The workspace is retained, but any subsequent request scoped to it returns a permission error. Archiving the account’s last active (non-archived) workspace is not allowed and returns FailedPrecondition. Admin only.

Parameters:

  • workspace_id (String)

    Workspace ID to archive (path).

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

Returns:

  • (nil)

See Also:



154
155
156
157
158
159
160
161
# File 'lib/cadenya/resources/workspace_admin.rb', line 154

def archive(workspace_id, params = {})
  @client.request(
    method: :delete,
    path: ["v1/account/workspaces/%1$s", workspace_id],
    model: NilClass,
    options: params[:request_options]
  )
end

#create(metadata:, spec:, request_options: {}) ⇒ Cadenya::Models::Workspace

Some parameter documentations has been truncated, see Models::WorkspaceAdminCreateParams for more details.

Creates a new workspace in the account. Admin only.

Parameters:

Returns:

See Also:



46
47
48
49
50
51
52
53
54
55
# File 'lib/cadenya/resources/workspace_admin.rb', line 46

def create(params)
  parsed, options = Cadenya::WorkspaceAdminCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "v1/account/workspaces",
    body: parsed,
    model: Cadenya::Workspace,
    options: options
  )
end

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

Some parameter documentations has been truncated, see Models::WorkspaceAdminListParams for more details.

Lists every workspace in the account, optionally including archived ones. Admin only.

Parameters:

  • cursor (String)

    Pagination cursor from previous response

  • include_archived (Boolean)

    When true, archived workspaces are included in the results. Defaults to

  • limit (Integer)

    Maximum number of results to return

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

Returns:

See Also:



127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/cadenya/resources/workspace_admin.rb', line 127

def list(params = {})
  parsed, options = Cadenya::WorkspaceAdminListParams.dump_request(params)
  query = Cadenya::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "v1/account/workspaces",
    query: query.transform_keys(include_archived: "includeArchived"),
    page: Cadenya::Internal::CursorPagination,
    model: Cadenya::Workspace,
    options: options
  )
end

#retrieve(workspace_id, request_options: {}) ⇒ Cadenya::Models::Workspace

Retrieves a workspace in the account by ID. Admin only.

Parameters:

  • workspace_id (String)

    Workspace ID to retrieve (path).

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

Returns:

See Also:



68
69
70
71
72
73
74
75
# File 'lib/cadenya/resources/workspace_admin.rb', line 68

def retrieve(workspace_id, params = {})
  @client.request(
    method: :get,
    path: ["v1/account/workspaces/%1$s", workspace_id],
    model: Cadenya::Workspace,
    options: params[:request_options]
  )
end

#update(workspace_id, metadata: nil, spec: nil, update_mask: nil, request_options: {}) ⇒ Cadenya::Models::Workspace

Some parameter documentations has been truncated, see Models::WorkspaceAdminUpdateParams for more details.

Updates a workspace’s metadata (e.g. name) and spec. Admin only.

Parameters:

Returns:

See Also:



97
98
99
100
101
102
103
104
105
106
# File 'lib/cadenya/resources/workspace_admin.rb', line 97

def update(workspace_id, params = {})
  parsed, options = Cadenya::WorkspaceAdminUpdateParams.dump_request(params)
  @client.request(
    method: :patch,
    path: ["v1/account/workspaces/%1$s", workspace_id],
    body: parsed,
    model: Cadenya::Workspace,
    options: options
  )
end