Claude Platform Docs

Adicionar workspace à regra de federação

client.Organization.Federation.Rules.Workspaces.Add(ctx, federationRuleID, body) (*FederationRuleWorkspace, error)
POST/v1/organizations/federation_rules/{federation_rule_id}/workspaces

Requer um token de acesso OAuth com o escopo org:admin, obtido via ant auth login --scope org:admin ou uma regra de federação de identidade de workload; chaves de Admin API não são aceitas. Consulte Gerenciar WIF com a Admin API.

Habilite uma regra de federação para um workspace.

Idempotente; habilitar novamente retorna a habilitação existente. A regra e o workspace devem pertencer à sua organização. A associação da conta de serviço de destino da regra a este workspace não é verificada na habilitação: a troca de tokens para este workspace é rejeitada, a menos que o destino seja membro (ele é implicitamente membro do workspace padrão). Regras arquivadas são rejeitadas com 400. Chamadores OAuth só podem gerenciar regras cujo oauth_scope seja workspace:developer ou workspace:inference; outros escopos exigem uma sessão do Console.

Parameters
federationRuleID string⁠Path parameter

ID of the federation rule.

body OrganizationFederationRuleWorkspaceAddParams
WorkspaceID string

Tagged ID of the workspace to enable this rule for.

Returns
type FederationRuleWorkspace struct { Type: "federation_rule_workspace"; CreatedAt; CreatedByActorID; /* 3 more */ }
Type FederationRuleWorkspace
defaultfederation_rule_workspace
CreatedAt Time

When this workspace was enabled for the rule.

formatdate-time
CreatedByActorID string

Tagged ID (user_... or svac_...) of the actor that enabled this workspace for the rule, if known.

FederationRuleID string

Tagged ID of the federation rule.

WorkspaceID string

Tagged ID of the workspace this rule is enabled for.

WorkspaceName string

Workspace display name. Populated when listing; null in the enable response.

Adicionar workspace à regra de federação
package main

import (
	"context"
	"fmt"

	"github.com/anthropics/anthropic-sdk-go"
	"github.com/anthropics/anthropic-sdk-go/option"
)

func main() {
	client := anthropic.NewClient(
		option.WithAPIKey("my-anthropic-api-key"),
	)
	federationRuleWorkspace, err := client.Organization.Federation.Rules.Workspaces.Add(
		context.TODO(),
		"federation_rule_id",
		anthropic.OrganizationFederationRuleWorkspaceAddParams{
			WorkspaceID: "workspace_id",
		},
	)
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", federationRuleWorkspace.CreatedByActorID)
}
Returns Examples
Response 200
{
  "created_at": "2024-10-30T23:58:27.427722Z",
  "created_by_actor_id": "created_by_actor_id",
  "federation_rule_id": "federation_rule_id",
  "type": "federation_rule_workspace",
  "workspace_id": "workspace_id",
  "workspace_name": "workspace_name"
}