| 1 | import type * as cloudfunctions from "@distilled.cloud/gcp/cloudfunctions_v2"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { RuntimeContext } from "../../RuntimeContext.ts"; |
| 5 | import type { Function as CloudFunction } from "./Function.ts"; |
| 6 | |
| 7 | export interface GenerateDownloadUrlRequest extends Omit< |
| 8 | cloudfunctions.GenerateDownloadUrlProjectsLocationsFunctionsRequest, |
| 9 | "name" |
| 10 | > {} |
| 11 | |
| 12 | /** |
| 13 | * Runtime binding for Cloud Functions `functions.generateDownloadUrl`. |
| 14 | * |
| 15 | * Bind this operation to a {@link Function} in a Function/Action init phase. |
| 16 | * Provide {@link GenerateDownloadUrlHttp}. The returned URL is valid for a |
| 17 | * limited time (about 30 minutes). Grants `roles/cloudfunctions.developer` |
| 18 | * (the narrowest predefined role with `functions.sourceCodeGet`) on the |
| 19 | * project under an IAM Condition naming only the bound function (2nd gen |
| 20 | * functions accept only invoker roles on their own IAM policy). |
| 21 | * |
| 22 | * ### Downloading Source |
| 23 | * **Example:** Generate a signed download URL |
| 24 | * ```typescript |
| 25 | * const download = yield* GCP.CloudFunctions.GenerateDownloadUrl(hello); |
| 26 | * const { downloadUrl } = yield* download(); |
| 27 | * ``` |
| 28 | * |
| 29 | * @binding |
| 30 | * @category CloudFunctions |
| 31 | */ |
| 32 | export interface GenerateDownloadUrl extends Binding.Service< |
| 33 | GenerateDownloadUrl, |
| 34 | "GCP.CloudFunctions.GenerateDownloadUrl", |
| 35 | ( |
| 36 | fn: CloudFunction, |
| 37 | ) => Effect.Effect< |
| 38 | ( |
| 39 | request?: GenerateDownloadUrlRequest, |
| 40 | ) => Effect.Effect< |
| 41 | cloudfunctions.GenerateDownloadUrlResponse, |
| 42 | cloudfunctions.GenerateDownloadUrlProjectsLocationsFunctionsError, |
| 43 | RuntimeContext |
| 44 | > |
| 45 | > |
| 46 | > {} |
| 47 | |
| 48 | export const GenerateDownloadUrl = Binding.Service<GenerateDownloadUrl>( |
| 49 | "GCP.CloudFunctions.GenerateDownloadUrl", |
| 50 | ); |