import type { PostgresCredentialInfoResult as AdvancedCredentialInfo, PostgresDatabaseInfoCredentialResult as NonAdvancedCredentialInfo, PostgresDatabaseRotateCredentialResult, PostgresDatabaseRotateCredentialsResult, PostgresRotateCredentialsResult } from '@heroku/types/data'; import { AddOnAttachment } from '@heroku/types/3.sdk'; import type { ResourceCtx } from '../../../core/extend-resource.js'; import type { ResolvedAddOn } from '../../platform/add-on/types.js'; import type { DatabaseCredentialOptions } from './index.js'; export type RotateDatabaseCredentialOptions = DatabaseCredentialOptions & { /** * Fires before the rotate request, allowing the caller to perform any * necessary pre-rotation checks or UI rendering. */ beforeRotate?: (preview: RotateDatabaseCredentialPreview) => Promise | void; }; export type RotateDatabaseCredentialOpts = { /** Rotate every credential on the database instead of a single one. */ all?: boolean; /** Name of the credential to rotate. Defaults to owner or default credential. */ credName?: string; /** Immediately kill connections using the credential(s) being rotated. */ forced?: boolean; }; /** * Resolved state of a rotation, passed to `beforeRotate` before the request * is sent: the add-on, the credential that will rotate, the owner and default * credentials, whether the database is Advanced or Essential tier, and the * add-on's attachments. */ export type RotateDatabaseCredentialPreview = { addon: ResolvedAddOn; attachments: AddOnAttachment[]; credToRotate?: AdvancedCredentialInfo | NonAdvancedCredentialInfo; defaultCred?: NonAdvancedCredentialInfo; isAdvancedTier: boolean; isEssentialTier: boolean; ownerCred?: AdvancedCredentialInfo; }; export type RotateAllDatabaseCredentialsResult = { addon: ResolvedAddOn; credentials: PostgresDatabaseRotateCredentialsResult | PostgresRotateCredentialsResult; }; export type RotateDatabaseCredentialResult = { addon: ResolvedAddOn; credential: PostgresDatabaseRotateCredentialResult | void; }; /** * Rotates one or all credentials on a Postgres database, dispatching to the * Advanced-tier or classic-tier endpoint based on the resolved add-on's plan. * * Essential and legacy Essential-tier databases don't support named-credential * rotation. */ export declare function rotate(ctx: Pick, addonIdentity: string, body: RotateDatabaseCredentialOpts & { all: true; }, options?: RotateDatabaseCredentialOptions): Promise; export declare function rotate(ctx: Pick, addonIdentity: string, body?: RotateDatabaseCredentialOpts, options?: RotateDatabaseCredentialOptions): Promise;