Class: Anthropic::Resources::Organization::Federation::Rules::Workspaces

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Workspaces

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 Workspaces.

Parameters:



146
147
148
# File 'lib/anthropic/resources/organization/federation/rules/workspaces.rb', line 146

def initialize(client:)
  @client = client
end

Instance Method Details

#add(federation_rule_id, workspace_id:, request_options: {}) ⇒ Anthropic::Models::Organization::Federation::FederationRuleWorkspace

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.

Enable a federation rule for a workspace.

Idempotent; re-enabling returns the existing enablement. The rule and workspace must both belong to your organization. Membership of the rule's target service account in this workspace is not checked at enablement: token exchange into this workspace is rejected unless the target is a member (it is implicitly a member of the default workspace). Archived rules are rejected with 400. OAuth callers may only manage rules whose oauth_scope is workspace:developer or workspace:inference; other scopes require a Console session.

Parameters:

  • federation_rule_id (String) —

    ID of the federation rule.

  • workspace_id (String) —

    Tagged ID of the workspace to enable this rule for.

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

Returns:

Raises:

See Also:



80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/anthropic/resources/organization/federation/rules/workspaces.rb', line 80

def add(federation_rule_id, params)
  parsed, options = Anthropic::Organization::Federation::Rules::WorkspaceAddParams.dump_request(params)
  @client.request(
    span_name: Anthropic::Internal::Tracing::SpanName::ORGANIZATION_FEDERATION_RULES_WORKSPACES_ADD,
    span_attributes: {"anthropic.organization.federation_rule.id" => federation_rule_id},
    span_created_id: {"anthropic.organization.federation_rule.workspace.id" => :workspace_id},
    span_route: "/v1/organizations/federation_rules/{federation_rule_id}/workspaces",
    method: :post,
    path: ["v1/organizations/federation_rules/%1$s/workspaces", federation_rule_id],
    body: parsed,
    model: Anthropic::Organization::Federation::FederationRuleWorkspace,
    options: options
  )
end

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

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 workspaces where this federation rule is enabled.

Returns all workspace enablements in a single response; the limit and page parameters are accepted but have no effect, and next_page is always null. Returns explicit per-workspace enablements only; for rules with applies_to_all_workspaces or a legacy single workspace_id, check those fields on the rule itself.

Parameters:

  • federation_rule_id (String) —

    ID of the federation rule.

  • 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)
  • limit: (Integer)
  • page: (String, nil)
  • request_options: (Anthropic::request_opts)

Returns:

See Also:



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

def list(federation_rule_id, params = {})
  parsed, options = Anthropic::Organization::Federation::Rules::WorkspaceListParams.dump_request(params)
  query = Anthropic::Internal::Util.encode_query_params(parsed)
  @client.request(
    span_name: Anthropic::Internal::Tracing::SpanName::ORGANIZATION_FEDERATION_RULES_WORKSPACES_LIST,
    span_attributes: {"anthropic.organization.federation_rule.id" => federation_rule_id},
    span_route: "/v1/organizations/federation_rules/{federation_rule_id}/workspaces",
    span_query: %w[limit page],
    method: :get,
    path: ["v1/organizations/federation_rules/%1$s/workspaces", federation_rule_id],
    query: query,
    page: Anthropic::Internal::PageCursor,
    model: Anthropic::Organization::Federation::FederationRuleWorkspace,
    options: options
  )
end

#remove(workspace_id, federation_rule_id:, request_options: {}) ⇒ Anthropic::Models::Organization::Federation::Rules::WorkspaceRemoveResponse

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.

Disable a federation rule for a workspace.

Idempotent; succeeds even if the enablement was already removed. OAuth callers may only manage rules whose oauth_scope is workspace:developer or workspace:inference; other scopes require a Console session.

Parameters:

  • workspace_id (String) —

    ID of the workspace to disable for.

  • federation_rule_id (String) —

    ID of the federation rule.

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

Returns:

Raises:

See Also:



119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/anthropic/resources/organization/federation/rules/workspaces.rb', line 119

def remove(workspace_id, params)
  parsed, options = Anthropic::Organization::Federation::Rules::WorkspaceRemoveParams.dump_request(params)
  federation_rule_id =
    parsed.delete(:federation_rule_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    span_name: Anthropic::Internal::Tracing::SpanName::ORGANIZATION_FEDERATION_RULES_WORKSPACES_REMOVE,
    span_attributes: {
      "anthropic.organization.federation_rule.id" => federation_rule_id,
      "anthropic.organization.federation_rule.workspace.id" => workspace_id
    },
    span_route: "/v1/organizations/federation_rules/{federation_rule_id}/workspaces/{workspace_id}",
    method: :delete,
    path: [
      "v1/organizations/federation_rules/%1$s/workspaces/%2$s",
      federation_rule_id,
      workspace_id
    ],
    model: Anthropic::Models::Organization::Federation::Rules::WorkspaceRemoveResponse,
    options: options
  )
end