| 1 | import type * as acmpca from "@distilled.cloud/aws/acm-pca"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { CertificateAuthority } from "./CertificateAuthority.ts"; |
| 5 | |
| 6 | export interface GetCertificateRequest extends Omit< |
| 7 | acmpca.GetCertificateRequest, |
| 8 | "CertificateAuthorityArn" |
| 9 | > {} |
| 10 | |
| 11 | /** |
| 12 | * Runtime binding for `acm-pca:GetCertificate`. |
| 13 | * |
| 14 | * Bind a {@link CertificateAuthority} inside a function runtime to retrieve |
| 15 | * a certificate previously issued by the CA (via the |
| 16 | * {@link IssueCertificate} binding). Issuance is asynchronous — retry while |
| 17 | * the typed `RequestInProgressException` is observed. Provide |
| 18 | * `ACMPCA.GetCertificateHttp` on the Function effect to implement the |
| 19 | * binding. |
| 20 | * |
| 21 | * ### Retrieving Issued Certificates |
| 22 | * **Example:** Poll for an Issued Certificate |
| 23 | * ```typescript |
| 24 | * // init |
| 25 | * const getCertificate = yield* ACMPCA.GetCertificate(ca); |
| 26 | * |
| 27 | * // runtime |
| 28 | * const certificate = yield* getCertificate({ |
| 29 | * CertificateArn: issued.CertificateArn!, |
| 30 | * }).pipe( |
| 31 | * Effect.retry({ |
| 32 | * while: (e) => e._tag === "RequestInProgressException", |
| 33 | * schedule: Schedule.exponential("500 millis"), |
| 34 | * times: 8, |
| 35 | * }), |
| 36 | * ); |
| 37 | * // certificate.Certificate / certificate.CertificateChain (PEM) |
| 38 | * ``` |
| 39 | * |
| 40 | * @binding |
| 41 | */ |
| 42 | export interface GetCertificate extends Binding.Service< |
| 43 | GetCertificate, |
| 44 | "AWS.ACMPCA.GetCertificate", |
| 45 | ( |
| 46 | certificateAuthority: CertificateAuthority, |
| 47 | ) => Effect.Effect< |
| 48 | ( |
| 49 | request: GetCertificateRequest, |
| 50 | ) => Effect.Effect< |
| 51 | acmpca.GetCertificateResponse, |
| 52 | acmpca.GetCertificateError |
| 53 | > |
| 54 | > |
| 55 | > {} |
| 56 | |
| 57 | export const GetCertificate = Binding.Service<GetCertificate>( |
| 58 | "AWS.ACMPCA.GetCertificate", |
| 59 | ); |