Class: Anthropic::Resources::Organization::Workspaces::ServiceAccounts
- Inherits:
-
Object
- Object
- Anthropic::Resources::Organization::Workspaces::ServiceAccounts
- Defined in:
- lib/anthropic/resources/organization/workspaces/service_accounts.rb,
sig/anthropic/resources/organization/workspaces/service_accounts.rbs
Instance Method Summary collapse
-
#add(workspace_id, service_account_id:, workspace_role:, request_options: {}) ⇒ Anthropic::Models::Organization::ServiceAccountWorkspaceMember
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:) ⇒ ServiceAccounts
constructor
private
A new instance of ServiceAccounts.
-
#list(workspace_id, limit: nil, page: nil, request_options: {}) ⇒ Anthropic::Internal::PageCursor<Anthropic::Models::Organization::ServiceAccountWorkspaceMember>
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(service_account_id, workspace_id:, request_options: {}) ⇒ Anthropic::Models::Organization::Workspaces::ServiceAccountRemoveResponse
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. -
#retrieve(service_account_id, workspace_id:, request_options: {}) ⇒ Anthropic::Models::Organization::ServiceAccountWorkspaceMember
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. -
#update(service_account_id, workspace_id:, workspace_role:, request_options: {}) ⇒ Anthropic::Models::Organization::ServiceAccountWorkspaceMember
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:) ⇒ ServiceAccounts
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 ServiceAccounts.
250 251 252 |
# File 'lib/anthropic/resources/organization/workspaces/service_accounts.rb', line 250 def initialize(client:) @client = client end |
Instance Method Details
#add(workspace_id, service_account_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.
The role determines what the service account can do in the workspace and which
workspace-scoped permissions it can be granted when authenticating through
federation. Every service account is already an implicit workspace_user member
of the default workspace; adding it explicitly assigns a chosen role. 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.
182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
# File 'lib/anthropic/resources/organization/workspaces/service_accounts.rb', line 182 def add(workspace_id, params) parsed, = Anthropic::Organization::Workspaces::ServiceAccountAddParams.dump_request(params) @client.request( span_name: Anthropic::Internal::Tracing::SpanName::ORGANIZATION_WORKSPACES_SERVICE_ACCOUNTS_ADD, span_attributes: {"anthropic.organization.workspace.id" => workspace_id}, span_created_id: {"anthropic.organization.workspace.service_account.id" => :service_account_id}, span_route: "/v1/organizations/workspaces/{workspace_id}/service_accounts", method: :post, path: ["v1/organizations/workspaces/%1$s/service_accounts", workspace_id], body: parsed, model: Anthropic::Organization::ServiceAccountWorkspaceMember, options: ) end |
#list(workspace_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 service accounts that are members of a workspace.
Each entry includes the service account's workspace_role. Use limit and the
next_page cursor to paginate. Archived workspaces return 400; use
GET /service_accounts/{id}/workspaces to audit memberships of an archived
workspace. The implicit default-workspace membership is not included in this
list. Memberships of archived service accounts are omitted from the results.
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/anthropic/resources/organization/workspaces/service_accounts.rb', line 135 def list(workspace_id, params = {}) parsed, = Anthropic::Organization::Workspaces::ServiceAccountListParams.dump_request(params) query = Anthropic::Internal::Util.encode_query_params(parsed) @client.request( span_name: Anthropic::Internal::Tracing::SpanName::ORGANIZATION_WORKSPACES_SERVICE_ACCOUNTS_LIST, span_attributes: {"anthropic.organization.workspace.id" => workspace_id}, span_route: "/v1/organizations/workspaces/{workspace_id}/service_accounts", span_query: %w[limit page], method: :get, path: ["v1/organizations/workspaces/%1$s/service_accounts", workspace_id], query: query, page: Anthropic::Internal::PageCursor, model: Anthropic::Organization::ServiceAccountWorkspaceMember, options: ) end |
#remove(service_account_id, workspace_id:, request_options: {}) ⇒ Anthropic::Models::Organization::Workspaces::ServiceAccountRemoveResponse
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.
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.
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
# File 'lib/anthropic/resources/organization/workspaces/service_accounts.rb', line 223 def remove(service_account_id, params) parsed, = Anthropic::Organization::Workspaces::ServiceAccountRemoveParams.dump_request(params) workspace_id = parsed.delete(:workspace_id) do raise ArgumentError.new("missing required path argument #{_1}") end @client.request( span_name: Anthropic::Internal::Tracing::SpanName::ORGANIZATION_WORKSPACES_SERVICE_ACCOUNTS_REMOVE, span_attributes: { "anthropic.organization.workspace.id" => workspace_id, "anthropic.organization.workspace.service_account.id" => service_account_id }, span_route: "/v1/organizations/workspaces/{workspace_id}/service_accounts/{service_account_id}", method: :delete, path: [ "v1/organizations/workspaces/%1$s/service_accounts/%2$s", workspace_id, service_account_id ], model: Anthropic::Models::Organization::Workspaces::ServiceAccountRemoveResponse, options: ) end |
#retrieve(service_account_id, workspace_id:, 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.
Retrieve a service account's membership in a workspace.
Returns the membership record, including the service account's workspace_role
in this workspace. Archived workspaces return 400. For the default workspace,
returns the implicit (implicit: true) membership when no explicit membership
exists; an explicitly added membership is returned with its assigned role. An
archived service account returns 404.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/anthropic/resources/organization/workspaces/service_accounts.rb', line 32 def retrieve(service_account_id, params) parsed, = Anthropic::Organization::Workspaces::ServiceAccountRetrieveParams.dump_request(params) workspace_id = parsed.delete(:workspace_id) do raise ArgumentError.new("missing required path argument #{_1}") end @client.request( span_name: Anthropic::Internal::Tracing::SpanName::ORGANIZATION_WORKSPACES_SERVICE_ACCOUNTS_RETRIEVE, span_attributes: { "anthropic.organization.workspace.id" => workspace_id, "anthropic.organization.workspace.service_account.id" => service_account_id }, span_route: "/v1/organizations/workspaces/{workspace_id}/service_accounts/{service_account_id}", method: :get, path: [ "v1/organizations/workspaces/%1$s/service_accounts/%2$s", workspace_id, service_account_id ], model: Anthropic::Organization::ServiceAccountWorkspaceMember, options: ) end |
#update(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.
Change a service account's role in a workspace.
The new workspace_role replaces the current one. Only explicit memberships can
be updated; to set a role on the implicit default-workspace membership, add the
service account explicitly with
POST /workspaces/{workspace_id}/service_accounts. Archived workspaces
return 400. Archived service accounts cannot be updated and are rejected.
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/anthropic/resources/organization/workspaces/service_accounts.rb', line 84 def update(service_account_id, params) parsed, = Anthropic::Organization::Workspaces::ServiceAccountUpdateParams.dump_request(params) workspace_id = parsed.delete(:workspace_id) do raise ArgumentError.new("missing required path argument #{_1}") end @client.request( span_name: Anthropic::Internal::Tracing::SpanName::ORGANIZATION_WORKSPACES_SERVICE_ACCOUNTS_UPDATE, span_attributes: { "anthropic.organization.workspace.id" => workspace_id, "anthropic.organization.workspace.service_account.id" => service_account_id }, span_route: "/v1/organizations/workspaces/{workspace_id}/service_accounts/{service_account_id}", method: :post, path: [ "v1/organizations/workspaces/%1$s/service_accounts/%2$s", workspace_id, service_account_id ], body: parsed, model: Anthropic::Organization::ServiceAccountWorkspaceMember, options: ) end |