UNPKG

neon-sdk

Version:

TypeScript SDK for managing your Neon Serverless PostgreSQL projects

1,420 lines (1,344 loc) 131 kB
type ApiRequestOptions = { readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH'; readonly url: string; readonly path?: Record<string, any>; readonly cookies?: Record<string, any>; readonly headers?: Record<string, any>; readonly query?: Record<string, any>; readonly formData?: Record<string, any>; readonly body?: any; readonly mediaType?: string; readonly responseHeader?: string; readonly errors?: Record<number, string>; }; declare class CancelError extends Error { constructor(message: string); get isCancelled(): boolean; } interface OnCancel { readonly isResolved: boolean; readonly isRejected: boolean; readonly isCancelled: boolean; (cancelHandler: () => void): void; } declare class CancelablePromise<T> implements Promise<T> { #private; constructor(executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void, onCancel: OnCancel) => void); get [Symbol.toStringTag](): string; then<TResult1 = T, TResult2 = never>(onFulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null, onRejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>; catch<TResult = never>(onRejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null): Promise<T | TResult>; finally(onFinally?: (() => void) | null): Promise<T>; cancel(): void; get isCancelled(): boolean; } type Resolver<T> = (options: ApiRequestOptions) => Promise<T>; type Headers = Record<string, string>; type OpenAPIConfig = { BASE: string; VERSION: string; WITH_CREDENTIALS: boolean; CREDENTIALS: 'include' | 'omit' | 'same-origin'; TOKEN?: string | Resolver<string> | undefined; USERNAME?: string | Resolver<string> | undefined; PASSWORD?: string | Resolver<string> | undefined; HEADERS?: Headers | Resolver<Headers> | undefined; ENCODE_PATH?: ((path: string) => string) | undefined; }; declare const OpenAPI: OpenAPIConfig; declare abstract class BaseHttpRequest { readonly config: OpenAPIConfig; constructor(config: OpenAPIConfig); abstract request<T>(options: ApiRequestOptions): CancelablePromise<T>; } type ApiKeyCreateRequest = { /** * A user-specified API key name. This value is required when creating an API key. */ key_name: string; }; type ApiKeyCreateResponse = { /** * The API key ID */ id: number; /** * The generated 64-bit token required to access the Neon API */ key: string; /** * The user-specified API key name */ name: string; /** * A timestamp indicating when the API key was created */ created_at: string; /** * ID of the user who created this API key */ created_by: string; }; type ApiKeyRevokeResponse = { /** * The API key ID */ id: number; /** * The user-specified API key name */ name: string; /** * A timestamp indicating when the API key was created */ created_at: string; /** * ID of the user who created this API key */ created_by: string; /** * A timestamp indicating when the API was last used */ last_used_at?: string | null; /** * The IP address from which the API key was last used */ last_used_from_addr: string; /** * A `true` or `false` value indicating whether the API key is revoked */ revoked: boolean; }; /** * The user data of the user that created this API key. */ type ApiKeyCreatorData = { /** * ID of the user who created this API key */ id: string; /** * The name of the user. */ name: string; /** * The URL to the user's avatar image. */ image: string; }; type ApiKeysListResponseItem = { /** * The API key ID */ id: number; /** * The user-specified API key name */ name: string; /** * A timestamp indicating when the API key was created */ created_at: string; created_by: ApiKeyCreatorData; /** * A timestamp indicating when the API was last used */ last_used_at?: string | null; /** * The IP address from which the API key was last used */ last_used_from_addr: string; }; type ErrorCode = string; /** * General Error */ type GeneralError = { request_id?: string; code: ErrorCode; /** * Error message */ message: string; }; declare class ApiKeyService { readonly httpRequest: BaseHttpRequest; constructor(httpRequest: BaseHttpRequest); /** * List API keys * Retrieves the API keys for your Neon account. * The response does not include API key tokens. A token is only provided when creating an API key. * API keys can also be managed in the Neon Console. * For more information, see [Manage API keys](https://neon.tech/docs/manage/api-keys/). * * @returns ApiKeysListResponseItem Returned the API keys for the Neon account * @returns GeneralError General Error * @throws ApiError */ listApiKeys(): CancelablePromise<Array<ApiKeysListResponseItem> | GeneralError>; /** * Create API key * Creates an API key. * The `key_name` is a user-specified name for the key. * This method returns an `id` and `key`. The `key` is a randomly generated, 64-bit token required to access the Neon API. * API keys can also be managed in the Neon Console. * See [Manage API keys](https://neon.tech/docs/manage/api-keys/). * * @param requestBody * @returns ApiKeyCreateResponse Created an API key * @returns GeneralError General Error * @throws ApiError */ createApiKey(requestBody: ApiKeyCreateRequest): CancelablePromise<ApiKeyCreateResponse | GeneralError>; /** * Revoke API key * Revokes the specified API key. * An API key that is no longer needed can be revoked. * This action cannot be reversed. * You can obtain `key_id` values by listing the API keys for your Neon account. * API keys can also be managed in the Neon Console. * See [Manage API keys](https://neon.tech/docs/manage/api-keys/). * * @param keyId The API key ID * @returns ApiKeyRevokeResponse Revoked the specified API key * @returns GeneralError General Error * @throws ApiError */ revokeApiKey(keyId: number): CancelablePromise<ApiKeyRevokeResponse | GeneralError>; } type IdentitySupportedAuthProvider = 'mock' | 'stack'; type IdentityCreateAuthProviderSDKKeysRequest = { project_id: string; auth_provider: IdentitySupportedAuthProvider; }; type IdentityCreateIntegrationRequest = { auth_provider: IdentitySupportedAuthProvider; project_id: string; branch_id: string; database_name: string; role_name: string; }; type IdentityCreateIntegrationResponse = { auth_provider: IdentitySupportedAuthProvider; auth_provider_project_id: string; pub_client_key: string; secret_server_key: string; jwks_url: string; schema_name: string; table_name: string; }; type IdentityTransferAuthProviderProjectRequest = { project_id: string; auth_provider: IdentitySupportedAuthProvider; }; type IdentityTransferAuthProviderProjectResponse = { /** * URL for completing the process of ownership transfer */ url: string; }; type IdentityAuthProviderProjectOwnedBy = 'user' | 'neon'; type IdentityAuthProviderProjectTransferStatus = 'initiated' | 'finished'; type IdentityIntegration = { auth_provider: string; auth_provider_project_id: string; branch_id: string; db_name: string; created_at: string; owned_by: IdentityAuthProviderProjectOwnedBy; transfer_status?: IdentityAuthProviderProjectTransferStatus; jwks_url: string; }; type ListProjectIdentityIntegrationsResponse = { data: Array<IdentityIntegration>; }; declare class AuthService { readonly httpRequest: BaseHttpRequest; constructor(httpRequest: BaseHttpRequest); /** * Create Neon Auth integration * Creates a project on a third-party authentication provider's platform for use with Neon Auth. * Use this endpoint if the frontend integration flow can't be used. * * @param requestBody * @returns GeneralError General Error * @returns IdentityCreateIntegrationResponse Creates Neon Auth integration * @throws ApiError */ createProjectIdentityIntegration(requestBody: IdentityCreateIntegrationRequest): CancelablePromise<GeneralError | IdentityCreateIntegrationResponse>; /** * Create Auth Provider SDK keys * Generates SDK or API Keys for the auth provider. These might be called different things depending * on the auth provider you're using, but are generally used for setting up the frontend and backend SDKs. * * @param requestBody * @returns GeneralError General Error * @returns IdentityCreateIntegrationResponse Creates Auth Provider SDK keys * @throws ApiError */ createProjectIdentityAuthProviderSdkKeys(requestBody: IdentityCreateAuthProviderSDKKeysRequest): CancelablePromise<GeneralError | IdentityCreateIntegrationResponse>; /** * Transfer Neon-managed auth project to your own account * Transfer ownership of your Neon-managed auth project to your own auth provider account. * * @param requestBody * @returns IdentityTransferAuthProviderProjectResponse Transfer initiated. Follow the URL to complete the process in your auth provider's UI. * @returns GeneralError General Error * @throws ApiError */ transferProjectIdentityAuthProviderProject(requestBody: IdentityTransferAuthProviderProjectRequest): CancelablePromise<IdentityTransferAuthProviderProjectResponse | GeneralError>; /** * Lists active integrations with auth providers * @param projectId The Neon project ID * @returns ListProjectIdentityIntegrationsResponse Return management API keys metadata * @returns GeneralError General Error * @throws ApiError */ listProjectIdentityIntegrations(projectId: string): CancelablePromise<ListProjectIdentityIntegrationsResponse | GeneralError>; /** * Delete integration with auth provider * @param projectId The Neon project ID * @param authProvider The authentication provider name * @returns any Delete the integration with the authentication provider * @returns GeneralError General Error * @throws ApiError */ deleteProjectIdentityIntegration(projectId: string, authProvider: IdentitySupportedAuthProvider): CancelablePromise<any | GeneralError>; } /** * Annotation properties. */ type AnnotationValueData = Record<string, string>; type AnnotationCreateValueRequest = { annotation_value?: AnnotationValueData; }; type AnnotationObjectData = { type: string; id: string; }; type AnnotationData = { object: AnnotationObjectData; value: AnnotationValueData; created_at?: string; updated_at?: string; }; type AnnotationResponse = { annotation: AnnotationData; }; type AnnotationsMapResponse = { annotations: Record<string, AnnotationData>; }; type ComputeUnit = number; /** * The compute endpoint type. Either `read_write` or `read_only`. * */ type EndpointType = 'read_only' | 'read_write'; /** * The Neon compute provisioner. * Specify the `k8s-neonvm` provisioner to create a compute endpoint that supports Autoscaling. * * Provisioner can be one of the following values: * * k8s-pod * * k8s-neonvm * * Clients must expect, that any string value that is not documented in the description above should be treated as a error. UNKNOWN value if safe to treat as an error too. * */ type Provisioner = string; /** * Duration of inactivity in seconds after which the compute endpoint is * automatically suspended. The value `0` means use the default value. * The value `-1` means never suspend. The default value is `300` seconds (5 minutes). * The minimum value is `60` seconds (1 minute). * The maximum value is `604800` seconds (1 week). For more information, see * [Scale to zero configuration](https://neon.tech/docs/manage/endpoints#scale-to-zero-configuration). * */ type SuspendTimeoutSeconds = number; type BranchCreateRequestEndpointOptions = { type: EndpointType; /** * The minimum number of Compute Units. The minimum value is `0.25`. * See [Compute size and Autoscaling configuration](https://neon.tech/docs/manage/endpoints#compute-size-and-autoscaling-configuration) * for more information. * */ autoscaling_limit_min_cu?: ComputeUnit; /** * The maximum number of Compute Units. * See [Compute size and Autoscaling configuration](https://neon.tech/docs/manage/endpoints#compute-size-and-autoscaling-configuration) * for more information. * */ autoscaling_limit_max_cu?: ComputeUnit; provisioner?: Provisioner; suspend_timeout_seconds?: SuspendTimeoutSeconds; }; type BranchCreateRequest = { endpoints?: Array<BranchCreateRequestEndpointOptions>; branch?: { /** * The `branch_id` of the parent branch. If omitted or empty, the branch will be created from the project's default branch. * */ parent_id?: string; /** * The branch name * */ name?: string; /** * A Log Sequence Number (LSN) on the parent branch. The branch will be created with data from this LSN. * */ parent_lsn?: string; /** * A timestamp identifying a point in time on the parent branch. The branch will be created with data starting from this point in time. * The timestamp must be provided in ISO 8601 format; for example: `2024-02-26T12:00:00Z`. * */ parent_timestamp?: string; /** * Whether the branch is protected * */ protected?: boolean; /** * Whether to create the branch as archived * */ archived?: boolean; /** * The source of initialization for the branch. Valid values are `schema-only` and `parent-data` (default). * * `schema-only` - creates a new root branch containing only the schema. Use `parent_id` to specify the source branch. Optionally, you can provide `parent_lsn` or `parent_timestamp` to branch from a specific point in time or LSN. These fields define which branch to copy the schema from and at what point—they do not establish a parent-child relationship between the `parent_id` branch and the new schema-only branch. * * `parent-data` - creates the branch with both schema and data from the parent. * */ init_source?: string; }; }; type BranchesCountResponse = { count: number; }; /** * The branch’s state, indicating if it is initializing, ready for use, or archived. * * 'init' - the branch is being created but is not available for querying. * * 'ready' - the branch is fully operational and ready for querying. Expect normal query response times. * * 'archived' - the branch is stored in cost-effective archival storage. Expect slow query response times. * */ type BranchState = string; type Branch = { /** * The branch ID. This value is generated when a branch is created. A `branch_id` value has a `br` prefix. For example: `br-small-term-683261`. * */ id: string; /** * The ID of the project to which the branch belongs * */ project_id: string; /** * The `branch_id` of the parent branch * */ parent_id?: string; /** * The Log Sequence Number (LSN) on the parent branch from which this branch was created * */ parent_lsn?: string; /** * The point in time on the parent branch from which this branch was created * */ parent_timestamp?: string; /** * The branch name * */ name: string; current_state: BranchState; pending_state?: BranchState; /** * A UTC timestamp indicating when the `current_state` began * */ state_changed_at: string; /** * The logical size of the branch, in bytes * */ logical_size?: number; /** * The branch creation source * */ creation_source: string; /** * DEPRECATED. Use `default` field. * Whether the branch is the project's primary branch * * @deprecated */ primary?: boolean; /** * Whether the branch is the project's default branch * */ default: boolean; /** * Whether the branch is protected * */ protected: boolean; /** * CPU seconds used by all of the branch's compute endpoints, including deleted ones. * This value is reset at the beginning of each billing period. * Examples: * 1. A branch that uses 1 CPU for 1 second is equal to `cpu_used_sec=1`. * 2. A branch that uses 2 CPUs simultaneously for 1 second is equal to `cpu_used_sec=2`. * * @deprecated */ cpu_used_sec: number; compute_time_seconds: number; active_time_seconds: number; written_data_bytes: number; data_transfer_bytes: number; /** * A timestamp indicating when the branch was created * */ created_at: string; /** * A timestamp indicating when the branch was last updated * */ updated_at: string; /** * A timestamp indicating when the branch was last reset * */ last_reset_at?: string; /** * The resolved user model that contains details of the user/org/integration/api_key used for branch creation. This field is filled only in listing/get/create/get/update/delete methods, if it is empty when calling other handlers, it does not mean that it is empty in the system. * */ created_by?: { /** * The name of the user. */ name?: string; /** * The URL to the user's avatar image. */ image?: string; }; /** * The source of initialization for the branch. Valid values are `schema-only` and `parent-data` (default). * * `schema-only` - creates a new root branch containing only the schema. Use `parent_id` to specify the source branch. Optionally, you can provide `parent_lsn` or `parent_timestamp` to branch from a specific point in time or LSN. These fields define which branch to copy the schema from and at what point—they do not establish a parent-child relationship between the `parent_id` branch and the new schema-only branch. * * `parent-data` - creates the branch with both schema and data from the parent. * */ init_source?: string; }; type BranchesResponse = { branches: Array<Branch>; }; type BranchResponse = { branch: Branch; }; /** * The action performed by the operation */ type OperationAction = 'create_compute' | 'create_timeline' | 'start_compute' | 'suspend_compute' | 'apply_config' | 'check_availability' | 'delete_timeline' | 'create_branch' | 'import_data' | 'tenant_ignore' | 'tenant_attach' | 'tenant_detach' | 'tenant_reattach' | 'replace_safekeeper' | 'disable_maintenance' | 'apply_storage_config' | 'prepare_secondary_pageserver' | 'switch_pageserver' | 'detach_parent_branch' | 'timeline_archive' | 'timeline_unarchive' | 'start_reserved_compute' | 'sync_dbs_and_roles_from_compute' | 'apply_schema_from_branch'; /** * The status of the operation */ type OperationStatus = 'scheduling' | 'running' | 'finished' | 'failed' | 'error' | 'cancelling' | 'cancelled' | 'skipped'; type Operation = { /** * The operation ID */ id: string; /** * The Neon project ID */ project_id: string; /** * The branch ID */ branch_id?: string; /** * The endpoint ID */ endpoint_id?: string; action: OperationAction; status: OperationStatus; /** * The error that occurred */ error?: string; /** * The number of times the operation failed */ failures_count: number; /** * A timestamp indicating when the operation was last retried */ retry_at?: string; /** * A timestamp indicating when the operation was created */ created_at: string; /** * A timestamp indicating when the operation status was last updated */ updated_at: string; /** * The total duration of the operation in milliseconds */ total_duration_ms: number; }; type OperationsResponse = { operations: Array<Operation>; }; type BranchOperations = (BranchResponse & OperationsResponse); type BranchRestoreRequest = { /** * The `branch_id` of the restore source branch. * If `source_timestamp` and `source_lsn` are omitted, the branch will be restored to head. * If `source_branch_id` is equal to the branch's id, `source_timestamp` or `source_lsn` is required. * */ source_branch_id: string; /** * A Log Sequence Number (LSN) on the source branch. The branch will be restored with data from this LSN. * */ source_lsn?: string; /** * A timestamp identifying a point in time on the source branch. The branch will be restored with data starting from this point in time. * The timestamp must be provided in ISO 8601 format; for example: `2024-02-26T12:00:00Z`. * */ source_timestamp?: string; /** * If not empty, the previous state of the branch will be saved to a branch with this name. * If the branch has children or the `source_branch_id` is equal to the branch id, this field is required. All existing child branches will be moved to the newly created branch under the name `preserve_under_name`. * */ preserve_under_name?: string; }; type BranchSchemaCompareResponse = { diff?: string; }; type BranchSchemaResponse = { sql?: string; }; type BranchUpdateRequest = { branch: { name?: string; protected?: boolean; }; }; type ConnectionParameters = { /** * Database name * */ database: string; /** * Password for the role * */ password: string; /** * Role name * */ role: string; /** * Hostname * */ host: string; /** * Pooler hostname * */ pooler_host: string; }; type ConnectionDetails = { /** * The connection URI is defined as specified here: [Connection URIs](https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING-URIS) * The connection URI can be used to connect to a Postgres database with psql or defined in a DATABASE_URL environment variable. * When creating a branch from a parent with more than one role or database, the response body does not include a connection URI. * */ connection_uri: string; connection_parameters: ConnectionParameters; }; type ConnectionURIsOptionalResponse = { connection_uris?: Array<ConnectionDetails>; }; /** * To paginate the response, issue an initial request with `limit` value. Then, add the value returned in the response `.pagination.next` attribute into the request under the `cursor` query parameter to the subsequent request to retrieve next page in pagination. The contents on cursor `next` are opaque, clients are not expected to make any assumptions on the format of the data inside the cursor. */ type CursorPagination = { next?: string; sort_by?: string; sort_order?: string; }; type CursorPaginationResponse = { pagination?: CursorPagination; }; type DatabaseCreateRequest = { database: { /** * The name of the database * */ name: string; /** * The name of the role that owns the database * */ owner_name: string; }; }; type Database = { /** * The database ID * */ id: number; /** * The ID of the branch to which the database belongs * */ branch_id: string; /** * The database name * */ name: string; /** * The name of role that owns the database * */ owner_name: string; /** * A timestamp indicating when the database was created * */ created_at: string; /** * A timestamp indicating when the database was last updated * */ updated_at: string; }; type DatabaseResponse = { database: Database; }; type DatabaseOperations = (DatabaseResponse & OperationsResponse); type DatabasesResponse = { databases: Array<Database>; }; type DatabaseUpdateRequest = { database: { /** * The name of the database * */ name?: string; /** * The name of the role that owns the database * */ owner_name?: string; }; }; /** * The connection pooler mode. Neon supports PgBouncer in `transaction` mode only. * */ type EndpointPoolerMode = 'transaction'; /** * A raw representation of PgBouncer settings */ type PgbouncerSettingsData = Record<string, string>; /** * A raw representation of Postgres settings */ type PgSettingsData = Record<string, string>; /** * A collection of settings for a compute endpoint */ type EndpointSettingsData = { pg_settings?: PgSettingsData; pgbouncer_settings?: PgbouncerSettingsData; }; /** * The state of the compute endpoint * */ type EndpointState = 'init' | 'active' | 'idle'; type Endpoint = { /** * The hostname of the compute endpoint. This is the hostname specified when connecting to a Neon database. * */ host: string; /** * The compute endpoint ID. Compute endpoint IDs have an `ep-` prefix. For example: `ep-little-smoke-851426` * */ id: string; /** * The ID of the project to which the compute endpoint belongs * */ project_id: string; /** * The ID of the branch that the compute endpoint is associated with * */ branch_id: string; /** * The minimum number of Compute Units * */ autoscaling_limit_min_cu: ComputeUnit; /** * The maximum number of Compute Units * */ autoscaling_limit_max_cu: ComputeUnit; /** * The region identifier * */ region_id: string; type: EndpointType; current_state: EndpointState; pending_state?: EndpointState; settings: EndpointSettingsData; /** * Whether connection pooling is enabled for the compute endpoint * */ pooler_enabled: boolean; pooler_mode: EndpointPoolerMode; /** * Whether to restrict connections to the compute endpoint. * Enabling this option schedules a suspend compute operation. * A disabled compute endpoint cannot be enabled by a connection or * console action. However, the compute endpoint is periodically * enabled by check_availability operations. * */ disabled: boolean; /** * Whether to permit passwordless access to the compute endpoint * */ passwordless_access: boolean; /** * A timestamp indicating when the compute endpoint was last active * */ last_active?: string; /** * The compute endpoint creation source * */ creation_source: string; /** * A timestamp indicating when the compute endpoint was created * */ created_at: string; /** * A timestamp indicating when the compute endpoint was last updated * */ updated_at: string; /** * DEPRECATED. Use the "host" property instead. * */ proxy_host: string; suspend_timeout_seconds: SuspendTimeoutSeconds; provisioner: Provisioner; /** * Attached compute's release version number. * */ compute_release_version?: string; }; type EndpointsResponse = { endpoints: Array<Endpoint>; }; type RoleCreateRequest = { role: { /** * The role name. Cannot exceed 63 bytes in length. * */ name: string; /** * Whether to create a role that cannot login. * */ no_login?: boolean; }; }; type Role = { /** * The ID of the branch to which the role belongs * */ branch_id: string; /** * The role name * */ name: string; /** * The role password * */ password?: string; /** * Whether or not the role is system-protected * */ protected?: boolean; /** * A timestamp indicating when the role was created * */ created_at: string; /** * A timestamp indicating when the role was last updated * */ updated_at: string; }; type RoleResponse = { role: Role; }; type RoleOperations = (RoleResponse & OperationsResponse); type RolePasswordResponse = { /** * The role password * */ password: string; }; type RolesResponse = { roles: Array<Role>; }; declare class BranchService { readonly httpRequest: BaseHttpRequest; constructor(httpRequest: BaseHttpRequest); /** * Create branch * Creates a branch in the specified project. * You can obtain a `project_id` by listing the projects for your Neon account. * * This method does not require a request body, but you can specify one to create a compute endpoint for the branch or to select a non-default parent branch. * The default behavior is to create a branch from the project's default branch with no compute endpoint, and the branch name is auto-generated. * There is a maximum of one read-write endpoint per branch. * A branch can have multiple read-only endpoints. * For related information, see [Manage branches](https://neon.tech/docs/manage/branches/). * * @param projectId The Neon project ID * @param requestBody * @returns GeneralError General Error * @returns any Created a branch. An endpoint is only created if it was specified in the request. * @throws ApiError */ createProjectBranch(projectId: string, requestBody?: (BranchCreateRequest & AnnotationCreateValueRequest)): CancelablePromise<GeneralError | (BranchResponse & EndpointsResponse & OperationsResponse & RolesResponse & DatabasesResponse & ConnectionURIsOptionalResponse)>; /** * List branches * Retrieves a list of branches for the specified project. * You can obtain a `project_id` by listing the projects for your Neon account. * * Each Neon project has a root branch named `main`. * A `branch_id` value has a `br-` prefix. * A project may contain child branches that were branched from `main` or from another branch. * A parent branch is identified by the `parent_id` value, which is the `id` of the parent branch. * For related information, see [Manage branches](https://neon.tech/docs/manage/branches/). * * @param projectId The Neon project ID * @param search Search by branch `name` or `id`. You can specify partial `name` or `id` values to filter results. * @param sortBy Sort the branches by sort_field. If not provided, branches will be sorted by updated_at descending order * @param cursor A cursor to use in pagination. A cursor defines your place in the data list. Include `response.pagination.next` in subsequent API calls to fetch next page of the list. * @param sortOrder Defines the sorting order of entities. * @param limit The maximum number of records to be returned in the response * @returns any Returned a list of branches for the specified project * @returns GeneralError General Error * @throws ApiError */ listProjectBranches(projectId: string, search?: string, sortBy?: 'name' | 'created_at' | 'updated_at', cursor?: string, sortOrder?: 'asc' | 'desc', limit?: number): CancelablePromise<(BranchesResponse & AnnotationsMapResponse & CursorPaginationResponse) | GeneralError>; /** * Retrieve number of branches * Retrieves the total number of branches in the specified project. * You can obtain a `project_id` by listing the projects for your Neon account. * * @param projectId The Neon project ID * @param search Count branches matching the `name` in search query * @returns any Returned a count of branches for the specified project * @returns GeneralError General Error * @throws ApiError */ countProjectBranches(projectId: string, search?: string): CancelablePromise<BranchesCountResponse | GeneralError>; /** * Retrieve branch details * Retrieves information about the specified branch. * You can obtain a `project_id` by listing the projects for your Neon account. * You can obtain a `branch_id` by listing the project's branches. * A `branch_id` value has a `br-` prefix. * * Each Neon project is initially created with a root and default branch named `main`. * A project can contain one or more branches. * A parent branch is identified by a `parent_id` value, which is the `id` of the parent branch. * For related information, see [Manage branches](https://neon.tech/docs/manage/branches/). * * @param projectId The Neon project ID * @param branchId The branch ID * @returns any Returned information about the specified branch * @returns GeneralError General Error * @throws ApiError */ getProjectBranch(projectId: string, branchId: string): CancelablePromise<(BranchResponse & AnnotationResponse) | GeneralError>; /** * Delete branch * Deletes the specified branch from a project, and places * all compute endpoints into an idle state, breaking existing client connections. * You can obtain a `project_id` by listing the projects for your Neon account. * You can obtain a `branch_id` by listing the project's branches. * For related information, see [Manage branches](https://neon.tech/docs/manage/branches/). * * When a successful response status is received, the compute endpoints are still active, * and the branch is not yet deleted from storage. * The deletion occurs after all operations finish. * You cannot delete a project's root or default branch, and you cannot delete a branch that has a child branch. * A project must have at least one branch. * * @param projectId The Neon project ID * @param branchId The branch ID * @returns BranchOperations Deleted the specified branch * @returns GeneralError General Error * @throws ApiError */ deleteProjectBranch(projectId: string, branchId: string): CancelablePromise<BranchOperations | GeneralError>; /** * Update branch * Updates the specified branch. * You can obtain a `project_id` by listing the projects for your Neon account. * You can obtain the `branch_id` by listing the project's branches. * For more information, see [Manage branches](https://neon.tech/docs/manage/branches/). * * @param projectId The Neon project ID * @param branchId The branch ID * @param requestBody * @returns BranchOperations Updated the specified branch * @returns GeneralError General Error * @throws ApiError */ updateProjectBranch(projectId: string, branchId: string, requestBody: BranchUpdateRequest): CancelablePromise<BranchOperations | GeneralError>; /** * Restore branch * Restores a branch to an earlier state in its own or another branch's history * @param projectId The Neon project ID * @param branchId The branch ID * @param requestBody * @returns BranchOperations Updated the specified branch * @returns GeneralError General Error * @throws ApiError */ restoreProjectBranch(projectId: string, branchId: string, requestBody: BranchRestoreRequest): CancelablePromise<BranchOperations | GeneralError>; /** * Retrieve database schema * Retrieves the schema from the specified database. The `lsn` and `timestamp` values cannot be specified at the same time. If both are omitted, the database schema is retrieved from database's head. * @param projectId The Neon project ID * @param branchId The branch ID * @param dbName Name of the database for which the schema is retrieved * @param lsn The Log Sequence Number (LSN) for which the schema is retrieved * * @param timestamp The point in time for which the schema is retrieved * * @returns BranchSchemaResponse Schema definition * @returns GeneralError General Error * @throws ApiError */ getProjectBranchSchema(projectId: string, branchId: string, dbName: string, lsn?: string, timestamp?: string): CancelablePromise<BranchSchemaResponse | GeneralError>; /** * Compare database schema * Compares the schema from the specified database with another branch's schema. * @param projectId The Neon project ID * @param branchId The branch ID * @param dbName Name of the database for which the schema is retrieved * @param baseBranchId The branch ID to compare the schema with * @param lsn The Log Sequence Number (LSN) for which the schema is retrieved * * @param timestamp The point in time for which the schema is retrieved * * @param baseLsn The Log Sequence Number (LSN) for the base branch schema * * @param baseTimestamp The point in time for the base branch schema * * @returns BranchSchemaCompareResponse Difference between the schemas * @returns GeneralError General Error * @throws ApiError */ getProjectBranchSchemaComparison(projectId: string, branchId: string, dbName: string, baseBranchId?: string, lsn?: string, timestamp?: string, baseLsn?: string, baseTimestamp?: string): CancelablePromise<BranchSchemaCompareResponse | GeneralError>; /** * Set branch as default * Sets the specified branch as the project's default branch. * The default designation is automatically removed from the previous default branch. * You can obtain a `project_id` by listing the projects for your Neon account. * You can obtain the `branch_id` by listing the project's branches. * For more information, see [Manage branches](https://neon.tech/docs/manage/branches/). * * @param projectId The Neon project ID * @param branchId The branch ID * @returns BranchOperations Updated the specified branch * @returns GeneralError General Error * @throws ApiError */ setDefaultProjectBranch(projectId: string, branchId: string): CancelablePromise<BranchOperations | GeneralError>; /** * List branch endpoints * Retrieves a list of compute endpoints for the specified branch. * Neon permits only one read-write compute endpoint per branch. * A branch can have multiple read-only compute endpoints. * You can obtain a `project_id` by listing the projects for your Neon account. * You can obtain the `branch_id` by listing the project's branches. * * @param projectId The Neon project ID * @param branchId The branch ID * @returns EndpointsResponse Returned a list of endpoints for the specified branch * @returns GeneralError General Error * @throws ApiError */ listProjectBranchEndpoints(projectId: string, branchId: string): CancelablePromise<EndpointsResponse | GeneralError>; /** * List databases * Retrieves a list of databases for the specified branch. * A branch can have multiple databases. * You can obtain a `project_id` by listing the projects for your Neon account. * You can obtain the `branch_id` by listing the project's branches. * For related information, see [Manage databases](https://neon.tech/docs/manage/databases/). * * @param projectId The Neon project ID * @param branchId The branch ID * @returns DatabasesResponse Returned a list of databases of the specified branch * @returns GeneralError General Error * @throws ApiError */ listProjectBranchDatabases(projectId: string, branchId: string): CancelablePromise<DatabasesResponse | GeneralError>; /** * Create database * Creates a database in the specified branch. * A branch can have multiple databases. * You can obtain a `project_id` by listing the projects for your Neon account. * You can obtain the `branch_id` by listing the project's branches. * For related information, see [Manage databases](https://neon.tech/docs/manage/databases/). * * @param projectId The Neon project ID * @param branchId The branch ID * @param requestBody * @returns GeneralError General Error * @returns DatabaseOperations Created a database in the specified branch * @throws ApiError */ createProjectBranchDatabase(projectId: string, branchId: string, requestBody: DatabaseCreateRequest): CancelablePromise<GeneralError | DatabaseOperations>; /** * Retrieve database details * Retrieves information about the specified database. * You can obtain a `project_id` by listing the projects for your Neon account. * You can obtain the `branch_id` and `database_name` by listing the branch's databases. * For related information, see [Manage databases](https://neon.tech/docs/manage/databases/). * * @param projectId The Neon project ID * @param branchId The branch ID * @param databaseName The database name * @returns DatabaseResponse Returned the database details * @returns GeneralError General Error * @throws ApiError */ getProjectBranchDatabase(projectId: string, branchId: string, databaseName: string): CancelablePromise<DatabaseResponse | GeneralError>; /** * Update database * Updates the specified database in the branch. * You can obtain a `project_id` by listing the projects for your Neon account. * You can obtain the `branch_id` and `database_name` by listing the branch's databases. * For related information, see [Manage databases](https://neon.tech/docs/manage/databases/). * * @param projectId The Neon project ID * @param branchId The branch ID * @param databaseName The database name * @param requestBody * @returns DatabaseOperations Updated the database * @returns GeneralError General Error * @throws ApiError */ updateProjectBranchDatabase(projectId: string, branchId: string, databaseName: string, requestBody: DatabaseUpdateRequest): CancelablePromise<DatabaseOperations | GeneralError>; /** * Delete database * Deletes the specified database from the branch. * You can obtain a `project_id` by listing the projects for your Neon account. * You can obtain the `branch_id` and `database_name` by listing the branch's databases. * For related information, see [Manage databases](https://neon.tech/docs/manage/databases/). * * @param projectId The Neon project ID * @param branchId The branch ID * @param databaseName The database name * @returns DatabaseOperations Deleted the specified database * @returns GeneralError General Error * @throws ApiError */ deleteProjectBranchDatabase(projectId: string, branchId: string, databaseName: string): CancelablePromise<DatabaseOperations | GeneralError>; /** * List roles * Retrieves a list of Postgres roles from the specified branch. * You can obtain a `project_id` by listing the projects for your Neon account. * You can obtain the `branch_id` by listing the project's branches. * For related information, see [Manage roles](https://neon.tech/docs/manage/roles/). * * @param projectId The Neon project ID * @param branchId The branch ID * @returns RolesResponse Returned a list of roles from the specified branch. * @returns GeneralError General Error * @throws ApiError */ listProjectBranchRoles(projectId: string, branchId: string): CancelablePromise<RolesResponse | GeneralError>; /** * Create role * Creates a Postgres role in the specified branch. * You can obtain a `project_id` by listing the projects for your Neon account. * You can obtain the `branch_id` by listing the project's branches. * For related information, see [Manage roles](https://neon.tech/docs/manage/roles/). * * Connections established to the active compute endpoint will be dropped. * If the compute endpoint is idle, the endpoint becomes active for a short period of time and is suspended afterward. * * @param projectId The Neon project ID * @param branchId The branch ID * @param requestBody * @returns GeneralError General Error * @returns RoleOperations Created a role in the specified branch * @throws ApiError */ createProjectBranchRole(projectId: string, branchId: string, requestBody: RoleCreateRequest): CancelablePromise<GeneralError | RoleOperations>; /** * Retrieve role details * Retrieves details about the specified role. * You can obtain a `project_id` by listing the projects for your Neon account. * You can obtain the `branch_id` by listing the project's branches. * You can obtain the `role_name` by listing the roles for a branch. * In Neon, the terms "role" and "user" are synonymous. * For related information, see [Manage roles](https://neon.tech/docs/manage/roles/). * * @param projectId The Neon project ID * @param branchId The branch ID * @param roleName The role name * @returns RoleResponse Returned details for the specified role * @returns GeneralError General Error * @throws ApiError */ getProjectBranchRole(projectId: string, branchId: string, roleName: string): CancelablePromise<RoleResponse | GeneralError>; /** * Delete role * Deletes the specified Postgres role from the branch. * You can obtain a `project_id` by listing the projects for your Neon account. * You can obtain the `branch_id` by listing the project's branches. * You can obtain the `role_name` by listing the roles for a branch. * For related information, see [Manage roles](https://neon.tech/docs/manage/roles/). * * @param projectId The Neon project ID * @param branchId The branch ID * @param roleName The role name * @returns RoleOperations Deleted the specified role from the branch * @returns GeneralError General Error * @throws ApiError */ deleteProjectBranchRole(projectId: string, branchId: string, roleName: string): CancelablePromise<RoleOperations | GeneralError>; /** * Retrieve role password * Retrieves the password for the specified Postgres role, if possible. * You can obtain a `project_id` by listing the projects for your Neon account. * You can obtain the `branch_id` by listing the project's branches. * You can obtain the `role_name` by listing the roles for a branch. * For related information, see [Manage roles](https://neon.tech/docs/manage/roles/). * * @param projectId The Neon project ID * @param branchId The branch ID * @param roleName The role name * @returns RolePasswordResponse Returned password for the specified role * @returns GeneralError General Error * @throws ApiError */ getProjectBranchRolePassword(projectId: string, branchId: string, roleName: string): CancelablePromise<RolePasswordResponse | GeneralError>; /** * Reset role password * Resets the password for the specified Postgres role. * Returns a new password and operations. The new password is ready to use when the last operation finishes. * The old password remains valid until last operation finishes. * Connections to the compute endpoint are dropped. If idle, * the compute endpoint becomes active for a short period of time. * * You can obtain a `project_id` by listing the projects for your Neon account. * You can obtain the `branch_id` by listing the project's branches. * You can obtain the `role_name` by listing the roles for a branch. * For related information, see [Manage roles](https://neon.tech/docs/manage/roles/). * * @param projectId The Neon project ID * @param branchId The branch ID * @param roleName The role nam * @returns RoleOperations Reset the password for the specified role * @returns GeneralError General Error * @throws ApiError */ resetProjectBranchRolePassword(projectId: string, branchId: string, roleName: string): CancelablePromise<RoleOperations | GeneralError>; } type ConsumptionHistoryGranularity = 'hourly' | 'daily' | 'monthly'; type ConsumptionHistoryPerTimeframe = { /** * The specified start date-time for the reported consumption. * */ timeframe_start: string; /** * The specified end date-time for the reported consumption. * */ timeframe_end: string; /** * Seconds. The amount of time the compute endpoints have been active. * */ active_time_seconds: number; /** * Seconds. The number of CPU seconds used by compute endpoints, including compute endpoints that have been deleted. * */ compute_time_seconds: number; /** * Bytes. The amount of written data for all branches. * */ written_data_bytes: number; /** * Bytes. The space occupied in storage. Synthetic storage size combines the logical data size and Write-Ahead Log (WAL) size for all branches. * */ synthetic_storage_size_bytes: number; /**