| 1 | import * as kafka from "@distilled.cloud/gcp/managedkafka_v1"; |
| 2 | import { Credentials } from "@distilled.cloud/gcp/Credentials"; |
| 3 | import * as Layer from "effect/Layer"; |
| 4 | import * as HttpClient from "effect/http/HttpClient"; |
| 5 | import { makeManagedKafkaHttpBinding } from "./BindingHttp.ts"; |
| 6 | import { GetSchemaRegistry } from "./GetSchemaRegistry.ts"; |
| 7 | import type { SchemaRegistry } from "./SchemaRegistry.ts"; |
| 8 | |
| 9 | /** |
| 10 | * HTTP implementation of {@link GetSchemaRegistry}. |
| 11 | * |
| 12 | * @layer |
| 13 | * @provides GCP.ManagedKafka.GetSchemaRegistry |
| 14 | */ |
| 15 | export const GetSchemaRegistryHttp: Layer.Layer< |
| 16 | GetSchemaRegistry, |
| 17 | never, |
| 18 | Credentials | HttpClient.HttpClient |
| 19 | > = Layer.effect( |
| 20 | GetSchemaRegistry, |
| 21 | makeManagedKafkaHttpBinding<SchemaRegistry>()< |
| 22 | kafka.GetProjectsLocationsSchemaRegistriesRequest, |
| 23 | kafka.SchemaRegistry, |
| 24 | kafka.GetProjectsLocationsSchemaRegistriesError |
| 25 | >({ |
| 26 | tag: "GCP.ManagedKafka.GetSchemaRegistry", |
| 27 | // Schema-registry permission checks do not match a resource-name IAM |
| 28 | // Condition on the registry (the conditioned grant stayed denied live), |
| 29 | // so the read-only viewer role is granted on the project. |
| 30 | iam: { role: "roles/managedkafka.schemaRegistryViewer" }, |
| 31 | operation: kafka.getProjectsLocationsSchemaRegistries, |
| 32 | }), |
| 33 | ); |