Service-Account-Mitglied eines Workspace erstellen
Erfordert ein OAuth-Zugriffstoken mit dem Scope org:admin, über ant auth login --scope org:admin oder eine Workload-Identity-Federation-Regel; Admin-API-Keys werden nicht akzeptiert. Siehe WIF mit der Admin API verwalten.
Fügt einen Service-Account mit der angegebenen workspace_role zu einem Workspace hinzu.
Die Rolle bestimmt, was der Service-Account im Workspace tun kann und
welche Workspace-bezogenen Berechtigungen ihm bei der Authentifizierung
über Federation gewährt werden können. Jeder Service-Account ist bereits implizites
workspace_user-Mitglied des Standard-Workspace; durch explizites Hinzufügen
wird eine gewählte Rolle zugewiesen. Wenn der Service-Account bereits explizites
Mitglied des Workspace ist, wird seine workspace_role durch den
hier angegebenen Wert ersetzt. Archivierte Workspaces geben 400 zurück. Archivierte Service-Accounts
können nicht hinzugefügt werden und werden abgelehnt.
Parameters
Returns
package com.anthropic.example;
import com.anthropic.client.AnthropicClient;
import com.anthropic.client.okhttp.AnthropicOkHttpClient;
import com.anthropic.models.organization.serviceaccounts.ServiceAccountWorkspaceMember;
import com.anthropic.models.organization.workspaces.NoBillingWorkspaceRole;
import com.anthropic.models.organization.workspaces.serviceaccounts.ServiceAccountAddParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
AnthropicClient client = AnthropicOkHttpClient.fromEnv();
ServiceAccountAddParams params = ServiceAccountAddParams.builder()
.workspaceId("workspace_id")
.serviceAccountId("service_account_id")
.workspaceRole(NoBillingWorkspaceRole.WORKSPACE_ADMIN)
.build();
ServiceAccountWorkspaceMember serviceAccountWorkspaceMember = client.organization().workspaces().serviceAccounts().add(params);
}
}{
"created_by_actor_id": "created_by_actor_id",
"implicit": true,
"service_account_id": "service_account_id",
"type": "service_account_workspace_member",
"workspace_id": "workspace_id",
"workspace_role": "workspace_admin"
}Returns Examples
{
"created_by_actor_id": "created_by_actor_id",
"implicit": true,
"service_account_id": "service_account_id",
"type": "service_account_workspace_member",
"workspace_id": "workspace_id",
"workspace_role": "workspace_admin"
}