| 1 | import { |
| 2 | makeNamedHttpBinding, |
| 3 | type BindingIam, |
| 4 | type GcpHttpOp, |
| 5 | } from "../HttpBinding.ts"; |
| 6 | import type { AclPolicy } from "./AclPolicy.ts"; |
| 7 | import type { Instance } from "./Instance.ts"; |
| 8 | |
| 9 | /** |
| 10 | * Shared HTTP scaffolding for Memorystore Redis ACL policy bindings. |
| 11 | * NOT exported from index.ts. |
| 12 | */ |
| 13 | export const makeRedisHttpBinding = < |
| 14 | I extends { name?: string }, |
| 15 | A, |
| 16 | E, |
| 17 | >(options: { |
| 18 | tag: string; |
| 19 | operation: GcpHttpOp<I, A, E>; |
| 20 | }) => |
| 21 | // Memorystore has no resource-level IAM; viewer under an IAM Condition on |
| 22 | // the policy name covers reads. |
| 23 | makeNamedHttpBinding<AclPolicy, I, A, E>({ |
| 24 | tag: options.tag, |
| 25 | operation: options.operation, |
| 26 | iam: { role: "roles/redis.viewer", scopeByCondition: true }, |
| 27 | resourceName: (policy) => policy.name, |
| 28 | }); |
| 29 | |
| 30 | /** |
| 31 | * Shared HTTP scaffolding for Memorystore Redis instance bindings. |
| 32 | * NOT exported from index.ts. |
| 33 | */ |
| 34 | export const makeRedisInstanceHttpBinding = < |
| 35 | I extends { name?: string }, |
| 36 | A, |
| 37 | E, |
| 38 | >(options: { |
| 39 | tag: string; |
| 40 | iam: BindingIam; |
| 41 | operation: GcpHttpOp<I, A, E>; |
| 42 | }) => |
| 43 | makeNamedHttpBinding<Instance, I, A, E>({ |
| 44 | tag: options.tag, |
| 45 | operation: options.operation, |
| 46 | iam: options.iam, |
| 47 | resourceName: (instance) => instance.name, |
| 48 | }); |