Class: Anthropic::Resources::Organization::ServiceAccounts::Workspaces

Inherits:
Object
  • Object
show all
Defined in:
lib/anthropic/resources/organization/service_accounts/workspaces.rb,
sig/anthropic/resources/organization/service_accounts/workspaces.rbs

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Workspaces

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

Parameters:



155
156
157
# File 'lib/anthropic/resources/organization/service_accounts/workspaces.rb', line 155

def initialize(client:)
  @client = client
end

Instance Method Details

#add(service_account_id, workspace_id:, workspace_role:, request_options: {}) ⇒ Anthropic::Models::Organization::ServiceAccountWorkspaceMember

Requires an OAuth access token with the org:admin scope, from ant auth login --scope org:admin or a workload identity federation rule; Admin API keys are not accepted. See Manage WIF with the Admin API.

Add a service account to a workspace with the given workspace_role.

Mirror of POST /workspaces/{workspace_id}/service_accounts, addressed from the service-account side; both create the same membership. If the service account is already an explicit member of the workspace, its workspace_role is replaced with the value supplied here. Archived workspaces return 400. Archived service accounts cannot be added and are rejected.

Parameters:

  • service_account_id (String) —

    ID of the service account.

  • workspace_id (String) —

    Tagged workspace ID to add the service account to.

  • workspace_role (Symbol, Anthropic::Models::Organization::NoBillingWorkspaceRole) —

    Role to assign to the service account in this workspace.

  • request_options (Anthropic::RequestOptions, Hash{Symbol=>Object}, nil)
  • workspace_id: (String)
  • workspace_role: (Anthropic::Models::Organization::no_billing_workspace_role)
  • request_options: (Anthropic::request_opts)

Returns:

Raises:

See Also:



85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/anthropic/resources/organization/service_accounts/workspaces.rb', line 85

def add(, params)
  parsed, options = Anthropic::Organization::ServiceAccounts::WorkspaceAddParams.dump_request(params)
  @client.request(
    span_name: Anthropic::Internal::Tracing::SpanName::ORGANIZATION_SERVICE_ACCOUNTS_WORKSPACES_ADD,
    span_attributes: {"anthropic.organization.service_account.id" => },
    span_created_id: {"anthropic.organization.service_account.workspace.id" => :workspace_id},
    span_route: "/v1/organizations/service_accounts/{service_account_id}/workspaces",
    method: :post,
    path: ["v1/organizations/service_accounts/%1$s/workspaces", ],
    body: parsed,
    model: Anthropic::Organization::ServiceAccountWorkspaceMember,
    options: options
  )
end

#list(service_account_id, limit: nil, page: nil, request_options: {}) ⇒ Anthropic::Internal::PageCursor<Anthropic::Models::Organization::ServiceAccountWorkspaceMember>

Requires an OAuth access token with the org:admin scope, from ant auth login --scope org:admin or a workload identity federation rule; Admin API keys are not accepted. See Manage WIF with the Admin API.

List the workspaces a service account is a member of.

Each entry includes the service account's workspace_role in that workspace. Use limit and the next_page cursor to paginate. When the service account has no explicit default-workspace membership, the implicit (implicit: true) membership is returned as the first entry on the first page; with limit=1 the first page may return up to 2 entries (the implicit entry plus one explicit membership) so a pagination cursor can be derived. Memberships are returned only while the service account is active. Without a page cursor, an archived service account returns an empty list. A page cursor that does not match an active membership returns a 400 invalid-request error. A cursor stops matching when the membership is removed, the workspace is deleted, or the service account is archived. Restart pagination from the first page to recover.

Parameters:

  • service_account_id (String) —

    ID of the service account.

  • limit (Integer) —

    Number of results per page.

  • page (String, nil) —

    Opaque cursor from a previous response's next_page.

  • request_options (Anthropic::RequestOptions, Hash{Symbol=>Object}, nil)
  • limit: (Integer)
  • page: (String, nil)
  • request_options: (Anthropic::request_opts)

Returns:

See Also:



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/anthropic/resources/organization/service_accounts/workspaces.rb', line 40

def list(, params = {})
  parsed, options = Anthropic::Organization::ServiceAccounts::WorkspaceListParams.dump_request(params)
  query = Anthropic::Internal::Util.encode_query_params(parsed)
  @client.request(
    span_name: Anthropic::Internal::Tracing::SpanName::ORGANIZATION_SERVICE_ACCOUNTS_WORKSPACES_LIST,
    span_attributes: {"anthropic.organization.service_account.id" => },
    span_route: "/v1/organizations/service_accounts/{service_account_id}/workspaces",
    span_query: %w[limit page],
    method: :get,
    path: ["v1/organizations/service_accounts/%1$s/workspaces", ],
    query: query,
    page: Anthropic::Internal::PageCursor,
    model: Anthropic::Organization::ServiceAccountWorkspaceMember,
    options: options
  )
end

#remove(workspace_id, service_account_id:, request_options: {}) ⇒ Anthropic::Models::Organization::ServiceAccounts::WorkspaceRemoveResponse

Requires an OAuth access token with the org:admin scope, from ant auth login --scope org:admin or a workload identity federation rule; Admin API keys are not accepted. See Manage WIF with the Admin API.

Remove a service account from a workspace.

Mirror of DELETE /workspaces/{workspace_id}/service_accounts/{service_account_id}, addressed from the service-account side. Removal is idempotent (returns 200 even if the membership was already removed). A DELETE against the implicit default-workspace membership returns 200 but is a no-op and the membership persists; deleting an explicit default-workspace row reverts to the implicit workspace_user membership. Archived workspaces return 400.

Parameters:

  • workspace_id (String) —

    ID of the workspace.

  • service_account_id (String) —

    ID of the service account.

  • request_options (Anthropic::RequestOptions, Hash{Symbol=>Object}, nil)
  • service_account_id: (String)
  • request_options: (Anthropic::request_opts)

Returns:

Raises:

See Also:



128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/anthropic/resources/organization/service_accounts/workspaces.rb', line 128

def remove(workspace_id, params)
  parsed, options = Anthropic::Organization::ServiceAccounts::WorkspaceRemoveParams.dump_request(params)
   =
    parsed.delete(:service_account_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    span_name: Anthropic::Internal::Tracing::SpanName::ORGANIZATION_SERVICE_ACCOUNTS_WORKSPACES_REMOVE,
    span_attributes: {
      "anthropic.organization.service_account.id" => ,
      "anthropic.organization.service_account.workspace.id" => workspace_id
    },
    span_route: "/v1/organizations/service_accounts/{service_account_id}/workspaces/{workspace_id}",
    method: :delete,
    path: [
      "v1/organizations/service_accounts/%1$s/workspaces/%2$s",
      ,
      workspace_id
    ],
    model: Anthropic::Models::Organization::ServiceAccounts::WorkspaceRemoveResponse,
    options: options
  )
end