Class: Anthropic::Resources::Beta::Organization::ServiceAccounts::Workspaces
- Inherits:
-
Object
- Object
- Anthropic::Resources::Beta::Organization::ServiceAccounts::Workspaces
- Defined in:
- lib/anthropic/resources/beta/organization/service_accounts/workspaces.rb,
sig/anthropic/resources/beta/organization/service_accounts/workspaces.rbs
Instance Method Summary collapse
-
#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:adminscope, fromant auth login --scope org:adminor a workload identity federation rule; Admin API keys are not accepted. -
#initialize(client:) ⇒ Workspaces
constructor
private
A new instance of Workspaces.
-
#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:adminscope, fromant auth login --scope org:adminor a workload identity federation rule; Admin API keys are not accepted. -
#remove(workspace_id, service_account_id:, betas: nil, request_options: {}) ⇒ Anthropic::Models::Beta::Organization::ServiceAccounts::WorkspaceRemoveResponse
Requires an OAuth access token with the
org:adminscope, fromant auth login --scope org:adminor a workload identity federation rule; Admin API keys are not accepted.
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.
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.
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(service_account_id, params) parsed, = 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", service_account_id], headers: parsed.slice(*header_params.keys).transform_keys(header_params), body: parsed.except(*header_params.keys), model: Anthropic::Beta::Organization::BetaServiceAccountWorkspaceMember, 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.
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(service_account_id, params = {}) query_params = [:limit, :page] parsed, = 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", service_account_id], query: query, headers: parsed.except(*query_params).transform_keys(betas: "anthropic-beta"), page: Anthropic::Internal::PageCursor, model: Anthropic::Beta::Organization::BetaServiceAccountWorkspaceMember, 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.
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, = Anthropic::Beta::Organization::ServiceAccounts::WorkspaceRemoveParams.dump_request(params) service_account_id = 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", service_account_id, workspace_id ], headers: parsed.transform_keys(betas: "anthropic-beta"), model: Anthropic::Models::Beta::Organization::ServiceAccounts::WorkspaceRemoveResponse, options: ) end |