import { Code, type Client } from "@connectrpc/connect";
import * as pb from "./internal/proto/tenki/cloud/workspace/v1beta1/secrets_pb.js";
import { SecretPolicies } from "./secret-policies.js";
export declare class WorkspaceSecretError extends Error {
    readonly code: Code;
    constructor(message: string, code: Code, options?: ErrorOptions);
}
export declare function workspaceSecretError(error: unknown): Error;
/** Where a secret applies: every CI job and sandbox in the workspace, or CI jobs in one repository. */
export type SecretAvailability = "workspace" | "repository";
export interface WorkspaceSecret {
    id: string;
    workspaceId: string;
    name: string;
    /** Repository (owner/name) whose CI jobs get the secret; undefined for a workspace secret. */
    repository?: string;
    /** One-line note for the people who manage the secret; undefined when there is none. */
    description?: string;
    activeVersion: number;
    revision: number;
    createdAt?: Date;
    updatedAt?: Date;
    revokedAt?: Date;
    deletedAt?: Date;
}
export interface WorkspaceSecretVersion {
    version: number;
    createdAt?: Date;
    revokedAt?: Date;
}
export interface SecretMutationOptions {
    expectedRevision: number;
    requestId?: string;
}
export interface CreateSecretOptions {
    requestId?: string;
    /** Gives the secret only to CI jobs in this connected repository (owner/name); omit for a workspace secret. */
    repository?: string;
    description?: string;
}
/**
 * Changes only what is set. A value or activeVersion makes that version active and restores a revoked
 * secret; description and availability changes don't.
 */
export interface UpdateSecretOptions extends SecretMutationOptions {
    /** Omitted retains the value; an empty array creates an empty value. */
    value?: Uint8Array;
    activeVersion?: number;
    /** An empty string clears the description. */
    description?: string;
    /** Omitted keeps the availability unless `repository` is set; "repository", or `repository` alone, moves the secret there. */
    availability?: SecretAvailability;
    repository?: string;
}
export interface SecretPageOptions {
    pageSize?: number;
    cursor?: string;
}
export interface ListSecretsOptions extends SecretPageOptions {
    /** Omitted lists workspace and repository secrets; `repository`, with or without "repository", narrows to one repository. */
    availability?: SecretAvailability;
    repository?: string;
}
export interface SecretRepositoryPageOptions extends SecretPageOptions {
    /** Case-insensitive substring match on the full name. */
    search?: string;
}
export declare function checkRepository(repository: string): void;
/** Access through WorkspaceClient.secrets. Reads return metadata only. */
export declare class Secrets {
    private readonly workspaceId;
    private readonly rpc;
    readonly policies: SecretPolicies;
    constructor(workspaceId: string, rpc: Client<typeof pb.WorkspaceSecretsService>);
    /**
     * Creates a secret. With `repository`, only CI jobs in that connected repository get it, in place of a
     * workspace secret with the same name. A string `options` is the request ID, as in 1.4.
     */
    create(name: string, value: Uint8Array, options?: string | CreateSecretOptions): Promise<WorkspaceSecret>;
    update(secretId: string, options: UpdateSecretOptions): Promise<WorkspaceSecret>;
    get(secretId: string): Promise<WorkspaceSecret>;
    list(options?: ListSecretsOptions): Promise<{
        secrets: WorkspaceSecret[];
        nextCursor: string;
    }>;
    /** Lists the connected repositories (owner/name) a secret can be limited to, ordered by name. */
    listRepositories(options?: SecretRepositoryPageOptions): Promise<{
        repositories: string[];
        nextCursor: string;
    }>;
    listVersions(secretId: string, options?: SecretPageOptions): Promise<{
        versions: WorkspaceSecretVersion[];
        nextCursor: string;
    }>;
    revoke(secretId: string, options: SecretMutationOptions & {
        version?: number;
    }): Promise<WorkspaceSecret>;
    delete(secretId: string, options: SecretMutationOptions): Promise<WorkspaceSecret>;
}
