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:



278
279
280
# File 'lib/anthropic/resources/beta/organization/workspaces/service_accounts.rb', line 278

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:

  • workspace_id (String) —

    Path param: ID of the workspace.

  • service_account_id (String) —

    Body param: Tagged service account ID to add.

  • workspace_role (Symbol, Anthropic::Models::Beta::Organization::BetaNoBillingWorkspaceRole) —

    Body param: Role to assign to the service account in this workspace.

  • betas (Array<Symbol, String, 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)
  • service_account_id: (String)
  • workspace_role: (Anthropic::Models::Beta::Organization::beta_no_billing_workspace_role)
  • betas: (::Array[Anthropic::Models::anthropic_beta])
  • request_options: (Anthropic::request_opts)

Returns:

Raises:

See Also:



202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
# File 'lib/anthropic/resources/beta/organization/workspaces/service_accounts.rb', line 202

def add(workspace_id, params)
  parsed, options = Anthropic::Beta::Organization::Workspaces::ServiceAccountAddParams.dump_request(params)
  header_params = {betas: "anthropic-beta"}
  @client.request(
    qualifiers: {beta: "true"},
    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],
    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<Symbol, String, 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)
  • limit: (Integer)
  • page: (String, nil)
  • betas: (::Array[Anthropic::Models::anthropic_beta])
  • request_options: (Anthropic::request_opts)

Returns:

See Also:



149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# File 'lib/anthropic/resources/beta/organization/workspaces/service_accounts.rb', line 149

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(
    qualifiers: {beta: "true"},
    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,
    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<Symbol, String, 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)
  • workspace_id: (String)
  • betas: (::Array[Anthropic::Models::anthropic_beta])
  • request_options: (Anthropic::request_opts)

Returns:

Raises:

See Also:



248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
# File 'lib/anthropic/resources/beta/organization/workspaces/service_accounts.rb', line 248

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(
    qualifiers: {beta: "true"},
    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" => 
    },
    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,
      
    ],
    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<Symbol, String, 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)
  • workspace_id: (String)
  • betas: (::Array[Anthropic::Models::anthropic_beta])
  • request_options: (Anthropic::request_opts)

Returns:

See Also:



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# 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(
    qualifiers: {beta: "true"},
    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" => 
    },
    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,
      
    ],
    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:

  • service_account_id (String) —

    Path param: ID of the service account.

  • workspace_id (String) —

    Path param: ID of the workspace.

  • workspace_role (Symbol, Anthropic::Models::Beta::Organization::BetaNoBillingWorkspaceRole) —

    Body param: New role for the service account in this workspace.

  • betas (Array<Symbol, String, 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)
  • workspace_id: (String)
  • workspace_role: (Anthropic::Models::Beta::Organization::beta_no_billing_workspace_role)
  • betas: (::Array[Anthropic::Models::anthropic_beta])
  • request_options: (Anthropic::request_opts)

Returns:

Raises:

See Also:



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/anthropic/resources/beta/organization/workspaces/service_accounts.rb', line 92

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(
    qualifiers: {beta: "true"},
    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" => 
    },
    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,
      
    ],
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Anthropic::Beta::Organization::BetaServiceAccountWorkspaceMember,
    options: options
  )
end