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

Inherits:
Object
  • Object
show all
Defined in:
lib/anthropic/resources/beta/organization/service_accounts/workspaces.rb,
sig/anthropic/resources/beta/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:



151
152
153
# File 'lib/anthropic/resources/beta/organization/service_accounts/workspaces.rb', line 151

def initialize(client:)
  @client = client
end

Instance Method Details

#add(service_account_id, workspace_id:, workspace_role:, betas: nil, request_options: {}) ⇒ Anthropic::Models::Beta::Organization::BetaServiceAccountWorkspaceMember

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:

Returns:

See Also:



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

def add(, params)
  parsed, options = Anthropic::Beta::Organization::ServiceAccounts::WorkspaceAddParams.dump_request(params)
  header_params = {betas: "anthropic-beta"}
  @client.request(
    method: :post,
    path: ["v1/organizations/service_accounts/%1$s/workspaces?beta=true", ],
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Anthropic::Beta::Organization::BetaServiceAccountWorkspaceMember,
    options: options
  )
end

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

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)

    Path param: ID of the service account.

  • limit (Integer)

    Query param: Number of results per page.

  • page (String, nil)

    Query param: Opaque cursor from a previous response's next_page.

  • betas (Array<String, Symbol, Anthropic::Models::AnthropicBeta>)

    Header param: Optional header to specify the beta version(s) you want to use.

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

Returns:

See Also:



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

def list(, params = {})
  query_params = [:limit, :page]
  parsed, options =
    Anthropic::Beta::Organization::ServiceAccounts::WorkspaceListParams.dump_request(params)
  query = Anthropic::Internal::Util.encode_query_params(parsed.slice(*query_params))
  @client.request(
    method: :get,
    path: ["v1/organizations/service_accounts/%1$s/workspaces?beta=true", ],
    query: query,
    headers: parsed.except(*query_params).transform_keys(betas: "anthropic-beta"),
    page: Anthropic::Internal::PageCursor,
    model: Anthropic::Beta::Organization::BetaServiceAccountWorkspaceMember,
    options: options
  )
end

#remove(workspace_id, service_account_id:, betas: nil, request_options: {}) ⇒ Anthropic::Models::Beta::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)

    Path param: ID of the workspace.

  • service_account_id (String)

    Path param: ID of the service account.

  • betas (Array<String, Symbol, Anthropic::Models::AnthropicBeta>)

    Header param: Optional header to specify the beta version(s) you want to use.

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

Returns:

See Also:



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

def remove(workspace_id, params)
  parsed, options =
    Anthropic::Beta::Organization::ServiceAccounts::WorkspaceRemoveParams.dump_request(params)
   =
    parsed.delete(:service_account_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :delete,
    path: [
      "v1/organizations/service_accounts/%1$s/workspaces/%2$s?beta=true",
      ,
      workspace_id
    ],
    headers: parsed.transform_keys(betas: "anthropic-beta"),
    model: Anthropic::Models::Beta::Organization::ServiceAccounts::WorkspaceRemoveResponse,
    options: options
  )
end