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

Inherits:
Object
  • Object
show all
Defined in:
lib/anthropic/resources/beta/organization/service_accounts.rb,
lib/anthropic/resources/beta/organization/service_accounts/workspaces.rb,
sig/anthropic/resources/beta/organization/service_accounts.rbs,
sig/anthropic/resources/beta/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:



208
209
210
211
# File 'lib/anthropic/resources/beta/organization/service_accounts.rb', line 208

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

Instance Attribute Details

#workspacesAnthropic::Resources::Beta::Organization::ServiceAccounts::Workspaces (readonly)



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

def workspaces
  @workspaces
end

Instance Method Details

#archive(service_account_id, betas: nil, request_options: {}) ⇒ Anthropic::Models::Beta::Organization::BetaServiceAccount

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:

Returns:

See Also:



194
195
196
197
198
199
200
201
202
203
# File 'lib/anthropic/resources/beta/organization/service_accounts.rb', line 194

def archive(, params = {})
  parsed, options = Anthropic::Beta::Organization::ServiceAccountArchiveParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["v1/organizations/service_accounts/%1$s/archive?beta=true", ],
    headers: parsed.transform_keys(betas: "anthropic-beta"),
    model: Anthropic::Beta::Organization::BetaServiceAccount,
    options: options
  )
end

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

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::Beta::Organization::ServiceAccountCreateParams for more details.

Parameters:

Returns:

See Also:



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

def create(params)
  parsed, options = Anthropic::Beta::Organization::ServiceAccountCreateParams.dump_request(params)
  header_params = {betas: "anthropic-beta"}
  @client.request(
    method: :post,
    path: "v1/organizations/service_accounts?beta=true",
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Anthropic::Beta::Organization::BetaServiceAccount,
    options: options
  )
end

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

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)

    Query param: Include archived resources. Defaults to false.

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



156
157
158
159
160
161
162
163
164
165
166
167
168
169
# File 'lib/anthropic/resources/beta/organization/service_accounts.rb', line 156

def list(params = {})
  query_params = [:include_archived, :limit, :page]
  parsed, options = Anthropic::Beta::Organization::ServiceAccountListParams.dump_request(params)
  query = Anthropic::Internal::Util.encode_query_params(parsed.slice(*query_params))
  @client.request(
    method: :get,
    path: "v1/organizations/service_accounts?beta=true",
    query: query,
    headers: parsed.except(*query_params).transform_keys(betas: "anthropic-beta"),
    page: Anthropic::Internal::PageCursor,
    model: Anthropic::Beta::Organization::BetaServiceAccount,
    options: options
  )
end

#retrieve(service_account_id, betas: nil, request_options: {}) ⇒ Anthropic::Models::Beta::Organization::BetaServiceAccount

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:

Returns:

See Also:



75
76
77
78
79
80
81
82
83
84
# File 'lib/anthropic/resources/beta/organization/service_accounts.rb', line 75

def retrieve(, params = {})
  parsed, options = Anthropic::Beta::Organization::ServiceAccountRetrieveParams.dump_request(params)
  @client.request(
    method: :get,
    path: ["v1/organizations/service_accounts/%1$s?beta=true", ],
    headers: parsed.transform_keys(betas: "anthropic-beta"),
    model: Anthropic::Beta::Organization::BetaServiceAccount,
    options: options
  )
end

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

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::Beta::Organization::ServiceAccountUpdateParams for more details.

Parameters:

Returns:

See Also:



117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/anthropic/resources/beta/organization/service_accounts.rb', line 117

def update(, params = {})
  parsed, options = Anthropic::Beta::Organization::ServiceAccountUpdateParams.dump_request(params)
  header_params = {betas: "anthropic-beta"}
  @client.request(
    method: :post,
    path: ["v1/organizations/service_accounts/%1$s?beta=true", ],
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Anthropic::Beta::Organization::BetaServiceAccount,
    options: options
  )
end