Class: Anthropic::Resources::Organization::ServiceAccounts

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

Defined Under Namespace

Classes: Workspaces

Instance Attribute Summary collapse

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:



206
207
208
209
# File 'lib/anthropic/resources/organization/service_accounts.rb', line 206

def initialize(client:)
  @client = client
  @workspaces = Anthropic::Resources::Organization::ServiceAccounts::Workspaces.new(client: client)
end

Instance Attribute Details

#workspaces ⇒ Anthropic::Resources::Organization::ServiceAccounts::Workspaces (readonly)



8
9
10
# File 'lib/anthropic/resources/organization/service_accounts.rb', line 8

def workspaces
  @workspaces
end

Instance Method Details

#archive(service_account_id, request_options: {}) ⇒ Anthropic::Models::Organization::ServiceAccount

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.

Archive a service account.

Idempotent; re-archiving returns the service account with its original archived_at. Rejected with 400 if any live (non-archived) federation rule still targets this service account, same as issuer archival; archive those rules first or change their target to another service account.

Parameters:

  • service_account_id (String) —

    ID of the service account to archive.

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

Returns:

Raises:

See Also:



191
192
193
194
195
196
197
198
199
200
201
# File 'lib/anthropic/resources/organization/service_accounts.rb', line 191

def archive(, params = {})
  @client.request(
    span_name: Anthropic::Internal::Tracing::SpanName::ORGANIZATION_SERVICE_ACCOUNTS_ARCHIVE,
    span_attributes: {"anthropic.organization.service_account.id" => },
    span_route: "/v1/organizations/service_accounts/{service_account_id}/archive",
    method: :post,
    path: ["v1/organizations/service_accounts/%1$s/archive", ],
    model: Anthropic::Organization::ServiceAccount,
    options: params[:request_options]
  )
end

#create(name:, description: nil, organization_role: nil, request_options: {}) ⇒ Anthropic::Models::Organization::ServiceAccount

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.

Create a service account.

A service account is a named workload identity that federation rules target. organization_role is developer (default) or admin; a rule may only be created or retargeted to grant org:admin scope when the target's organization_role is admin. Creating an admin-role service account requires an interactive credential (a user OAuth token or a Console session) — a workload may only create developer-role service accounts.

Some parameter documentations has been truncated, see Models::Organization::ServiceAccountCreateParams for more details.

Parameters:

  • name (String) —

    Slug identifier (lowercase, digits, hyphens). Unique within the organization; a

  • description (String, nil) —

    Optional free-text description.

  • organization_role (Symbol, Anthropic::Models::Organization::ServiceAccountCreateParams::OrganizationRole) —

    Org-level role. Defaults to developer.

  • request_options (Anthropic::RequestOptions, Hash{Symbol=>Object}, nil)
  • name: (String)
  • description: (String, nil)
  • organization_role: (Anthropic::Models::Organization::ServiceAccountCreateParams::organization_role)
  • request_options: (Anthropic::request_opts)

Returns:

Raises:

See Also:



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

def create(params)
  parsed, options = Anthropic::Organization::ServiceAccountCreateParams.dump_request(params)
  @client.request(
    span_name: Anthropic::Internal::Tracing::SpanName::ORGANIZATION_SERVICE_ACCOUNTS_CREATE,
    span_created_id: "anthropic.organization.service_account.id",
    span_route: "/v1/organizations/service_accounts",
    method: :post,
    path: "v1/organizations/service_accounts",
    body: parsed,
    model: Anthropic::Organization::ServiceAccount,
    options: options
  )
end

#list(include_archived: nil, limit: nil, page: nil, request_options: {}) ⇒ Anthropic::Internal::PageCursor<Anthropic::Models::Organization::ServiceAccount>

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 service accounts in the caller's organization.

Results are ordered by creation time, newest first. Use limit and the next_page cursor to paginate; set include_archived=true to include archived service accounts.

Parameters:

  • include_archived (Boolean) —

    Include archived resources. Defaults to false.

  • limit (Integer) —

    Number of results per page.

  • page (String, nil) —

    Opaque cursor from a previous response's next_page.

  • request_options (Anthropic::RequestOptions, Hash{Symbol=>Object}, nil)
  • include_archived: (Boolean)
  • limit: (Integer)
  • page: (String, nil)
  • request_options: (Anthropic::request_opts)

Returns:

See Also:



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

def list(params = {})
  parsed, options = Anthropic::Organization::ServiceAccountListParams.dump_request(params)
  query = Anthropic::Internal::Util.encode_query_params(parsed)
  @client.request(
    span_name: Anthropic::Internal::Tracing::SpanName::ORGANIZATION_SERVICE_ACCOUNTS_LIST,
    span_route: "/v1/organizations/service_accounts",
    span_query: %w[include_archived limit page],
    method: :get,
    path: "v1/organizations/service_accounts",
    query: query,
    page: Anthropic::Internal::PageCursor,
    model: Anthropic::Organization::ServiceAccount,
    options: options
  )
end

#retrieve(service_account_id, request_options: {}) ⇒ Anthropic::Models::Organization::ServiceAccount

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 by its ID (svac_...).

Parameters:

  • service_account_id (String) —

    ID of the service account.

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

Returns:

See Also:



72
73
74
75
76
77
78
79
80
81
82
# File 'lib/anthropic/resources/organization/service_accounts.rb', line 72

def retrieve(, params = {})
  @client.request(
    span_name: Anthropic::Internal::Tracing::SpanName::ORGANIZATION_SERVICE_ACCOUNTS_RETRIEVE,
    span_attributes: {"anthropic.organization.service_account.id" => },
    span_route: "/v1/organizations/service_accounts/{service_account_id}",
    method: :get,
    path: ["v1/organizations/service_accounts/%1$s", ],
    model: Anthropic::Organization::ServiceAccount,
    options: params[:request_options]
  )
end

#update(service_account_id, description: nil, organization_role: nil, request_options: {}) ⇒ Anthropic::Models::Organization::ServiceAccount

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.

Update a service account.

Only description and organization_role are mutable; name cannot be changed. Archived service accounts cannot be updated; this returns 400. Setting organization_role to admin (even when unchanged) requires an interactive credential (a user OAuth token or a Console session).

Some parameter documentations has been truncated, see Models::Organization::ServiceAccountUpdateParams for more details.

Parameters:

  • service_account_id (String) —

    ID of the service account to update.

  • description (String, nil) —

    Replaces the description. Omit to leave unchanged; send null to clear (the fie

  • organization_role (Symbol, Anthropic::Models::Organization::ServiceAccountUpdateParams::OrganizationRole, nil) —

    Replaces the org-level role. Omit or send null to leave unchanged.

  • request_options (Anthropic::RequestOptions, Hash{Symbol=>Object}, nil)
  • description: (String, nil)
  • organization_role: (Anthropic::Models::Organization::ServiceAccountUpdateParams::organization_role, nil)
  • request_options: (Anthropic::request_opts)

Returns:

Raises:

See Also:



114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/anthropic/resources/organization/service_accounts.rb', line 114

def update(, params = {})
  parsed, options = Anthropic::Organization::ServiceAccountUpdateParams.dump_request(params)
  @client.request(
    span_name: Anthropic::Internal::Tracing::SpanName::ORGANIZATION_SERVICE_ACCOUNTS_UPDATE,
    span_attributes: {"anthropic.organization.service_account.id" => },
    span_route: "/v1/organizations/service_accounts/{service_account_id}",
    method: :post,
    path: ["v1/organizations/service_accounts/%1$s", ],
    body: parsed,
    model: Anthropic::Organization::ServiceAccount,
    options: options
  )
end