GoodMemGoodMem
ReferenceSdkV2.NET

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

MethodSummary
CheckAsyncCheck effective authorization.
GrantsCreateAsyncCreate an authorization grant.
GrantsDeleteAsyncRevoke an authorization grant.
GrantsGetAsyncGet an authorization grant.
GrantsListAsyncList authorization grants.
RoleAssignmentsCreateAsyncAssign a scoped role.
RoleAssignmentsDeleteAsyncRevoke a scoped role assignment.
RoleAssignmentsGetAsyncGet a scoped role assignment.
RoleAssignmentsListAsyncList 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)

HTTPPOST /v1/access-policy:check

Parameters

TypeNameDescription
CheckAuthorizationsRequestrequestThe request payload; the linked model lists every field and its JSON wire name.
CancellationTokenctCancellation / deadline signal for the call. (optional)

Returns

Task<CheckAuthorizationsResponse> — an awaitable that resolves to CheckAuthorizationsResponse.

Exceptions

TypeCondition
ArgumentNullExceptionrequest is null.
NetworkExceptionThe request could not reach the server (DNS, connection, or TLS failure).
ApiExceptionThe 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)

HTTPPOST /v1/access-policy/grants

Parameters

TypeNameDescription
CreateAuthorizationGrantRequestrequestThe request payload; the linked model lists every field and its JSON wire name.
CancellationTokenctCancellation / deadline signal for the call. (optional)

Returns

Task<AuthorizationGrant> — an awaitable that resolves to AuthorizationGrant.

Exceptions

TypeCondition
ArgumentNullExceptionrequest is null.
NetworkExceptionThe request could not reach the server (DNS, connection, or TLS failure).
ApiExceptionThe 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)

HTTPDELETE /v1/access-policy/grants/&#123;id&#125;

Parameters

TypeNameDescription
stringidGrant UUID
CancellationTokenctCancellation / deadline signal for the call. (optional)

Returns

Task<AuthorizationGrant> — an awaitable that resolves to AuthorizationGrant.

Exceptions

TypeCondition
ArgumentExceptionid is null or empty.
NetworkExceptionThe request could not reach the server (DNS, connection, or TLS failure).
ApiExceptionThe 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)

HTTPGET /v1/access-policy/grants/&#123;id&#125;

Parameters

TypeNameDescription
stringidGrant UUID
AccessPolicyGrantsGetOptionsoptionsOptions bag carrying the lookup key(s) / convenience knobs; the linked type lists them all. (optional)
CancellationTokenctCancellation / deadline signal for the call. (optional)

Returns

Task<AuthorizationGrant> — an awaitable that resolves to AuthorizationGrant.

Exceptions

TypeCondition
ArgumentExceptionid is null or empty.
NetworkExceptionThe request could not reach the server (DNS, connection, or TLS failure).
ApiExceptionThe 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)

HTTPGET /v1/access-policy/grants

Parameters

TypeNameDescription
AccessPolicyGrantsListOptionsoptionsOptions bag carrying the lookup key(s) / convenience knobs; the linked type lists them all. (optional)
CancellationTokenctCancellation / deadline signal for the call. (optional)

Returns

IAsyncEnumerable<AuthorizationGrant> — an async stream; await foreach yields each AuthorizationGrant across pages / events.

Exceptions

TypeCondition
NetworkExceptionThe request could not reach the server (DNS, connection, or TLS failure).
ApiExceptionThe 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)

HTTPPOST /v1/access-policy/role-assignments

Parameters

TypeNameDescription
AssignRoleRequestrequestThe request payload; the linked model lists every field and its JSON wire name.
CancellationTokenctCancellation / deadline signal for the call. (optional)

Returns

Task<RoleAssignment> — an awaitable that resolves to RoleAssignment.

Exceptions

TypeCondition
ArgumentNullExceptionrequest is null.
NetworkExceptionThe request could not reach the server (DNS, connection, or TLS failure).
ApiExceptionThe 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)

HTTPDELETE /v1/access-policy/role-assignments/&#123;id&#125;

Parameters

TypeNameDescription
stringidRole-assignment UUID
CancellationTokenctCancellation / deadline signal for the call. (optional)

Returns

Task<RoleAssignment> — an awaitable that resolves to RoleAssignment.

Exceptions

TypeCondition
ArgumentExceptionid is null or empty.
NetworkExceptionThe request could not reach the server (DNS, connection, or TLS failure).
ApiExceptionThe 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)

HTTPGET /v1/access-policy/role-assignments/&#123;id&#125;

Parameters

TypeNameDescription
stringidRole-assignment UUID
AccessPolicyRoleAssignmentsGetOptionsoptionsOptions bag carrying the lookup key(s) / convenience knobs; the linked type lists them all. (optional)
CancellationTokenctCancellation / deadline signal for the call. (optional)

Returns

Task<RoleAssignment> — an awaitable that resolves to RoleAssignment.

Exceptions

TypeCondition
ArgumentExceptionid is null or empty.
NetworkExceptionThe request could not reach the server (DNS, connection, or TLS failure).
ApiExceptionThe 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)

HTTPGET /v1/access-policy/role-assignments

Parameters

TypeNameDescription
AccessPolicyRoleAssignmentsListOptionsoptionsOptions bag carrying the lookup key(s) / convenience knobs; the linked type lists them all. (optional)
CancellationTokenctCancellation / deadline signal for the call. (optional)

Returns

IAsyncEnumerable<RoleAssignment> — an async stream; await foreach yields each RoleAssignment across pages / events.

Exceptions

TypeCondition
NetworkExceptionThe request could not reach the server (DNS, connection, or TLS failure).
ApiExceptionThe 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.

PropertyTypeJSON (wire)Description
ChecksIReadOnlyList<AuthorizationCheck>checksConcrete 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.

PropertyTypeJSON (wire)Description
OperationOperationoperationOperation the caller proposes to perform.
TargetAccessPolicyTargettargetTarget 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.

PropertyTypeJSON (wire)Description
ResultsIReadOnlyList<AuthorizationCheckResult>resultsResults corresponding one-for-one with the request checks.

AuthorizationCheckResult

One advisory decision; false covers both an absent target and an authorization denial.

PropertyTypeJSON (wire)Description
AllowedboolallowedWhether the caller currently has effective authority.

CreateAuthorizationGrantRequest

Creates one live direct authorization grant.

PropertyTypeJSON (wire)Description
GrantIdstringgrantIdOptional caller-provided grant UUID. (optional)
AudienceGrantAudienceaudienceAudience receiving the grant.
RuleAccessPolicyRuleruleAuthorization descriptor to grant.

GrantAudience

Exactly one principal or the all-authenticated audience.

PropertyTypeJSON (wire)Description
PrincipalIdstringprincipalIdActive HUMAN or SERVICE principal UUID. (optional)
AllAuthenticatedGrantAudienceAllAuthenticatedallAuthenticatedSet 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.

PropertyTypeJSON (wire)Description
GrantIdstringgrantIdDurable grant UUID.
AudienceGrantAudienceaudienceGrant audience.
RuleAccessPolicyRuleruleGranted authorization descriptor.
CreatedAtDateTimeOffsetcreatedAtCreation time in epoch milliseconds.
CreatedByIdstringcreatedByIdExact audit actor that created the grant.
RevokedAtDateTimeOffsetrevokedAtRevocation time in epoch milliseconds, when revoked. (optional)
RevokedByIdstringrevokedByIdExact audit actor that revoked the grant, when revoked. (optional)

ListAuthorizationGrantsResponse

One page of direct authorization grants.

PropertyTypeJSON (wire)Description
GrantsIReadOnlyList<AuthorizationGrant>grantsGrant rows in stable creation order.
NextTokenstringnextTokenOpaque continuation token, omitted on the final page. (optional)

AssignRoleRequest

Assigns one code-defined role at an INSTANCE or SPACE boundary.

PropertyTypeJSON (wire)Description
RoleAssignmentIdstringroleAssignmentIdOptional caller-provided role-assignment UUID. (optional)
PrincipalIdstringprincipalIdActive principal receiving the role.
RolestringroleCode-defined non-ROOT role to assign.
AssignedResourceRoleAssignmentTargetassignedResourceINSTANCE or SPACE boundary receiving the assignment.

RoleAssignmentTarget

An INSTANCE or SPACE role-assignment boundary. resourceId is omitted for INSTANCE and required for SPACE.

PropertyTypeJSON (wire)Description
KindstringkindRole-assignment target kind.
ResourceIdstringresourceIdMemory-space UUID; omitted for the singleton INSTANCE target. (optional)

RoleAssignment

Current or historical scoped role assignment.

PropertyTypeJSON (wire)Description
RoleAssignmentIdstringroleAssignmentIdDurable role-assignment UUID.
PrincipalIdstringprincipalIdAssigned principal UUID.
RoleRoleroleCode-defined assigned role.
AssignedResourceRoleAssignmentTargetassignedResourceINSTANCE or SPACE assignment boundary.
AssignedAtDateTimeOffsetassignedAtAssignment time in epoch milliseconds.
AssignedByIdstringassignedByIdExact audit actor that assigned the role.
RevokedAtDateTimeOffsetrevokedAtRevocation time in epoch milliseconds, when revoked. (optional)
RevokedByIdstringrevokedByIdExact 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.

PropertyTypeJSON (wire)Description
RoleAssignmentsIReadOnlyList<RoleAssignment>roleAssignmentsRole assignments in stable assignment order.
NextTokenstringnextTokenOpaque continuation token, omitted on the final page. (optional)