| 1 | import * as cloudfunctions from "@distilled.cloud/gcp/cloudfunctions_v2"; |
| 2 | import * as Layer from "effect/Layer"; |
| 3 | import { makeFunctionHttpBinding } from "./BindingHttp.ts"; |
| 4 | import { GenerateDownloadUrl } from "./GenerateDownloadUrl.ts"; |
| 5 | |
| 6 | /** |
| 7 | * HTTP implementation of {@link GenerateDownloadUrl}. |
| 8 | * |
| 9 | * @layer |
| 10 | * @provides GCP.CloudFunctions.GenerateDownloadUrl |
| 11 | */ |
| 12 | export const GenerateDownloadUrlHttp = Layer.effect( |
| 13 | GenerateDownloadUrl, |
| 14 | makeFunctionHttpBinding({ |
| 15 | tag: "GCP.CloudFunctions.GenerateDownloadUrl", |
| 16 | // Narrowest predefined role with cloudfunctions.functions.sourceCodeGet. |
| 17 | // 2nd gen functions accept only invoker roles on their own IAM policy, |
| 18 | // so grant on the project under a condition naming the function. |
| 19 | iam: { role: "roles/cloudfunctions.developer", scopeByCondition: true }, |
| 20 | operation: cloudfunctions.generateDownloadUrlProjectsLocationsFunctions, |
| 21 | }), |
| 22 | ); |