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

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

Instance Method Summary collapse

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.

Parameters:



241
242
243
# File 'lib/anthropic/resources/beta/organization/workspaces/service_accounts.rb', line 241

def initialize(client:)
  @client = client
end

Instance Method Details

#add(workspace_id, service_account_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.

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.

Parameters:

Returns:

See Also:



179
180
181
182
183
184
185
186
187
188
189
190
# File 'lib/anthropic/resources/beta/organization/workspaces/service_accounts.rb', line 179

def add(workspace_id, params)
  parsed, options = Anthropic::Beta::Organization::Workspaces::ServiceAccountAddParams.dump_request(params)
  header_params = {betas: "anthropic-beta"}
  @client.request(
    method: :post,
    path: ["v1/organizations/workspaces/%1$s/service_accounts?beta=true", workspace_id],
    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(workspace_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 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.

Parameters:

  • workspace_id (String)

    Path param: ID of the workspace.

  • 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:



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

def list(workspace_id, params = {})
  query_params = [:limit, :page]
  parsed, options =
    Anthropic::Beta::Organization::Workspaces::ServiceAccountListParams.dump_request(params)
  query = Anthropic::Internal::Util.encode_query_params(parsed.slice(*query_params))
  @client.request(
    method: :get,
    path: ["v1/organizations/workspaces/%1$s/service_accounts?beta=true", workspace_id],
    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(service_account_id, workspace_id:, betas: nil, request_options: {}) ⇒ Anthropic::Models::Beta::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.

Parameters:

  • service_account_id (String)

    Path param: ID of the service account.

  • workspace_id (String)

    Path param: ID of the workspace.

  • 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:



218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
# File 'lib/anthropic/resources/beta/organization/workspaces/service_accounts.rb', line 218

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

#retrieve(service_account_id, workspace_id:, 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.

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.

Parameters:

  • service_account_id (String)

    Path param: ID of the service account.

  • workspace_id (String)

    Path param: ID of the workspace.

  • 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:



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/anthropic/resources/beta/organization/workspaces/service_accounts.rb', line 35

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

#update(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.

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.

Parameters:

Returns:

See Also:



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/anthropic/resources/beta/organization/workspaces/service_accounts.rb', line 83

def update(, params)
  parsed, options =
    Anthropic::Beta::Organization::Workspaces::ServiceAccountUpdateParams.dump_request(params)
  workspace_id =
    parsed.delete(:workspace_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  header_params = {betas: "anthropic-beta"}
  @client.request(
    method: :post,
    path: [
      "v1/organizations/workspaces/%1$s/service_accounts/%2$s?beta=true",
      workspace_id,
      
    ],
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Anthropic::Beta::Organization::BetaServiceAccountWorkspaceMember,
    options: options
  )
end