Access Policy
Direct grants + scoped role assignments for resource access policy.
Namespace: Goodmem.Client.Api · Class: AccessPolicyApi
Reach this surface as client.AccessPolicy on a GoodmemClient. Every network method is asynchronous — it returns a Task<T> (or an IAsyncEnumerable<T> for pagination and streaming) and accepts a CancellationToken; the Async suffix marks the standard .NET Task-based async pattern.
Methods
| Method | Summary |
|---|---|
CheckAsync | Check effective authorization. |
GrantsCreateAsync | Create an authorization grant. |
GrantsDeleteAsync | Revoke an authorization grant. |
GrantsGetAsync | Get an authorization grant. |
GrantsListAsync | List authorization grants. |
RoleAssignmentsCreateAsync | Assign a scoped role. |
RoleAssignmentsDeleteAsync | Revoke a scoped role assignment. |
RoleAssignmentsGetAsync | Get a scoped role assignment. |
RoleAssignmentsListAsync | List scoped role assignments. |
CheckAsync
Evaluates 1 to 50 concrete operation-and-target checks under the authenticated caller's live authority and any API-key ceiling. Results are positional and advisory: missing targets and denied operations both return allowed=false, and every later resource request performs fresh authorization. Top-level creates target INSTANCE; CREATE_MEMORY and LIST_MEMORY target their parent SPACE; reads, mutations, proxy operations, and access-policy administration target concrete resources. LIST_API_KEY and LIST_RETRIEVE_MEMORY_LOG_POLICY are rejected because their current candidate-based list rules have no instance-wide preflight.
Declaration
public Task<CheckAuthorizationsResponse> CheckAsync(CheckAuthorizationsRequest request, CancellationToken ct = default)
HTTP — POST /v1/access-policy:check
Parameters
| Type | Name | Description |
|---|---|---|
CheckAuthorizationsRequest | request | The request payload; the linked model lists every field and its JSON wire name. |
CancellationToken | ct | Cancellation / deadline signal for the call. (optional) |
Returns
Task<CheckAuthorizationsResponse> — an awaitable that resolves to CheckAuthorizationsResponse.
Exceptions
| Type | Condition |
|---|---|
ArgumentNullException | request is null. |
NetworkException | The request could not reach the server (DNS, connection, or TLS failure). |
ApiException | The server returned a non-success (non-2xx) status. A status-specific subtype is thrown where it applies — e.g. NotFoundException (404), PermissionDeniedException (403), ConflictException (409). |
Example
var decisions = await client.AccessPolicy.CheckAsync(
new CheckAuthorizationsRequest
{
Checks = new[]
{
new AuthorizationCheck
{
Operation = Operation.ReadInstance,
Target = new AccessPolicyTarget { Kind = ResourceKind.Instance },
},
},
}
);
Console.WriteLine(decisions.Results[0].Allowed);GrantsCreateAsync
Creates one direct grant after resolving its typed policy target and requiring MANAGE_ACCESS. Direct grants cannot confer credential-read or ownership-transfer authority. ALL_AUTHENTICATED grants require an assigned-resource selector. MANAGE_ACCESS and MANAGE_USER_ENROLLMENT require a concrete principal and ANY or EXACT; MANAGE_USER_ENROLLMENT with EXACT must target USER.
Declaration
public Task<AuthorizationGrant> GrantsCreateAsync(CreateAuthorizationGrantRequest request, CancellationToken ct = default)
HTTP — POST /v1/access-policy/grants
Parameters
| Type | Name | Description |
|---|---|---|
CreateAuthorizationGrantRequest | request | The request payload; the linked model lists every field and its JSON wire name. |
CancellationToken | ct | Cancellation / deadline signal for the call. (optional) |
Returns
Task<AuthorizationGrant> — an awaitable that resolves to AuthorizationGrant.
Exceptions
| Type | Condition |
|---|---|
ArgumentNullException | request is null. |
NetworkException | The request could not reach the server (DNS, connection, or TLS failure). |
ApiException | The server returned a non-success (non-2xx) status. A status-specific subtype is thrown where it applies — e.g. NotFoundException (404), PermissionDeniedException (403), ConflictException (409). |
Example
var grant = await client.AccessPolicy.GrantsCreateAsync(
new CreateAuthorizationGrantRequest
{
Audience = GrantAudience.OfPrincipalId("your-principal-id"),
Rule = new AccessPolicyRule
{
Operation = Operation.ReadSpace,
Selector = Selector.Exact,
AssignedResource = new AccessPolicyTarget
{
Kind = ResourceKind.Space,
ResourceId = spaceId,
},
},
}
);GrantsDeleteAsync
Soft-revokes one grant and returns its durable historical row. Repeating the request is idempotent while the caller retains MANAGE_ACCESS on the target.
Declaration
public Task<AuthorizationGrant> GrantsDeleteAsync(string id, CancellationToken ct = default)
HTTP — DELETE /v1/access-policy/grants/{id}
Parameters
| Type | Name | Description |
|---|---|---|
string | id | Grant UUID |
CancellationToken | ct | Cancellation / deadline signal for the call. (optional) |
Returns
Task<AuthorizationGrant> — an awaitable that resolves to AuthorizationGrant.
Exceptions
| Type | Condition |
|---|---|
ArgumentException | id is null or empty. |
NetworkException | The request could not reach the server (DNS, connection, or TLS failure). |
ApiException | The server returned a non-success (non-2xx) status. A status-specific subtype is thrown where it applies — e.g. NotFoundException (404), PermissionDeniedException (403), ConflictException (409). |
Example
var revokedGrant = await client.AccessPolicy.GrantsDeleteAsync("your-grant-id");GrantsGetAsync
Reads one live grant, or one revoked historical grant when includeRevoked is true, after requiring MANAGE_ACCESS on its policy target.
Declaration
public Task<AuthorizationGrant> GrantsGetAsync(string id, AccessPolicyGrantsGetOptions? options = null, CancellationToken ct = default)
HTTP — GET /v1/access-policy/grants/{id}
Parameters
| Type | Name | Description |
|---|---|---|
string | id | Grant UUID |
AccessPolicyGrantsGetOptions | options | Options bag carrying the lookup key(s) / convenience knobs; the linked type lists them all. (optional) |
CancellationToken | ct | Cancellation / deadline signal for the call. (optional) |
Returns
Task<AuthorizationGrant> — an awaitable that resolves to AuthorizationGrant.
Exceptions
| Type | Condition |
|---|---|
ArgumentException | id is null or empty. |
NetworkException | The request could not reach the server (DNS, connection, or TLS failure). |
ApiException | The server returned a non-success (non-2xx) status. A status-specific subtype is thrown where it applies — e.g. NotFoundException (404), PermissionDeniedException (403), ConflictException (409). |
Example
var fetchedGrant = await client.AccessPolicy.GrantsGetAsync("your-grant-id");GrantsListAsync
Lists grants attached to one resource. MANAGE_ACCESS is required on that resource; continuation tokens are bound to the caller and filters.
Declaration
public IAsyncEnumerable<AuthorizationGrant> GrantsListAsync(AccessPolicyGrantsListOptions? options = null, CancellationToken ct = default)
HTTP — GET /v1/access-policy/grants
Parameters
| Type | Name | Description |
|---|---|---|
AccessPolicyGrantsListOptions | options | Options bag carrying the lookup key(s) / convenience knobs; the linked type lists them all. (optional) |
CancellationToken | ct | Cancellation / deadline signal for the call. (optional) |
Returns
IAsyncEnumerable<AuthorizationGrant> — an async stream; await foreach yields each AuthorizationGrant across pages / events.
Exceptions
| Type | Condition |
|---|---|
NetworkException | The request could not reach the server (DNS, connection, or TLS failure). |
ApiException | The server returned a non-success (non-2xx) status. A status-specific subtype is thrown where it applies — e.g. NotFoundException (404), PermissionDeniedException (403), ConflictException (409). |
Example
await foreach (
var visibleGrant in client.AccessPolicy.GrantsListAsync(
new AccessPolicyGrantsListOptions
{
ResourceKind = "SPACE",
ResourceId = spaceId,
}
)
)
Console.WriteLine(visibleGrant.GrantId);RoleAssignmentsCreateAsync
Assigns one code-defined role to an active principal at INSTANCE or SPACE scope after requiring MANAGE_ACCESS. ROOT is maintained only by ownership workflows.
Declaration
public Task<RoleAssignment> RoleAssignmentsCreateAsync(AssignRoleRequest request, CancellationToken ct = default)
HTTP — POST /v1/access-policy/role-assignments
Parameters
| Type | Name | Description |
|---|---|---|
AssignRoleRequest | request | The request payload; the linked model lists every field and its JSON wire name. |
CancellationToken | ct | Cancellation / deadline signal for the call. (optional) |
Returns
Task<RoleAssignment> — an awaitable that resolves to RoleAssignment.
Exceptions
| Type | Condition |
|---|---|
ArgumentNullException | request is null. |
NetworkException | The request could not reach the server (DNS, connection, or TLS failure). |
ApiException | The server returned a non-success (non-2xx) status. A status-specific subtype is thrown where it applies — e.g. NotFoundException (404), PermissionDeniedException (403), ConflictException (409). |
Example
var assignment = await client.AccessPolicy.RoleAssignmentsCreateAsync(
new AssignRoleRequest
{
PrincipalId = "your-principal-id",
Role = "SPACE_VIEWER",
AssignedResource = new RoleAssignmentTarget
{
Kind = "SPACE",
ResourceId = spaceId,
},
}
);RoleAssignmentsDeleteAsync
Soft-revokes one non-ROOT assignment and returns its durable historical row. Repeating the request is idempotent while the caller retains MANAGE_ACCESS.
Declaration
public Task<RoleAssignment> RoleAssignmentsDeleteAsync(string id, CancellationToken ct = default)
HTTP — DELETE /v1/access-policy/role-assignments/{id}
Parameters
| Type | Name | Description |
|---|---|---|
string | id | Role-assignment UUID |
CancellationToken | ct | Cancellation / deadline signal for the call. (optional) |
Returns
Task<RoleAssignment> — an awaitable that resolves to RoleAssignment.
Exceptions
| Type | Condition |
|---|---|
ArgumentException | id is null or empty. |
NetworkException | The request could not reach the server (DNS, connection, or TLS failure). |
ApiException | The server returned a non-success (non-2xx) status. A status-specific subtype is thrown where it applies — e.g. NotFoundException (404), PermissionDeniedException (403), ConflictException (409). |
Example
var revokedAssignment =
await client.AccessPolicy.RoleAssignmentsDeleteAsync("your-role-assignment-id");RoleAssignmentsGetAsync
Reads one live assignment, or one revoked historical assignment when includeRevoked is true, after requiring MANAGE_ACCESS on its policy target.
Declaration
public Task<RoleAssignment> RoleAssignmentsGetAsync(string id, AccessPolicyRoleAssignmentsGetOptions? options = null, CancellationToken ct = default)
HTTP — GET /v1/access-policy/role-assignments/{id}
Parameters
| Type | Name | Description |
|---|---|---|
string | id | Role-assignment UUID |
AccessPolicyRoleAssignmentsGetOptions | options | Options bag carrying the lookup key(s) / convenience knobs; the linked type lists them all. (optional) |
CancellationToken | ct | Cancellation / deadline signal for the call. (optional) |
Returns
Task<RoleAssignment> — an awaitable that resolves to RoleAssignment.
Exceptions
| Type | Condition |
|---|---|
ArgumentException | id is null or empty. |
NetworkException | The request could not reach the server (DNS, connection, or TLS failure). |
ApiException | The server returned a non-success (non-2xx) status. A status-specific subtype is thrown where it applies — e.g. NotFoundException (404), PermissionDeniedException (403), ConflictException (409). |
Example
var fetchedAssignment =
await client.AccessPolicy.RoleAssignmentsGetAsync("your-role-assignment-id");RoleAssignmentsListAsync
Lists assignments attached to one required INSTANCE or SPACE boundary after requiring MANAGE_ACCESS. Continuation tokens are bound to the caller and filters.
Declaration
public IAsyncEnumerable<RoleAssignment> RoleAssignmentsListAsync(AccessPolicyRoleAssignmentsListOptions? options = null, CancellationToken ct = default)
HTTP — GET /v1/access-policy/role-assignments
Parameters
| Type | Name | Description |
|---|---|---|
AccessPolicyRoleAssignmentsListOptions | options | Options bag carrying the lookup key(s) / convenience knobs; the linked type lists them all. (optional) |
CancellationToken | ct | Cancellation / deadline signal for the call. (optional) |
Returns
IAsyncEnumerable<RoleAssignment> — an async stream; await foreach yields each RoleAssignment across pages / events.
Exceptions
| Type | Condition |
|---|---|
NetworkException | The request could not reach the server (DNS, connection, or TLS failure). |
ApiException | The server returned a non-success (non-2xx) status. A status-specific subtype is thrown where it applies — e.g. NotFoundException (404), PermissionDeniedException (403), ConflictException (409). |
Example
await foreach (
var visibleAssignment in client.AccessPolicy.RoleAssignmentsListAsync(
new AccessPolicyRoleAssignmentsListOptions
{
ResourceKind = "SPACE",
ResourceId = spaceId,
}
)
)
Console.WriteLine(visibleAssignment.RoleAssignmentId);Data Models
Types in the Goodmem.Client.Models namespace. Each row lists the C# property, its type, the JSON wire name, and a description.
CheckAuthorizationsRequest
Evaluates between 1 and 50 concrete authorization checks.
| Property | Type | JSON (wire) | Description |
|---|---|---|---|
Checks | IReadOnlyList<AuthorizationCheck> | checks | Concrete checks evaluated in request order. |
AuthorizationCheck
One concrete, advisory authorization check. Top-level creates target INSTANCE; CREATE_MEMORY and LIST_MEMORY target a parent SPACE; ordinary resource operations target the concrete resource. LIST_API_KEY and LIST_RETRIEVE_MEMORY_LOG_POLICY are not supported by this endpoint.
| Property | Type | JSON (wire) | Description |
|---|---|---|---|
Operation | Operation | operation | Operation the caller proposes to perform. |
Target | AccessPolicyTarget | target | Target required by the operation: INSTANCE for top-level creates, parent SPACE for CREATE_MEMORY or LIST_MEMORY, otherwise the concrete resource. |
CheckAuthorizationsResponse
Positional advisory authorization results.
| Property | Type | JSON (wire) | Description |
|---|---|---|---|
Results | IReadOnlyList<AuthorizationCheckResult> | results | Results corresponding one-for-one with the request checks. |
AuthorizationCheckResult
One advisory decision; false covers both an absent target and an authorization denial.
| Property | Type | JSON (wire) | Description |
|---|---|---|---|
Allowed | bool | allowed | Whether the caller currently has effective authority. |
CreateAuthorizationGrantRequest
Creates one live direct authorization grant.
| Property | Type | JSON (wire) | Description |
|---|---|---|---|
GrantId | string | grantId | Optional caller-provided grant UUID. (optional) |
Audience | GrantAudience | audience | Audience receiving the grant. |
Rule | AccessPolicyRule | rule | Authorization descriptor to grant. |
GrantAudience
Exactly one principal or the all-authenticated audience.
| Property | Type | JSON (wire) | Description |
|---|---|---|---|
PrincipalId | string | principalId | Active HUMAN or SERVICE principal UUID. (optional) |
AllAuthenticated | GrantAudienceAllAuthenticated | allAuthenticated | Set to true to address every authenticated principal. (optional) |
GrantAudienceAllAuthenticated
The literal true, selecting every successfully authenticated principal.
String enum: "True"
AuthorizationGrant
Current or historical direct authorization grant.
| Property | Type | JSON (wire) | Description |
|---|---|---|---|
GrantId | string | grantId | Durable grant UUID. |
Audience | GrantAudience | audience | Grant audience. |
Rule | AccessPolicyRule | rule | Granted authorization descriptor. |
CreatedAt | DateTimeOffset | createdAt | Creation time in epoch milliseconds. |
CreatedById | string | createdById | Exact audit actor that created the grant. |
RevokedAt | DateTimeOffset | revokedAt | Revocation time in epoch milliseconds, when revoked. (optional) |
RevokedById | string | revokedById | Exact audit actor that revoked the grant, when revoked. (optional) |
ListAuthorizationGrantsResponse
One page of direct authorization grants.
| Property | Type | JSON (wire) | Description |
|---|---|---|---|
Grants | IReadOnlyList<AuthorizationGrant> | grants | Grant rows in stable creation order. |
NextToken | string | nextToken | Opaque continuation token, omitted on the final page. (optional) |
AssignRoleRequest
Assigns one code-defined role at an INSTANCE or SPACE boundary.
| Property | Type | JSON (wire) | Description |
|---|---|---|---|
RoleAssignmentId | string | roleAssignmentId | Optional caller-provided role-assignment UUID. (optional) |
PrincipalId | string | principalId | Active principal receiving the role. |
Role | string | role | Code-defined non-ROOT role to assign. |
AssignedResource | RoleAssignmentTarget | assignedResource | INSTANCE or SPACE boundary receiving the assignment. |
RoleAssignmentTarget
An INSTANCE or SPACE role-assignment boundary. resourceId is omitted for INSTANCE and required for SPACE.
| Property | Type | JSON (wire) | Description |
|---|---|---|---|
Kind | string | kind | Role-assignment target kind. |
ResourceId | string | resourceId | Memory-space UUID; omitted for the singleton INSTANCE target. (optional) |
RoleAssignment
Current or historical scoped role assignment.
| Property | Type | JSON (wire) | Description |
|---|---|---|---|
RoleAssignmentId | string | roleAssignmentId | Durable role-assignment UUID. |
PrincipalId | string | principalId | Assigned principal UUID. |
Role | Role | role | Code-defined assigned role. |
AssignedResource | RoleAssignmentTarget | assignedResource | INSTANCE or SPACE assignment boundary. |
AssignedAt | DateTimeOffset | assignedAt | Assignment time in epoch milliseconds. |
AssignedById | string | assignedById | Exact audit actor that assigned the role. |
RevokedAt | DateTimeOffset | revokedAt | Revocation time in epoch milliseconds, when revoked. (optional) |
RevokedById | string | revokedById | Exact audit actor that revoked the assignment, when revoked. (optional) |
Role
String enum: "ROOT" · "ADMIN" · "USER" · "SPACE_VIEWER" · "SPACE_CONTRIBUTOR" · "SPACE_CONTENT_MANAGER" · "SPACE_ADMIN"
ListRoleAssignmentsResponse
One page of scoped role assignments.
| Property | Type | JSON (wire) | Description |
|---|---|---|---|
RoleAssignments | IReadOnlyList<RoleAssignment> | roleAssignments | Role assignments in stable assignment order. |
NextToken | string | nextToken | Opaque continuation token, omitted on the final page. (optional) |