Class ApiKey.Scope
-
- All Implemented Interfaces:
public final class ApiKey.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 interfaceApiKey.Scope.VisitorAn interface that defines how to map each variant of Scope to a value of type T.
public final classApiKey.Scope.Type
-
Method Summary
Modifier and Type Method Description final Optional<ApiKeyOrganizationScope>organization()final Optional<ApiKeyWorkspaceScope>workspace()final Optional<JsonValue>_json()final ApiKey.Scope.Typetype()final BooleanisOrganization()final BooleanisWorkspace()final ApiKeyOrganizationScopeasOrganization()final ApiKeyWorkspaceScopeasWorkspace()final <T extends Any> Taccept(ApiKey.Scope.Visitor<T> visitor)Maps this instance's current variant to a value of type T using the given visitor. final ApiKey.Scopevalidate()Validates that the types of all values in this object match their expected types recursively. final BooleanisValid()Booleanequals(Object other)IntegerhashCode()StringtoString()final static ApiKey.ScopeofOrganization(ApiKeyOrganizationScope organization)final static ApiKey.ScopeofWorkspace(ApiKeyWorkspaceScope workspace)final static ApiKey.ScopeofWorkspace(String workspaceId)Returns an immutable instance of Scope whose ofWorkspace variant is built from the given required workspaceId. -
-
Method Detail
-
organization
final Optional<ApiKeyOrganizationScope> organization()
-
workspace
final Optional<ApiKeyWorkspaceScope> workspace()
-
type
final ApiKey.Scope.Type type()
-
isOrganization
final Boolean isOrganization()
-
isWorkspace
final Boolean isWorkspace()
-
asOrganization
final ApiKeyOrganizationScope asOrganization()
-
asWorkspace
final ApiKeyWorkspaceScope asWorkspace()
-
accept
final <T extends Any> T accept(ApiKey.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(ApiKeyOrganizationScope organization) { return Optional.of(organization.toString()); } // ... @Override public Optional<String> unknown(JsonValue json) { // Or inspect the `json`. return Optional.empty(); } });
-
validate
final ApiKey.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 ApiKey.Scope ofOrganization(ApiKeyOrganizationScope organization)
-
ofWorkspace
final static ApiKey.Scope ofWorkspace(ApiKeyWorkspaceScope workspace)
-
ofWorkspace
final static ApiKey.Scope ofWorkspace(String workspaceId)
Returns an immutable instance of Scope whose ofWorkspace variant is built from the given required workspaceId.
-
-
-
-