Class BetaApiKey.Scope
-
- All Implemented Interfaces:
public final class BetaApiKey.ScopeWhere the API key belongs: its Workspace (
{"type": "workspace", "workspace_id": "wrkspc_..."}, with the Workspace's real ID even when it is the organization's default Workspace), or the organization ({"type": "organization"}) for a principal-bound API key that has no Workspace.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceBetaApiKey.Scope.VisitorAn interface that defines how to map each variant of Scope to a value of type T.
public final classBetaApiKey.Scope.Type
-
Method Summary
-
-
Method Detail
-
organization
final Optional<BetaApiKeyOrganizationScope> organization()
-
workspace
final Optional<BetaApiKeyWorkspaceScope> workspace()
-
type
final BetaApiKey.Scope.Type type()
-
isOrganization
final Boolean isOrganization()
-
isWorkspace
final Boolean isWorkspace()
-
asOrganization
final BetaApiKeyOrganizationScope asOrganization()
-
asWorkspace
final BetaApiKeyWorkspaceScope asWorkspace()
-
accept
final <T extends Any> T accept(BetaApiKey.Scope.Visitor<T> visitor)
Maps this instance's current variant to a value of type T using the given visitor.
Note that this method is not forwards compatible with new variants from the API, unless visitor overrides Visitor.unknown. To handle variants not known to this version of the SDK gracefully, consider overriding Visitor.unknown:
import com.anthropic.core.JsonValue; import java.util.Optional; Optional<String> result = scope.accept(new Scope.Visitor<Optional<String>>() { @Override public Optional<String> visitOrganization(BetaApiKeyOrganizationScope organization) { return Optional.of(organization.toString()); } // ... @Override public Optional<String> unknown(JsonValue json) { // Or inspect the `json`. return Optional.empty(); } });
-
validate
final BetaApiKey.Scope validate()
Validates that the types of all values in this object match their expected types recursively.
This method is not forwards compatible with new types from the API for existing fields.
-
ofOrganization
final static BetaApiKey.Scope ofOrganization(BetaApiKeyOrganizationScope organization)
-
ofWorkspace
final static BetaApiKey.Scope ofWorkspace(BetaApiKeyWorkspaceScope workspace)
-
ofWorkspace
final static BetaApiKey.Scope ofWorkspace(String workspaceId)
Returns an immutable instance of Scope whose ofWorkspace variant is built from the given required workspaceId.
-
-
-
-