Admin
.NET SDK reference for server administration: retrieval log policies, ownership transfer, draining, license reloads, and job purging.
Server lifecycle ops — drain, license reload, background-job purge.
Namespace: Goodmem.Client.Api · Class: AdminApi
Reach this surface as client.Admin 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 |
|---|---|
DrainAsync | Request the server to enter drain mode. |
TransferInstanceOwnershipAsync | Transfer GoodMem instance ownership. |
BackgroundJobsPurgeAsync | Purge completed background jobs. |
LicenseReloadAsync | Reload the active license from disk. |
RetrieveMemoryLogPoliciesCreateAsync | Create a RetrieveMemory log policy. |
RetrieveMemoryLogPoliciesDeleteAsync | Delete a RetrieveMemory log policy. |
RetrieveMemoryLogPoliciesGetAsync | Get a RetrieveMemory log policy. |
RetrieveMemoryLogPoliciesListAsync | List RetrieveMemory log policies. |
DrainAsync
Initiates drain mode and optionally waits for the server to quiesce.
Declaration
public Task<AdminDrainResponse> DrainAsync(AdminDrainRequest? request = null, CancellationToken ct = default)
HTTP — POST /v1/admin:drain
Parameters
| Type | Name | Description |
|---|---|---|
AdminDrainRequest | request | The request payload; the linked model lists every field and its JSON wire name. (optional) |
CancellationToken | ct | Cancellation / deadline signal for the call. (optional) |
Returns
Task<AdminDrainResponse> — an awaitable that resolves to AdminDrainResponse.
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
var result = await client.Admin.DrainAsync(new AdminDrainRequest { TimeoutSec = 0 });
Console.WriteLine(result.Quiesced);TransferInstanceOwnershipAsync
Transfers the singleton GoodMem instance to another active human principal. Only the current instance owner may invoke this operation; ADMIN, MANAGE_ACCESS, and ordinary grants are insufficient. Ownership and the synthetic ROOT assignment move atomically. All ordinary roles, including ADMIN, remain unchanged. No credential is created or returned. After an unknown outcome, read the current owner before retrying.
Declaration
public Task<TransferInstanceOwnershipResponse> TransferInstanceOwnershipAsync(TransferOwnershipRequest request, CancellationToken ct = default)
HTTP — POST /v1/admin:transferInstanceOwnership
Parameters
| Type | Name | Description |
|---|---|---|
TransferOwnershipRequest | 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<TransferInstanceOwnershipResponse> — an awaitable that resolves to TransferInstanceOwnershipResponse.
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 transferredInstance = await client.Admin.TransferInstanceOwnershipAsync(
new TransferOwnershipRequest { NewOwnerId = "your-principal-id" }
);BackgroundJobsPurgeAsync
Deletes terminal background jobs older than a retention cutoff.
Declaration
public Task<AdminPurgeJobsResponse> BackgroundJobsPurgeAsync(AdminPurgeJobsRequest? request = null, CancellationToken ct = default)
HTTP — POST /v1/admin/background-jobs:purge
Parameters
| Type | Name | Description |
|---|---|---|
AdminPurgeJobsRequest | request | The request payload; the linked model lists every field and its JSON wire name. (optional) |
CancellationToken | ct | Cancellation / deadline signal for the call. (optional) |
Returns
Task<AdminPurgeJobsResponse> — an awaitable that resolves to AdminPurgeJobsResponse.
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
var result = await client.Admin.BackgroundJobsPurgeAsync(
new AdminPurgeJobsRequest { OlderThan = "2000-01-01T00:00:00Z", DryRun = true }
);
Console.WriteLine(result.JobsPurged);LicenseReloadAsync
Triggers the server to reload its license file from the configured directory and returns metadata about the currently active license.
Declaration
public Task<AdminReloadLicenseResponse> LicenseReloadAsync(CancellationToken ct = default)
HTTP — POST /v1/admin/license:reload
Parameters
| Type | Name | Description |
|---|---|---|
CancellationToken | ct | Cancellation / deadline signal for the call. (optional) |
Returns
Task<AdminReloadLicenseResponse> — an awaitable that resolves to AdminReloadLicenseResponse.
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
var result = await client.Admin.LicenseReloadAsync();
Console.WriteLine(result.Status);RetrieveMemoryLogPoliciesCreateAsync
Creates an immutable administrative policy that can automatically enable durable RetrieveMemory request logging.
Declaration
public Task<RetrieveMemoryLogPolicy> RetrieveMemoryLogPoliciesCreateAsync(CreateRetrieveMemoryLogPolicyRequest? request = null, CancellationToken ct = default)
HTTP — POST /v1/admin/retrieve-memory-log-policies
Parameters
| Type | Name | Description |
|---|---|---|
CreateRetrieveMemoryLogPolicyRequest | request | The request payload; the linked model lists every field and its JSON wire name. (optional) |
CancellationToken | ct | Cancellation / deadline signal for the call. (optional) |
Returns
Task<RetrieveMemoryLogPolicy> — an awaitable that resolves to RetrieveMemoryLogPolicy.
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
var created = await client.Admin.RetrieveMemoryLogPoliciesCreateAsync(
new CreateRetrieveMemoryLogPolicyRequest
{
DisplayName = "audit-doc-example",
Condition = new RetrieveMemoryLogPolicyCondition { MatchAll = true },
}
);
Console.WriteLine(created.PolicyId);RetrieveMemoryLogPoliciesDeleteAsync
Idempotently tombstones an immutable RetrieveMemory log policy.
Declaration
public Task<RetrieveMemoryLogPolicy> RetrieveMemoryLogPoliciesDeleteAsync(string id, DeleteRetrieveMemoryLogPolicyRequest? request = null, CancellationToken ct = default)
HTTP — DELETE /v1/admin/retrieve-memory-log-policies/{id}
Parameters
| Type | Name | Description |
|---|---|---|
string | id | The UUID of the policy to delete |
DeleteRetrieveMemoryLogPolicyRequest | request | The request payload; the linked model lists every field and its JSON wire name. (optional) |
CancellationToken | ct | Cancellation / deadline signal for the call. (optional) |
Returns
Task<RetrieveMemoryLogPolicy> — an awaitable that resolves to RetrieveMemoryLogPolicy.
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 tombstoned = await client.Admin.RetrieveMemoryLogPoliciesDeleteAsync(
"your-policy-id",
new DeleteRetrieveMemoryLogPolicyRequest { Reason = "doc example cleanup" }
);
Console.WriteLine(tombstoned.PolicyId);RetrieveMemoryLogPoliciesGetAsync
Retrieves a live RetrieveMemory log policy by UUID, or a tombstoned policy when includeDeleted is true.
Declaration
public Task<RetrieveMemoryLogPolicy> RetrieveMemoryLogPoliciesGetAsync(string id, AdminRetrieveMemoryLogPoliciesGetOptions? options = null, CancellationToken ct = default)
HTTP — GET /v1/admin/retrieve-memory-log-policies/{id}
Parameters
| Type | Name | Description |
|---|---|---|
string | id | The UUID of the policy to retrieve |
AdminRetrieveMemoryLogPoliciesGetOptions | 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<RetrieveMemoryLogPolicy> — an awaitable that resolves to RetrieveMemoryLogPolicy.
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 fetched = await client.Admin.RetrieveMemoryLogPoliciesGetAsync("your-policy-id");
Console.WriteLine(fetched.DisplayName);RetrieveMemoryLogPoliciesListAsync
Lists RetrieveMemory log policies with optional tombstone, active-time, name, label, sort, and pagination filters.
LABEL FILTERS: Label filters accept either label.<key>=<value> or label[key]=value (for example, label.environment=production or label[environment]=production).
Declaration
public IAsyncEnumerable<RetrieveMemoryLogPolicy> RetrieveMemoryLogPoliciesListAsync(AdminRetrieveMemoryLogPoliciesListOptions? options = null, CancellationToken ct = default)
HTTP — GET /v1/admin/retrieve-memory-log-policies
Parameters
| Type | Name | Description |
|---|---|---|
AdminRetrieveMemoryLogPoliciesListOptions | 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<RetrieveMemoryLogPolicy> — an async stream; await foreach yields each RetrieveMemoryLogPolicy 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
// Auto-paginate every retrieve-memory log policy.
await foreach (var policy in client.Admin.RetrieveMemoryLogPoliciesListAsync())
Console.WriteLine(policy.DisplayName);Data Models
Types in the Goodmem.Client.Models namespace. Each row lists the C# property, its type, the JSON wire name, and a description.
AdminPurgeJobsRequest
| Property | Type | JSON (wire) | Description |
|---|---|---|---|
OlderThan | string | olderThan | ISO-8601 timestamp cutoff; only terminal jobs older than this instant are eligible. (optional) |
Statuses | IReadOnlyList<PurgeableBackgroundJobStatus> | statuses | Optional terminal background job statuses to target for purging. If omitted, all terminal statuses are eligible. Canonical values are BACKGROUND_JOB_SUCCEEDED, BACKGROUND_JOB_FAILED, and BACKGROUND_JOB_CANCELED. Short aliases SUCCEEDED, FAILED, and CANCELED are also accepted for compatibility. (optional) |
DryRun | bool | dryRun | If true, report purge counts without deleting any rows. (optional) |
Limit | int | limit | Maximum number of jobs to purge in this request. Must be >= 0; 0 means no limit. (optional) |
PurgeableBackgroundJobStatus
Terminal background job statuses eligible for purge requests.
String enum: "BACKGROUND_JOB_SUCCEEDED" · "BACKGROUND_JOB_FAILED" · "BACKGROUND_JOB_CANCELED"
AdminPurgeJobsResponse
| Property | Type | JSON (wire) | Description |
|---|---|---|---|
JobsPurged | long | jobsPurged | Number of background job rows removed, or that would be removed during dry-run. |
AttemptsPurged | long | attemptsPurged | Number of background job attempt rows removed. |
ReferencesPurged | long | referencesPurged | Number of background job reference rows removed. |
DryRun | bool | dryRun | Whether the purge executed in dry-run mode. |
AdminDrainRequest
| Property | Type | JSON (wire) | Description |
|---|---|---|---|
TimeoutSec | int | timeoutSec | Maximum seconds to wait for the server to quiesce before returning. (optional) |
Reason | string | reason | Human-readable reason for initiating drain mode. (optional) |
WaitForQuiesce | bool | waitForQuiesce | If true, wait for in-flight requests to complete and the server to reach QUIESCED before responding. (optional) |
AdminDrainResponse
| Property | Type | JSON (wire) | Description |
|---|---|---|---|
State | string | state | Lifecycle state reported after the drain request was processed. (optional) |
Quiesced | bool | quiesced | Whether the server has reached the QUIESCED lifecycle state. |
Message | string | message | Human-readable status message describing the drain outcome. (optional) |
AdminReloadLicenseResponse
| Property | Type | JSON (wire) | Description |
|---|---|---|---|
Status | string | status | Outcome of the reload attempt, such as LOADED, UNCHANGED, FAILED, or NOT_FOUND. |
Message | string | message | Human-readable message describing the reload result. |
ActiveLicense | ActiveLicenseMetadata | activeLicense | Metadata for the currently active license after reload, or null if no license is active. (optional) |
ActiveLicenseMetadata
| Property | Type | JSON (wire) | Description |
|---|---|---|---|
Filename | string | filename | Filename of the active license on disk. |
Sha256 | string | sha256 | Hex-encoded SHA-256 hash of the active license file. |
SizeBytes | long | sizeBytes | Size of the active license file in bytes. |
ModifiedAt | string | modifiedAt | Last modification timestamp of the active license file. |
CreateRetrieveMemoryLogPolicyRequest
REST request for creating an immutable RetrieveMemory log policy.
| Property | Type | JSON (wire) | Description |
|---|---|---|---|
PolicyId | string | policyId | Optional client-provided policy UUID. (optional) |
DisplayName | string | displayName | Human-readable policy name. |
Description | string | description | Optional operator description. (optional) |
Condition | RetrieveMemoryLogPolicyCondition | condition | Policy match condition. |
ActiveFrom | DateTimeOffset | activeFrom | Inclusive activation time in milliseconds since epoch. (optional) |
ActiveUntil | DateTimeOffset | activeUntil | Exclusive deactivation time in milliseconds since epoch. (optional) |
Labels | IReadOnlyDictionary<string, string> | labels | Operator labels for listing and administration. (optional) |
RetrieveMemoryLogPolicyCondition
RetrieveMemory log policy condition. Set matchAll=true to match every authenticated RetrieveMemory request and do not provide anyOf clauses. Otherwise, anyOf is required and must contain at least one non-empty scoped clause.
| Property | Type | JSON (wire) | Description |
|---|---|---|---|
MatchAll | bool | matchAll | When true, match every authenticated RetrieveMemory request. Must be omitted or false when anyOf contains clauses. Defaults to false when omitted. (optional) |
AnyOf | IReadOnlyList<RetrieveMemoryLogPolicyConditionClause> | anyOf | OR clauses used for scoped matching. Required and non-empty when matchAll is false or omitted. Must be omitted or empty when matchAll is true. Each clause must include at least one match dimension. (optional) |
RetrieveMemoryLogPolicyConditionClause
One OR clause in a RetrieveMemory log policy condition. All populated dimensions in the clause must match; clauses are ORed together.
| Property | Type | JSON (wire) | Description |
|---|---|---|---|
RequestorUserIds | IReadOnlyList<string> | requestorUserIds | Authenticated requestor user UUID strings. (optional) |
ApiKeyIds | IReadOnlyList<string> | apiKeyIds | API key UUID strings used to authenticate RetrieveMemory requests. (optional) |
SpaceIds | IReadOnlyList<string> | spaceIds | Post-permission accessible space UUID strings. (optional) |
ApiKeyLabelSelectors | IReadOnlyDictionary<string, string> | apiKeyLabelSelectors | Exact API-key label selectors that must all match. (optional) |
SpaceLabelSelectors | IReadOnlyDictionary<string, string> | spaceLabelSelectors | Exact space label selectors that must match at least one accessible space. (optional) |
RetrieveMemoryLogPolicy
REST representation of an immutable RetrieveMemory log policy.
| Property | Type | JSON (wire) | Description |
|---|---|---|---|
PolicyId | string | policyId | Policy UUID. |
DisplayName | string | displayName | Human-readable policy name. |
Description | string | description | Optional operator description. (optional) |
Condition | RetrieveMemoryLogPolicyCondition | condition | Policy match condition. |
ActiveFrom | DateTimeOffset | activeFrom | Inclusive activation time in milliseconds since epoch. |
ActiveUntil | DateTimeOffset | activeUntil | Exclusive deactivation time in milliseconds since epoch. (optional) |
Labels | IReadOnlyDictionary<string, string> | labels | Operator labels for listing and administration. |
CurrentlyActive | bool | currentlyActive | Whether the policy is active at response evaluation time. |
DeletedAt | DateTimeOffset | deletedAt | Tombstone time in milliseconds since epoch. (optional) |
DeletedById | string | deletedById | User UUID that tombstoned the policy. (optional) |
DeleteReason | string | deleteReason | Optional tombstone reason. (optional) |
CreatedAt | DateTimeOffset | createdAt | Creation time in milliseconds since epoch. |
UpdatedAt | DateTimeOffset | updatedAt | Update time in milliseconds since epoch. |
CreatedById | string | createdById | Creator user UUID. |
UpdatedById | string | updatedById | Last-updater user UUID. |
DeleteRetrieveMemoryLogPolicyRequest
Optional REST body for tombstoning a RetrieveMemory log policy.
| Property | Type | JSON (wire) | Description |
|---|---|---|---|
Reason | string | reason | Optional tombstone reason. (optional) |
ListRetrieveMemoryLogPoliciesResponse
REST response containing a page of RetrieveMemory log policies.
| Property | Type | JSON (wire) | Description |
|---|---|---|---|
Policies | IReadOnlyList<RetrieveMemoryLogPolicy> | policies | Policy page. |
NextToken | string | nextToken | Opaque token for the next page. (optional) |
TransferInstanceOwnershipResponse
The singleton GoodMem instance after its ownership transfer completes.
| Property | Type | JSON (wire) | Description |
|---|---|---|---|
Instance | GoodMemInstance | instance | Updated singleton instance and ownership audit metadata. |