diff --git a/AGENTS.md b/AGENTS.md index 64cf024..6ea5a80 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -12,8 +12,25 @@ generates live [LikeC4](https://likec4.dev) architecture diagrams from the Aspir - The `AspireC4.Hosting` library (the Aspire integration). - An incremental Roslyn source generator (`AspireC4.SourceGenerators`) that validates registry constants and `.c4` DSL files against `.WithTag()`, `.WithKind()`, `.WithLikeC4Group()`, and `.WithMetadata()` call sites. +- An optional Entity Framework Core ER diagram: the `AspireC4.Hosting.EntityFrameworkCore` AppHost library, + the analyzer-only `AspireC4.EntityFrameworkCore` package and the `AspireC4.EntityFrameworkCore.ModelDump` + build-time tool. It is **additive** — `WithEntityFrameworkDiagram()` extends the builder `AddAspireC4()` + returns, so consumers run the architecture diagram alone or both diagrams, never the ER diagram alone. - A `TestAppHost` sample AppHost and a TypeScript AppHost sample. +### Packages and target frameworks + +| Package | Project | Target framework | Shipped as | +|---|---|---|---| +| `AspireC4.Hosting` | `src/src/AspireC4/` | `net10.0` | `lib/net10.0/` + `analyzers/dotnet/cs/` + `build/` | +| `AspireC4.Hosting.EntityFrameworkCore` | `src/src/EntityFrameworkCore/` | `net10.0` | `lib/net10.0/` | +| `AspireC4.EntityFrameworkCore` | `src/src/EntityFrameworkCore.Analyzers/` | `netstandard2.0` | `analyzers/dotnet/cs/` only (no runtime assembly) | +| `AspireC4.EntityFrameworkCore.ModelDump` | `src/src/EntityFrameworkCore.ModelDump/` | `net10.0` | `tools/` + `build/` | + +AppHosts therefore target `net10.0`. `src/Directory.Build.props` owns the framework; the two Roslyn +projects override it to `netstandard2.0`. The packed content is pinned to `lib/net10.0/...` in +`.config/purview-build.json`, so a framework change has to update that manifest too. + ### Layout | Path | Purpose | @@ -44,6 +61,15 @@ one about its own package, and update it when that package's public API or setup link the root `README.md` into a project with `Link="Sdk/README.md"`, which would override it. Use absolute URLs in package READMEs, because relative links do not resolve on nuget.org. +### Documentation screenshots + +Screenshots embedded in the root `README.md`, the wiki pages under `docs/wiki/` and the package READMEs +live in `docs/images/screenshots/`; its own `README.md` records provenance, consumers and how to refresh +them. Use a relative path from the root README, and absolute `raw.githubusercontent.com` URLs from +`docs/wiki/` (published from a separate repository) and from package READMEs (nuget.org). Skills under +`skills/` install on their own, so they never embed these files — name the diagram's export folder +(`./.aspirec4/images/`) in prose instead. + ## Toolchain | Tool | Purpose | Version source | @@ -122,8 +148,9 @@ just erd-svg # Render an emitted Mermaid .mmd to SVG in a one-shot ``` `erd-check` defaults to the model at `src/src/TestAppHost/.aspirec4/erd/schema.gen.json`, written by -`dotnet run --project src/src/TestAppHost`. Requires `bunx playwright install chromium` once. See the -`erd-viewer` skill in `.github/skills/` before changing the viewer or its checks. +`dotnet run --project src/src/TestAppHost`. Requires `bunx playwright install chromium` once. The checks +live in `scripts/erd-viewer-check.mts` and `scripts/erd-vendor.mts`; read them, and the viewer under +`src/src/EntityFrameworkCore/Assets/viewer/`, before changing either. ### Other @@ -290,8 +317,9 @@ headline. ## LikeC4 DSL work -When writing or validating `.c4`/`.likec4` files, load `.agents/skills/likec4-dsl/SKILL.md` and its -`references/*.md`. Key contracts: +When writing or validating `.c4`/`.likec4` files, load the `likec4-dsl` skill +(`.agents/skills/likec4-dsl/SKILL.md` plus its `references/*.md`) — install it first if it is missing, since +`.agents/skills/` is gitignored. Key contracts: - Validate with `likec4 validate` (never `check`/`lint`/`build`), prefer `likec4 validate --json --no-layout --file `. @@ -305,8 +333,8 @@ When writing or validating `.c4`/`.likec4` files, load `.agents/skills/likec4-ds (`.github/workflows/release.yml`, delegating to the `purview-dev/build` reusable `purview-release.yml` with `release-mode: NuGet`) reads and validates it, builds, tests, packs, builds release notes from conventional commits, and creates a GitHub Release with the `.nupkg`/`.snupkg`. It does **not** push to nuget.org. -- `.github/skills/release/SKILL.md` reflects the current pipeline correctly — keep it in sync when the release - process changes. Prefer `just pipeline-release` / `pipeline-local-release`. +- [Release Flow](docs/wiki/Release-Flow.md) and `.config/purview-build.json` describe the current pipeline — + keep both in sync when the release process changes. Prefer `just pipeline-release` / `pipeline-local-release`. - Roslyn diagnostics (`ASPIREC4001`–`ASPIREC4007`) are tracked in `src/src/SourceGenerators/AnalyzerReleases.Shipped.md` / `AnalyzerReleases.Unshipped.md`. Move unshipped rows into a new `## Release ` shipped section when cutting a release that adds, removes, or changes a rule. See @@ -314,14 +342,16 @@ When writing or validating `.c4`/`.likec4` files, load `.agents/skills/likec4-ds ## Skills -Relevant bundled skills in `.agents/skills/`: +Skills installed from other repositories live in `.agents/skills/` (gitignored); `skills-lock.json` +records what is installed. The families: -- `likec4-dsl` — LikeC4 DSL/CLI work. -- `project-placement-defaults`, `sdk-configuration-reference`, `sdk-project-behavior-and-detection` — - Purview.BuildSdk behaviour and configuration. -- `source-generator-codewriter-modernization`, `source-generator-testing`, `tunit-test-authoring` — - Roslyn generator work and tests. -- `telemetry-sourcegenerator-*` — Purview.Telemetry.SourceGenerator usage (library telemetry). +- `purview-architecture*`, `purview-engineering-principles`, `purview-testing-conventions` — architecture + and test conventions. +- `purview-buildsdk-*` — Purview.BuildSdk behaviour and configuration. +- `purview-containers-*` — the Purview.Containers packages this library consumes. +- `purview-sourcegenerator-*` — Roslyn generator authoring, packaging and tests. +- `purview-telemetry*` — Purview.Telemetry.SourceGenerator usage (library telemetry). +- `purview-persistence` — the EF Core conventions the ER diagram is drawn from. - Agents and prompts live in `.agents/agents/` and `.agents/prompts/`. ## Agent skills @@ -337,8 +367,8 @@ own skills are never installed into it - that would leave two copies to drift ap their authored path, `skills//SKILL.md`. `.github/skills/` is a third, separate place: skills about working *in* this repository, which would -be meaningless to a consumer who installed the published set. `release` and `erd-viewer` live there. -A skill that tells you how to run this repo's own tooling belongs in `.github/skills/`, never in +be meaningless to a consumer who installed the published set. A skill that tells you how to run this +repo's own tooling belongs in `.github/skills/`, never in `skills/` - `SkillTests` requires everything under `skills/` to carry the `purview-aspirec4` prefix because those names land in a directory shared with every skill a developer has installed. @@ -348,9 +378,10 @@ npx skills add purview-dev/aspirec4 | Skill | Answers | | -- | -- | -| `skills/purview-aspirec4-quickstart/` | installing, `AddAspireC4`, what happens on startup, Docker sidecar versus local CLI | +| `skills/purview-aspirec4-quickstart/` | installing, `AddAspireC4`, what happens on startup, Docker sidecar versus local CLI, and when to add the ER diagram as well | | `skills/purview-aspirec4-configuration/` | every `AspireC4DiagramOptions` property and its fluent method | | `skills/purview-aspirec4-resources/` | `WithLikeC4Details`, `WithLikeC4Reference`, `WithLikeC4Group`, and exclusion | +| `skills/purview-aspirec4-entityframework/` | `WithEntityFrameworkDiagram`, the three model-discovery sources, renderers, domain types, and ER image export | | `skills/purview-aspirec4-validation/` | the `[LikeC4Registry]` class, severity levels, and the `ASPIREC4xxx` diagnostics | Every skill carries the `purview-aspirec4` prefix. Skills install into one flat directory per agent, diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index cd36fe2..f3d7ce3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -261,6 +261,14 @@ config.Item("AppHost:BrowserToken").Returns("value"); |---|---| | `AspireC4.UnitTests` | `LikeC4ModelBuilder`, `LikeC4DslGenerator`, annotations, options — no Docker required | | `AspireC4.IntegrationTests` | Full Aspire lifecycle: container startup, file generation, endpoint availability | +| `EntityFrameworkCore.UnitTests` | d2 model builder, d2 DSL generator and descriptor loader — no Docker required | +| `EntityFrameworkCore.Analyzers.UnitTests` | EF model generator, plus the generator→assembly→AppHost round-trip | +| `SourceGenerators.UnitTests` | The registry/DSL strict-validation generator | +| `Repository.UnitTests` | Repository-level rules, including the authored skills in `skills/` | + +Every project targets `net10.0` except the two Roslyn components (`SourceGenerators` and +`EntityFrameworkCore.Analyzers`), which target `netstandard2.0`. The framework is set once in +`src/Directory.Build.props`, which is also where the `Aspire.Hosting.AspireC4` namespace prefix lives. Integration tests require Docker to be running. They pull `ghcr.io/likec4/likec4` on first run. diff --git a/README.md b/README.md index 293a1df..f1d4fc8 100644 --- a/README.md +++ b/README.md @@ -16,9 +16,40 @@ Each package ships its own README on NuGet; this document is the complete reference. +### Use one diagram or both + +`AspireC4.Hosting` is the **base** package: it is what registers AspireC4, generates the LikeC4 +architecture diagram and owns the dashboard integration. Everything else hangs off it. + +- **Architecture only** (the common case): install `AspireC4.Hosting` and call `AddAspireC4()`. +- **Architecture and ER diagram**: additionally install `AspireC4.Hosting.EntityFrameworkCore` and call + `.WithEntityFrameworkDiagram()` on the builder `AddAspireC4()` returns. `WithEntityFrameworkDiagram()` + is an extension on `IResourceBuilder`, so the architecture diagram is always present + — the ER diagram is additive, never a replacement. +- **ER diagram at full fidelity**: optionally add `AspireC4.EntityFrameworkCore` (to the project that + declares the `DbContext`) and/or `AspireC4.EntityFrameworkCore.ModelDump` (to the project that owns + the EF Core provider). Both are opt-in by package reference alone. + +The same split applies to dependencies: the ER diagram needs the projects that own your `DbContext` +types to be registered with `AddProject(...)`. + +### Target frameworks + +| Package | Target framework | Shipped as | +| --- | --- | --- | +| `AspireC4.Hosting` | `net10.0` | `lib/net10.0/` library | +| `AspireC4.Hosting.EntityFrameworkCore` | `net10.0` | `lib/net10.0/` library | +| `AspireC4.EntityFrameworkCore` | `netstandard2.0` | `analyzers/dotnet/cs/` — analyzer-only, no runtime assembly | +| `AspireC4.EntityFrameworkCore.ModelDump` | `net10.0` | `tools/` — a build-time tool invoked by MSBuild | + +The AppHost consumes the two libraries, so an AppHost must target **`net10.0`**. The analyzer package is +`netstandard2.0` so it loads into any compiler, and it adds no assembly to your output; the model dump is +a `net10.0` tool run by the build, so the build machine needs a .NET 10 runtime. + ## Prerequisites -- **.NET 8 or later**. +- **.NET 10 SDK or later.** Every shipping package targets `net10.0`, and an Aspire 13.5 AppHost + targets `net10.0` too. - **Aspire 13.5.3 or later**. Aspire AppHost projects must reference both the AppHost SDK and `Aspire.Hosting.AppHost`. - **Docker** is used by default to run the LikeC4 sidecar container. @@ -63,6 +94,20 @@ This writes `./.aspirec4/likec4/model.gen.c4`, starts the LikeC4 server, and ref > (`./likec4/gen/`, `./erd/gen/`) and the flat `aspirec4` / `aspirec4-er` names. See > [Upgrading from before 13.6](#upgrading-from-before-136). +## Screenshots + +Both are captured from the sample AppHost in this repository (`src/src/TestAppHost`) and stored in +[`docs/images/screenshots/`](docs/images/screenshots/), so the links below stay valid however often the +diagrams are regenerated. Run `dotnet run --project src/src/TestAppHost` to refresh them. + +| Architecture diagram (`AddAspireC4()`) | ER diagram (`WithEntityFrameworkDiagram()`) | +| --- | --- | +| ![AspireC4 architecture diagram of the sample AppHost: a Node app referencing Redis Commander, local Redis and Postgres in a local dev group, PgWeb, Azure Redis and Azure Postgres, with labelled relationships](docs/images/screenshots/architecture-diagram.png) | ![AspireC4 interactive ER diagram of the sample AppHost: five DbContext groups of tables with primary and foreign key badges and crow's-foot relationship edges](docs/images/screenshots/entity-framework-er-diagram.png) | + +Every diagram also exports its views on startup, to `./.aspirec4/images/` beside the AppHost — see +[Export the views as images](#export-the-views-as-images). Those exported files are the simplest way to +add your own screenshots to a pull request, a wiki or a design document. + ## Configuration Configure the diagram through `AspireC4DiagramOptions`: @@ -268,11 +313,16 @@ Only tags, links, metadata, relationships and nested elements are applied — Li nothing else, so your project stays the single source of each element's title, technology, description and icon. See [Generated Output](docs/wiki/Generated-Output.md) for the details. -## Entity Framework Core ER diagrams (d2) +## Entity Framework Core ER diagrams + +This is an **optional second diagram** on top of the architecture one: `AddAspireC4()` is always required, +and `.WithEntityFrameworkDiagram()` adds the ER diagram to it. Install nothing else and you still get the +architecture diagram; install this only where you want the schema view too. -`AspireC4.Hosting.EntityFrameworkCore` adds a second, complementary diagram: a live -[d2](https://d2lang.com) `sql_table` ER diagram generated from your Entity Framework Core `DbContext` -types, hosted alongside the architecture diagram and linked from it. +`AspireC4.Hosting.EntityFrameworkCore` adds a live ER diagram generated from your Entity Framework Core +`DbContext` types, hosted alongside the architecture diagram and linked from it. The default `Interactive` +renderer draws a browser viewer; `Mermaid`, `Dbml` and `D2` emit text formats instead (see +[Renderers](#renderers)). The AppHost package is all that is required. `WithEntityFrameworkDiagram()` finds every associated `DbContext` automatically — reading a build-time dump or a source-generated descriptor where a project diff --git a/docs/images/screenshots/README.md b/docs/images/screenshots/README.md new file mode 100644 index 0000000..4889da0 --- /dev/null +++ b/docs/images/screenshots/README.md @@ -0,0 +1,39 @@ +# Screenshots + +The images the READMEs and wiki pages embed. They live here — not in the sample's generated output — +so a documentation link never breaks when a diagram is regenerated. + +| File | Shows | Used by | +| --- | --- | --- | +| `architecture-diagram.png` | the LikeC4 architecture diagram generated by `AddAspireC4()` for the sample AppHost, with a group, relationships and per-resource technologies | root `README.md`, `docs/wiki/Home.md`, `src/src/AspireC4/README.md` | +| `entity-framework-er-diagram.png` | the interactive ER diagram from `WithEntityFrameworkDiagram()`, one group per `DbContext`, key badges and relationship edges | root `README.md`, `docs/wiki/Home.md`, `docs/wiki/Entity-Framework-Diagrams.md`, `src/src/EntityFrameworkCore/README.md` | + +## Refreshing them + +Both are captured from the sample AppHost at `src/src/TestAppHost`: + +```sh +dotnet run --project src/src/TestAppHost +``` + +That run exports the architecture view as one PNG per view (`architecture-index.png`, …) and the ER diagram +as `schema.svg` / `schema.png`, which is the d2 render. The image used here is the **interactive viewer** +instead: capture it with the viewer's own **Save as PNG** button, or turn on `UseViewerFidelityExport` to +have the AppHost produce the identical file. Copy whichever you want over the file here, keeping the name +above so no documentation link has to change. + +If a file has to be renamed, update every reference. The paths appear in: + +- `README.md` +- `docs/wiki/Home.md` +- `docs/wiki/Entity-Framework-Diagrams.md` +- `src/src/AspireC4/README.md` +- `src/src/EntityFrameworkCore/README.md` + +## Rules + +- **Relative links** from the root `README.md` (`docs/images/screenshots/`). +- **Absolute `raw.githubusercontent.com` URLs** from `docs/wiki/*.md`, because the wiki is published from a + separate repository, and from package READMEs, because relative links do not resolve on nuget.org. +- Skills under `skills/` are installed on their own, so they never embed these files — name the export + folder (`./.aspirec4/images/`) in prose instead. diff --git a/docs/images/screenshots/architecture-diagram.png b/docs/images/screenshots/architecture-diagram.png new file mode 100644 index 0000000..c887bee Binary files /dev/null and b/docs/images/screenshots/architecture-diagram.png differ diff --git a/docs/images/screenshots/entity-framework-er-diagram.png b/docs/images/screenshots/entity-framework-er-diagram.png new file mode 100644 index 0000000..ac0ee3d Binary files /dev/null and b/docs/images/screenshots/entity-framework-er-diagram.png differ diff --git a/docs/wiki/Contributing.md b/docs/wiki/Contributing.md index c020c80..2648cde 100644 --- a/docs/wiki/Contributing.md +++ b/docs/wiki/Contributing.md @@ -154,6 +154,10 @@ Fix: Correct HMR port fallback on Windows. All tests in this repository **must use [TUnit](https://github.com/thomhurst/TUnit)**. Do not use xUnit, NUnit, or MSTest. Test projects declare just ``; the SDK (Purview.BuildSdk) wires TUnit, TUnit.Mocks, and Bogus into them automatically. +Every project targets `net10.0` except the two Roslyn components (`SourceGenerators` and +`EntityFrameworkCore.Analyzers`), which target `netstandard2.0`. The framework is set once in +`src/Directory.Build.props`. + ```csharp [Test] public async Task Something_Should_DoX() @@ -173,6 +177,10 @@ Mocking uses TUnit.Mocks (`.Returns(...)` API); NSubstitute is not referenced. |---|---| | `AspireC4.UnitTests` | `LikeC4ModelBuilder`, `LikeC4DslGenerator`, annotations, options — no Docker required | | `AspireC4.IntegrationTests` | Full Aspire lifecycle: container startup, file generation, endpoint availability | +| `EntityFrameworkCore.UnitTests` | d2 model builder, d2 DSL generator and descriptor loader — no Docker required | +| `EntityFrameworkCore.Analyzers.UnitTests` | EF model generator, plus the generator→assembly→AppHost round-trip | +| `SourceGenerators.UnitTests` | The registry/DSL strict-validation generator | +| `Repository.UnitTests` | Repository-level rules, including the authored skills in `skills/` | Integration tests require Docker to be running. They pull `ghcr.io/likec4/likec4` on first run. diff --git a/docs/wiki/Dashboard-Integration.md b/docs/wiki/Dashboard-Integration.md index 8894149..88cc510 100644 --- a/docs/wiki/Dashboard-Integration.md +++ b/docs/wiki/Dashboard-Integration.md @@ -57,4 +57,5 @@ HMR keeps the diagram up to date in the browser as the file regenerates. The HMR ## Next pages - [Generated Output](Generated-Output.md) +- [Entity Framework Core ER Diagrams](Entity-Framework-Diagrams.md) - [Configuration](Configuration.md) \ No newline at end of file diff --git a/docs/wiki/Entity-Framework-Diagrams.md b/docs/wiki/Entity-Framework-Diagrams.md new file mode 100644 index 0000000..380e4c9 --- /dev/null +++ b/docs/wiki/Entity-Framework-Diagrams.md @@ -0,0 +1,233 @@ +# Entity Framework Core ER Diagrams + +`AspireC4.Hosting.EntityFrameworkCore` adds a **second, optional diagram** to AspireC4: a live ER diagram +of your Entity Framework Core `DbContext` types, hosted beside the architecture diagram and linked from +it. + +It is **additive** — `AddAspireC4()` is always the base, and `WithEntityFrameworkDiagram()` adds the ER +diagram to the builder it returns. You can run the architecture diagram on its own and never install this +package; there is no way to run the ER diagram without the architecture diagram. + +![AspireC4 interactive ER diagram of the sample AppHost: five DbContext groups of tables with primary and foreign key badges and crow's-foot relationship edges](https://raw.githubusercontent.com/purview-dev/aspirec4/main/docs/images/screenshots/entity-framework-er-diagram.png) + +## Packages and target frameworks + +| Package | Target framework | Add to | Why | +| --- | --- | --- | --- | +| `AspireC4.Hosting` | `net10.0` | the AppHost | the architecture diagram this one hangs off. Required first | +| `AspireC4.Hosting.EntityFrameworkCore` | `net10.0` | the AppHost | the ER diagram itself | +| `AspireC4.EntityFrameworkCore` | `netstandard2.0` (analyzer-only) | a project **you own** that declares a `DbContext` | captures fluent `OnModelCreating` configuration | +| `AspireC4.EntityFrameworkCore.ModelDump` | `net10.0` (build-time tool) | the project that owns the EF Core **provider** and a design-time factory | the authoritative model, composite foreign keys included | + +Both libraries target `net10.0`, so the AppHost must too. The analyzer package is `netstandard2.0` and +ships only under `analyzers/dotnet/cs/`: it adds no runtime assembly, so it works whatever framework the +owning project targets. The dump tool runs as `dotnet .dll` from an MSBuild `Exec`, so the build +machine needs a .NET 10 runtime. + +## Enabling it + +### 1. Add the package to the AppHost + +```bash +dotnet add package AspireC4.Hosting.EntityFrameworkCore +``` + +### 2. Register the projects that own your `DbContext` types + +The diagram is built from **Aspire project resources**. Every project added with +`AddProject(...)` is scanned for `DbContext` types, including contexts that live in class +libraries the project references. A project that is only a ``, or that runs as a +container or executable, is not scanned. + +### 3. Call `WithEntityFrameworkDiagram()` + +```csharp +var builder = DistributedApplication.CreateBuilder(args); + +builder.AddAspireC4() + .WithEntityFrameworkDiagram(); + +builder.AddProject("orders-api"); + +builder.Build().Run(); +``` + +Run the AppHost. The dashboard shows both diagrams under a shared `aspirec4` parent row, each project that +contributed a context gets an **ER Diagram** link, and the project's element in the architecture diagram +gets one too. Output is written to `./.aspirec4/erd/` beside the AppHost. + +The model is read from each project's **build output** (`bin/`), so a project must have been built before +the AppHost starts. Building the AppHost builds its referenced projects, so normally you do not need to do +anything. + +## How the model is read + +Each context is recovered from the best source available, and the diagram records which one was used: + +| Source | When | Fidelity | +| --- | --- | --- | +| **Dump** | the project, or one it references, references `AspireC4.EntityFrameworkCore.ModelDump` | `Full` — the real EF model, value converters and composite foreign keys included | +| **Descriptor** | the project references the analyzer-only `AspireC4.EntityFrameworkCore` package | `Full` — includes fluent `OnModelCreating` configuration | +| **Metadata** | otherwise | `Approximate` — conventions and data annotations only | + +The metadata reader opens the built assembly with a reflection-only load context, so no code runs. It +cannot see `OnModelCreating` — a method body is absent from metadata — so a project without a package +still appears, but fluent renames, default schemas and `Ignore` calls do not. A shared or third-party +assembly you cannot instrument contributes at this fidelity. + +Every context carries its fidelity in the diagram, so an approximate model is never mistaken for a +complete one. When the same context reaches the diagram through several projects, the higher-fidelity +description wins. + +### The build-time dump (opt-in) + +Reference `AspireC4.EntityFrameworkCore.ModelDump` from the project that owns the EF Core provider; that +reference **is** the opt-in. After every build the tool builds each context's real `IModel` through its +`IDesignTimeDbContextFactory` and writes the diagram contract to `obj/aspirec4/ef/`. That directory is +never copied to `bin/` or `publish/` and is gitignored, so the dump has no deployment footprint. The +AppHost reads it from that project and every project it references, and falls back when it is missing or +older than the built assembly. + +Set `` when the design-time factory needs one to build its options — +the model is never opened, so any syntactically valid value works. A dump failure never fails the build. + +## Choosing which contexts appear + +By default every project resource is scanned. To narrow that down: + +```csharp +builder.AddAspireC4() + .WithEntityFrameworkDiagram(configure: options => options + .WithProjectOptInOnly() // only projects marked below + .WithExcludedContexts("IdentityDbContext")); // short or fully-qualified name + +builder.AddProject("orders-api") + .WithEntityFrameworkModel(options => options + .WithIncludedContexts("OrdersDbContext")); // per-project filter + +builder.AddProject("billing-api") + .WithEntityFrameworkModel(label: "Billing"); // label the project's group +``` + +Names match case-insensitively and an exclusion always wins over an inclusion. This is how a context +shared by several projects — an `IdentityDbContext` in a common library nobody owns — is kept out without +editing that library. + +## Renderers + +| `Renderer` | Output | Use it for | +| --- | --- | --- | +| `Interactive` *(default)* | `.json` + browser viewer | exploring the schema: search, column-level edges, crow's-foot cardinality, PNG/SVG export | +| `Mermaid` | `.mmd` + preview | pasting into GitHub, Azure DevOps or a wiki | +| `Dbml` | `.dbml` | dbdiagram.io and other DBML tooling | +| `D2` | `.d2` + a live d2 sidecar | a live d2 view | + +Every text format is a lossy projection of the model; only the interactive renderer consumes the +descriptor directly, which is why it is the default. + +The interactive and Mermaid viewers are static files served by a small `nginx` sidecar, so the dashboard +has a real URL to link to. Set `UseViewerServer = false` where there is no container runtime: the diagram +is still generated and the dashboard offers a command that opens it locally. + +## Configuration + +Set options in the `configure` callback or in the `AspireC4:EntityFramework` configuration section. + +| Property | Default | Description | +| --- | --- | --- | +| `Renderer` | `Interactive` | `Interactive`, `Mermaid`, `Dbml` or `D2` | +| `Title` | `null` | title shown in the diagram | +| `DiscoverAllProjects` | `true` | scan every project resource. `WithProjectOptInOnly()` restricts it | +| `IncludedContexts` / `ExcludedContexts` | empty | `WithIncludedContexts(...)` / `WithExcludedContexts(...)` | +| `OutputDirectory` | `"./.aspirec4/erd/"` | where generated files are written, relative to the AppHost | +| `FileName` | `"schema.gen"` | generated file name without extension | +| `DomainTypeDisplay` | `DomainTypeFirst` | how a value object or enum shows beside the store type: `AssetId (guid)`, `ActorType (int, enum)` | +| `ShowNullability` | `true` | mark nullable columns with `?` | +| `GroupBySchema` / `GroupByContext` | `true` | group tables by database schema, and by `DbContext` when there are several | +| `UseSubgraphs` | `true` | Mermaid only: one `subgraph` per `DbContext` (Mermaid 11.17+) | +| `LayoutEngine` | `Elk` | D2 only: `Dagre`, `Elk` or `Tala` | +| `UseViewerServer` | `true` | serve the viewer from a container | +| `HideFromDashboard` | `false` | hide the diagram's sidecar from the dashboard | +| `ExportImages` | `true` | write `schema.svg` / `schema.png` to `./.aspirec4/images/` when the model changes | +| `ImageFormats` | `{Svg, Png}` | `WithImageExport(...)`, or `WithoutImageExport()` to turn export off | +| `UseViewerFidelityExport` | `false` | render images through the interactive viewer in a headless browser. Pulls a ~3.7 GB Playwright image | +| `D2Command` | `null` | a local `d2` binary for image export, instead of the container | +| `ContainerRuntimeCommand` | `"docker"` | set to `podman` where Aspire uses Podman | + +> [!IMPORTANT] +> Set `OutputDirectory` in the callback rather than in configuration. The sidecar's bind mount is fixed +> when the AppHost builder runs, so a value from configuration changes where files are written but not +> what the sidecar serves. + +### Without a container runtime + +```csharp +// Generate the files without starting a viewer container, and render images with a local d2 +builder.AddAspireC4() + .WithEntityFrameworkDiagram(configure: options => + { + options.UseViewerServer = false; // the dashboard offers an "open locally" command instead + options.D2Command = "d2"; // or call options.WithoutImageExport() + }); + +// Or, with the D2 renderer, replace the d2 container with a local binary +builder.AddAspireC4() + .WithEntityFrameworkDiagram(configure: options => options.Renderer = ErdRenderer.D2) + .WithLocalD2CLI(); // must come after WithEntityFrameworkDiagram +``` + +d2 is a Go binary; install it with scoop, Homebrew, `install.sh` or `go install`. + +## Exporting images + +Both diagrams export to **one folder**, `./.aspirec4/images/`, so there is a single place to look. The ER +diagram writes `schema.svg` and `schema.png` (renamed by `FileName`) whenever the model changes, and never +on `aspire publish`. + +The ER export is fully cached: it is derived from the EF model alone, so restarting the AppHost over an +unchanged schema renders nothing. A stamp file beside the images records what they were rendered from. + +`UseViewerFidelityExport` makes the file identical to the viewer's own **Save as SVG / PNG** support by +loading the generated viewer in a headless browser and calling the same function the toolbar uses. It is +off by default because it pulls `mcr.microsoft.com/playwright` (around 3.7 GB) and takes seconds rather +than milliseconds. It applies only to the `Interactive` renderer. + +Prefer SVG for a large schema — a raster of the whole thing is unreadable at any sensible size. The +images folder is also the place to take a screenshot from: the one on this page is a viewer capture of the +sample AppHost's schema, kept in `docs/images/screenshots/`. + +## Dashboard + +With only the architecture diagram registered, `aspirec4` is a single flat row. Registering the ER diagram +nests both under a shared parent: + +```text +aspirec4 # parent row, added only when there is more than one diagram +├── aspirec4-likec4 # the architecture diagram, renamed as it is nested +└── aspirec4-er # the ER diagram, with its own sidecar nested beneath it +``` + +The ER diagram row carries an **Images** property with the resolved export path and an **Open Diagram +Images** command that opens the folder. Grouping and the `-likec4` rename arrived in 13.6; +`WithLegacyLayout()` keeps the flat `aspirec4` / `aspirec4-er` pair — see [Migration](Migration.md). + +## Troubleshooting + +- **No diagram content.** Check the project is added with `AddProject` and has been built. + The `aspirec4-er` resource's log names each project where no model was found. +- **Tables are missing their fluent configuration.** The context was read from metadata + (`Approximate`). Add `AspireC4.EntityFrameworkCore` to the project that declares it. +- **A composite or fluent-only relationship is not drawn.** Only the model dump sees these. Add + `AspireC4.EntityFrameworkCore.ModelDump` to the project with the provider and a design-time factory. +- **Not captured from any static source:** owned types, inheritance mapping, delete behaviour, sequences, + check constraints. Relationships across `DbContext` boundaries are never drawn. +- **The runner, not the product.** Running `AspireC4.IntegrationTests` from an IDE test runner fails + Aspire's project-resource start-up, which surfaces as an empty ER model. Use `just test-integration`. + +## Next pages + +- [Getting Started](Getting-Started.md) +- [Generated Output](Generated-Output.md) +- [Dashboard Integration](Dashboard-Integration.md) +- [Configuration](Configuration.md) + diff --git a/docs/wiki/Generated-Output.md b/docs/wiki/Generated-Output.md index c11177b..5868f8d 100644 --- a/docs/wiki/Generated-Output.md +++ b/docs/wiki/Generated-Output.md @@ -25,6 +25,23 @@ Every AspireC4 diagram writes beneath the same `./.aspirec4/` root in the AppHos | `likec4.config.json` | LikeC4 project configuration (`name`, `title`, `include.paths`, `imageAliases`, `metadata`). Generated when `GenerateConfigFile` is `true`. | | Additional `.c4` files | Any files registered through `WithAdditionalDSLFile` are copied here; LikeC4 discovers all `.c4` files in the project directory automatically. | +The ER diagram writes its own files beneath `./.aspirec4/erd/` — `schema.gen.json` (or `.mmd`, `.dbml`, +`.d2`, depending on the renderer) plus the viewer assets. It is a separate diagram with its own options; +see [Entity Framework Core ER Diagrams](Entity-Framework-Diagrams.md). + +## Exporting images + +Both diagrams export to the same `./.aspirec4/images/` folder: the architecture diagram writes one PNG +per view with an `architecture-` prefix, the ER diagram writes `schema.svg` and `schema.png`. Export runs +in the background and only when the output would differ, so startup is never delayed and an unchanged +diagram renders nothing. + +The images are the one piece of generated output worth committing — a diagram in a pull request is +documentation. The screenshots embedded in this repository's READMEs and wiki pages are kept in +`docs/images/screenshots/`, captured from the sample AppHost; see its `README.md` for the file list and how +to refresh them. See [Configuration](Configuration.md) for `ImageExportDirectory`, `ImageFormats` and +`WithoutImageExport()`. + ## Generating into your own LikeC4 project `WithLikeC4ProjectFolder(path)` points AspireC4 at a LikeC4 project you already maintain. That directory is what the LikeC4 server serves, so the project's own `likec4.config.json`, `.c4` sources and views are all in play, and the generated model joins them as one more file: diff --git a/docs/wiki/Getting-Started.md b/docs/wiki/Getting-Started.md index 9932e2a..985b2b3 100644 --- a/docs/wiki/Getting-Started.md +++ b/docs/wiki/Getting-Started.md @@ -4,7 +4,7 @@ This guide walks through installing AspireC4 and generating your first live arch ## Prerequisites -- **.NET 8 or later**. +- **.NET 10 or later.** The AppHost targets `net10.0`, and so do the `AspireC4.Hosting` and `AspireC4.Hosting.EntityFrameworkCore` libraries. - **Aspire 13.5.3 or later**. Aspire AppHost projects must reference both the AppHost SDK and `Aspire.Hosting.AppHost`. - **Docker** is used by default to run the LikeC4 sidecar container. - Optional: a local Node.js CLI runtime (`npx`, `pnpm`, `yarn`, `bun`, or `deno`) if you call `.WithLocalCLI()`. @@ -73,6 +73,36 @@ builder.AddAspireC4(options => See [Configuration](Configuration.md) for the full options reference and [Customizing Resources](Customizing-Resources.md) for per-resource details. +## Add an ER diagram too (optional) + +The architecture diagram is the base: `AddAspireC4()` is all you need, and you can stop there. To add a +linked ER diagram of your Entity Framework Core `DbContext` types as well, install the second AppHost +package and call one more method on the builder `AddAspireC4()` returns: + +```bash +dotnet add package AspireC4.Hosting.EntityFrameworkCore +``` + +```csharp +var builder = DistributedApplication.CreateBuilder(args); + +builder.AddAspireC4() + .WithEntityFrameworkDiagram(); + +builder.AddProject("api"); + +builder.Build().Run(); +``` + +The dashboard then shows both diagrams under one `aspirec4` parent row, and each contributing project is +linked to the ER diagram. Output moves to `./.aspirec4/erd/`, beside the architecture diagram's +`./.aspirec4/likec4/`. + +Two more optional packages raise the fidelity of the ER model — `AspireC4.EntityFrameworkCore` in the +project declaring the `DbContext`, and `AspireC4.EntityFrameworkCore.ModelDump` in the project owning the +EF Core provider. Both are opt-in by reference alone. See +[Entity Framework Core ER Diagrams](Entity-Framework-Diagrams.md). + ## Use a local CLI instead of Docker When Docker is not available, or you prefer a local Node.js-based workflow: @@ -91,6 +121,7 @@ AspireC4 supports both C# and TypeScript AppHosts. See [TypeScript AppHosts](Typ - [Configuration](Configuration.md) - [Customizing Resources](Customizing-Resources.md) +- [Entity Framework Core ER Diagrams](Entity-Framework-Diagrams.md) - [Generated Output](Generated-Output.md) - [Dashboard Integration](Dashboard-Integration.md) - [Source Generator Validation](Source-Generator.md) \ No newline at end of file diff --git a/docs/wiki/Home.md b/docs/wiki/Home.md index 87dd1eb..543dc33 100644 --- a/docs/wiki/Home.md +++ b/docs/wiki/Home.md @@ -15,6 +15,7 @@ AspireC4 turns your distributed application into a living architecture diagram. - [Getting Started](Getting-Started.md) - [Configuration](Configuration.md) - [Customizing Resources](Customizing-Resources.md) +- [Entity Framework Core ER Diagrams](Entity-Framework-Diagrams.md) - [TypeScript AppHosts](Typescript-AppHost.md) - [Generated Output](Generated-Output.md) - [Dashboard Integration](Dashboard-Integration.md) @@ -25,21 +26,44 @@ AspireC4 turns your distributed application into a living architecture diagram. - [Contributing](Contributing.md) - [Release Flow](Release-Flow.md) +## Screenshots + +| Architecture diagram | Entity Framework Core ER diagram | +| --- | --- | +| ![AspireC4 architecture diagram of the sample AppHost, with a local dev group and labelled relationships](https://raw.githubusercontent.com/purview-dev/aspirec4/main/docs/images/screenshots/architecture-diagram.png) | ![AspireC4 interactive ER diagram of the sample AppHost, with one group per DbContext, key badges and crow's-foot relationship edges](https://raw.githubusercontent.com/purview-dev/aspirec4/main/docs/images/screenshots/entity-framework-er-diagram.png) | + +Both are captured from the sample AppHost in the repository and stored in `docs/images/screenshots/` — that +folder is where the images used by these pages live. Run `dotnet run --project src/src/TestAppHost` to +refresh them. Every diagram also exports its own views to `./.aspirec4/images/` beside the AppHost on +startup, which is the easiest way to capture a screenshot of your own application; see +[Generated Output](Generated-Output.md). + ## Feature highlights - **Live diagram generation.** `AddAspireC4()` registers a lifecycle hook that generates the `.c4` file before startup and regenerates it (debounced) whenever a resource changes state — so the diagram always reflects the current application. +- **Optional Entity Framework Core ER diagram.** `WithEntityFrameworkDiagram()` (package `AspireC4.Hosting.EntityFrameworkCore`) adds a second, linked diagram of your `DbContext` types. It is additive — the architecture diagram is the base and is always required, so you run one diagram or both. See [Entity Framework Core ER Diagrams](Entity-Framework-Diagrams.md). - **One generated-output root.** The architecture and ER diagrams default beneath `./.aspirec4/`, so source control needs a single `**/.aspirec4/` ignore entry. - **Docker or local CLI.** The LikeC4 server runs as the `ghcr.io/likec4/likec4` container by default, or through a local JavaScript package manager CLI (`npx`, `pnpm`, `yarn`, `bun`, or `deno`) with `.WithLocalCLI()`. - **Rich per-resource customization.** `WithLikeC4Details()` controls labels, technologies, descriptions, summaries, icons, kinds, tags, links, and metadata; `WithLikeC4Reference()` customizes relationships; `WithLikeC4Group()` groups resources in the generated view. - **Automatic icons.** Icons are inferred from resource type and name using a bundled manifest, with custom `IconResolvers` evaluated first, and optional GraphViz `dot` assistance. - **Compile-time validation.** A Roslyn source generator validates `.WithTag()`, `.WithKind()`, `.WithLikeC4Group()`, and `.WithMetadata()` values against a `[LikeC4Registry]` class and/or LikeC4 `specification` blocks, with severity controls from suggestions to errors. +- **Image export.** Every view is written out as PNG (architecture) or SVG/PNG (ER) whenever the model changes, so a diagram can be attached to a pull request without running the server. - **TypeScript AppHost support.** The same features are available to TypeScript AppHosts through the Aspire-generated fluent API. - **Dashboard integration.** The diagram URL is surfaced in the Aspire dashboard, with optional per-resource dashboard links, and support for hiding the sidecar in favour of links on project resources. ## Prerequisites -- **.NET 8 or later**. +- **.NET 10 or later.** The AppHost targets `net10.0`, which is the target framework of both libraries. - **Aspire 13.5.3 or later**, with `Aspire.Hosting.AppHost` referenced by the AppHost project. - **Docker** (default LikeC4 server), or a local Node.js CLI runtime if you use `.WithLocalCLI()`. +### Target frameworks + +| Package | Target framework | Shipped as | +| --- | --- | --- | +| `AspireC4.Hosting` | `net10.0` | library | +| `AspireC4.Hosting.EntityFrameworkCore` | `net10.0` | library | +| `AspireC4.EntityFrameworkCore` | `netstandard2.0` | analyzer-only, no runtime assembly | +| `AspireC4.EntityFrameworkCore.ModelDump` | `net10.0` | build-time tool under `tools/` | + See [Getting Started](Getting-Started.md) for installation and the first run. \ No newline at end of file diff --git a/docs/wiki/Release-Flow.md b/docs/wiki/Release-Flow.md index 16eaaba..ee6085f 100644 --- a/docs/wiki/Release-Flow.md +++ b/docs/wiki/Release-Flow.md @@ -76,7 +76,7 @@ The build must produce no `RS2000`–`RS2008` diagnostics. `purview-build.json` declares the package content that must be present in the packed `.nupkg` (`PackValidation:RequiredContent`). Keep the `lib/...` entries pinned to the concrete target framework -(`lib/net8.0/...`) rather than the `$(TFM)` token. +(`lib/net10.0/...`) rather than the `$(TFM)` token. The validator expands `$(TFM)` into one entry per framework group it discovers in the package — including the framework-agnostic `any` group contributed by the root-level `build/.props`. That makes diff --git a/docs/wiki/Typescript-AppHost.md b/docs/wiki/Typescript-AppHost.md index a90e62f..a3fb495 100644 --- a/docs/wiki/Typescript-AppHost.md +++ b/docs/wiki/Typescript-AppHost.md @@ -109,6 +109,28 @@ aspire restore When adding another Aspire integration, use `aspire add ` so Aspire updates `aspire.config.json` and regenerates the TypeScript API. Inspect `.aspire/modules/aspire.mts` to see the APIs currently available to `apphost.mts`. +## Entity Framework Core diagrams + +The ER diagram is an optional second diagram and is additive, exactly as in a C# AppHost: `addAspireC4()` +is the base, and the ER diagram is added on top of it. It is only compiled into the TypeScript API when +the package is declared, so add it to `packages` in `aspire.config.json` and run `aspire restore`: + +```json +{ + "packages": { + "Aspire.Hosting.JavaScript": "13.5.3", + "AspireC4.Hosting": "13.5.3", + "AspireC4.Hosting.EntityFrameworkCore": "13.5.3" + } +} +``` + +The fluent methods are exported in camel case (`addAspireC4`, `withLikeC4Details`, `withEntityFrameworkDiagram`, +…). The ER output still lands in `./.aspirec4/erd/`, and the per-service fidelity packages +(`AspireC4.EntityFrameworkCore` and `AspireC4.EntityFrameworkCore.ModelDump`) are C# project references, so +they apply to whatever service project declares the `DbContext`. See +[Entity Framework Core ER Diagrams](Entity-Framework-Diagrams.md). + ## Output paths and legacy mode The TypeScript AppHost writes to the same paths as the C# AppHost: `./.aspirec4/likec4/` for the architecture diagram and `./.aspirec4/erd/` for the ER diagram, both relative to the AppHost working directory. If you are upgrading from 13.5 and need the pre-13.6 layout unchanged, call `withLegacyLayout()` inside the `configure` callback: diff --git a/docs/wiki/_Sidebar.md b/docs/wiki/_Sidebar.md index 0d6c415..38222bd 100644 --- a/docs/wiki/_Sidebar.md +++ b/docs/wiki/_Sidebar.md @@ -2,6 +2,7 @@ - [Getting Started](Getting-Started.md) - [Configuration](Configuration.md) - [Customizing Resources](Customizing-Resources.md) +- [Entity Framework Core ER Diagrams](Entity-Framework-Diagrams.md) - [TypeScript AppHosts](Typescript-AppHost.md) - [Generated Output](Generated-Output.md) - [Dashboard Integration](Dashboard-Integration.md) diff --git a/samples/typescript-app-host/.modules/.codegen-hash b/samples/typescript-app-host/.modules/.codegen-hash new file mode 100644 index 0000000..a9a7319 --- /dev/null +++ b/samples/typescript-app-host/.modules/.codegen-hash @@ -0,0 +1 @@ +8D973C74F7E4DBB83977C694EFD842CB85D2914E805551DF81AB8DFD93D7B0AD \ No newline at end of file diff --git a/samples/typescript-app-host/.modules/aspire.ts b/samples/typescript-app-host/.modules/aspire.ts new file mode 100644 index 0000000..f9c41f5 --- /dev/null +++ b/samples/typescript-app-host/.modules/aspire.ts @@ -0,0 +1,58026 @@ +// aspire.ts - Capability-based Aspire SDK +// This SDK uses the ATS (Aspire Type System) capability API. +// Capabilities are endpoints like 'Aspire.Hosting/createBuilder'. +// +// GENERATED CODE - DO NOT EDIT + +import { + AspireClient, + Handle, + MarshalledHandle, + AppHostUsageError, + CancellationToken, + CapabilityError, + registerCallback, + wrapIfHandle, + registerHandleWrapper, + isPromiseLike +} from './transport.js'; +import type { AspireClientRpc } from './transport.js'; + +import type { HandleReference } from './base.js'; + +import { + ResourceBuilderBase, + ReferenceExpression, + refExpr, + AspireDict, + AspireList +} from './base.js'; + +import type { Awaitable } from './base.js'; + +// ============================================================================ +// Handle Type Aliases (Internal - not exported to users) +// ============================================================================ + +/** Handle to AzureKeyVaultResource */ +type AzureKeyVaultResourceHandle = Handle<'Aspire.Hosting.Azure.KeyVault/Aspire.Hosting.Azure.AzureKeyVaultResource'>; + +/** Handle to AzureKeyVaultSecretResource */ +type AzureKeyVaultSecretResourceHandle = Handle<'Aspire.Hosting.Azure.KeyVault/Aspire.Hosting.Azure.AzureKeyVaultSecretResource'>; + +/** Handle to AzurePostgresFlexibleServerDatabaseResource */ +type AzurePostgresFlexibleServerDatabaseResourceHandle = Handle<'Aspire.Hosting.Azure.PostgreSQL/Aspire.Hosting.Azure.AzurePostgresFlexibleServerDatabaseResource'>; + +/** Handle to AzurePostgresFlexibleServerResource */ +type AzurePostgresFlexibleServerResourceHandle = Handle<'Aspire.Hosting.Azure.PostgreSQL/Aspire.Hosting.Azure.AzurePostgresFlexibleServerResource'>; + +/** Handle to AzureManagedRedisResource */ +type AzureManagedRedisResourceHandle = Handle<'Aspire.Hosting.Azure.Redis/Aspire.Hosting.Azure.AzureManagedRedisResource'>; + +/** Handle to IAzureResource */ +type IAzureResourceHandle = Handle<'Aspire.Hosting.Azure/Aspire.Hosting.ApplicationModel.IAzureResource'>; + +/** Handle to AzureBicepResource */ +type AzureBicepResourceHandle = Handle<'Aspire.Hosting.Azure/Aspire.Hosting.Azure.AzureBicepResource'>; + +/** Handle to AzureEnvironmentResource */ +type AzureEnvironmentResourceHandle = Handle<'Aspire.Hosting.Azure/Aspire.Hosting.Azure.AzureEnvironmentResource'>; + +/** Handle to AzureProvisioningResource */ +type AzureProvisioningResourceHandle = Handle<'Aspire.Hosting.Azure/Aspire.Hosting.Azure.AzureProvisioningResource'>; + +/** Handle to AzureResourceInfrastructure */ +type AzureResourceInfrastructureHandle = Handle<'Aspire.Hosting.Azure/Aspire.Hosting.Azure.AzureResourceInfrastructure'>; + +/** Handle to AzureUserAssignedIdentityResource */ +type AzureUserAssignedIdentityResourceHandle = Handle<'Aspire.Hosting.Azure/Aspire.Hosting.Azure.AzureUserAssignedIdentityResource'>; + +/** Handle to BicepOutputReference */ +type BicepOutputReferenceHandle = Handle<'Aspire.Hosting.Azure/Aspire.Hosting.Azure.BicepOutputReference'>; + +/** Handle to IAzureKeyVaultResource */ +type IAzureKeyVaultResourceHandle = Handle<'Aspire.Hosting.Azure/Aspire.Hosting.Azure.IAzureKeyVaultResource'>; + +/** Handle to IAzureKeyVaultSecretReference */ +type IAzureKeyVaultSecretReferenceHandle = Handle<'Aspire.Hosting.Azure/Aspire.Hosting.Azure.IAzureKeyVaultSecretReference'>; + +/** Handle to JavaScriptAppResource */ +type JavaScriptAppResourceHandle = Handle<'Aspire.Hosting.JavaScript/Aspire.Hosting.JavaScript.JavaScriptAppResource'>; + +/** Handle to NextJsAppResource */ +type NextJsAppResourceHandle = Handle<'Aspire.Hosting.JavaScript/Aspire.Hosting.JavaScript.NextJsAppResource'>; + +/** Handle to NodeAppResource */ +type NodeAppResourceHandle = Handle<'Aspire.Hosting.JavaScript/Aspire.Hosting.JavaScript.NodeAppResource'>; + +/** Handle to ViteAppResource */ +type ViteAppResourceHandle = Handle<'Aspire.Hosting.JavaScript/Aspire.Hosting.JavaScript.ViteAppResource'>; + +/** Handle to PostgresDatabaseResource */ +type PostgresDatabaseResourceHandle = Handle<'Aspire.Hosting.PostgreSQL/Aspire.Hosting.ApplicationModel.PostgresDatabaseResource'>; + +/** Handle to PostgresServerResource */ +type PostgresServerResourceHandle = Handle<'Aspire.Hosting.PostgreSQL/Aspire.Hosting.ApplicationModel.PostgresServerResource'>; + +/** Handle to PgAdminContainerResource */ +type PgAdminContainerResourceHandle = Handle<'Aspire.Hosting.PostgreSQL/Aspire.Hosting.Postgres.PgAdminContainerResource'>; + +/** Handle to PgWebContainerResource */ +type PgWebContainerResourceHandle = Handle<'Aspire.Hosting.PostgreSQL/Aspire.Hosting.Postgres.PgWebContainerResource'>; + +/** Handle to PostgresMcpContainerResource */ +type PostgresMcpContainerResourceHandle = Handle<'Aspire.Hosting.PostgreSQL/Aspire.Hosting.Postgres.PostgresMcpContainerResource'>; + +/** Handle to RedisResource */ +type RedisResourceHandle = Handle<'Aspire.Hosting.Redis/Aspire.Hosting.ApplicationModel.RedisResource'>; + +/** Handle to RedisCommanderResource */ +type RedisCommanderResourceHandle = Handle<'Aspire.Hosting.Redis/Aspire.Hosting.Redis.RedisCommanderResource'>; + +/** Handle to RedisInsightResource */ +type RedisInsightResourceHandle = Handle<'Aspire.Hosting.Redis/Aspire.Hosting.Redis.RedisInsightResource'>; + +/** Handle to AfterResourcesCreatedEvent */ +type AfterResourcesCreatedEventHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.AfterResourcesCreatedEvent'>; + +/** Handle to BeforeResourceStartedEvent */ +type BeforeResourceStartedEventHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.BeforeResourceStartedEvent'>; + +/** Handle to BeforeStartEvent */ +type BeforeStartEventHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.BeforeStartEvent'>; + +/** Handle to CommandLineArgsCallbackContext */ +type CommandLineArgsCallbackContextHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.CommandLineArgsCallbackContext'>; + +/** Handle to CommandLineArgsEditor */ +type CommandLineArgsEditorHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.CommandLineArgsEditor'>; + +/** Handle to ConnectionStringAvailableEvent */ +type ConnectionStringAvailableEventHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ConnectionStringAvailableEvent'>; + +/** Handle to ContainerImagePushOptions */ +type ContainerImagePushOptionsHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ContainerImagePushOptions'>; + +/** Handle to ContainerImagePushOptionsCallbackContext */ +type ContainerImagePushOptionsCallbackContextHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ContainerImagePushOptionsCallbackContext'>; + +/** Handle to ContainerRegistryResource */ +type ContainerRegistryResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ContainerRegistryResource'>; + +/** Handle to ContainerResource */ +type ContainerResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ContainerResource'>; + +/** Handle to CSharpAppResource */ +type CSharpAppResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.CSharpAppResource'>; + +/** Handle to DistributedApplicationModel */ +type DistributedApplicationModelHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.DistributedApplicationModel'>; + +/** Handle to DockerfileBuilder */ +type DockerfileBuilderHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.Docker.DockerfileBuilder'>; + +/** Handle to DockerfileStage */ +type DockerfileStageHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.Docker.DockerfileStage'>; + +/** Handle to DockerfileBuilderCallbackContext */ +type DockerfileBuilderCallbackContextHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.DockerfileBuilderCallbackContext'>; + +/** Handle to DotnetToolResource */ +type DotnetToolResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.DotnetToolResource'>; + +/** Handle to EndpointReference */ +type EndpointReferenceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.EndpointReference'>; + +/** Handle to EndpointReferenceExpression */ +type EndpointReferenceExpressionHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.EndpointReferenceExpression'>; + +/** Handle to EndpointUpdateContext */ +type EndpointUpdateContextHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.EndpointUpdateContext'>; + +/** Handle to EnvironmentCallbackContext */ +type EnvironmentCallbackContextHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.EnvironmentCallbackContext'>; + +/** Handle to EnvironmentEditor */ +type EnvironmentEditorHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.EnvironmentEditor'>; + +/** Handle to ExecutableResource */ +type ExecutableResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ExecutableResource'>; + +/** Handle to ExecuteCommandContext */ +type ExecuteCommandContextHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ExecuteCommandContext'>; + +/** Handle to IAspireStore */ +type IAspireStoreHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.IAspireStore'>; + +/** Handle to IComputeResource */ +type IComputeResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.IComputeResource'>; + +/** Handle to IContainerFilesDestinationResource */ +type IContainerFilesDestinationResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.IContainerFilesDestinationResource'>; + +/** Handle to IExecutionConfigurationBuilder */ +type IExecutionConfigurationBuilderHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.IExecutionConfigurationBuilder'>; + +/** Handle to IExecutionConfigurationResult */ +type IExecutionConfigurationResultHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.IExecutionConfigurationResult'>; + +/** Handle to IExpressionValue */ +type IExpressionValueHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.IExpressionValue'>; + +/** Handle to InitializeResourceEvent */ +type InitializeResourceEventHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.InitializeResourceEvent'>; + +/** Handle to IResource */ +type IResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResource'>; + +/** Handle to IResourceWithArgs */ +type IResourceWithArgsHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithArgs'>; + +/** Handle to IResourceWithConnectionString */ +type IResourceWithConnectionStringHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithConnectionString'>; + +/** Handle to IResourceWithEndpoints */ +type IResourceWithEndpointsHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithEndpoints'>; + +/** Handle to IResourceWithEnvironment */ +type IResourceWithEnvironmentHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithEnvironment'>; + +/** Handle to IResourceWithWaitSupport */ +type IResourceWithWaitSupportHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithWaitSupport'>; + +/** Handle to LogFacade */ +type LogFacadeHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.LogFacade'>; + +/** Handle to ParameterResource */ +type ParameterResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ParameterResource'>; + +/** Handle to ProjectResource */ +type ProjectResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ProjectResource'>; + +/** Handle to ReferenceExpression */ +type ReferenceExpressionHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ReferenceExpression'>; + +/** Handle to ReferenceExpressionBuilder */ +type ReferenceExpressionBuilderHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ReferenceExpressionBuilder'>; + +/** Handle to ResourceEndpointsAllocatedEvent */ +type ResourceEndpointsAllocatedEventHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceEndpointsAllocatedEvent'>; + +/** Handle to ResourceLoggerService */ +type ResourceLoggerServiceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceLoggerService'>; + +/** Handle to ResourceNotificationService */ +type ResourceNotificationServiceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceNotificationService'>; + +/** Handle to ResourceReadyEvent */ +type ResourceReadyEventHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceReadyEvent'>; + +/** Handle to ResourceStoppedEvent */ +type ResourceStoppedEventHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceStoppedEvent'>; + +/** Handle to ResourceUrlsCallbackContext */ +type ResourceUrlsCallbackContextHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceUrlsCallbackContext'>; + +/** Handle to ResourceUrlsEditor */ +type ResourceUrlsEditorHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceUrlsEditor'>; + +/** Handle to UpdateCommandStateContext */ +type UpdateCommandStateContextHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.UpdateCommandStateContext'>; + +/** Handle to EventingSubscriberRegistrationContext */ +type EventingSubscriberRegistrationContextHandle = Handle<'Aspire.Hosting/Aspire.Hosting.Ats.EventingSubscriberRegistrationContext'>; + +/** Handle to DistributedApplication */ +type DistributedApplicationHandle = Handle<'Aspire.Hosting/Aspire.Hosting.DistributedApplication'>; + +/** Handle to DistributedApplicationExecutionContext */ +type DistributedApplicationExecutionContextHandle = Handle<'Aspire.Hosting/Aspire.Hosting.DistributedApplicationExecutionContext'>; + +/** Handle to DistributedApplicationEventSubscription */ +type DistributedApplicationEventSubscriptionHandle = Handle<'Aspire.Hosting/Aspire.Hosting.Eventing.DistributedApplicationEventSubscription'>; + +/** Handle to IDistributedApplicationEventing */ +type IDistributedApplicationEventingHandle = Handle<'Aspire.Hosting/Aspire.Hosting.Eventing.IDistributedApplicationEventing'>; + +/** Handle to ExternalServiceResource */ +type ExternalServiceResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ExternalServiceResource'>; + +/** Handle to IDistributedApplicationBuilder */ +type IDistributedApplicationBuilderHandle = Handle<'Aspire.Hosting/Aspire.Hosting.IDistributedApplicationBuilder'>; + +/** Handle to IResourceWithContainerFiles */ +type IResourceWithContainerFilesHandle = Handle<'Aspire.Hosting/Aspire.Hosting.IResourceWithContainerFiles'>; + +/** Handle to IResourceWithServiceDiscovery */ +type IResourceWithServiceDiscoveryHandle = Handle<'Aspire.Hosting/Aspire.Hosting.IResourceWithServiceDiscovery'>; + +/** Handle to IUserSecretsManager */ +type IUserSecretsManagerHandle = Handle<'Aspire.Hosting/Aspire.Hosting.IUserSecretsManager'>; + +/** Handle to IDistributedApplicationPipeline */ +type IDistributedApplicationPipelineHandle = Handle<'Aspire.Hosting/Aspire.Hosting.Pipelines.IDistributedApplicationPipeline'>; + +/** Handle to IReportingStep */ +type IReportingStepHandle = Handle<'Aspire.Hosting/Aspire.Hosting.Pipelines.IReportingStep'>; + +/** Handle to IReportingTask */ +type IReportingTaskHandle = Handle<'Aspire.Hosting/Aspire.Hosting.Pipelines.IReportingTask'>; + +/** Handle to PipelineConfigurationContext */ +type PipelineConfigurationContextHandle = Handle<'Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineConfigurationContext'>; + +/** Handle to PipelineContext */ +type PipelineContextHandle = Handle<'Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineContext'>; + +/** Handle to PipelineEditor */ +type PipelineEditorHandle = Handle<'Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineEditor'>; + +/** Handle to PipelineStep */ +type PipelineStepHandle = Handle<'Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineStep'>; + +/** Handle to PipelineStepContext */ +type PipelineStepContextHandle = Handle<'Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineStepContext'>; + +/** Handle to PipelineStepFactoryContext */ +type PipelineStepFactoryContextHandle = Handle<'Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineStepFactoryContext'>; + +/** Handle to PipelineSummary */ +type PipelineSummaryHandle = Handle<'Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineSummary'>; + +/** Handle to ProjectResourceOptions */ +type ProjectResourceOptionsHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ProjectResourceOptions'>; + +/** Handle to AspireC4Resource */ +type AspireC4ResourceHandle = Handle<'AspireC4.Hosting/Aspire.Hosting.AspireC4.ApplicationModel.AspireC4Resource'>; + +/** Handle to AspireC4DiagramOptions */ +type AspireC4DiagramOptionsHandle = Handle<'AspireC4.Hosting/Aspire.Hosting.AspireC4.AspireC4DiagramOptions'>; + +/** Handle to LikeC4NodeDetailsAnnotation */ +type LikeC4NodeDetailsAnnotationHandle = Handle<'AspireC4.Hosting/Aspire.Hosting.AspireC4.LikeC4.Annotations.LikeC4NodeDetailsAnnotation'>; + +/** Handle to LikeC4RelationshipDetailsAnnotation */ +type LikeC4RelationshipDetailsAnnotationHandle = Handle<'AspireC4.Hosting/Aspire.Hosting.AspireC4.LikeC4.Annotations.LikeC4RelationshipDetailsAnnotation'>; + +/** Handle to IConfiguration */ +type IConfigurationHandle = Handle<'Microsoft.Extensions.Configuration.Abstractions/Microsoft.Extensions.Configuration.IConfiguration'>; + +/** Handle to IConfigurationSection */ +type IConfigurationSectionHandle = Handle<'Microsoft.Extensions.Configuration.Abstractions/Microsoft.Extensions.Configuration.IConfigurationSection'>; + +/** Handle to IHostEnvironment */ +type IHostEnvironmentHandle = Handle<'Microsoft.Extensions.Hosting.Abstractions/Microsoft.Extensions.Hosting.IHostEnvironment'>; + +/** Handle to ILogger */ +type ILoggerHandle = Handle<'Microsoft.Extensions.Logging.Abstractions/Microsoft.Extensions.Logging.ILogger'>; + +/** Handle to ILoggerFactory */ +type ILoggerFactoryHandle = Handle<'Microsoft.Extensions.Logging.Abstractions/Microsoft.Extensions.Logging.ILoggerFactory'>; + +/** Handle to IServiceProvider */ +type IServiceProviderHandle = Handle<'System.ComponentModel/System.IServiceProvider'>; + +// ============================================================================ +// Enum Types +// ============================================================================ + +/** Enum type for AspireMetadataInclusion */ +export enum AspireMetadataInclusion { + None = "None", + Metadata = "Metadata", + Links = "Links", + All = "All", +} + +/** Enum type for AzureKeyVaultRole */ +export enum AzureKeyVaultRole { + KeyVaultAdministrator = "KeyVaultAdministrator", + KeyVaultCertificateUser = "KeyVaultCertificateUser", + KeyVaultCertificatesOfficer = "KeyVaultCertificatesOfficer", + KeyVaultContributor = "KeyVaultContributor", + KeyVaultCryptoOfficer = "KeyVaultCryptoOfficer", + KeyVaultCryptoServiceEncryptionUser = "KeyVaultCryptoServiceEncryptionUser", + KeyVaultCryptoServiceReleaseUser = "KeyVaultCryptoServiceReleaseUser", + KeyVaultCryptoUser = "KeyVaultCryptoUser", + KeyVaultDataAccessAdministrator = "KeyVaultDataAccessAdministrator", + KeyVaultReader = "KeyVaultReader", + KeyVaultSecretsOfficer = "KeyVaultSecretsOfficer", + KeyVaultSecretsUser = "KeyVaultSecretsUser", + ManagedHsmContributor = "ManagedHsmContributor", +} + +/** Enum type for CertificateTrustScope */ +export enum CertificateTrustScope { + None = "None", + Append = "Append", + Override = "Override", + System = "System", +} + +/** Enum type for CommandResultFormat */ +export enum CommandResultFormat { + Text = "Text", + Json = "Json", + Markdown = "Markdown", +} + +/** Enum type for ContainerLifetime */ +export enum ContainerLifetime { + Session = "Session", + Persistent = "Persistent", +} + +/** Enum type for DeploymentScope */ +export enum DeploymentScope { + ResourceGroup = "ResourceGroup", + Subscription = "Subscription", + ManagementGroup = "ManagementGroup", + Tenant = "Tenant", +} + +/** Enum type for DistributedApplicationOperation */ +export enum DistributedApplicationOperation { + Run = "Run", + Publish = "Publish", +} + +/** Enum type for EndpointProperty */ +export enum EndpointProperty { + Url = "Url", + Host = "Host", + IPV4Host = "IPV4Host", + Port = "Port", + Scheme = "Scheme", + TargetPort = "TargetPort", + HostAndPort = "HostAndPort", + TlsEnabled = "TlsEnabled", +} + +/** Enum type for HttpCommandResultMode */ +export enum HttpCommandResultMode { + None = "None", + Auto = "Auto", + Json = "Json", + Text = "Text", +} + +/** Enum type for IconVariant */ +export enum IconVariant { + Regular = "Regular", + Filled = "Filled", +} + +/** Enum type for ImagePullPolicy */ +export enum ImagePullPolicy { + Default = "Default", + Always = "Always", + Missing = "Missing", + Never = "Never", +} + +/** Enum type for LikeC4RelationshipKindSyntax */ +export enum LikeC4RelationshipKindSyntax { + Dot = "Dot", + Bracket = "Bracket", +} + +/** Enum type for LocalCLIRuntime */ +export enum LocalCLIRuntime { + Auto = "Auto", + Npx = "Npx", + Pnpm = "Pnpm", + Yarn = "Yarn", + Bun = "Bun", + Deno = "Deno", +} + +/** Enum type for NormaliseMetadataBehaviour */ +export enum NormaliseMetadataBehaviour { + Normalise = "Normalise", + NormaliseLowercase = "NormaliseLowercase", + Throw = "Throw", +} + +/** Enum type for OtlpProtocol */ +export enum OtlpProtocol { + Grpc = "Grpc", + HttpProtobuf = "HttpProtobuf", + HttpJson = "HttpJson", +} + +/** Enum type for ProbeType */ +export enum ProbeType { + Startup = "Startup", + Readiness = "Readiness", + Liveness = "Liveness", +} + +/** Enum type for ProtocolType */ +export enum ProtocolType { + IP = "IP", + IPv6HopByHopOptions = "IPv6HopByHopOptions", + Unspecified = "Unspecified", + Icmp = "Icmp", + Igmp = "Igmp", + Ggp = "Ggp", + IPv4 = "IPv4", + Tcp = "Tcp", + Pup = "Pup", + Udp = "Udp", + Idp = "Idp", + IPv6 = "IPv6", + IPv6RoutingHeader = "IPv6RoutingHeader", + IPv6FragmentHeader = "IPv6FragmentHeader", + IPSecEncapsulatingSecurityPayload = "IPSecEncapsulatingSecurityPayload", + IPSecAuthenticationHeader = "IPSecAuthenticationHeader", + IcmpV6 = "IcmpV6", + IPv6NoNextHeader = "IPv6NoNextHeader", + IPv6DestinationOptions = "IPv6DestinationOptions", + ND = "ND", + Raw = "Raw", + Ipx = "Ipx", + Spx = "Spx", + SpxII = "SpxII", + Unknown = "Unknown", +} + +/** Enum type for UrlDisplayLocation */ +export enum UrlDisplayLocation { + SummaryAndDetails = "SummaryAndDetails", + DetailsOnly = "DetailsOnly", +} + +/** Enum type for WaitBehavior */ +export enum WaitBehavior { + WaitOnResourceUnavailable = "WaitOnResourceUnavailable", + StopOnResourceUnavailable = "StopOnResourceUnavailable", +} + +// ============================================================================ +// DTO Interfaces +// ============================================================================ + +/** DTO interface for AddContainerOptions */ +export interface AddContainerOptions { + image?: string; + tag?: string; +} + +/** DTO interface for CertificateTrustExecutionConfigurationContext */ +export interface CertificateTrustExecutionConfigurationContext { + certificateBundlePath?: ReferenceExpression; + certificateDirectoriesPath?: ReferenceExpression; + rootCertificatesPath?: string; + isContainer?: boolean; +} + +/** DTO interface for CertificateTrustExecutionConfigurationExportData */ +export interface CertificateTrustExecutionConfigurationExportData { + scope?: CertificateTrustScope; + certificateSubjects?: string[]; + customBundlePaths?: string[]; +} + +/** DTO interface for CommandOptions */ +export interface CommandOptions { + description?: string; + parameter?: any; + confirmationMessage?: string; + iconName?: string; + iconVariant?: IconVariant; + isHighlighted?: boolean; + updateState?: any; +} + +/** DTO interface for CommandResultData */ +export interface CommandResultData { + value?: string; + format?: CommandResultFormat; + displayImmediately?: boolean; +} + +/** DTO interface for CreateBuilderOptions */ +export interface CreateBuilderOptions { + args?: string[]; + projectDirectory?: string; + appHostFilePath?: string; + containerRegistryOverride?: string; + disableDashboard?: boolean; + dashboardApplicationName?: string; + allowUnsecuredTransport?: boolean; + enableResourceLogging?: boolean; + /** When false, pre-flush rejected promises are not re-thrown by build(). Default: true. */ + throwOnPendingRejections?: boolean; +} + +/** DTO interface for ExecuteCommandResult */ +export interface ExecuteCommandResult { + success?: boolean; + canceled?: boolean; + errorMessage?: string; + message?: string; + data?: CommandResultData; +} + +/** DTO interface for GenerateParameterDefault */ +export interface GenerateParameterDefault { + minLength?: number; + lower?: boolean; + upper?: boolean; + numeric?: boolean; + special?: boolean; + minLower?: number; + minUpper?: number; + minNumeric?: number; + minSpecial?: number; +} + +/** DTO interface for HttpCommandExportOptions */ +export interface HttpCommandExportOptions { + description?: string; + confirmationMessage?: string; + iconName?: string; + iconVariant?: IconVariant; + isHighlighted?: boolean; + commandName?: string; + endpointName?: string; + methodName?: string; + resultMode?: HttpCommandResultMode; +} + +/** DTO interface for HttpsCertificateExecutionConfigurationContext */ +export interface HttpsCertificateExecutionConfigurationContext { + certificatePath?: ReferenceExpression; + keyPath?: ReferenceExpression; + pfxPath?: ReferenceExpression; +} + +/** DTO interface for HttpsCertificateExecutionConfigurationExportData */ +export interface HttpsCertificateExecutionConfigurationExportData { + subject?: string; + thumbprint?: string; + keyPathExpression?: string; + pfxPathExpression?: string; + isKeyPathReferenced?: boolean; + isPfxPathReferenced?: boolean; + password?: string; +} + +/** DTO interface for HttpsCertificateInfo */ +export interface HttpsCertificateInfo { + subject?: string; + issuer?: string; + thumbprint?: string; +} + +/** DTO interface for ReferenceEnvironmentInjectionOptions */ +export interface ReferenceEnvironmentInjectionOptions { + connectionString?: boolean; + connectionProperties?: boolean; + serviceDiscovery?: boolean; + endpoints?: boolean; +} + +/** DTO interface for ResourceEventDto */ +export interface ResourceEventDto { + resourceName?: string; + resourceId?: string; + state?: string; + stateStyle?: string; + healthStatus?: string; + exitCode?: number; +} + +/** DTO interface for ResourceUrlAnnotation */ +export interface ResourceUrlAnnotation { + url?: string; + displayText?: string; + endpoint?: EndpointReferenceHandle; + displayLocation?: UrlDisplayLocation; +} + +// ============================================================================ +// Exported Values +// ============================================================================ + +export namespace WellKnownPipelineSteps { + export const BeforeStart = "before-start"; + + export const Build = "build"; + + export const BuildPrereq = "build-prereq"; + + export const CheckContainerRuntime = "check-container-runtime"; + + export const Deploy = "deploy"; + + export const DeployPrereq = "deploy-prereq"; + + export const Destroy = "destroy"; + + export const DestroyPrereq = "destroy-prereq"; + + export const Diagnostics = "diagnostics"; + + export const ProcessParameters = "process-parameters"; + + export const Publish = "publish"; + + export const PublishPrereq = "publish-prereq"; + + export const Push = "push"; + + export const PushPrereq = "push-prereq"; + + export const ValidateComputeEnvironments = "validate-compute-environments"; + +} + +export namespace WellKnownPipelineTags { + export const BuildCompute = "build-compute"; + + export const DeployCompute = "deploy-compute"; + + export const ProvisionInfrastructure = "provision-infra"; + + export const PushContainerImage = "push-container-image"; + +} + +// ============================================================================ +// Options Interfaces +// ============================================================================ + +export interface AddAspireC4Options { + name?: string; + port?: number; + configure?: (obj: AspireC4DiagramOptions) => Promise; +} + +export interface AddConnectionStringOptions { + environmentVariableNameOrExpression?: string | ReferenceExpression; +} + +export interface AddContainerFilesOptions { + logger?: Awaitable; +} + +export interface AddContainerFilesStagesOptions { + logger?: Awaitable; +} + +export interface AddContainerRegistryOptions { + repository?: string | ParameterResource | Awaitable; +} + +export interface AddCSharpAppOptions { + options?: Awaitable; +} + +export interface AddDatabaseOptions { + databaseName?: string; +} + +export interface AddDockerfileBuilderOptions { + stage?: string; +} + +export interface AddDockerfileOptions { + dockerfilePath?: string; + stage?: string; +} + +export interface AddForEndpointOptions { + displayText?: string; +} + +export interface AddJavaScriptAppOptions { + runScriptName?: string; +} + +export interface AddNextJsAppOptions { + runScriptName?: string; +} + +export interface AddOptions { + displayText?: string; +} + +export interface AddParameterFromConfigurationOptions { + secret?: boolean; +} + +export interface AddParameterOptions { + value?: string; + publishValueAsDefault?: boolean; + secret?: boolean; +} + +export interface AddParameterWithGeneratedValueOptions { + secret?: boolean; + persist?: boolean; +} + +export interface AddPostgresOptions { + userName?: Awaitable; + password?: Awaitable; + port?: number; +} + +export interface AddProjectOptions { + launchProfileOrOptions?: string | ProjectResourceOptions | Awaitable; +} + +export interface AddRedisOptions { + port?: number; + password?: Awaitable; +} + +export interface AddSecretOptions { + secretName?: string; +} + +export interface AddStepOptions { + dependsOn?: string[]; + requiredBy?: string[]; +} + +export interface AddViteAppOptions { + runScriptName?: string; +} + +export interface AppendFormattedOptions { + format?: string; +} + +export interface AppendValueProviderOptions { + format?: string; +} + +export interface ArgOptions { + defaultValue?: string; +} + +export interface AsExistingOptions { + resourceGroup?: string | ParameterResource | Awaitable; +} + +export interface BuildOptions { + resourceLogger?: Awaitable; + cancellationToken?: AbortSignal | CancellationToken; +} + +export interface CompleteStepMarkdownOptions { + completionState?: string; + cancellationToken?: AbortSignal | CancellationToken; +} + +export interface CompleteStepOptions { + completionState?: string; + cancellationToken?: AbortSignal | CancellationToken; +} + +export interface CompleteTaskMarkdownOptions { + completionState?: string; + cancellationToken?: AbortSignal | CancellationToken; +} + +export interface CompleteTaskOptions { + completionMessage?: string; + completionState?: string; + cancellationToken?: AbortSignal | CancellationToken; +} + +export interface CopyFromOptions { + chown?: string; +} + +export interface CopyOptions { + chown?: string; +} + +export interface CreateMarkdownTaskOptions { + cancellationToken?: AbortSignal | CancellationToken; +} + +export interface CreateTaskOptions { + cancellationToken?: AbortSignal | CancellationToken; +} + +export interface FromOptions { + stageName?: string; +} + +export interface GetValueAsyncOptions { + cancellationToken?: AbortSignal | CancellationToken; +} + +export interface PublishAsDockerFileOptions { + configure?: (obj: ContainerResource) => Promise; +} + +export interface PublishAsExistingOptions { + resourceGroup?: string | ParameterResource | Awaitable; +} + +export interface PublishAsNodeServerOptions { + outputPath?: string; +} + +export interface PublishAsNpmScriptOptions { + startScriptName?: string; + runScriptArguments?: string; +} + +export interface PublishAsStaticWebsiteOptions { + apiPath?: string; + apiTarget?: Awaitable; + outputPath?: string; + stripPrefix?: boolean; + targetEndpointName?: string; +} + +export interface PublishResourceUpdateOptions { + state?: string; + stateStyle?: string; +} + +export interface RunAsContainer1Options { + configureContainer?: (obj: PostgresServerResource) => Promise; +} + +export interface RunAsContainerOptions { + configureContainer?: (obj: RedisResource) => Promise; +} + +export interface RunAsExistingOptions { + resourceGroup?: string | ParameterResource | Awaitable; +} + +export interface RunOptions { + cancellationToken?: AbortSignal | CancellationToken; +} + +export interface SaveStateJsonOptions { + cancellationToken?: AbortSignal | CancellationToken; +} + +export interface UpdateTaskMarkdownOptions { + cancellationToken?: AbortSignal | CancellationToken; +} + +export interface UpdateTaskOptions { + cancellationToken?: AbortSignal | CancellationToken; +} + +export interface WaitForCompletionOptions { + exitCode?: number; +} + +export interface WaitForOptions { + waitBehavior?: WaitBehavior; +} + +export interface WaitForResourceStateOptions { + targetState?: string; +} + +export interface WaitForStartOptions { + waitBehavior?: WaitBehavior; +} + +export interface WithAccessKeyAuthenticationOptions { + keyVaultBuilder?: Awaitable; +} + +export interface WithAutoIconOptions { + enabled?: boolean; +} + +export interface WithBindMountOptions { + isReadOnly?: boolean; +} + +export interface WithBrowserDebuggerOptions { + browser?: string; +} + +export interface WithBuildScriptOptions { + args?: string[]; +} + +export interface WithBunOptions { + install?: boolean; + installArgs?: string[]; +} + +export interface WithCommandOptions { + commandOptions?: CommandOptions; +} + +export interface WithContainerCertificatePathsOptions { + customCertificatesDestination?: string; + defaultCertificateBundlePaths?: string[]; + defaultCertificateDirectoryPaths?: string[]; +} + +export interface WithDataBindMountOptions { + isReadOnly?: boolean; +} + +export interface WithDataVolumeOptions { + name?: string; + isReadOnly?: boolean; +} + +export interface WithDescriptionOptions { + enableMarkdown?: boolean; +} + +export interface WithDockerfileBaseImageOptions { + buildImage?: string; + runtimeImage?: string; +} + +export interface WithDockerfileBuilderOptions { + stage?: string; +} + +export interface WithDockerfileOptions { + dockerfilePath?: string; + stage?: string; +} + +export interface WithEndpointCallbackOptions { + createIfNotExists?: boolean; +} + +export interface WithEndpointOptions { + port?: number; + targetPort?: number; + scheme?: string; + name?: string; + env?: string; + isProxied?: boolean; + isExternal?: boolean; + protocol?: ProtocolType; +} + +export interface WithHideFromDashboardOptions { + displayName?: string; +} + +export interface WithHostPortOptions { + port?: number; +} + +export interface WithHttpEndpointCallbackOptions { + name?: string; + createIfNotExists?: boolean; +} + +export interface WithHttpEndpointOptions { + port?: number; + targetPort?: number; + name?: string; + env?: string; + isProxied?: boolean; +} + +export interface WithHttpHealthCheckOptions { + path?: string; + statusCode?: number; + endpointName?: string; +} + +export interface WithHttpProbeOptions { + path?: string; + initialDelaySeconds?: number; + periodSeconds?: number; + timeoutSeconds?: number; + failureThreshold?: number; + successThreshold?: number; + endpointName?: string; +} + +export interface WithHttpsDeveloperCertificateOptions { + password?: Awaitable; +} + +export interface WithHttpsEndpointCallbackOptions { + name?: string; + createIfNotExists?: boolean; +} + +export interface WithHttpsEndpointOptions { + port?: number; + targetPort?: number; + name?: string; + env?: string; + isProxied?: boolean; +} + +export interface WithIconNameOptions { + iconVariant?: IconVariant; +} + +export interface WithImageOptions { + tag?: string; +} + +export interface WithLikeC4DetailsOptions { + label?: string; + technology?: string; + description?: string; + summary?: string; + icon?: string; + configure?: (obj: LikeC4NodeDetailsAnnotation) => Promise; +} + +export interface WithLikeC4ReferenceOptions { + configure?: (obj: LikeC4RelationshipDetailsAnnotation) => Promise; +} + +export interface WithLikeC4ReferenceWithEnvironmentOptions { + configure?: (obj: LikeC4RelationshipDetailsAnnotation) => Promise; + connectionName?: string; + optional?: boolean; + skipAspireReference?: boolean; +} + +export interface WithLinkNodeOptions { + title?: string; +} + +export interface WithLinkRelationshipOptions { + title?: string; +} + +export interface WithLinkUriNodeOptions { + title?: string; +} + +export interface WithLinkUriRelationshipOptions { + title?: string; +} + +export interface WithLocalCLIOptions { + runtime?: LocalCLIRuntime; +} + +export interface WithMcpServerOptions { + path?: string; + endpointName?: string; +} + +export interface WithNpmOptions { + install?: boolean; + installCommand?: string; + installArgs?: string[]; +} + +export interface WithOtlpExporterOptions { + protocol?: OtlpProtocol; +} + +export interface WithParameterOptions { + value?: string | string[] | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | BicepOutputReference | ReferenceExpression | EndpointReference | Awaitable; +} + +export interface WithPasswordAuthenticationOptions { + keyVaultBuilder?: Awaitable; + userName?: Awaitable; + password?: Awaitable; +} + +export interface WithPersistenceOptions { + interval?: number; + keysChangedThreshold?: number; +} + +export interface WithPgAdminOptions { + configureContainer?: (obj: PgAdminContainerResource) => Promise; + containerName?: string; +} + +export interface WithPgWebOptions { + configureContainer?: (obj: PgWebContainerResource) => Promise; + containerName?: string; +} + +export interface WithPipelineStepFactoryOptions { + dependsOn?: string[]; + requiredBy?: string[]; + tags?: string[]; + description?: string; +} + +export interface WithPnpmOptions { + install?: boolean; + installArgs?: string[]; +} + +export interface WithPostgresMcpOptions { + configureContainer?: (obj: PostgresMcpContainerResource) => Promise; + containerName?: string; +} + +export interface WithRedisCommanderOptions { + configureContainer?: (obj: RedisCommanderResource) => Promise; + containerName?: string; +} + +export interface WithRedisInsightOptions { + configureContainer?: (obj: RedisInsightResource) => Promise; + containerName?: string; +} + +export interface WithReferenceOptions { + connectionName?: string; + optional?: boolean; + name?: string; +} + +export interface WithRequiredCommandOptions { + helpLink?: string; +} + +export interface WithRunScriptOptions { + args?: string[]; +} + +export interface WithUrlOptions { + displayText?: string; +} + +export interface WithVolumeOptions { + name?: string; + isReadOnly?: boolean; +} + +export interface WithYarnOptions { + install?: boolean; + installArgs?: string[]; +} + +// ============================================================================ +// AfterResourcesCreatedEvent +// ============================================================================ + +export interface AfterResourcesCreatedEvent { + toJSON(): MarshalledHandle; + /** Gets the Services property */ + services(): Promise; + /** Gets the Model property */ + model(): Promise; +} + +// ============================================================================ +// AfterResourcesCreatedEventImpl +// ============================================================================ + +/** + * Type class for AfterResourcesCreatedEvent. + */ +class AfterResourcesCreatedEventImpl implements AfterResourcesCreatedEvent { + constructor(private _handle: AfterResourcesCreatedEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + async services(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/AfterResourcesCreatedEvent.services', + { context: this._handle } + ); + return new ServiceProviderImpl(handle, this._client); + } + + async model(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/AfterResourcesCreatedEvent.model', + { context: this._handle } + ); + return new DistributedApplicationModelImpl(handle, this._client); + } + +} + +// ============================================================================ +// AspireC4DiagramOptions +// ============================================================================ + +export interface AspireC4DiagramOptions { + toJSON(): MarshalledHandle; + /** Gets the GeneratedViewId property */ + generatedViewId: { + get: () => Promise; + set: (value: string) => Promise; + }; + /** Gets the DefaultViewId property */ + defaultViewId: { + get: () => Promise; + set: (value: string) => Promise; + }; + /** Gets the Title property */ + title: { + get: () => Promise; + set: (value: string) => Promise; + }; + /** Gets the ViewTitle property */ + viewTitle: { + get: () => Promise; + set: (value: string) => Promise; + }; + /** Gets the ViewDescription property */ + viewDescription: { + get: () => Promise; + set: (value: string) => Promise; + }; + /** Gets the OutputDirectory property */ + outputDirectory: { + get: () => Promise; + set: (value: string) => Promise; + }; + /** Gets the FileName property */ + fileName: { + get: () => Promise; + set: (value: string) => Promise; + }; + /** Gets the DisableHMR property */ + disableHMR: { + get: () => Promise; + set: (value: boolean) => Promise; + }; + /** Gets the HMRPort property */ + hMRPort: { + get: () => Promise; + set: (value: number) => Promise; + }; + /** Gets the ContainerImageTag property */ + containerImageTag: { + get: () => Promise; + set: (value: string) => Promise; + }; + /** Gets the CheckLatestImageVersion property */ + checkLatestImageVersion: { + get: () => Promise; + set: (value: boolean) => Promise; + }; + /** Gets the AutoIconsEnabled property */ + autoIconsEnabled: { + get: () => Promise; + set: (value: boolean) => Promise; + }; + /** Gets the HideFromDashboard property */ + hideFromDashboard: { + get: () => Promise; + set: (value: boolean) => Promise; + }; + /** Gets the DashboardLinkDisplayName property */ + dashboardLinkDisplayName: { + get: () => Promise; + set: (value: string) => Promise; + }; + /** Gets the RelationshipKindSyntax property */ + relationshipKindSyntax: { + get: () => Promise; + set: (value: LikeC4RelationshipKindSyntax) => Promise; + }; + /** Gets the FormatGeneratedFile property */ + formatGeneratedFile: { + get: () => Promise; + set: (value: boolean) => Promise; + }; + /** Gets the ExternalProcessTimeoutSeconds property */ + externalProcessTimeoutSeconds: { + get: () => Promise; + set: (value: number) => Promise; + }; + /** Gets the UseDotIfAvailable property */ + useDotIfAvailable: { + get: () => Promise; + set: (value: boolean) => Promise; + }; + /** Gets the AutoIncludeAspireMetadata property */ + autoIncludeAspireMetadata: { + get: () => Promise; + set: (value: AspireMetadataInclusion) => Promise; + }; + /** Gets the NormaliseMetadataBehaviour property */ + normaliseMetadataBehaviour: { + get: () => Promise; + set: (value: NormaliseMetadataBehaviour) => Promise; + }; + /** Gets the AdditionalDSLFiles property */ + readonly additionalDSLFiles: AspireList; + /** Gets the AdditionalDSLFolders property */ + readonly additionalDSLFolders: AspireList; + /** Gets the ImageAliases property */ + readonly imageAliases: AspireDict; + /** Gets the GenerateConfigFile property */ + generateConfigFile: { + get: () => Promise; + set: (value: boolean) => Promise; + }; + /** Gets the IncludeAspireDashboardLinks property */ + includeAspireDashboardLinks: { + get: () => Promise; + set: (value: boolean) => Promise; + }; + /** Gets the IncludeAspireTokenInDashboardLinks property */ + includeAspireTokenInDashboardLinks: { + get: () => Promise; + set: (value: boolean) => Promise; + }; + /** Gets the StateTagMap property */ + readonly stateTagMap: AspireDict; + /** Gets the IncludeDefaultStateStyles property */ + includeDefaultStateStyles: { + get: () => Promise; + set: (value: boolean) => Promise; + }; + /** Gets the ConfigFileMetadata property */ + readonly configFileMetadata: AspireDict; +} + +// ============================================================================ +// AspireC4DiagramOptionsImpl +// ============================================================================ + +/** + * Type class for AspireC4DiagramOptions. + */ +class AspireC4DiagramOptionsImpl implements AspireC4DiagramOptions { + constructor(private _handle: AspireC4DiagramOptionsHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + generatedViewId = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.generatedViewId', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.setGeneratedViewId', + { context: this._handle, value } + ); + } + }; + + defaultViewId = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.defaultViewId', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.setDefaultViewId', + { context: this._handle, value } + ); + } + }; + + title = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.title', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.setTitle', + { context: this._handle, value } + ); + } + }; + + viewTitle = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.viewTitle', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.setViewTitle', + { context: this._handle, value } + ); + } + }; + + viewDescription = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.viewDescription', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.setViewDescription', + { context: this._handle, value } + ); + } + }; + + outputDirectory = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.outputDirectory', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.setOutputDirectory', + { context: this._handle, value } + ); + } + }; + + fileName = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.fileName', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.setFileName', + { context: this._handle, value } + ); + } + }; + + disableHMR = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.disableHMR', + { context: this._handle } + ); + }, + set: async (value: boolean): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.setDisableHMR', + { context: this._handle, value } + ); + } + }; + + hMRPort = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.hMRPort', + { context: this._handle } + ); + }, + set: async (value: number): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.setHMRPort', + { context: this._handle, value } + ); + } + }; + + containerImageTag = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.containerImageTag', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.setContainerImageTag', + { context: this._handle, value } + ); + } + }; + + checkLatestImageVersion = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.checkLatestImageVersion', + { context: this._handle } + ); + }, + set: async (value: boolean): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.setCheckLatestImageVersion', + { context: this._handle, value } + ); + } + }; + + autoIconsEnabled = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.autoIconsEnabled', + { context: this._handle } + ); + }, + set: async (value: boolean): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.setAutoIconsEnabled', + { context: this._handle, value } + ); + } + }; + + hideFromDashboard = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.hideFromDashboard', + { context: this._handle } + ); + }, + set: async (value: boolean): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.setHideFromDashboard', + { context: this._handle, value } + ); + } + }; + + dashboardLinkDisplayName = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.dashboardLinkDisplayName', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.setDashboardLinkDisplayName', + { context: this._handle, value } + ); + } + }; + + relationshipKindSyntax = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.relationshipKindSyntax', + { context: this._handle } + ); + }, + set: async (value: LikeC4RelationshipKindSyntax): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.setRelationshipKindSyntax', + { context: this._handle, value } + ); + } + }; + + formatGeneratedFile = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.formatGeneratedFile', + { context: this._handle } + ); + }, + set: async (value: boolean): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.setFormatGeneratedFile', + { context: this._handle, value } + ); + } + }; + + externalProcessTimeoutSeconds = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.externalProcessTimeoutSeconds', + { context: this._handle } + ); + }, + set: async (value: number): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.setExternalProcessTimeoutSeconds', + { context: this._handle, value } + ); + } + }; + + useDotIfAvailable = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.useDotIfAvailable', + { context: this._handle } + ); + }, + set: async (value: boolean): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.setUseDotIfAvailable', + { context: this._handle, value } + ); + } + }; + + autoIncludeAspireMetadata = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.autoIncludeAspireMetadata', + { context: this._handle } + ); + }, + set: async (value: AspireMetadataInclusion): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.setAutoIncludeAspireMetadata', + { context: this._handle, value } + ); + } + }; + + normaliseMetadataBehaviour = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.normaliseMetadataBehaviour', + { context: this._handle } + ); + }, + set: async (value: NormaliseMetadataBehaviour): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.setNormaliseMetadataBehaviour', + { context: this._handle, value } + ); + } + }; + + private _additionalDSLFiles?: AspireList; + get additionalDSLFiles(): AspireList { + if (!this._additionalDSLFiles) { + this._additionalDSLFiles = new AspireList( + this._handle, + this._client, + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.additionalDSLFiles', + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.additionalDSLFiles' + ); + } + return this._additionalDSLFiles; + } + + private _additionalDSLFolders?: AspireList; + get additionalDSLFolders(): AspireList { + if (!this._additionalDSLFolders) { + this._additionalDSLFolders = new AspireList( + this._handle, + this._client, + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.additionalDSLFolders', + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.additionalDSLFolders' + ); + } + return this._additionalDSLFolders; + } + + private _imageAliases?: AspireDict; + get imageAliases(): AspireDict { + if (!this._imageAliases) { + this._imageAliases = new AspireDict( + this._handle, + this._client, + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.imageAliases', + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.imageAliases' + ); + } + return this._imageAliases; + } + + generateConfigFile = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.generateConfigFile', + { context: this._handle } + ); + }, + set: async (value: boolean): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.setGenerateConfigFile', + { context: this._handle, value } + ); + } + }; + + includeAspireDashboardLinks = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.includeAspireDashboardLinks', + { context: this._handle } + ); + }, + set: async (value: boolean): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.setIncludeAspireDashboardLinks', + { context: this._handle, value } + ); + } + }; + + includeAspireTokenInDashboardLinks = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.includeAspireTokenInDashboardLinks', + { context: this._handle } + ); + }, + set: async (value: boolean): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.setIncludeAspireTokenInDashboardLinks', + { context: this._handle, value } + ); + } + }; + + private _stateTagMap?: AspireDict; + get stateTagMap(): AspireDict { + if (!this._stateTagMap) { + this._stateTagMap = new AspireDict( + this._handle, + this._client, + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.stateTagMap', + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.stateTagMap' + ); + } + return this._stateTagMap; + } + + includeDefaultStateStyles = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.includeDefaultStateStyles', + { context: this._handle } + ); + }, + set: async (value: boolean): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.setIncludeDefaultStateStyles', + { context: this._handle, value } + ); + } + }; + + private _configFileMetadata?: AspireDict; + get configFileMetadata(): AspireDict { + if (!this._configFileMetadata) { + this._configFileMetadata = new AspireDict( + this._handle, + this._client, + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.configFileMetadata', + 'Aspire.Hosting.AspireC4/AspireC4DiagramOptions.configFileMetadata' + ); + } + return this._configFileMetadata; + } + +} + +// ============================================================================ +// AzureResourceInfrastructure +// ============================================================================ + +export interface AzureResourceInfrastructure { + toJSON(): MarshalledHandle; + /** Gets the BicepName property */ + bicepName(): Promise; + /** Gets the TargetScope property */ + targetScope: { + get: () => Promise; + set: (value: DeploymentScope) => Promise; + }; +} + +// ============================================================================ +// AzureResourceInfrastructureImpl +// ============================================================================ + +/** + * Type class for AzureResourceInfrastructure. + */ +class AzureResourceInfrastructureImpl implements AzureResourceInfrastructure { + constructor(private _handle: AzureResourceInfrastructureHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + async bicepName(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/AzureResourceInfrastructure.bicepName', + { context: this._handle } + ); + } + + targetScope = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/AzureResourceInfrastructure.targetScope', + { context: this._handle } + ); + }, + set: async (value: DeploymentScope): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Azure/AzureResourceInfrastructure.setTargetScope', + { context: this._handle, value } + ); + } + }; + +} + +// ============================================================================ +// BeforeResourceStartedEvent +// ============================================================================ + +export interface BeforeResourceStartedEvent { + toJSON(): MarshalledHandle; + /** Gets the Resource property */ + resource(): Promise; + /** Gets the Services property */ + services(): Promise; +} + +// ============================================================================ +// BeforeResourceStartedEventImpl +// ============================================================================ + +/** + * Type class for BeforeResourceStartedEvent. + */ +class BeforeResourceStartedEventImpl implements BeforeResourceStartedEvent { + constructor(private _handle: BeforeResourceStartedEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + async resource(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/BeforeResourceStartedEvent.resource', + { context: this._handle } + ); + return new ResourceImpl(handle, this._client); + } + + async services(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/BeforeResourceStartedEvent.services', + { context: this._handle } + ); + return new ServiceProviderImpl(handle, this._client); + } + +} + +// ============================================================================ +// BeforeStartEvent +// ============================================================================ + +export interface BeforeStartEvent { + toJSON(): MarshalledHandle; + /** Gets the Services property */ + services(): Promise; + /** Gets the Model property */ + model(): Promise; +} + +// ============================================================================ +// BeforeStartEventImpl +// ============================================================================ + +/** + * Type class for BeforeStartEvent. + */ +class BeforeStartEventImpl implements BeforeStartEvent { + constructor(private _handle: BeforeStartEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + async services(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/BeforeStartEvent.services', + { context: this._handle } + ); + return new ServiceProviderImpl(handle, this._client); + } + + async model(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/BeforeStartEvent.model', + { context: this._handle } + ); + return new DistributedApplicationModelImpl(handle, this._client); + } + +} + +// ============================================================================ +// BicepOutputReference +// ============================================================================ + +export interface BicepOutputReference { + toJSON(): MarshalledHandle; + /** Gets the Name property */ + name(): Promise; + /** Gets the Value property */ + value(): Promise; + /** Gets the ValueExpression property */ + valueExpression(): Promise; +} + +// ============================================================================ +// BicepOutputReferenceImpl +// ============================================================================ + +/** + * Type class for BicepOutputReference. + */ +class BicepOutputReferenceImpl implements BicepOutputReference { + constructor(private _handle: BicepOutputReferenceHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + async name(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/BicepOutputReference.name', + { context: this._handle } + ); + } + + async value(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/BicepOutputReference.value', + { context: this._handle } + ); + } + + async valueExpression(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/BicepOutputReference.valueExpression', + { context: this._handle } + ); + } + +} + +// ============================================================================ +// CommandLineArgsCallbackContext +// ============================================================================ + +export interface CommandLineArgsCallbackContext { + toJSON(): MarshalledHandle; + /** Gets the command-line argument editor */ + args(): Promise; + /** Gets the callback logger facade */ + log(): Promise; + /** Gets the resource associated with this callback */ + resource(): Promise; + /** Gets the execution context for this callback invocation */ + executionContext(): Promise; +} + +// ============================================================================ +// CommandLineArgsCallbackContextImpl +// ============================================================================ + +/** + * Type class for CommandLineArgsCallbackContext. + */ +class CommandLineArgsCallbackContextImpl implements CommandLineArgsCallbackContext { + constructor(private _handle: CommandLineArgsCallbackContextHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + async args(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/CommandLineArgsCallbackContext.args', + { context: this._handle } + ); + return new CommandLineArgsEditorImpl(handle, this._client); + } + + async log(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/CommandLineArgsCallbackContext.log', + { context: this._handle } + ); + return new LogFacadeImpl(handle, this._client); + } + + async resource(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/CommandLineArgsCallbackContext.resource', + { context: this._handle } + ); + return new ResourceImpl(handle, this._client); + } + + async executionContext(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/CommandLineArgsCallbackContext.executionContext', + { context: this._handle } + ); + return new DistributedApplicationExecutionContextImpl(handle, this._client); + } + +} + +// ============================================================================ +// CommandLineArgsEditor +// ============================================================================ + +export interface CommandLineArgsEditor { + toJSON(): MarshalledHandle; + /** Adds a command-line argument */ + add(value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): CommandLineArgsEditorPromise; +} + +export interface CommandLineArgsEditorPromise extends PromiseLike { + /** Adds a command-line argument */ + add(value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): CommandLineArgsEditorPromise; +} + +// ============================================================================ +// CommandLineArgsEditorImpl +// ============================================================================ + +/** + * Type class for CommandLineArgsEditor. + */ +class CommandLineArgsEditorImpl implements CommandLineArgsEditor { + constructor(private _handle: CommandLineArgsEditorHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** @internal */ + async _addInternal(value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): Promise { + value = isPromiseLike(value) ? await value : value; + const rpcArgs: Record = { context: this._handle, value }; + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/add', + rpcArgs + ); + return this; + } + + add(value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): CommandLineArgsEditorPromise { + return new CommandLineArgsEditorPromiseImpl(this._addInternal(value), this._client); + } + +} + +/** + * Thenable wrapper for CommandLineArgsEditor that enables fluent chaining. + */ +class CommandLineArgsEditorPromiseImpl implements CommandLineArgsEditorPromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: CommandLineArgsEditor) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + add(value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): CommandLineArgsEditorPromise { + return new CommandLineArgsEditorPromiseImpl(this._promise.then(obj => obj.add(value)), this._client); + } + +} + +// ============================================================================ +// ConnectionStringAvailableEvent +// ============================================================================ + +export interface ConnectionStringAvailableEvent { + toJSON(): MarshalledHandle; + /** Gets the Resource property */ + resource(): Promise; + /** Gets the Services property */ + services(): Promise; +} + +// ============================================================================ +// ConnectionStringAvailableEventImpl +// ============================================================================ + +/** + * Type class for ConnectionStringAvailableEvent. + */ +class ConnectionStringAvailableEventImpl implements ConnectionStringAvailableEvent { + constructor(private _handle: ConnectionStringAvailableEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + async resource(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ConnectionStringAvailableEvent.resource', + { context: this._handle } + ); + return new ResourceImpl(handle, this._client); + } + + async services(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ConnectionStringAvailableEvent.services', + { context: this._handle } + ); + return new ServiceProviderImpl(handle, this._client); + } + +} + +// ============================================================================ +// ContainerImagePushOptions +// ============================================================================ + +export interface ContainerImagePushOptions { + toJSON(): MarshalledHandle; + /** Gets the RemoteImageName property */ + remoteImageName: { + get: () => Promise; + set: (value: string) => Promise; + }; + /** Gets the RemoteImageTag property */ + remoteImageTag: { + get: () => Promise; + set: (value: string) => Promise; + }; +} + +// ============================================================================ +// ContainerImagePushOptionsImpl +// ============================================================================ + +/** + * Type class for ContainerImagePushOptions. + */ +class ContainerImagePushOptionsImpl implements ContainerImagePushOptions { + constructor(private _handle: ContainerImagePushOptionsHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + remoteImageName = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ContainerImagePushOptions.remoteImageName', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ContainerImagePushOptions.setRemoteImageName', + { context: this._handle, value } + ); + } + }; + + remoteImageTag = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ContainerImagePushOptions.remoteImageTag', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ContainerImagePushOptions.setRemoteImageTag', + { context: this._handle, value } + ); + } + }; + +} + +// ============================================================================ +// ContainerImagePushOptionsCallbackContext +// ============================================================================ + +export interface ContainerImagePushOptionsCallbackContext { + toJSON(): MarshalledHandle; + /** Gets the Resource property */ + resource: { + get: () => Promise; + set: (value: Awaitable) => Promise; + }; + /** Gets the CancellationToken property */ + cancellationToken: { + get: () => Promise; + set: (value: AbortSignal | CancellationToken) => Promise; + }; + /** Gets the Options property */ + options: { + get: () => Promise; + set: (value: Awaitable) => Promise; + }; +} + +// ============================================================================ +// ContainerImagePushOptionsCallbackContextImpl +// ============================================================================ + +/** + * Type class for ContainerImagePushOptionsCallbackContext. + */ +class ContainerImagePushOptionsCallbackContextImpl implements ContainerImagePushOptionsCallbackContext { + constructor(private _handle: ContainerImagePushOptionsCallbackContextHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ContainerImagePushOptionsCallbackContext.resource', + { context: this._handle } + ); + return new ResourceImpl(handle, this._client); + }, + set: async (value: Awaitable): Promise => { + value = isPromiseLike(value) ? await value : value; + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ContainerImagePushOptionsCallbackContext.setResource', + { context: this._handle, value } + ); + } + }; + + cancellationToken = { + get: async (): Promise => { + const result = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ContainerImagePushOptionsCallbackContext.cancellationToken', + { context: this._handle } + ); + return CancellationToken.fromValue(result); + }, + set: async (value: AbortSignal | CancellationToken): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ContainerImagePushOptionsCallbackContext.setCancellationToken', + { context: this._handle, value: CancellationToken.fromValue(value) } + ); + } + }; + + options = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ContainerImagePushOptionsCallbackContext.options', + { context: this._handle } + ); + return new ContainerImagePushOptionsImpl(handle, this._client); + }, + set: async (value: Awaitable): Promise => { + value = isPromiseLike(value) ? await value : value; + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ContainerImagePushOptionsCallbackContext.setOptions', + { context: this._handle, value } + ); + } + }; + +} + +// ============================================================================ +// DistributedApplication +// ============================================================================ + +export interface DistributedApplication { + toJSON(): MarshalledHandle; + /** Runs the distributed application */ + run(options?: RunOptions): DistributedApplicationPromise; +} + +export interface DistributedApplicationPromise extends PromiseLike { + /** Runs the distributed application */ + run(options?: RunOptions): DistributedApplicationPromise; +} + +// ============================================================================ +// DistributedApplicationImpl +// ============================================================================ + +/** + * Type class for DistributedApplication. + */ +class DistributedApplicationImpl implements DistributedApplication { + constructor(private _handle: DistributedApplicationHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** @internal */ + async _runInternal(cancellationToken?: AbortSignal | CancellationToken): Promise { + const rpcArgs: Record = { context: this._handle }; + if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); + await this._client.invokeCapability( + 'Aspire.Hosting/run', + rpcArgs + ); + return this; + } + + run(options?: RunOptions): DistributedApplicationPromise { + const cancellationToken = options?.cancellationToken; + return new DistributedApplicationPromiseImpl(this._runInternal(cancellationToken), this._client); + } + +} + +/** + * Thenable wrapper for DistributedApplication that enables fluent chaining. + */ +class DistributedApplicationPromiseImpl implements DistributedApplicationPromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: DistributedApplication) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + run(options?: RunOptions): DistributedApplicationPromise { + return new DistributedApplicationPromiseImpl(this._promise.then(obj => obj.run(options)), this._client); + } + +} + +// ============================================================================ +// DistributedApplicationExecutionContext +// ============================================================================ + +export interface DistributedApplicationExecutionContext { + toJSON(): MarshalledHandle; + /** Gets the PublisherName property */ + publisherName: { + get: () => Promise; + set: (value: string) => Promise; + }; + /** Gets the Operation property */ + operation(): Promise; + /** Gets the ServiceProvider property */ + serviceProvider(): Promise; + /** Gets the IsPublishMode property */ + isPublishMode(): Promise; + /** Gets the IsRunMode property */ + isRunMode(): Promise; +} + +// ============================================================================ +// DistributedApplicationExecutionContextImpl +// ============================================================================ + +/** + * Type class for DistributedApplicationExecutionContext. + */ +class DistributedApplicationExecutionContextImpl implements DistributedApplicationExecutionContext { + constructor(private _handle: DistributedApplicationExecutionContextHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + publisherName = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting/DistributedApplicationExecutionContext.publisherName', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting/DistributedApplicationExecutionContext.setPublisherName', + { context: this._handle, value } + ); + } + }; + + async operation(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting/DistributedApplicationExecutionContext.operation', + { context: this._handle } + ); + } + + async serviceProvider(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting/DistributedApplicationExecutionContext.serviceProvider', + { context: this._handle } + ); + return new ServiceProviderImpl(handle, this._client); + } + + async isPublishMode(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting/DistributedApplicationExecutionContext.isPublishMode', + { context: this._handle } + ); + } + + async isRunMode(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting/DistributedApplicationExecutionContext.isRunMode', + { context: this._handle } + ); + } + +} + +// ============================================================================ +// DistributedApplicationModel +// ============================================================================ + +export interface DistributedApplicationModel { + toJSON(): MarshalledHandle; + /** Gets resources from the distributed application model */ + getResources(): Promise; + /** Finds a resource by name */ + findResourceByName(name: string): ResourcePromise; +} + +export interface DistributedApplicationModelPromise extends PromiseLike { + /** Gets resources from the distributed application model */ + getResources(): Promise; + /** Finds a resource by name */ + findResourceByName(name: string): ResourcePromise; +} + +// ============================================================================ +// DistributedApplicationModelImpl +// ============================================================================ + +/** + * Type class for DistributedApplicationModel. + */ +class DistributedApplicationModelImpl implements DistributedApplicationModel { + constructor(private _handle: DistributedApplicationModelHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + async getResources(): Promise { + const rpcArgs: Record = { model: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResources', + rpcArgs + ); + } + + /** @internal */ + async _findResourceByNameInternal(name: string): Promise { + const rpcArgs: Record = { model: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/findResourceByName', + rpcArgs + ); + return new ResourceImpl(result, this._client); + } + + findResourceByName(name: string): ResourcePromise { + return new ResourcePromiseImpl(this._findResourceByNameInternal(name), this._client); + } + +} + +/** + * Thenable wrapper for DistributedApplicationModel that enables fluent chaining. + */ +class DistributedApplicationModelPromiseImpl implements DistributedApplicationModelPromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: DistributedApplicationModel) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + getResources(): Promise { + return this._promise.then(obj => obj.getResources()); + } + + findResourceByName(name: string): ResourcePromise { + return new ResourcePromiseImpl(this._promise.then(obj => obj.findResourceByName(name)), this._client); + } + +} + +// ============================================================================ +// DockerfileBuilder +// ============================================================================ + +export interface DockerfileBuilder { + toJSON(): MarshalledHandle; + /** Adds a global ARG statement to the Dockerfile */ + arg(name: string, options?: ArgOptions): DockerfileBuilderPromise; + /** Adds a FROM statement to start a Dockerfile stage */ + from(image: string, options?: FromOptions): DockerfileStagePromise; + /** Adds Dockerfile stages for published container files */ + addContainerFilesStages(resource: Awaitable, options?: AddContainerFilesStagesOptions): DockerfileBuilderPromise; +} + +export interface DockerfileBuilderPromise extends PromiseLike { + /** Adds a global ARG statement to the Dockerfile */ + arg(name: string, options?: ArgOptions): DockerfileBuilderPromise; + /** Adds a FROM statement to start a Dockerfile stage */ + from(image: string, options?: FromOptions): DockerfileStagePromise; + /** Adds Dockerfile stages for published container files */ + addContainerFilesStages(resource: Awaitable, options?: AddContainerFilesStagesOptions): DockerfileBuilderPromise; +} + +// ============================================================================ +// DockerfileBuilderImpl +// ============================================================================ + +/** + * Type class for DockerfileBuilder. + */ +class DockerfileBuilderImpl implements DockerfileBuilder { + constructor(private _handle: DockerfileBuilderHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** @internal */ + async _argInternal(name: string, defaultValue?: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (defaultValue !== undefined) rpcArgs.defaultValue = defaultValue; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/dockerfileBuilderArg', + rpcArgs + ); + return new DockerfileBuilderImpl(result, this._client); + } + + arg(name: string, options?: ArgOptions): DockerfileBuilderPromise { + const defaultValue = options?.defaultValue; + return new DockerfileBuilderPromiseImpl(this._argInternal(name, defaultValue), this._client); + } + + /** @internal */ + async _fromInternal(image: string, stageName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, image }; + if (stageName !== undefined) rpcArgs.stageName = stageName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/dockerfileBuilderFrom', + rpcArgs + ); + return new DockerfileStageImpl(result, this._client); + } + + from(image: string, options?: FromOptions): DockerfileStagePromise { + const stageName = options?.stageName; + return new DockerfileStagePromiseImpl(this._fromInternal(image, stageName), this._client); + } + + /** @internal */ + async _addContainerFilesStagesInternal(resource: Awaitable, logger?: Awaitable): Promise { + resource = isPromiseLike(resource) ? await resource : resource; + logger = isPromiseLike(logger) ? await logger : logger; + const rpcArgs: Record = { builder: this._handle, resource }; + if (logger !== undefined) rpcArgs.logger = logger; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/dockerfileBuilderAddContainerFilesStages', + rpcArgs + ); + return new DockerfileBuilderImpl(result, this._client); + } + + addContainerFilesStages(resource: Awaitable, options?: AddContainerFilesStagesOptions): DockerfileBuilderPromise { + let logger = options?.logger; + return new DockerfileBuilderPromiseImpl(this._addContainerFilesStagesInternal(resource, logger), this._client); + } + +} + +/** + * Thenable wrapper for DockerfileBuilder that enables fluent chaining. + */ +class DockerfileBuilderPromiseImpl implements DockerfileBuilderPromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: DockerfileBuilder) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + arg(name: string, options?: ArgOptions): DockerfileBuilderPromise { + return new DockerfileBuilderPromiseImpl(this._promise.then(obj => obj.arg(name, options)), this._client); + } + + from(image: string, options?: FromOptions): DockerfileStagePromise { + return new DockerfileStagePromiseImpl(this._promise.then(obj => obj.from(image, options)), this._client); + } + + addContainerFilesStages(resource: Awaitable, options?: AddContainerFilesStagesOptions): DockerfileBuilderPromise { + return new DockerfileBuilderPromiseImpl(this._promise.then(obj => obj.addContainerFilesStages(resource, options)), this._client); + } + +} + +// ============================================================================ +// DockerfileBuilderCallbackContext +// ============================================================================ + +export interface DockerfileBuilderCallbackContext { + toJSON(): MarshalledHandle; + /** Gets the Resource property */ + resource(): Promise; + /** Gets the Builder property */ + builder(): Promise; + /** Gets the Services property */ + services(): Promise; + /** Gets the CancellationToken property */ + cancellationToken(): Promise; +} + +// ============================================================================ +// DockerfileBuilderCallbackContextImpl +// ============================================================================ + +/** + * Type class for DockerfileBuilderCallbackContext. + */ +class DockerfileBuilderCallbackContextImpl implements DockerfileBuilderCallbackContext { + constructor(private _handle: DockerfileBuilderCallbackContextHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + async resource(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/DockerfileBuilderCallbackContext.resource', + { context: this._handle } + ); + return new ResourceImpl(handle, this._client); + } + + async builder(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/DockerfileBuilderCallbackContext.builder', + { context: this._handle } + ); + return new DockerfileBuilderImpl(handle, this._client); + } + + async services(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/DockerfileBuilderCallbackContext.services', + { context: this._handle } + ); + return new ServiceProviderImpl(handle, this._client); + } + + async cancellationToken(): Promise { + const result = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/DockerfileBuilderCallbackContext.cancellationToken', + { context: this._handle } + ); + return CancellationToken.fromValue(result); + } + +} + +// ============================================================================ +// DockerfileStage +// ============================================================================ + +export interface DockerfileStage { + toJSON(): MarshalledHandle; + /** Adds an ARG statement to a Dockerfile stage */ + arg(name: string, options?: ArgOptions): DockerfileStagePromise; + /** Adds a WORKDIR statement to a Dockerfile stage */ + workDir(path: string): DockerfileStagePromise; + /** Adds a RUN statement to a Dockerfile stage */ + run(command: string): DockerfileStagePromise; + /** Adds a COPY statement to a Dockerfile stage */ + copy(source: string, destination: string, options?: CopyOptions): DockerfileStagePromise; + /** Adds a COPY --from statement to a Dockerfile stage */ + copyFrom(from: string, source: string, destination: string, options?: CopyFromOptions): DockerfileStagePromise; + /** Adds an ENV statement to a Dockerfile stage */ + env(name: string, value: string): DockerfileStagePromise; + /** Adds an EXPOSE statement to a Dockerfile stage */ + expose(port: number): DockerfileStagePromise; + /** Adds a CMD statement to a Dockerfile stage */ + cmd(command: string[]): DockerfileStagePromise; + /** Adds an ENTRYPOINT statement to a Dockerfile stage */ + entrypoint(command: string[]): DockerfileStagePromise; + /** Adds a RUN statement with mounts to a Dockerfile stage */ + runWithMounts(command: string, mounts: string[]): DockerfileStagePromise; + /** Adds a USER statement to a Dockerfile stage */ + user(user: string): DockerfileStagePromise; + /** Adds an empty line to a Dockerfile stage */ + emptyLine(): DockerfileStagePromise; + /** Adds a comment to a Dockerfile stage */ + comment(comment: string): DockerfileStagePromise; + /** Adds COPY --from statements for published container files */ + addContainerFiles(resource: Awaitable, rootDestinationPath: string, options?: AddContainerFilesOptions): DockerfileStagePromise; +} + +export interface DockerfileStagePromise extends PromiseLike { + /** Adds an ARG statement to a Dockerfile stage */ + arg(name: string, options?: ArgOptions): DockerfileStagePromise; + /** Adds a WORKDIR statement to a Dockerfile stage */ + workDir(path: string): DockerfileStagePromise; + /** Adds a RUN statement to a Dockerfile stage */ + run(command: string): DockerfileStagePromise; + /** Adds a COPY statement to a Dockerfile stage */ + copy(source: string, destination: string, options?: CopyOptions): DockerfileStagePromise; + /** Adds a COPY --from statement to a Dockerfile stage */ + copyFrom(from: string, source: string, destination: string, options?: CopyFromOptions): DockerfileStagePromise; + /** Adds an ENV statement to a Dockerfile stage */ + env(name: string, value: string): DockerfileStagePromise; + /** Adds an EXPOSE statement to a Dockerfile stage */ + expose(port: number): DockerfileStagePromise; + /** Adds a CMD statement to a Dockerfile stage */ + cmd(command: string[]): DockerfileStagePromise; + /** Adds an ENTRYPOINT statement to a Dockerfile stage */ + entrypoint(command: string[]): DockerfileStagePromise; + /** Adds a RUN statement with mounts to a Dockerfile stage */ + runWithMounts(command: string, mounts: string[]): DockerfileStagePromise; + /** Adds a USER statement to a Dockerfile stage */ + user(user: string): DockerfileStagePromise; + /** Adds an empty line to a Dockerfile stage */ + emptyLine(): DockerfileStagePromise; + /** Adds a comment to a Dockerfile stage */ + comment(comment: string): DockerfileStagePromise; + /** Adds COPY --from statements for published container files */ + addContainerFiles(resource: Awaitable, rootDestinationPath: string, options?: AddContainerFilesOptions): DockerfileStagePromise; +} + +// ============================================================================ +// DockerfileStageImpl +// ============================================================================ + +/** + * Type class for DockerfileStage. + */ +class DockerfileStageImpl implements DockerfileStage { + constructor(private _handle: DockerfileStageHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** @internal */ + async _argInternal(name: string, defaultValue?: string): Promise { + const rpcArgs: Record = { stage: this._handle, name }; + if (defaultValue !== undefined) rpcArgs.defaultValue = defaultValue; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/dockerfileStageArg', + rpcArgs + ); + return new DockerfileStageImpl(result, this._client); + } + + arg(name: string, options?: ArgOptions): DockerfileStagePromise { + const defaultValue = options?.defaultValue; + return new DockerfileStagePromiseImpl(this._argInternal(name, defaultValue), this._client); + } + + /** @internal */ + async _workDirInternal(path: string): Promise { + const rpcArgs: Record = { stage: this._handle, path }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/workDir', + rpcArgs + ); + return new DockerfileStageImpl(result, this._client); + } + + workDir(path: string): DockerfileStagePromise { + return new DockerfileStagePromiseImpl(this._workDirInternal(path), this._client); + } + + /** @internal */ + async _runInternal(command: string): Promise { + const rpcArgs: Record = { stage: this._handle, command }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/dockerfileStageRun', + rpcArgs + ); + return new DockerfileStageImpl(result, this._client); + } + + run(command: string): DockerfileStagePromise { + return new DockerfileStagePromiseImpl(this._runInternal(command), this._client); + } + + /** @internal */ + async _copyInternal(source: string, destination: string, chown?: string): Promise { + const rpcArgs: Record = { stage: this._handle, source, destination }; + if (chown !== undefined) rpcArgs.chown = chown; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/dockerfileStageCopy', + rpcArgs + ); + return new DockerfileStageImpl(result, this._client); + } + + copy(source: string, destination: string, options?: CopyOptions): DockerfileStagePromise { + const chown = options?.chown; + return new DockerfileStagePromiseImpl(this._copyInternal(source, destination, chown), this._client); + } + + /** @internal */ + async _copyFromInternal(from: string, source: string, destination: string, chown?: string): Promise { + const rpcArgs: Record = { stage: this._handle, from, source, destination }; + if (chown !== undefined) rpcArgs.chown = chown; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/dockerfileStageCopyFrom', + rpcArgs + ); + return new DockerfileStageImpl(result, this._client); + } + + copyFrom(from: string, source: string, destination: string, options?: CopyFromOptions): DockerfileStagePromise { + const chown = options?.chown; + return new DockerfileStagePromiseImpl(this._copyFromInternal(from, source, destination, chown), this._client); + } + + /** @internal */ + async _envInternal(name: string, value: string): Promise { + const rpcArgs: Record = { stage: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/env', + rpcArgs + ); + return new DockerfileStageImpl(result, this._client); + } + + env(name: string, value: string): DockerfileStagePromise { + return new DockerfileStagePromiseImpl(this._envInternal(name, value), this._client); + } + + /** @internal */ + async _exposeInternal(port: number): Promise { + const rpcArgs: Record = { stage: this._handle, port }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/expose', + rpcArgs + ); + return new DockerfileStageImpl(result, this._client); + } + + expose(port: number): DockerfileStagePromise { + return new DockerfileStagePromiseImpl(this._exposeInternal(port), this._client); + } + + /** @internal */ + async _cmdInternal(command: string[]): Promise { + const rpcArgs: Record = { stage: this._handle, command }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/cmd', + rpcArgs + ); + return new DockerfileStageImpl(result, this._client); + } + + cmd(command: string[]): DockerfileStagePromise { + return new DockerfileStagePromiseImpl(this._cmdInternal(command), this._client); + } + + /** @internal */ + async _entrypointInternal(command: string[]): Promise { + const rpcArgs: Record = { stage: this._handle, command }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/entrypoint', + rpcArgs + ); + return new DockerfileStageImpl(result, this._client); + } + + entrypoint(command: string[]): DockerfileStagePromise { + return new DockerfileStagePromiseImpl(this._entrypointInternal(command), this._client); + } + + /** @internal */ + async _runWithMountsInternal(command: string, mounts: string[]): Promise { + const rpcArgs: Record = { stage: this._handle, command, mounts }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/runWithMounts', + rpcArgs + ); + return new DockerfileStageImpl(result, this._client); + } + + runWithMounts(command: string, mounts: string[]): DockerfileStagePromise { + return new DockerfileStagePromiseImpl(this._runWithMountsInternal(command, mounts), this._client); + } + + /** @internal */ + async _userInternal(user: string): Promise { + const rpcArgs: Record = { stage: this._handle, user }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/user', + rpcArgs + ); + return new DockerfileStageImpl(result, this._client); + } + + user(user: string): DockerfileStagePromise { + return new DockerfileStagePromiseImpl(this._userInternal(user), this._client); + } + + /** @internal */ + async _emptyLineInternal(): Promise { + const rpcArgs: Record = { stage: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/emptyLine', + rpcArgs + ); + return new DockerfileStageImpl(result, this._client); + } + + emptyLine(): DockerfileStagePromise { + return new DockerfileStagePromiseImpl(this._emptyLineInternal(), this._client); + } + + /** @internal */ + async _commentInternal(comment: string): Promise { + const rpcArgs: Record = { stage: this._handle, comment }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/comment', + rpcArgs + ); + return new DockerfileStageImpl(result, this._client); + } + + comment(comment: string): DockerfileStagePromise { + return new DockerfileStagePromiseImpl(this._commentInternal(comment), this._client); + } + + /** @internal */ + async _addContainerFilesInternal(resource: Awaitable, rootDestinationPath: string, logger?: Awaitable): Promise { + resource = isPromiseLike(resource) ? await resource : resource; + logger = isPromiseLike(logger) ? await logger : logger; + const rpcArgs: Record = { stage: this._handle, resource, rootDestinationPath }; + if (logger !== undefined) rpcArgs.logger = logger; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/dockerfileStageAddContainerFiles', + rpcArgs + ); + return new DockerfileStageImpl(result, this._client); + } + + addContainerFiles(resource: Awaitable, rootDestinationPath: string, options?: AddContainerFilesOptions): DockerfileStagePromise { + let logger = options?.logger; + return new DockerfileStagePromiseImpl(this._addContainerFilesInternal(resource, rootDestinationPath, logger), this._client); + } + +} + +/** + * Thenable wrapper for DockerfileStage that enables fluent chaining. + */ +class DockerfileStagePromiseImpl implements DockerfileStagePromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: DockerfileStage) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + arg(name: string, options?: ArgOptions): DockerfileStagePromise { + return new DockerfileStagePromiseImpl(this._promise.then(obj => obj.arg(name, options)), this._client); + } + + workDir(path: string): DockerfileStagePromise { + return new DockerfileStagePromiseImpl(this._promise.then(obj => obj.workDir(path)), this._client); + } + + run(command: string): DockerfileStagePromise { + return new DockerfileStagePromiseImpl(this._promise.then(obj => obj.run(command)), this._client); + } + + copy(source: string, destination: string, options?: CopyOptions): DockerfileStagePromise { + return new DockerfileStagePromiseImpl(this._promise.then(obj => obj.copy(source, destination, options)), this._client); + } + + copyFrom(from: string, source: string, destination: string, options?: CopyFromOptions): DockerfileStagePromise { + return new DockerfileStagePromiseImpl(this._promise.then(obj => obj.copyFrom(from, source, destination, options)), this._client); + } + + env(name: string, value: string): DockerfileStagePromise { + return new DockerfileStagePromiseImpl(this._promise.then(obj => obj.env(name, value)), this._client); + } + + expose(port: number): DockerfileStagePromise { + return new DockerfileStagePromiseImpl(this._promise.then(obj => obj.expose(port)), this._client); + } + + cmd(command: string[]): DockerfileStagePromise { + return new DockerfileStagePromiseImpl(this._promise.then(obj => obj.cmd(command)), this._client); + } + + entrypoint(command: string[]): DockerfileStagePromise { + return new DockerfileStagePromiseImpl(this._promise.then(obj => obj.entrypoint(command)), this._client); + } + + runWithMounts(command: string, mounts: string[]): DockerfileStagePromise { + return new DockerfileStagePromiseImpl(this._promise.then(obj => obj.runWithMounts(command, mounts)), this._client); + } + + user(user: string): DockerfileStagePromise { + return new DockerfileStagePromiseImpl(this._promise.then(obj => obj.user(user)), this._client); + } + + emptyLine(): DockerfileStagePromise { + return new DockerfileStagePromiseImpl(this._promise.then(obj => obj.emptyLine()), this._client); + } + + comment(comment: string): DockerfileStagePromise { + return new DockerfileStagePromiseImpl(this._promise.then(obj => obj.comment(comment)), this._client); + } + + addContainerFiles(resource: Awaitable, rootDestinationPath: string, options?: AddContainerFilesOptions): DockerfileStagePromise { + return new DockerfileStagePromiseImpl(this._promise.then(obj => obj.addContainerFiles(resource, rootDestinationPath, options)), this._client); + } + +} + +// ============================================================================ +// EndpointReference +// ============================================================================ + +export interface EndpointReference { + toJSON(): MarshalledHandle; + /** Gets the Resource property */ + resource(): Promise; + /** Gets the EndpointName property */ + endpointName(): Promise; + /** Gets the ErrorMessage property */ + errorMessage: { + get: () => Promise; + set: (value: string) => Promise; + }; + /** Gets the IsAllocated property */ + isAllocated(): Promise; + /** Gets the Exists property */ + exists(): Promise; + /** Gets the IsHttp property */ + isHttp(): Promise; + /** Gets the IsHttps property */ + isHttps(): Promise; + /** Gets the TlsEnabled property */ + tlsEnabled(): Promise; + /** Gets the IsHttpSchemeNamedEndpoint property */ + isHttpSchemeNamedEndpoint(): Promise; + /** Gets the ExcludeReferenceEndpoint property */ + excludeReferenceEndpoint(): Promise; + /** Gets the Port property */ + port(): Promise; + /** Gets the TargetPort property */ + targetPort(): Promise; + /** Gets the Host property */ + host(): Promise; + /** Gets the Scheme property */ + scheme(): Promise; + /** Gets the Url property */ + url(): Promise; + /** Gets the URL of the endpoint asynchronously */ + getValueAsync(options?: GetValueAsyncOptions): Promise; + /** Gets the specified property expression of the endpoint */ + property(property: EndpointProperty): Promise; + /** Gets a conditional expression that resolves to the enabledValue when TLS is enabled on the endpoint, or to the disabledValue otherwise. */ + getTlsValue(enabledValue: ReferenceExpression, disabledValue: ReferenceExpression): Promise; +} + +export interface EndpointReferencePromise extends PromiseLike { + /** Gets the Resource property */ + resource(): Promise; + /** Gets the EndpointName property */ + endpointName(): Promise; + /** Gets the IsAllocated property */ + isAllocated(): Promise; + /** Gets the Exists property */ + exists(): Promise; + /** Gets the IsHttp property */ + isHttp(): Promise; + /** Gets the IsHttps property */ + isHttps(): Promise; + /** Gets the TlsEnabled property */ + tlsEnabled(): Promise; + /** Gets the IsHttpSchemeNamedEndpoint property */ + isHttpSchemeNamedEndpoint(): Promise; + /** Gets the ExcludeReferenceEndpoint property */ + excludeReferenceEndpoint(): Promise; + /** Gets the Port property */ + port(): Promise; + /** Gets the TargetPort property */ + targetPort(): Promise; + /** Gets the Host property */ + host(): Promise; + /** Gets the Scheme property */ + scheme(): Promise; + /** Gets the Url property */ + url(): Promise; + /** Gets the URL of the endpoint asynchronously */ + getValueAsync(options?: GetValueAsyncOptions): Promise; + /** Gets the specified property expression of the endpoint */ + property(property: EndpointProperty): Promise; + /** Gets a conditional expression that resolves to the enabledValue when TLS is enabled on the endpoint, or to the disabledValue otherwise. */ + getTlsValue(enabledValue: ReferenceExpression, disabledValue: ReferenceExpression): Promise; +} + +// ============================================================================ +// EndpointReferenceImpl +// ============================================================================ + +/** + * Type class for EndpointReference. + */ +class EndpointReferenceImpl implements EndpointReference { + constructor(private _handle: EndpointReferenceHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + async resource(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReference.resource', + { context: this._handle } + ); + return new ResourceWithEndpointsImpl(handle, this._client); + } + + async endpointName(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReference.endpointName', + { context: this._handle } + ); + } + + errorMessage = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReference.errorMessage', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReference.setErrorMessage', + { context: this._handle, value } + ); + } + }; + + async isAllocated(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReference.isAllocated', + { context: this._handle } + ); + } + + async exists(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReference.exists', + { context: this._handle } + ); + } + + async isHttp(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReference.isHttp', + { context: this._handle } + ); + } + + async isHttps(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReference.isHttps', + { context: this._handle } + ); + } + + async tlsEnabled(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReference.tlsEnabled', + { context: this._handle } + ); + } + + async isHttpSchemeNamedEndpoint(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReference.isHttpSchemeNamedEndpoint', + { context: this._handle } + ); + } + + async excludeReferenceEndpoint(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReference.excludeReferenceEndpoint', + { context: this._handle } + ); + } + + async port(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReference.port', + { context: this._handle } + ); + } + + async targetPort(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReference.targetPort', + { context: this._handle } + ); + } + + async host(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReference.host', + { context: this._handle } + ); + } + + async scheme(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReference.scheme', + { context: this._handle } + ); + } + + async url(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReference.url', + { context: this._handle } + ); + } + + async getValueAsync(options?: GetValueAsyncOptions): Promise { + const cancellationToken = options?.cancellationToken; + const rpcArgs: Record = { context: this._handle }; + if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReference.getValueAsync', + rpcArgs + ); + } + + async property(property: EndpointProperty): Promise { + const rpcArgs: Record = { context: this._handle, property }; + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReference.property', + rpcArgs + ); + } + + async getTlsValue(enabledValue: ReferenceExpression, disabledValue: ReferenceExpression): Promise { + const rpcArgs: Record = { context: this._handle, enabledValue, disabledValue }; + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReference.getTlsValue', + rpcArgs + ); + } + +} + +/** + * Thenable wrapper for EndpointReference that enables fluent chaining. + */ +class EndpointReferencePromiseImpl implements EndpointReferencePromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: EndpointReference) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + resource(): Promise { + return this._promise.then(obj => obj.resource()); + } + + endpointName(): Promise { + return this._promise.then(obj => obj.endpointName()); + } + + isAllocated(): Promise { + return this._promise.then(obj => obj.isAllocated()); + } + + exists(): Promise { + return this._promise.then(obj => obj.exists()); + } + + isHttp(): Promise { + return this._promise.then(obj => obj.isHttp()); + } + + isHttps(): Promise { + return this._promise.then(obj => obj.isHttps()); + } + + tlsEnabled(): Promise { + return this._promise.then(obj => obj.tlsEnabled()); + } + + isHttpSchemeNamedEndpoint(): Promise { + return this._promise.then(obj => obj.isHttpSchemeNamedEndpoint()); + } + + excludeReferenceEndpoint(): Promise { + return this._promise.then(obj => obj.excludeReferenceEndpoint()); + } + + port(): Promise { + return this._promise.then(obj => obj.port()); + } + + targetPort(): Promise { + return this._promise.then(obj => obj.targetPort()); + } + + host(): Promise { + return this._promise.then(obj => obj.host()); + } + + scheme(): Promise { + return this._promise.then(obj => obj.scheme()); + } + + url(): Promise { + return this._promise.then(obj => obj.url()); + } + + getValueAsync(options?: GetValueAsyncOptions): Promise { + return this._promise.then(obj => obj.getValueAsync(options)); + } + + property(property: EndpointProperty): Promise { + return this._promise.then(obj => obj.property(property)); + } + + getTlsValue(enabledValue: ReferenceExpression, disabledValue: ReferenceExpression): Promise { + return this._promise.then(obj => obj.getTlsValue(enabledValue, disabledValue)); + } + +} + +// ============================================================================ +// EndpointReferenceExpression +// ============================================================================ + +export interface EndpointReferenceExpression { + toJSON(): MarshalledHandle; + /** Gets the Endpoint property */ + endpoint(): Promise; + /** Gets the Property property */ + property(): Promise; + /** Gets the ValueExpression property */ + valueExpression(): Promise; +} + +// ============================================================================ +// EndpointReferenceExpressionImpl +// ============================================================================ + +/** + * Type class for EndpointReferenceExpression. + */ +class EndpointReferenceExpressionImpl implements EndpointReferenceExpression { + constructor(private _handle: EndpointReferenceExpressionHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + async endpoint(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReferenceExpression.endpoint', + { context: this._handle } + ); + return new EndpointReferenceImpl(handle, this._client); + } + + async property(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReferenceExpression.property', + { context: this._handle } + ); + } + + async valueExpression(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReferenceExpression.valueExpression', + { context: this._handle } + ); + } + +} + +// ============================================================================ +// EndpointUpdateContext +// ============================================================================ + +export interface EndpointUpdateContext { + toJSON(): MarshalledHandle; + /** Gets the Name property */ + name(): Promise; + /** Gets the Protocol property */ + protocol: { + get: () => Promise; + set: (value: ProtocolType) => Promise; + }; + /** Gets the Port property */ + port: { + get: () => Promise; + set: (value: number) => Promise; + }; + /** Gets the TargetPort property */ + targetPort: { + get: () => Promise; + set: (value: number) => Promise; + }; + /** Gets the UriScheme property */ + uriScheme: { + get: () => Promise; + set: (value: string) => Promise; + }; + /** Gets the TargetHost property */ + targetHost: { + get: () => Promise; + set: (value: string) => Promise; + }; + /** Gets the Transport property */ + transport: { + get: () => Promise; + set: (value: string) => Promise; + }; + /** Gets the IsExternal property */ + isExternal: { + get: () => Promise; + set: (value: boolean) => Promise; + }; + /** Gets the IsProxied property */ + isProxied: { + get: () => Promise; + set: (value: boolean) => Promise; + }; + /** Gets the ExcludeReferenceEndpoint property */ + excludeReferenceEndpoint: { + get: () => Promise; + set: (value: boolean) => Promise; + }; + /** Gets the TlsEnabled property */ + tlsEnabled: { + get: () => Promise; + set: (value: boolean) => Promise; + }; +} + +// ============================================================================ +// EndpointUpdateContextImpl +// ============================================================================ + +/** + * Type class for EndpointUpdateContext. + */ +class EndpointUpdateContextImpl implements EndpointUpdateContext { + constructor(private _handle: EndpointUpdateContextHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + async name(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointUpdateContext.name', + { context: this._handle } + ); + } + + protocol = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointUpdateContext.protocol', + { context: this._handle } + ); + }, + set: async (value: ProtocolType): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointUpdateContext.setProtocol', + { context: this._handle, value } + ); + } + }; + + port = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointUpdateContext.port', + { context: this._handle } + ); + }, + set: async (value: number): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointUpdateContext.setPort', + { context: this._handle, value } + ); + } + }; + + targetPort = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointUpdateContext.targetPort', + { context: this._handle } + ); + }, + set: async (value: number): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointUpdateContext.setTargetPort', + { context: this._handle, value } + ); + } + }; + + uriScheme = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointUpdateContext.uriScheme', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointUpdateContext.setUriScheme', + { context: this._handle, value } + ); + } + }; + + targetHost = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointUpdateContext.targetHost', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointUpdateContext.setTargetHost', + { context: this._handle, value } + ); + } + }; + + transport = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointUpdateContext.transport', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointUpdateContext.setTransport', + { context: this._handle, value } + ); + } + }; + + isExternal = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointUpdateContext.isExternal', + { context: this._handle } + ); + }, + set: async (value: boolean): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointUpdateContext.setIsExternal', + { context: this._handle, value } + ); + } + }; + + isProxied = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointUpdateContext.isProxied', + { context: this._handle } + ); + }, + set: async (value: boolean): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointUpdateContext.setIsProxied', + { context: this._handle, value } + ); + } + }; + + excludeReferenceEndpoint = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointUpdateContext.excludeReferenceEndpoint', + { context: this._handle } + ); + }, + set: async (value: boolean): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointUpdateContext.setExcludeReferenceEndpoint', + { context: this._handle, value } + ); + } + }; + + tlsEnabled = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointUpdateContext.tlsEnabled', + { context: this._handle } + ); + }, + set: async (value: boolean): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointUpdateContext.setTlsEnabled', + { context: this._handle, value } + ); + } + }; + +} + +// ============================================================================ +// EnvironmentCallbackContext +// ============================================================================ + +export interface EnvironmentCallbackContext { + toJSON(): MarshalledHandle; + /** Gets the environment variable editor */ + environment(): Promise; + /** Gets the callback logger facade */ + log(): Promise; + /** Gets the resource associated with this callback */ + resource(): Promise; + /** Gets the execution context for this callback invocation */ + executionContext(): Promise; +} + +// ============================================================================ +// EnvironmentCallbackContextImpl +// ============================================================================ + +/** + * Type class for EnvironmentCallbackContext. + */ +class EnvironmentCallbackContextImpl implements EnvironmentCallbackContext { + constructor(private _handle: EnvironmentCallbackContextHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + async environment(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EnvironmentCallbackContext.environment', + { context: this._handle } + ); + return new EnvironmentEditorImpl(handle, this._client); + } + + async log(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EnvironmentCallbackContext.log', + { context: this._handle } + ); + return new LogFacadeImpl(handle, this._client); + } + + async resource(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EnvironmentCallbackContext.resource', + { context: this._handle } + ); + return new ResourceImpl(handle, this._client); + } + + async executionContext(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EnvironmentCallbackContext.executionContext', + { context: this._handle } + ); + return new DistributedApplicationExecutionContextImpl(handle, this._client); + } + +} + +// ============================================================================ +// EnvironmentEditor +// ============================================================================ + +export interface EnvironmentEditor { + toJSON(): MarshalledHandle; + /** Sets an environment variable */ + set(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): EnvironmentEditorPromise; +} + +export interface EnvironmentEditorPromise extends PromiseLike { + /** Sets an environment variable */ + set(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): EnvironmentEditorPromise; +} + +// ============================================================================ +// EnvironmentEditorImpl +// ============================================================================ + +/** + * Type class for EnvironmentEditor. + */ +class EnvironmentEditorImpl implements EnvironmentEditor { + constructor(private _handle: EnvironmentEditorHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** @internal */ + async _setInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): Promise { + value = isPromiseLike(value) ? await value : value; + const rpcArgs: Record = { context: this._handle, name, value }; + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/set', + rpcArgs + ); + return this; + } + + set(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): EnvironmentEditorPromise { + return new EnvironmentEditorPromiseImpl(this._setInternal(name, value), this._client); + } + +} + +/** + * Thenable wrapper for EnvironmentEditor that enables fluent chaining. + */ +class EnvironmentEditorPromiseImpl implements EnvironmentEditorPromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: EnvironmentEditor) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + set(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): EnvironmentEditorPromise { + return new EnvironmentEditorPromiseImpl(this._promise.then(obj => obj.set(name, value)), this._client); + } + +} + +// ============================================================================ +// EventingSubscriberRegistrationContext +// ============================================================================ + +export interface EventingSubscriberRegistrationContext { + toJSON(): MarshalledHandle; + /** Gets the ExecutionContext property */ + executionContext(): Promise; + /** Gets the CancellationToken property */ + cancellationToken(): Promise; + /** Subscribes an eventing subscriber to the BeforeStart event */ + onBeforeStart(callback: (arg: BeforeStartEvent) => Promise): Promise; + /** Subscribes an eventing subscriber to the AfterResourcesCreated event */ + onAfterResourcesCreated(callback: (arg: AfterResourcesCreatedEvent) => Promise): Promise; +} + +export interface EventingSubscriberRegistrationContextPromise extends PromiseLike { + /** Gets the ExecutionContext property */ + executionContext(): Promise; + /** Gets the CancellationToken property */ + cancellationToken(): Promise; + /** Subscribes an eventing subscriber to the BeforeStart event */ + onBeforeStart(callback: (arg: BeforeStartEvent) => Promise): Promise; + /** Subscribes an eventing subscriber to the AfterResourcesCreated event */ + onAfterResourcesCreated(callback: (arg: AfterResourcesCreatedEvent) => Promise): Promise; +} + +// ============================================================================ +// EventingSubscriberRegistrationContextImpl +// ============================================================================ + +/** + * Type class for EventingSubscriberRegistrationContext. + */ +class EventingSubscriberRegistrationContextImpl implements EventingSubscriberRegistrationContext { + constructor(private _handle: EventingSubscriberRegistrationContextHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + async executionContext(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Ats/EventingSubscriberRegistrationContext.executionContext', + { context: this._handle } + ); + return new DistributedApplicationExecutionContextImpl(handle, this._client); + } + + async cancellationToken(): Promise { + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Ats/EventingSubscriberRegistrationContext.cancellationToken', + { context: this._handle } + ); + return CancellationToken.fromValue(result); + } + + async onBeforeStart(callback: (arg: BeforeStartEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeStartEventHandle; + const arg = new BeforeStartEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { context: this._handle, callback: callbackId }; + return await this._client.invokeCapability( + 'Aspire.Hosting/eventingSubscriberOnBeforeStart', + rpcArgs + ); + } + + async onAfterResourcesCreated(callback: (arg: AfterResourcesCreatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as AfterResourcesCreatedEventHandle; + const arg = new AfterResourcesCreatedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { context: this._handle, callback: callbackId }; + return await this._client.invokeCapability( + 'Aspire.Hosting/eventingSubscriberOnAfterResourcesCreated', + rpcArgs + ); + } + +} + +/** + * Thenable wrapper for EventingSubscriberRegistrationContext that enables fluent chaining. + */ +class EventingSubscriberRegistrationContextPromiseImpl implements EventingSubscriberRegistrationContextPromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: EventingSubscriberRegistrationContext) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + executionContext(): Promise { + return this._promise.then(obj => obj.executionContext()); + } + + cancellationToken(): Promise { + return this._promise.then(obj => obj.cancellationToken()); + } + + onBeforeStart(callback: (arg: BeforeStartEvent) => Promise): Promise { + return this._promise.then(obj => obj.onBeforeStart(callback)); + } + + onAfterResourcesCreated(callback: (arg: AfterResourcesCreatedEvent) => Promise): Promise { + return this._promise.then(obj => obj.onAfterResourcesCreated(callback)); + } + +} + +// ============================================================================ +// ExecuteCommandContext +// ============================================================================ + +export interface ExecuteCommandContext { + toJSON(): MarshalledHandle; + /** Gets the ServiceProvider property */ + serviceProvider: { + get: () => Promise; + set: (value: Awaitable) => Promise; + }; + /** Gets the ResourceName property */ + resourceName: { + get: () => Promise; + set: (value: string) => Promise; + }; + /** Gets the CancellationToken property */ + cancellationToken: { + get: () => Promise; + set: (value: AbortSignal | CancellationToken) => Promise; + }; + /** Gets the Logger property */ + logger: { + get: () => Promise; + set: (value: Awaitable) => Promise; + }; +} + +// ============================================================================ +// ExecuteCommandContextImpl +// ============================================================================ + +/** + * Type class for ExecuteCommandContext. + */ +class ExecuteCommandContextImpl implements ExecuteCommandContext { + constructor(private _handle: ExecuteCommandContextHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + serviceProvider = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ExecuteCommandContext.serviceProvider', + { context: this._handle } + ); + return new ServiceProviderImpl(handle, this._client); + }, + set: async (value: Awaitable): Promise => { + value = isPromiseLike(value) ? await value : value; + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ExecuteCommandContext.setServiceProvider', + { context: this._handle, value } + ); + } + }; + + resourceName = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ExecuteCommandContext.resourceName', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ExecuteCommandContext.setResourceName', + { context: this._handle, value } + ); + } + }; + + cancellationToken = { + get: async (): Promise => { + const result = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ExecuteCommandContext.cancellationToken', + { context: this._handle } + ); + return CancellationToken.fromValue(result); + }, + set: async (value: AbortSignal | CancellationToken): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ExecuteCommandContext.setCancellationToken', + { context: this._handle, value: CancellationToken.fromValue(value) } + ); + } + }; + + logger = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ExecuteCommandContext.logger', + { context: this._handle } + ); + return new LoggerImpl(handle, this._client); + }, + set: async (value: Awaitable): Promise => { + value = isPromiseLike(value) ? await value : value; + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ExecuteCommandContext.setLogger', + { context: this._handle, value } + ); + } + }; + +} + +// ============================================================================ +// InitializeResourceEvent +// ============================================================================ + +export interface InitializeResourceEvent { + toJSON(): MarshalledHandle; + /** Gets the Resource property */ + resource(): Promise; + /** Gets the Eventing property */ + eventing(): Promise; + /** Gets the Logger property */ + logger(): Promise; + /** Gets the Notifications property */ + notifications(): Promise; + /** Gets the Services property */ + services(): Promise; +} + +// ============================================================================ +// InitializeResourceEventImpl +// ============================================================================ + +/** + * Type class for InitializeResourceEvent. + */ +class InitializeResourceEventImpl implements InitializeResourceEvent { + constructor(private _handle: InitializeResourceEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + async resource(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/InitializeResourceEvent.resource', + { context: this._handle } + ); + return new ResourceImpl(handle, this._client); + } + + async eventing(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/InitializeResourceEvent.eventing', + { context: this._handle } + ); + return new DistributedApplicationEventingImpl(handle, this._client); + } + + async logger(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/InitializeResourceEvent.logger', + { context: this._handle } + ); + return new LoggerImpl(handle, this._client); + } + + async notifications(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/InitializeResourceEvent.notifications', + { context: this._handle } + ); + return new ResourceNotificationServiceImpl(handle, this._client); + } + + async services(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/InitializeResourceEvent.services', + { context: this._handle } + ); + return new ServiceProviderImpl(handle, this._client); + } + +} + +// ============================================================================ +// LikeC4NodeDetailsAnnotation +// ============================================================================ + +export interface LikeC4NodeDetailsAnnotation { + toJSON(): MarshalledHandle; + /** Gets the Label property */ + label: { + get: () => Promise; + set: (value: string) => Promise; + }; + /** Gets the Technology property */ + technology: { + get: () => Promise; + set: (value: string) => Promise; + }; + /** Gets the Description property */ + description: { + get: () => Promise; + set: (value: string) => Promise; + }; + /** Gets the Summary property */ + summary: { + get: () => Promise; + set: (value: string) => Promise; + }; + /** Gets the Icon property */ + icon: { + get: () => Promise; + set: (value: string) => Promise; + }; + /** Gets the AutoIconEnabled property */ + autoIconEnabled: { + get: () => Promise; + set: (value: boolean) => Promise; + }; + /** Gets the Kind property */ + kind: { + get: () => Promise; + set: (value: string) => Promise; + }; + /** Gets the Tags property */ + tags(): Promise; + /** Invokes the WithLabel method */ + withLabel(label: string): LikeC4NodeDetailsAnnotationPromise; + /** Invokes the WithTechnology method */ + withTechnology(technology: string): LikeC4NodeDetailsAnnotationPromise; + /** Invokes the WithDescription method */ + withDescription(description: string): LikeC4NodeDetailsAnnotationPromise; + /** Invokes the WithSummary method */ + withSummary(summary: string): LikeC4NodeDetailsAnnotationPromise; + /** Invokes the WithIcon method */ + withIcon(icon: string): LikeC4NodeDetailsAnnotationPromise; + /** Invokes the WithAutoIcon method */ + withAutoIcon(options?: WithAutoIconOptions): LikeC4NodeDetailsAnnotationPromise; + /** Invokes the WithKind method */ + withKind(kind: string): LikeC4NodeDetailsAnnotationPromise; + /** Invokes the WithTag method */ + withTag(tag: string): LikeC4NodeDetailsAnnotationPromise; + /** Invokes the WithLink method */ + withLinkNode(url: string, options?: WithLinkNodeOptions): LikeC4NodeDetailsAnnotationPromise; + /** Invokes the WithLink method */ + withLinkUriNode(uri: string, options?: WithLinkUriNodeOptions): LikeC4NodeDetailsAnnotationPromise; + /** Invokes the WithMetadata method */ + withMetadataNode(key: string, value: string): LikeC4NodeDetailsAnnotationPromise; +} + +export interface LikeC4NodeDetailsAnnotationPromise extends PromiseLike { + /** Gets the Tags property */ + tags(): Promise; + /** Invokes the WithLabel method */ + withLabel(label: string): LikeC4NodeDetailsAnnotationPromise; + /** Invokes the WithTechnology method */ + withTechnology(technology: string): LikeC4NodeDetailsAnnotationPromise; + /** Invokes the WithDescription method */ + withDescription(description: string): LikeC4NodeDetailsAnnotationPromise; + /** Invokes the WithSummary method */ + withSummary(summary: string): LikeC4NodeDetailsAnnotationPromise; + /** Invokes the WithIcon method */ + withIcon(icon: string): LikeC4NodeDetailsAnnotationPromise; + /** Invokes the WithAutoIcon method */ + withAutoIcon(options?: WithAutoIconOptions): LikeC4NodeDetailsAnnotationPromise; + /** Invokes the WithKind method */ + withKind(kind: string): LikeC4NodeDetailsAnnotationPromise; + /** Invokes the WithTag method */ + withTag(tag: string): LikeC4NodeDetailsAnnotationPromise; + /** Invokes the WithLink method */ + withLinkNode(url: string, options?: WithLinkNodeOptions): LikeC4NodeDetailsAnnotationPromise; + /** Invokes the WithLink method */ + withLinkUriNode(uri: string, options?: WithLinkUriNodeOptions): LikeC4NodeDetailsAnnotationPromise; + /** Invokes the WithMetadata method */ + withMetadataNode(key: string, value: string): LikeC4NodeDetailsAnnotationPromise; +} + +// ============================================================================ +// LikeC4NodeDetailsAnnotationImpl +// ============================================================================ + +/** + * Type class for LikeC4NodeDetailsAnnotation. + */ +class LikeC4NodeDetailsAnnotationImpl implements LikeC4NodeDetailsAnnotation { + constructor(private _handle: LikeC4NodeDetailsAnnotationHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + label = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4.LikeC4.Annotations/LikeC4NodeDetailsAnnotation.label', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4.LikeC4.Annotations/LikeC4NodeDetailsAnnotation.setLabel', + { context: this._handle, value } + ); + } + }; + + technology = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4.LikeC4.Annotations/LikeC4NodeDetailsAnnotation.technology', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4.LikeC4.Annotations/LikeC4NodeDetailsAnnotation.setTechnology', + { context: this._handle, value } + ); + } + }; + + description = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4.LikeC4.Annotations/LikeC4NodeDetailsAnnotation.description', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4.LikeC4.Annotations/LikeC4NodeDetailsAnnotation.setDescription', + { context: this._handle, value } + ); + } + }; + + summary = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4.LikeC4.Annotations/LikeC4NodeDetailsAnnotation.summary', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4.LikeC4.Annotations/LikeC4NodeDetailsAnnotation.setSummary', + { context: this._handle, value } + ); + } + }; + + icon = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4.LikeC4.Annotations/LikeC4NodeDetailsAnnotation.icon', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4.LikeC4.Annotations/LikeC4NodeDetailsAnnotation.setIcon', + { context: this._handle, value } + ); + } + }; + + autoIconEnabled = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4.LikeC4.Annotations/LikeC4NodeDetailsAnnotation.autoIconEnabled', + { context: this._handle } + ); + }, + set: async (value: boolean): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4.LikeC4.Annotations/LikeC4NodeDetailsAnnotation.setAutoIconEnabled', + { context: this._handle, value } + ); + } + }; + + kind = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4.LikeC4.Annotations/LikeC4NodeDetailsAnnotation.kind', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4.LikeC4.Annotations/LikeC4NodeDetailsAnnotation.setKind', + { context: this._handle, value } + ); + } + }; + + async tags(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4.LikeC4.Annotations/LikeC4NodeDetailsAnnotation.tags', + { context: this._handle } + ); + } + + /** @internal */ + async _withLabelInternal(label: string): Promise { + const rpcArgs: Record = { context: this._handle, label }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4.LikeC4.Annotations/LikeC4NodeDetailsAnnotation.withLabel', + rpcArgs + ); + return new LikeC4NodeDetailsAnnotationImpl(result, this._client); + } + + withLabel(label: string): LikeC4NodeDetailsAnnotationPromise { + return new LikeC4NodeDetailsAnnotationPromiseImpl(this._withLabelInternal(label), this._client); + } + + /** @internal */ + async _withTechnologyInternal(technology: string): Promise { + const rpcArgs: Record = { context: this._handle, technology }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4.LikeC4.Annotations/LikeC4NodeDetailsAnnotation.withTechnology', + rpcArgs + ); + return new LikeC4NodeDetailsAnnotationImpl(result, this._client); + } + + withTechnology(technology: string): LikeC4NodeDetailsAnnotationPromise { + return new LikeC4NodeDetailsAnnotationPromiseImpl(this._withTechnologyInternal(technology), this._client); + } + + /** @internal */ + async _withDescriptionInternal(description: string): Promise { + const rpcArgs: Record = { context: this._handle, description }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4.LikeC4.Annotations/LikeC4NodeDetailsAnnotation.withDescription', + rpcArgs + ); + return new LikeC4NodeDetailsAnnotationImpl(result, this._client); + } + + withDescription(description: string): LikeC4NodeDetailsAnnotationPromise { + return new LikeC4NodeDetailsAnnotationPromiseImpl(this._withDescriptionInternal(description), this._client); + } + + /** @internal */ + async _withSummaryInternal(summary: string): Promise { + const rpcArgs: Record = { context: this._handle, summary }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4.LikeC4.Annotations/LikeC4NodeDetailsAnnotation.withSummary', + rpcArgs + ); + return new LikeC4NodeDetailsAnnotationImpl(result, this._client); + } + + withSummary(summary: string): LikeC4NodeDetailsAnnotationPromise { + return new LikeC4NodeDetailsAnnotationPromiseImpl(this._withSummaryInternal(summary), this._client); + } + + /** @internal */ + async _withIconInternal(icon: string): Promise { + const rpcArgs: Record = { context: this._handle, icon }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4.LikeC4.Annotations/LikeC4NodeDetailsAnnotation.withIcon', + rpcArgs + ); + return new LikeC4NodeDetailsAnnotationImpl(result, this._client); + } + + withIcon(icon: string): LikeC4NodeDetailsAnnotationPromise { + return new LikeC4NodeDetailsAnnotationPromiseImpl(this._withIconInternal(icon), this._client); + } + + /** @internal */ + async _withAutoIconInternal(enabled?: boolean): Promise { + const rpcArgs: Record = { context: this._handle }; + if (enabled !== undefined) rpcArgs.enabled = enabled; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4.LikeC4.Annotations/LikeC4NodeDetailsAnnotation.withAutoIcon', + rpcArgs + ); + return new LikeC4NodeDetailsAnnotationImpl(result, this._client); + } + + withAutoIcon(options?: WithAutoIconOptions): LikeC4NodeDetailsAnnotationPromise { + const enabled = options?.enabled; + return new LikeC4NodeDetailsAnnotationPromiseImpl(this._withAutoIconInternal(enabled), this._client); + } + + /** @internal */ + async _withKindInternal(kind: string): Promise { + const rpcArgs: Record = { context: this._handle, kind }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4.LikeC4.Annotations/LikeC4NodeDetailsAnnotation.withKind', + rpcArgs + ); + return new LikeC4NodeDetailsAnnotationImpl(result, this._client); + } + + withKind(kind: string): LikeC4NodeDetailsAnnotationPromise { + return new LikeC4NodeDetailsAnnotationPromiseImpl(this._withKindInternal(kind), this._client); + } + + /** @internal */ + async _withTagInternal(tag: string): Promise { + const rpcArgs: Record = { context: this._handle, tag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4.LikeC4.Annotations/LikeC4NodeDetailsAnnotation.withTag', + rpcArgs + ); + return new LikeC4NodeDetailsAnnotationImpl(result, this._client); + } + + withTag(tag: string): LikeC4NodeDetailsAnnotationPromise { + return new LikeC4NodeDetailsAnnotationPromiseImpl(this._withTagInternal(tag), this._client); + } + + /** @internal */ + async _withLinkNodeInternal(url: string, title?: string): Promise { + const rpcArgs: Record = { context: this._handle, url }; + if (title !== undefined) rpcArgs.title = title; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4.LikeC4.Annotations/withLinkNode', + rpcArgs + ); + return new LikeC4NodeDetailsAnnotationImpl(result, this._client); + } + + withLinkNode(url: string, options?: WithLinkNodeOptions): LikeC4NodeDetailsAnnotationPromise { + const title = options?.title; + return new LikeC4NodeDetailsAnnotationPromiseImpl(this._withLinkNodeInternal(url, title), this._client); + } + + /** @internal */ + async _withLinkUriNodeInternal(uri: string, title?: string): Promise { + const rpcArgs: Record = { context: this._handle, uri }; + if (title !== undefined) rpcArgs.title = title; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4.LikeC4.Annotations/withLinkUriNode', + rpcArgs + ); + return new LikeC4NodeDetailsAnnotationImpl(result, this._client); + } + + withLinkUriNode(uri: string, options?: WithLinkUriNodeOptions): LikeC4NodeDetailsAnnotationPromise { + const title = options?.title; + return new LikeC4NodeDetailsAnnotationPromiseImpl(this._withLinkUriNodeInternal(uri, title), this._client); + } + + /** @internal */ + async _withMetadataNodeInternal(key: string, value: string): Promise { + const rpcArgs: Record = { context: this._handle, key, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4.LikeC4.Annotations/withMetadataNode', + rpcArgs + ); + return new LikeC4NodeDetailsAnnotationImpl(result, this._client); + } + + withMetadataNode(key: string, value: string): LikeC4NodeDetailsAnnotationPromise { + return new LikeC4NodeDetailsAnnotationPromiseImpl(this._withMetadataNodeInternal(key, value), this._client); + } + +} + +/** + * Thenable wrapper for LikeC4NodeDetailsAnnotation that enables fluent chaining. + */ +class LikeC4NodeDetailsAnnotationPromiseImpl implements LikeC4NodeDetailsAnnotationPromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: LikeC4NodeDetailsAnnotation) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + tags(): Promise { + return this._promise.then(obj => obj.tags()); + } + + withLabel(label: string): LikeC4NodeDetailsAnnotationPromise { + return new LikeC4NodeDetailsAnnotationPromiseImpl(this._promise.then(obj => obj.withLabel(label)), this._client); + } + + withTechnology(technology: string): LikeC4NodeDetailsAnnotationPromise { + return new LikeC4NodeDetailsAnnotationPromiseImpl(this._promise.then(obj => obj.withTechnology(technology)), this._client); + } + + withDescription(description: string): LikeC4NodeDetailsAnnotationPromise { + return new LikeC4NodeDetailsAnnotationPromiseImpl(this._promise.then(obj => obj.withDescription(description)), this._client); + } + + withSummary(summary: string): LikeC4NodeDetailsAnnotationPromise { + return new LikeC4NodeDetailsAnnotationPromiseImpl(this._promise.then(obj => obj.withSummary(summary)), this._client); + } + + withIcon(icon: string): LikeC4NodeDetailsAnnotationPromise { + return new LikeC4NodeDetailsAnnotationPromiseImpl(this._promise.then(obj => obj.withIcon(icon)), this._client); + } + + withAutoIcon(options?: WithAutoIconOptions): LikeC4NodeDetailsAnnotationPromise { + return new LikeC4NodeDetailsAnnotationPromiseImpl(this._promise.then(obj => obj.withAutoIcon(options)), this._client); + } + + withKind(kind: string): LikeC4NodeDetailsAnnotationPromise { + return new LikeC4NodeDetailsAnnotationPromiseImpl(this._promise.then(obj => obj.withKind(kind)), this._client); + } + + withTag(tag: string): LikeC4NodeDetailsAnnotationPromise { + return new LikeC4NodeDetailsAnnotationPromiseImpl(this._promise.then(obj => obj.withTag(tag)), this._client); + } + + withLinkNode(url: string, options?: WithLinkNodeOptions): LikeC4NodeDetailsAnnotationPromise { + return new LikeC4NodeDetailsAnnotationPromiseImpl(this._promise.then(obj => obj.withLinkNode(url, options)), this._client); + } + + withLinkUriNode(uri: string, options?: WithLinkUriNodeOptions): LikeC4NodeDetailsAnnotationPromise { + return new LikeC4NodeDetailsAnnotationPromiseImpl(this._promise.then(obj => obj.withLinkUriNode(uri, options)), this._client); + } + + withMetadataNode(key: string, value: string): LikeC4NodeDetailsAnnotationPromise { + return new LikeC4NodeDetailsAnnotationPromiseImpl(this._promise.then(obj => obj.withMetadataNode(key, value)), this._client); + } + +} + +// ============================================================================ +// LikeC4RelationshipDetailsAnnotation +// ============================================================================ + +export interface LikeC4RelationshipDetailsAnnotation { + toJSON(): MarshalledHandle; + /** Gets the TargetName property */ + targetName(): Promise; + /** Gets the Label property */ + label: { + get: () => Promise; + set: (value: string) => Promise; + }; + /** Gets the Technology property */ + technology: { + get: () => Promise; + set: (value: string) => Promise; + }; + /** Gets the Description property */ + description: { + get: () => Promise; + set: (value: string) => Promise; + }; + /** Gets the Kind property */ + kind: { + get: () => Promise; + set: (value: string) => Promise; + }; + /** Gets the NavigateTo property */ + navigateTo: { + get: () => Promise; + set: (value: string) => Promise; + }; + /** Gets the Tags property */ + tags(): Promise; + /** Invokes the WithLabel method */ + withLabel(label: string): LikeC4RelationshipDetailsAnnotationPromise; + /** Invokes the WithTechnology method */ + withTechnology(technology: string): LikeC4RelationshipDetailsAnnotationPromise; + /** Invokes the WithDescription method */ + withDescription(description: string): LikeC4RelationshipDetailsAnnotationPromise; + /** Invokes the WithKind method */ + withKind(kind: string): LikeC4RelationshipDetailsAnnotationPromise; + /** Invokes the WithTag method */ + withTag(tag: string): LikeC4RelationshipDetailsAnnotationPromise; + /** Invokes the WithLink method */ + withLinkRelationship(url: string, options?: WithLinkRelationshipOptions): LikeC4RelationshipDetailsAnnotationPromise; + /** Invokes the WithLink method */ + withLinkUriRelationship(uri: string, options?: WithLinkUriRelationshipOptions): LikeC4RelationshipDetailsAnnotationPromise; + /** Invokes the WithMetadata method */ + withMetadataRelationship(key: string, value: string): LikeC4RelationshipDetailsAnnotationPromise; + /** Invokes the WithNavigateTo method */ + withNavigateTo(viewId: string): LikeC4RelationshipDetailsAnnotationPromise; +} + +export interface LikeC4RelationshipDetailsAnnotationPromise extends PromiseLike { + /** Gets the TargetName property */ + targetName(): Promise; + /** Gets the Tags property */ + tags(): Promise; + /** Invokes the WithLabel method */ + withLabel(label: string): LikeC4RelationshipDetailsAnnotationPromise; + /** Invokes the WithTechnology method */ + withTechnology(technology: string): LikeC4RelationshipDetailsAnnotationPromise; + /** Invokes the WithDescription method */ + withDescription(description: string): LikeC4RelationshipDetailsAnnotationPromise; + /** Invokes the WithKind method */ + withKind(kind: string): LikeC4RelationshipDetailsAnnotationPromise; + /** Invokes the WithTag method */ + withTag(tag: string): LikeC4RelationshipDetailsAnnotationPromise; + /** Invokes the WithLink method */ + withLinkRelationship(url: string, options?: WithLinkRelationshipOptions): LikeC4RelationshipDetailsAnnotationPromise; + /** Invokes the WithLink method */ + withLinkUriRelationship(uri: string, options?: WithLinkUriRelationshipOptions): LikeC4RelationshipDetailsAnnotationPromise; + /** Invokes the WithMetadata method */ + withMetadataRelationship(key: string, value: string): LikeC4RelationshipDetailsAnnotationPromise; + /** Invokes the WithNavigateTo method */ + withNavigateTo(viewId: string): LikeC4RelationshipDetailsAnnotationPromise; +} + +// ============================================================================ +// LikeC4RelationshipDetailsAnnotationImpl +// ============================================================================ + +/** + * Type class for LikeC4RelationshipDetailsAnnotation. + */ +class LikeC4RelationshipDetailsAnnotationImpl implements LikeC4RelationshipDetailsAnnotation { + constructor(private _handle: LikeC4RelationshipDetailsAnnotationHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + async targetName(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4.LikeC4.Annotations/LikeC4RelationshipDetailsAnnotation.targetName', + { context: this._handle } + ); + } + + label = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4.LikeC4.Annotations/LikeC4RelationshipDetailsAnnotation.label', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4.LikeC4.Annotations/LikeC4RelationshipDetailsAnnotation.setLabel', + { context: this._handle, value } + ); + } + }; + + technology = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4.LikeC4.Annotations/LikeC4RelationshipDetailsAnnotation.technology', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4.LikeC4.Annotations/LikeC4RelationshipDetailsAnnotation.setTechnology', + { context: this._handle, value } + ); + } + }; + + description = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4.LikeC4.Annotations/LikeC4RelationshipDetailsAnnotation.description', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4.LikeC4.Annotations/LikeC4RelationshipDetailsAnnotation.setDescription', + { context: this._handle, value } + ); + } + }; + + kind = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4.LikeC4.Annotations/LikeC4RelationshipDetailsAnnotation.kind', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4.LikeC4.Annotations/LikeC4RelationshipDetailsAnnotation.setKind', + { context: this._handle, value } + ); + } + }; + + navigateTo = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4.LikeC4.Annotations/LikeC4RelationshipDetailsAnnotation.navigateTo', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4.LikeC4.Annotations/LikeC4RelationshipDetailsAnnotation.setNavigateTo', + { context: this._handle, value } + ); + } + }; + + async tags(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4.LikeC4.Annotations/LikeC4RelationshipDetailsAnnotation.tags', + { context: this._handle } + ); + } + + /** @internal */ + async _withLabelInternal(label: string): Promise { + const rpcArgs: Record = { context: this._handle, label }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4.LikeC4.Annotations/LikeC4RelationshipDetailsAnnotation.withLabel', + rpcArgs + ); + return new LikeC4RelationshipDetailsAnnotationImpl(result, this._client); + } + + withLabel(label: string): LikeC4RelationshipDetailsAnnotationPromise { + return new LikeC4RelationshipDetailsAnnotationPromiseImpl(this._withLabelInternal(label), this._client); + } + + /** @internal */ + async _withTechnologyInternal(technology: string): Promise { + const rpcArgs: Record = { context: this._handle, technology }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4.LikeC4.Annotations/LikeC4RelationshipDetailsAnnotation.withTechnology', + rpcArgs + ); + return new LikeC4RelationshipDetailsAnnotationImpl(result, this._client); + } + + withTechnology(technology: string): LikeC4RelationshipDetailsAnnotationPromise { + return new LikeC4RelationshipDetailsAnnotationPromiseImpl(this._withTechnologyInternal(technology), this._client); + } + + /** @internal */ + async _withDescriptionInternal(description: string): Promise { + const rpcArgs: Record = { context: this._handle, description }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4.LikeC4.Annotations/LikeC4RelationshipDetailsAnnotation.withDescription', + rpcArgs + ); + return new LikeC4RelationshipDetailsAnnotationImpl(result, this._client); + } + + withDescription(description: string): LikeC4RelationshipDetailsAnnotationPromise { + return new LikeC4RelationshipDetailsAnnotationPromiseImpl(this._withDescriptionInternal(description), this._client); + } + + /** @internal */ + async _withKindInternal(kind: string): Promise { + const rpcArgs: Record = { context: this._handle, kind }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4.LikeC4.Annotations/LikeC4RelationshipDetailsAnnotation.withKind', + rpcArgs + ); + return new LikeC4RelationshipDetailsAnnotationImpl(result, this._client); + } + + withKind(kind: string): LikeC4RelationshipDetailsAnnotationPromise { + return new LikeC4RelationshipDetailsAnnotationPromiseImpl(this._withKindInternal(kind), this._client); + } + + /** @internal */ + async _withTagInternal(tag: string): Promise { + const rpcArgs: Record = { context: this._handle, tag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4.LikeC4.Annotations/LikeC4RelationshipDetailsAnnotation.withTag', + rpcArgs + ); + return new LikeC4RelationshipDetailsAnnotationImpl(result, this._client); + } + + withTag(tag: string): LikeC4RelationshipDetailsAnnotationPromise { + return new LikeC4RelationshipDetailsAnnotationPromiseImpl(this._withTagInternal(tag), this._client); + } + + /** @internal */ + async _withLinkRelationshipInternal(url: string, title?: string): Promise { + const rpcArgs: Record = { context: this._handle, url }; + if (title !== undefined) rpcArgs.title = title; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4.LikeC4.Annotations/withLinkRelationship', + rpcArgs + ); + return new LikeC4RelationshipDetailsAnnotationImpl(result, this._client); + } + + withLinkRelationship(url: string, options?: WithLinkRelationshipOptions): LikeC4RelationshipDetailsAnnotationPromise { + const title = options?.title; + return new LikeC4RelationshipDetailsAnnotationPromiseImpl(this._withLinkRelationshipInternal(url, title), this._client); + } + + /** @internal */ + async _withLinkUriRelationshipInternal(uri: string, title?: string): Promise { + const rpcArgs: Record = { context: this._handle, uri }; + if (title !== undefined) rpcArgs.title = title; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4.LikeC4.Annotations/withLinkUriRelationship', + rpcArgs + ); + return new LikeC4RelationshipDetailsAnnotationImpl(result, this._client); + } + + withLinkUriRelationship(uri: string, options?: WithLinkUriRelationshipOptions): LikeC4RelationshipDetailsAnnotationPromise { + const title = options?.title; + return new LikeC4RelationshipDetailsAnnotationPromiseImpl(this._withLinkUriRelationshipInternal(uri, title), this._client); + } + + /** @internal */ + async _withMetadataRelationshipInternal(key: string, value: string): Promise { + const rpcArgs: Record = { context: this._handle, key, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4.LikeC4.Annotations/withMetadataRelationship', + rpcArgs + ); + return new LikeC4RelationshipDetailsAnnotationImpl(result, this._client); + } + + withMetadataRelationship(key: string, value: string): LikeC4RelationshipDetailsAnnotationPromise { + return new LikeC4RelationshipDetailsAnnotationPromiseImpl(this._withMetadataRelationshipInternal(key, value), this._client); + } + + /** @internal */ + async _withNavigateToInternal(viewId: string): Promise { + const rpcArgs: Record = { context: this._handle, viewId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.AspireC4.LikeC4.Annotations/LikeC4RelationshipDetailsAnnotation.withNavigateTo', + rpcArgs + ); + return new LikeC4RelationshipDetailsAnnotationImpl(result, this._client); + } + + withNavigateTo(viewId: string): LikeC4RelationshipDetailsAnnotationPromise { + return new LikeC4RelationshipDetailsAnnotationPromiseImpl(this._withNavigateToInternal(viewId), this._client); + } + +} + +/** + * Thenable wrapper for LikeC4RelationshipDetailsAnnotation that enables fluent chaining. + */ +class LikeC4RelationshipDetailsAnnotationPromiseImpl implements LikeC4RelationshipDetailsAnnotationPromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: LikeC4RelationshipDetailsAnnotation) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + targetName(): Promise { + return this._promise.then(obj => obj.targetName()); + } + + tags(): Promise { + return this._promise.then(obj => obj.tags()); + } + + withLabel(label: string): LikeC4RelationshipDetailsAnnotationPromise { + return new LikeC4RelationshipDetailsAnnotationPromiseImpl(this._promise.then(obj => obj.withLabel(label)), this._client); + } + + withTechnology(technology: string): LikeC4RelationshipDetailsAnnotationPromise { + return new LikeC4RelationshipDetailsAnnotationPromiseImpl(this._promise.then(obj => obj.withTechnology(technology)), this._client); + } + + withDescription(description: string): LikeC4RelationshipDetailsAnnotationPromise { + return new LikeC4RelationshipDetailsAnnotationPromiseImpl(this._promise.then(obj => obj.withDescription(description)), this._client); + } + + withKind(kind: string): LikeC4RelationshipDetailsAnnotationPromise { + return new LikeC4RelationshipDetailsAnnotationPromiseImpl(this._promise.then(obj => obj.withKind(kind)), this._client); + } + + withTag(tag: string): LikeC4RelationshipDetailsAnnotationPromise { + return new LikeC4RelationshipDetailsAnnotationPromiseImpl(this._promise.then(obj => obj.withTag(tag)), this._client); + } + + withLinkRelationship(url: string, options?: WithLinkRelationshipOptions): LikeC4RelationshipDetailsAnnotationPromise { + return new LikeC4RelationshipDetailsAnnotationPromiseImpl(this._promise.then(obj => obj.withLinkRelationship(url, options)), this._client); + } + + withLinkUriRelationship(uri: string, options?: WithLinkUriRelationshipOptions): LikeC4RelationshipDetailsAnnotationPromise { + return new LikeC4RelationshipDetailsAnnotationPromiseImpl(this._promise.then(obj => obj.withLinkUriRelationship(uri, options)), this._client); + } + + withMetadataRelationship(key: string, value: string): LikeC4RelationshipDetailsAnnotationPromise { + return new LikeC4RelationshipDetailsAnnotationPromiseImpl(this._promise.then(obj => obj.withMetadataRelationship(key, value)), this._client); + } + + withNavigateTo(viewId: string): LikeC4RelationshipDetailsAnnotationPromise { + return new LikeC4RelationshipDetailsAnnotationPromiseImpl(this._promise.then(obj => obj.withNavigateTo(viewId)), this._client); + } + +} + +// ============================================================================ +// LogFacade +// ============================================================================ + +export interface LogFacade { + toJSON(): MarshalledHandle; + /** Writes an informational log message */ + info(message: string): LogFacadePromise; + /** Writes a warning log message */ + warning(message: string): LogFacadePromise; + /** Writes an error log message */ + error(message: string): LogFacadePromise; + /** Writes a debug log message */ + debug(message: string): LogFacadePromise; +} + +export interface LogFacadePromise extends PromiseLike { + /** Writes an informational log message */ + info(message: string): LogFacadePromise; + /** Writes a warning log message */ + warning(message: string): LogFacadePromise; + /** Writes an error log message */ + error(message: string): LogFacadePromise; + /** Writes a debug log message */ + debug(message: string): LogFacadePromise; +} + +// ============================================================================ +// LogFacadeImpl +// ============================================================================ + +/** + * Type class for LogFacade. + */ +class LogFacadeImpl implements LogFacade { + constructor(private _handle: LogFacadeHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** @internal */ + async _infoInternal(message: string): Promise { + const rpcArgs: Record = { context: this._handle, message }; + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/info', + rpcArgs + ); + return this; + } + + info(message: string): LogFacadePromise { + return new LogFacadePromiseImpl(this._infoInternal(message), this._client); + } + + /** @internal */ + async _warningInternal(message: string): Promise { + const rpcArgs: Record = { context: this._handle, message }; + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/warning', + rpcArgs + ); + return this; + } + + warning(message: string): LogFacadePromise { + return new LogFacadePromiseImpl(this._warningInternal(message), this._client); + } + + /** @internal */ + async _errorInternal(message: string): Promise { + const rpcArgs: Record = { context: this._handle, message }; + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/error', + rpcArgs + ); + return this; + } + + error(message: string): LogFacadePromise { + return new LogFacadePromiseImpl(this._errorInternal(message), this._client); + } + + /** @internal */ + async _debugInternal(message: string): Promise { + const rpcArgs: Record = { context: this._handle, message }; + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/debug', + rpcArgs + ); + return this; + } + + debug(message: string): LogFacadePromise { + return new LogFacadePromiseImpl(this._debugInternal(message), this._client); + } + +} + +/** + * Thenable wrapper for LogFacade that enables fluent chaining. + */ +class LogFacadePromiseImpl implements LogFacadePromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: LogFacade) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + info(message: string): LogFacadePromise { + return new LogFacadePromiseImpl(this._promise.then(obj => obj.info(message)), this._client); + } + + warning(message: string): LogFacadePromise { + return new LogFacadePromiseImpl(this._promise.then(obj => obj.warning(message)), this._client); + } + + error(message: string): LogFacadePromise { + return new LogFacadePromiseImpl(this._promise.then(obj => obj.error(message)), this._client); + } + + debug(message: string): LogFacadePromise { + return new LogFacadePromiseImpl(this._promise.then(obj => obj.debug(message)), this._client); + } + +} + +// ============================================================================ +// PipelineConfigurationContext +// ============================================================================ + +export interface PipelineConfigurationContext { + toJSON(): MarshalledHandle; + /** Gets the pipeline editor */ + pipeline(): Promise; + /** Gets the callback logger facade */ + log(): Promise; + /** Gets pipeline steps with the specified tag */ + getSteps(tag: string): Promise; +} + +export interface PipelineConfigurationContextPromise extends PromiseLike { + /** Gets the pipeline editor */ + pipeline(): Promise; + /** Gets the callback logger facade */ + log(): Promise; + /** Gets pipeline steps with the specified tag */ + getSteps(tag: string): Promise; +} + +// ============================================================================ +// PipelineConfigurationContextImpl +// ============================================================================ + +/** + * Type class for PipelineConfigurationContext. + */ +class PipelineConfigurationContextImpl implements PipelineConfigurationContext { + constructor(private _handle: PipelineConfigurationContextHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + async pipeline(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.pipeline', + { context: this._handle } + ); + return new PipelineEditorImpl(handle, this._client); + } + + async log(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.log', + { context: this._handle } + ); + return new LogFacadeImpl(handle, this._client); + } + + async getSteps(tag: string): Promise { + const rpcArgs: Record = { context: this._handle, tag }; + return await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/getSteps', + rpcArgs + ); + } + +} + +/** + * Thenable wrapper for PipelineConfigurationContext that enables fluent chaining. + */ +class PipelineConfigurationContextPromiseImpl implements PipelineConfigurationContextPromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: PipelineConfigurationContext) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + pipeline(): Promise { + return this._promise.then(obj => obj.pipeline()); + } + + log(): Promise { + return this._promise.then(obj => obj.log()); + } + + getSteps(tag: string): Promise { + return this._promise.then(obj => obj.getSteps(tag)); + } + +} + +// ============================================================================ +// PipelineContext +// ============================================================================ + +export interface PipelineContext { + toJSON(): MarshalledHandle; + /** Gets the Model property */ + model(): Promise; + /** Gets the ExecutionContext property */ + executionContext(): Promise; + /** Gets the Services property */ + services(): Promise; + /** Gets the Logger property */ + logger(): Promise; + /** Gets the CancellationToken property */ + cancellationToken: { + get: () => Promise; + set: (value: AbortSignal | CancellationToken) => Promise; + }; + /** Gets the Summary property */ + summary(): Promise; +} + +// ============================================================================ +// PipelineContextImpl +// ============================================================================ + +/** + * Type class for PipelineContext. + */ +class PipelineContextImpl implements PipelineContext { + constructor(private _handle: PipelineContextHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + async model(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineContext.model', + { context: this._handle } + ); + return new DistributedApplicationModelImpl(handle, this._client); + } + + async executionContext(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineContext.executionContext', + { context: this._handle } + ); + return new DistributedApplicationExecutionContextImpl(handle, this._client); + } + + async services(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineContext.services', + { context: this._handle } + ); + return new ServiceProviderImpl(handle, this._client); + } + + async logger(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineContext.logger', + { context: this._handle } + ); + return new LoggerImpl(handle, this._client); + } + + cancellationToken = { + get: async (): Promise => { + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineContext.cancellationToken', + { context: this._handle } + ); + return CancellationToken.fromValue(result); + }, + set: async (value: AbortSignal | CancellationToken): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineContext.setCancellationToken', + { context: this._handle, value: CancellationToken.fromValue(value) } + ); + } + }; + + async summary(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineContext.summary', + { context: this._handle } + ); + return new PipelineSummaryImpl(handle, this._client); + } + +} + +// ============================================================================ +// PipelineEditor +// ============================================================================ + +export interface PipelineEditor { + toJSON(): MarshalledHandle; + /** Gets all configured pipeline steps */ + steps(): Promise; + /** Gets pipeline steps with the specified tag */ + stepsByTag(tag: string): Promise; +} + +export interface PipelineEditorPromise extends PromiseLike { + /** Gets all configured pipeline steps */ + steps(): Promise; + /** Gets pipeline steps with the specified tag */ + stepsByTag(tag: string): Promise; +} + +// ============================================================================ +// PipelineEditorImpl +// ============================================================================ + +/** + * Type class for PipelineEditor. + */ +class PipelineEditorImpl implements PipelineEditor { + constructor(private _handle: PipelineEditorHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + async steps(): Promise { + const rpcArgs: Record = { context: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/steps', + rpcArgs + ); + } + + async stepsByTag(tag: string): Promise { + const rpcArgs: Record = { context: this._handle, tag }; + return await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/stepsByTag', + rpcArgs + ); + } + +} + +/** + * Thenable wrapper for PipelineEditor that enables fluent chaining. + */ +class PipelineEditorPromiseImpl implements PipelineEditorPromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: PipelineEditor) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + steps(): Promise { + return this._promise.then(obj => obj.steps()); + } + + stepsByTag(tag: string): Promise { + return this._promise.then(obj => obj.stepsByTag(tag)); + } + +} + +// ============================================================================ +// PipelineStep +// ============================================================================ + +export interface PipelineStep { + toJSON(): MarshalledHandle; + /** Gets the unique name of the step */ + name(): Promise; + /** Gets the human-readable description of the step */ + description(): Promise; + /** Adds a dependency on another step by name */ + dependsOn(stepName: string): PipelineStepPromise; + /** Specifies that another step requires this step by name */ + requiredBy(stepName: string): PipelineStepPromise; + /** Adds a tag to the step */ + addTag(tag: string): PipelineStepPromise; +} + +export interface PipelineStepPromise extends PromiseLike { + /** Gets the unique name of the step */ + name(): Promise; + /** Gets the human-readable description of the step */ + description(): Promise; + /** Adds a dependency on another step by name */ + dependsOn(stepName: string): PipelineStepPromise; + /** Specifies that another step requires this step by name */ + requiredBy(stepName: string): PipelineStepPromise; + /** Adds a tag to the step */ + addTag(tag: string): PipelineStepPromise; +} + +// ============================================================================ +// PipelineStepImpl +// ============================================================================ + +/** + * Type class for PipelineStep. + */ +class PipelineStepImpl implements PipelineStep { + constructor(private _handle: PipelineStepHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + async name(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStep.name', + { context: this._handle } + ); + } + + async description(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStep.description', + { context: this._handle } + ); + } + + /** @internal */ + async _dependsOnInternal(stepName: string): Promise { + const rpcArgs: Record = { context: this._handle, stepName }; + await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/dependsOn', + rpcArgs + ); + return this; + } + + dependsOn(stepName: string): PipelineStepPromise { + return new PipelineStepPromiseImpl(this._dependsOnInternal(stepName), this._client); + } + + /** @internal */ + async _requiredByInternal(stepName: string): Promise { + const rpcArgs: Record = { context: this._handle, stepName }; + await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/requiredBy', + rpcArgs + ); + return this; + } + + requiredBy(stepName: string): PipelineStepPromise { + return new PipelineStepPromiseImpl(this._requiredByInternal(stepName), this._client); + } + + /** @internal */ + async _addTagInternal(tag: string): Promise { + const rpcArgs: Record = { context: this._handle, tag }; + await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/addTag', + rpcArgs + ); + return this; + } + + addTag(tag: string): PipelineStepPromise { + return new PipelineStepPromiseImpl(this._addTagInternal(tag), this._client); + } + +} + +/** + * Thenable wrapper for PipelineStep that enables fluent chaining. + */ +class PipelineStepPromiseImpl implements PipelineStepPromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: PipelineStep) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + name(): Promise { + return this._promise.then(obj => obj.name()); + } + + description(): Promise { + return this._promise.then(obj => obj.description()); + } + + dependsOn(stepName: string): PipelineStepPromise { + return new PipelineStepPromiseImpl(this._promise.then(obj => obj.dependsOn(stepName)), this._client); + } + + requiredBy(stepName: string): PipelineStepPromise { + return new PipelineStepPromiseImpl(this._promise.then(obj => obj.requiredBy(stepName)), this._client); + } + + addTag(tag: string): PipelineStepPromise { + return new PipelineStepPromiseImpl(this._promise.then(obj => obj.addTag(tag)), this._client); + } + +} + +// ============================================================================ +// PipelineStepContext +// ============================================================================ + +export interface PipelineStepContext { + toJSON(): MarshalledHandle; + /** Gets the PipelineContext property */ + pipelineContext: { + get: () => Promise; + set: (value: Awaitable) => Promise; + }; + /** Gets the ReportingStep property */ + reportingStep: { + get: () => Promise; + set: (value: Awaitable) => Promise; + }; + /** Gets the Model property */ + model(): Promise; + /** Gets the ExecutionContext property */ + executionContext(): Promise; + /** Gets the Services property */ + services(): Promise; + /** Gets the Logger property */ + logger(): Promise; + /** Gets the CancellationToken property */ + cancellationToken(): Promise; + /** Gets the Summary property */ + summary(): Promise; +} + +// ============================================================================ +// PipelineStepContextImpl +// ============================================================================ + +/** + * Type class for PipelineStepContext. + */ +class PipelineStepContextImpl implements PipelineStepContext { + constructor(private _handle: PipelineStepContextHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + pipelineContext = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.pipelineContext', + { context: this._handle } + ); + return new PipelineContextImpl(handle, this._client); + }, + set: async (value: Awaitable): Promise => { + value = isPromiseLike(value) ? await value : value; + await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.setPipelineContext', + { context: this._handle, value } + ); + } + }; + + reportingStep = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.reportingStep', + { context: this._handle } + ); + return new ReportingStepImpl(handle, this._client); + }, + set: async (value: Awaitable): Promise => { + value = isPromiseLike(value) ? await value : value; + await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.setReportingStep', + { context: this._handle, value } + ); + } + }; + + async model(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.model', + { context: this._handle } + ); + return new DistributedApplicationModelImpl(handle, this._client); + } + + async executionContext(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.executionContext', + { context: this._handle } + ); + return new DistributedApplicationExecutionContextImpl(handle, this._client); + } + + async services(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.services', + { context: this._handle } + ); + return new ServiceProviderImpl(handle, this._client); + } + + async logger(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.logger', + { context: this._handle } + ); + return new LoggerImpl(handle, this._client); + } + + async cancellationToken(): Promise { + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.cancellationToken', + { context: this._handle } + ); + return CancellationToken.fromValue(result); + } + + async summary(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.summary', + { context: this._handle } + ); + return new PipelineSummaryImpl(handle, this._client); + } + +} + +// ============================================================================ +// PipelineStepFactoryContext +// ============================================================================ + +export interface PipelineStepFactoryContext { + toJSON(): MarshalledHandle; + /** Gets the PipelineContext property */ + pipelineContext: { + get: () => Promise; + set: (value: Awaitable) => Promise; + }; + /** Gets the Resource property */ + resource: { + get: () => Promise; + set: (value: Awaitable) => Promise; + }; +} + +// ============================================================================ +// PipelineStepFactoryContextImpl +// ============================================================================ + +/** + * Type class for PipelineStepFactoryContext. + */ +class PipelineStepFactoryContextImpl implements PipelineStepFactoryContext { + constructor(private _handle: PipelineStepFactoryContextHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + pipelineContext = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepFactoryContext.pipelineContext', + { context: this._handle } + ); + return new PipelineContextImpl(handle, this._client); + }, + set: async (value: Awaitable): Promise => { + value = isPromiseLike(value) ? await value : value; + await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepFactoryContext.setPipelineContext', + { context: this._handle, value } + ); + } + }; + + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepFactoryContext.resource', + { context: this._handle } + ); + return new ResourceImpl(handle, this._client); + }, + set: async (value: Awaitable): Promise => { + value = isPromiseLike(value) ? await value : value; + await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepFactoryContext.setResource', + { context: this._handle, value } + ); + } + }; + +} + +// ============================================================================ +// PipelineSummary +// ============================================================================ + +export interface PipelineSummary { + toJSON(): MarshalledHandle; + /** Invokes the Add method */ + add(key: string, value: string): PipelineSummaryPromise; + /** Adds a Markdown-formatted value to the pipeline summary */ + addMarkdown(key: string, markdownString: string): PipelineSummaryPromise; +} + +export interface PipelineSummaryPromise extends PromiseLike { + /** Invokes the Add method */ + add(key: string, value: string): PipelineSummaryPromise; + /** Adds a Markdown-formatted value to the pipeline summary */ + addMarkdown(key: string, markdownString: string): PipelineSummaryPromise; +} + +// ============================================================================ +// PipelineSummaryImpl +// ============================================================================ + +/** + * Type class for PipelineSummary. + */ +class PipelineSummaryImpl implements PipelineSummary { + constructor(private _handle: PipelineSummaryHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** @internal */ + async _addInternal(key: string, value: string): Promise { + const rpcArgs: Record = { context: this._handle, key, value }; + await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineSummary.add', + rpcArgs + ); + return this; + } + + add(key: string, value: string): PipelineSummaryPromise { + return new PipelineSummaryPromiseImpl(this._addInternal(key, value), this._client); + } + + /** @internal */ + async _addMarkdownInternal(key: string, markdownString: string): Promise { + const rpcArgs: Record = { summary: this._handle, key, markdownString }; + await this._client.invokeCapability( + 'Aspire.Hosting/addMarkdown', + rpcArgs + ); + return this; + } + + addMarkdown(key: string, markdownString: string): PipelineSummaryPromise { + return new PipelineSummaryPromiseImpl(this._addMarkdownInternal(key, markdownString), this._client); + } + +} + +/** + * Thenable wrapper for PipelineSummary that enables fluent chaining. + */ +class PipelineSummaryPromiseImpl implements PipelineSummaryPromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: PipelineSummary) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + add(key: string, value: string): PipelineSummaryPromise { + return new PipelineSummaryPromiseImpl(this._promise.then(obj => obj.add(key, value)), this._client); + } + + addMarkdown(key: string, markdownString: string): PipelineSummaryPromise { + return new PipelineSummaryPromiseImpl(this._promise.then(obj => obj.addMarkdown(key, markdownString)), this._client); + } + +} + +// ============================================================================ +// ProjectResourceOptions +// ============================================================================ + +export interface ProjectResourceOptions { + toJSON(): MarshalledHandle; + /** Gets the LaunchProfileName property */ + launchProfileName: { + get: () => Promise; + set: (value: string) => Promise; + }; + /** Gets the ExcludeLaunchProfile property */ + excludeLaunchProfile: { + get: () => Promise; + set: (value: boolean) => Promise; + }; + /** Gets the ExcludeKestrelEndpoints property */ + excludeKestrelEndpoints: { + get: () => Promise; + set: (value: boolean) => Promise; + }; +} + +// ============================================================================ +// ProjectResourceOptionsImpl +// ============================================================================ + +/** + * Type class for ProjectResourceOptions. + */ +class ProjectResourceOptionsImpl implements ProjectResourceOptions { + constructor(private _handle: ProjectResourceOptionsHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + launchProfileName = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting/ProjectResourceOptions.launchProfileName', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting/ProjectResourceOptions.setLaunchProfileName', + { context: this._handle, value } + ); + } + }; + + excludeLaunchProfile = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting/ProjectResourceOptions.excludeLaunchProfile', + { context: this._handle } + ); + }, + set: async (value: boolean): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting/ProjectResourceOptions.setExcludeLaunchProfile', + { context: this._handle, value } + ); + } + }; + + excludeKestrelEndpoints = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting/ProjectResourceOptions.excludeKestrelEndpoints', + { context: this._handle } + ); + }, + set: async (value: boolean): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting/ProjectResourceOptions.setExcludeKestrelEndpoints', + { context: this._handle, value } + ); + } + }; + +} + +// ============================================================================ +// ReferenceExpressionBuilder +// ============================================================================ + +export interface ReferenceExpressionBuilder { + toJSON(): MarshalledHandle; + /** Gets the IsEmpty property */ + isEmpty(): Promise; + /** Appends a literal string to the reference expression */ + appendLiteral(value: string): ReferenceExpressionBuilderPromise; + /** Appends a formatted string value to the reference expression */ + appendFormatted(value: string, options?: AppendFormattedOptions): ReferenceExpressionBuilderPromise; + /** Appends a value provider to the reference expression */ + appendValueProvider(valueProvider: any, options?: AppendValueProviderOptions): ReferenceExpressionBuilderPromise; + /** Builds the reference expression */ + build(): Promise; +} + +export interface ReferenceExpressionBuilderPromise extends PromiseLike { + /** Gets the IsEmpty property */ + isEmpty(): Promise; + /** Appends a literal string to the reference expression */ + appendLiteral(value: string): ReferenceExpressionBuilderPromise; + /** Appends a formatted string value to the reference expression */ + appendFormatted(value: string, options?: AppendFormattedOptions): ReferenceExpressionBuilderPromise; + /** Appends a value provider to the reference expression */ + appendValueProvider(valueProvider: any, options?: AppendValueProviderOptions): ReferenceExpressionBuilderPromise; + /** Builds the reference expression */ + build(): Promise; +} + +// ============================================================================ +// ReferenceExpressionBuilderImpl +// ============================================================================ + +/** + * Type class for ReferenceExpressionBuilder. + */ +class ReferenceExpressionBuilderImpl implements ReferenceExpressionBuilder { + constructor(private _handle: ReferenceExpressionBuilderHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + async isEmpty(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ReferenceExpressionBuilder.isEmpty', + { context: this._handle } + ); + } + + /** @internal */ + async _appendLiteralInternal(value: string): Promise { + const rpcArgs: Record = { context: this._handle, value }; + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/appendLiteral', + rpcArgs + ); + return this; + } + + appendLiteral(value: string): ReferenceExpressionBuilderPromise { + return new ReferenceExpressionBuilderPromiseImpl(this._appendLiteralInternal(value), this._client); + } + + /** @internal */ + async _appendFormattedInternal(value: string, format?: string): Promise { + const rpcArgs: Record = { context: this._handle, value }; + if (format !== undefined) rpcArgs.format = format; + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/appendFormatted', + rpcArgs + ); + return this; + } + + appendFormatted(value: string, options?: AppendFormattedOptions): ReferenceExpressionBuilderPromise { + const format = options?.format; + return new ReferenceExpressionBuilderPromiseImpl(this._appendFormattedInternal(value, format), this._client); + } + + /** @internal */ + async _appendValueProviderInternal(valueProvider: any, format?: string): Promise { + const rpcArgs: Record = { context: this._handle, valueProvider }; + if (format !== undefined) rpcArgs.format = format; + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/appendValueProvider', + rpcArgs + ); + return this; + } + + appendValueProvider(valueProvider: any, options?: AppendValueProviderOptions): ReferenceExpressionBuilderPromise { + const format = options?.format; + return new ReferenceExpressionBuilderPromiseImpl(this._appendValueProviderInternal(valueProvider, format), this._client); + } + + async build(): Promise { + const rpcArgs: Record = { context: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/build', + rpcArgs + ); + } + +} + +/** + * Thenable wrapper for ReferenceExpressionBuilder that enables fluent chaining. + */ +class ReferenceExpressionBuilderPromiseImpl implements ReferenceExpressionBuilderPromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: ReferenceExpressionBuilder) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + isEmpty(): Promise { + return this._promise.then(obj => obj.isEmpty()); + } + + appendLiteral(value: string): ReferenceExpressionBuilderPromise { + return new ReferenceExpressionBuilderPromiseImpl(this._promise.then(obj => obj.appendLiteral(value)), this._client); + } + + appendFormatted(value: string, options?: AppendFormattedOptions): ReferenceExpressionBuilderPromise { + return new ReferenceExpressionBuilderPromiseImpl(this._promise.then(obj => obj.appendFormatted(value, options)), this._client); + } + + appendValueProvider(valueProvider: any, options?: AppendValueProviderOptions): ReferenceExpressionBuilderPromise { + return new ReferenceExpressionBuilderPromiseImpl(this._promise.then(obj => obj.appendValueProvider(valueProvider, options)), this._client); + } + + build(): Promise { + return this._promise.then(obj => obj.build()); + } + +} + +// ============================================================================ +// ResourceEndpointsAllocatedEvent +// ============================================================================ + +export interface ResourceEndpointsAllocatedEvent { + toJSON(): MarshalledHandle; + /** Gets the Resource property */ + resource(): Promise; + /** Gets the Services property */ + services(): Promise; +} + +// ============================================================================ +// ResourceEndpointsAllocatedEventImpl +// ============================================================================ + +/** + * Type class for ResourceEndpointsAllocatedEvent. + */ +class ResourceEndpointsAllocatedEventImpl implements ResourceEndpointsAllocatedEvent { + constructor(private _handle: ResourceEndpointsAllocatedEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + async resource(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceEndpointsAllocatedEvent.resource', + { context: this._handle } + ); + return new ResourceImpl(handle, this._client); + } + + async services(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceEndpointsAllocatedEvent.services', + { context: this._handle } + ); + return new ServiceProviderImpl(handle, this._client); + } + +} + +// ============================================================================ +// ResourceLoggerService +// ============================================================================ + +export interface ResourceLoggerService { + toJSON(): MarshalledHandle; + /** Completes the log stream for a resource */ + completeLog(resource: Awaitable): ResourceLoggerServicePromise; + /** Completes the log stream by resource name */ + completeLogByName(resourceName: string): ResourceLoggerServicePromise; +} + +export interface ResourceLoggerServicePromise extends PromiseLike { + /** Completes the log stream for a resource */ + completeLog(resource: Awaitable): ResourceLoggerServicePromise; + /** Completes the log stream by resource name */ + completeLogByName(resourceName: string): ResourceLoggerServicePromise; +} + +// ============================================================================ +// ResourceLoggerServiceImpl +// ============================================================================ + +/** + * Type class for ResourceLoggerService. + */ +class ResourceLoggerServiceImpl implements ResourceLoggerService { + constructor(private _handle: ResourceLoggerServiceHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** @internal */ + async _completeLogInternal(resource: Awaitable): Promise { + resource = isPromiseLike(resource) ? await resource : resource; + const rpcArgs: Record = { loggerService: this._handle, resource }; + await this._client.invokeCapability( + 'Aspire.Hosting/completeLog', + rpcArgs + ); + return this; + } + + completeLog(resource: Awaitable): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromiseImpl(this._completeLogInternal(resource), this._client); + } + + /** @internal */ + async _completeLogByNameInternal(resourceName: string): Promise { + const rpcArgs: Record = { loggerService: this._handle, resourceName }; + await this._client.invokeCapability( + 'Aspire.Hosting/completeLogByName', + rpcArgs + ); + return this; + } + + completeLogByName(resourceName: string): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromiseImpl(this._completeLogByNameInternal(resourceName), this._client); + } + +} + +/** + * Thenable wrapper for ResourceLoggerService that enables fluent chaining. + */ +class ResourceLoggerServicePromiseImpl implements ResourceLoggerServicePromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: ResourceLoggerService) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + completeLog(resource: Awaitable): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromiseImpl(this._promise.then(obj => obj.completeLog(resource)), this._client); + } + + completeLogByName(resourceName: string): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromiseImpl(this._promise.then(obj => obj.completeLogByName(resourceName)), this._client); + } + +} + +// ============================================================================ +// ResourceNotificationService +// ============================================================================ + +export interface ResourceNotificationService { + toJSON(): MarshalledHandle; + /** Waits for a resource to reach a specified state */ + waitForResourceState(resourceName: string, options?: WaitForResourceStateOptions): ResourceNotificationServicePromise; + /** Waits for a resource to reach one of the specified states */ + waitForResourceStates(resourceName: string, targetStates: string[]): Promise; + /** Waits for a resource to become healthy */ + waitForResourceHealthy(resourceName: string): Promise; + /** Waits for all dependencies of a resource to be ready */ + waitForDependencies(resource: Awaitable): ResourceNotificationServicePromise; + /** Tries to get the current state of a resource */ + tryGetResourceState(resourceName: string): Promise; + /** Publishes an update for a resource's state */ + publishResourceUpdate(resource: Awaitable, options?: PublishResourceUpdateOptions): ResourceNotificationServicePromise; +} + +export interface ResourceNotificationServicePromise extends PromiseLike { + /** Waits for a resource to reach a specified state */ + waitForResourceState(resourceName: string, options?: WaitForResourceStateOptions): ResourceNotificationServicePromise; + /** Waits for a resource to reach one of the specified states */ + waitForResourceStates(resourceName: string, targetStates: string[]): Promise; + /** Waits for a resource to become healthy */ + waitForResourceHealthy(resourceName: string): Promise; + /** Waits for all dependencies of a resource to be ready */ + waitForDependencies(resource: Awaitable): ResourceNotificationServicePromise; + /** Tries to get the current state of a resource */ + tryGetResourceState(resourceName: string): Promise; + /** Publishes an update for a resource's state */ + publishResourceUpdate(resource: Awaitable, options?: PublishResourceUpdateOptions): ResourceNotificationServicePromise; +} + +// ============================================================================ +// ResourceNotificationServiceImpl +// ============================================================================ + +/** + * Type class for ResourceNotificationService. + */ +class ResourceNotificationServiceImpl implements ResourceNotificationService { + constructor(private _handle: ResourceNotificationServiceHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** @internal */ + async _waitForResourceStateInternal(resourceName: string, targetState?: string): Promise { + const rpcArgs: Record = { notificationService: this._handle, resourceName }; + if (targetState !== undefined) rpcArgs.targetState = targetState; + await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceState', + rpcArgs + ); + return this; + } + + waitForResourceState(resourceName: string, options?: WaitForResourceStateOptions): ResourceNotificationServicePromise { + const targetState = options?.targetState; + return new ResourceNotificationServicePromiseImpl(this._waitForResourceStateInternal(resourceName, targetState), this._client); + } + + async waitForResourceStates(resourceName: string, targetStates: string[]): Promise { + const rpcArgs: Record = { notificationService: this._handle, resourceName, targetStates }; + return await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceStates', + rpcArgs + ); + } + + async waitForResourceHealthy(resourceName: string): Promise { + const rpcArgs: Record = { notificationService: this._handle, resourceName }; + return await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceHealthy', + rpcArgs + ); + } + + /** @internal */ + async _waitForDependenciesInternal(resource: Awaitable): Promise { + resource = isPromiseLike(resource) ? await resource : resource; + const rpcArgs: Record = { notificationService: this._handle, resource }; + await this._client.invokeCapability( + 'Aspire.Hosting/waitForDependencies', + rpcArgs + ); + return this; + } + + waitForDependencies(resource: Awaitable): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromiseImpl(this._waitForDependenciesInternal(resource), this._client); + } + + async tryGetResourceState(resourceName: string): Promise { + const rpcArgs: Record = { notificationService: this._handle, resourceName }; + return await this._client.invokeCapability( + 'Aspire.Hosting/tryGetResourceState', + rpcArgs + ); + } + + /** @internal */ + async _publishResourceUpdateInternal(resource: Awaitable, state?: string, stateStyle?: string): Promise { + resource = isPromiseLike(resource) ? await resource : resource; + const rpcArgs: Record = { notificationService: this._handle, resource }; + if (state !== undefined) rpcArgs.state = state; + if (stateStyle !== undefined) rpcArgs.stateStyle = stateStyle; + await this._client.invokeCapability( + 'Aspire.Hosting/publishResourceUpdate', + rpcArgs + ); + return this; + } + + publishResourceUpdate(resource: Awaitable, options?: PublishResourceUpdateOptions): ResourceNotificationServicePromise { + const state = options?.state; + const stateStyle = options?.stateStyle; + return new ResourceNotificationServicePromiseImpl(this._publishResourceUpdateInternal(resource, state, stateStyle), this._client); + } + +} + +/** + * Thenable wrapper for ResourceNotificationService that enables fluent chaining. + */ +class ResourceNotificationServicePromiseImpl implements ResourceNotificationServicePromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: ResourceNotificationService) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + waitForResourceState(resourceName: string, options?: WaitForResourceStateOptions): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromiseImpl(this._promise.then(obj => obj.waitForResourceState(resourceName, options)), this._client); + } + + waitForResourceStates(resourceName: string, targetStates: string[]): Promise { + return this._promise.then(obj => obj.waitForResourceStates(resourceName, targetStates)); + } + + waitForResourceHealthy(resourceName: string): Promise { + return this._promise.then(obj => obj.waitForResourceHealthy(resourceName)); + } + + waitForDependencies(resource: Awaitable): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromiseImpl(this._promise.then(obj => obj.waitForDependencies(resource)), this._client); + } + + tryGetResourceState(resourceName: string): Promise { + return this._promise.then(obj => obj.tryGetResourceState(resourceName)); + } + + publishResourceUpdate(resource: Awaitable, options?: PublishResourceUpdateOptions): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromiseImpl(this._promise.then(obj => obj.publishResourceUpdate(resource, options)), this._client); + } + +} + +// ============================================================================ +// ResourceReadyEvent +// ============================================================================ + +export interface ResourceReadyEvent { + toJSON(): MarshalledHandle; + /** Gets the Resource property */ + resource(): Promise; + /** Gets the Services property */ + services(): Promise; +} + +// ============================================================================ +// ResourceReadyEventImpl +// ============================================================================ + +/** + * Type class for ResourceReadyEvent. + */ +class ResourceReadyEventImpl implements ResourceReadyEvent { + constructor(private _handle: ResourceReadyEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + async resource(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceReadyEvent.resource', + { context: this._handle } + ); + return new ResourceImpl(handle, this._client); + } + + async services(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceReadyEvent.services', + { context: this._handle } + ); + return new ServiceProviderImpl(handle, this._client); + } + +} + +// ============================================================================ +// ResourceStoppedEvent +// ============================================================================ + +export interface ResourceStoppedEvent { + toJSON(): MarshalledHandle; + /** Gets the Resource property */ + resource(): Promise; + /** Gets the Services property */ + services(): Promise; +} + +// ============================================================================ +// ResourceStoppedEventImpl +// ============================================================================ + +/** + * Type class for ResourceStoppedEvent. + */ +class ResourceStoppedEventImpl implements ResourceStoppedEvent { + constructor(private _handle: ResourceStoppedEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + async resource(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceStoppedEvent.resource', + { context: this._handle } + ); + return new ResourceImpl(handle, this._client); + } + + async services(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceStoppedEvent.services', + { context: this._handle } + ); + return new ServiceProviderImpl(handle, this._client); + } + +} + +// ============================================================================ +// ResourceUrlsCallbackContext +// ============================================================================ + +export interface ResourceUrlsCallbackContext { + toJSON(): MarshalledHandle; + /** Gets the resource associated with these URLs */ + resource(): Promise; + /** Gets the URL editor */ + urls(): Promise; + /** Gets the callback logger facade */ + log(): Promise; + /** Gets the execution context for this callback invocation */ + executionContext(): Promise; + /** Gets an endpoint reference from the associated resource */ + getEndpoint(name: string): EndpointReferencePromise; +} + +export interface ResourceUrlsCallbackContextPromise extends PromiseLike { + /** Gets the resource associated with these URLs */ + resource(): Promise; + /** Gets the URL editor */ + urls(): Promise; + /** Gets the callback logger facade */ + log(): Promise; + /** Gets the execution context for this callback invocation */ + executionContext(): Promise; + /** Gets an endpoint reference from the associated resource */ + getEndpoint(name: string): EndpointReferencePromise; +} + +// ============================================================================ +// ResourceUrlsCallbackContextImpl +// ============================================================================ + +/** + * Type class for ResourceUrlsCallbackContext. + */ +class ResourceUrlsCallbackContextImpl implements ResourceUrlsCallbackContext { + constructor(private _handle: ResourceUrlsCallbackContextHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + async resource(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.resource', + { context: this._handle } + ); + return new ResourceImpl(handle, this._client); + } + + async urls(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.urls', + { context: this._handle } + ); + return new ResourceUrlsEditorImpl(handle, this._client); + } + + async log(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.log', + { context: this._handle } + ); + return new LogFacadeImpl(handle, this._client); + } + + async executionContext(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.executionContext', + { context: this._handle } + ); + return new DistributedApplicationExecutionContextImpl(handle, this._client); + } + + /** @internal */ + async _getEndpointInternal(name: string): Promise { + const rpcArgs: Record = { context: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/getEndpoint', + rpcArgs + ); + return new EndpointReferenceImpl(result, this._client); + } + + getEndpoint(name: string): EndpointReferencePromise { + return new EndpointReferencePromiseImpl(this._getEndpointInternal(name), this._client); + } + +} + +/** + * Thenable wrapper for ResourceUrlsCallbackContext that enables fluent chaining. + */ +class ResourceUrlsCallbackContextPromiseImpl implements ResourceUrlsCallbackContextPromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: ResourceUrlsCallbackContext) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + resource(): Promise { + return this._promise.then(obj => obj.resource()); + } + + urls(): Promise { + return this._promise.then(obj => obj.urls()); + } + + log(): Promise { + return this._promise.then(obj => obj.log()); + } + + executionContext(): Promise { + return this._promise.then(obj => obj.executionContext()); + } + + getEndpoint(name: string): EndpointReferencePromise { + return new EndpointReferencePromiseImpl(this._promise.then(obj => obj.getEndpoint(name)), this._client); + } + +} + +// ============================================================================ +// ResourceUrlsEditor +// ============================================================================ + +export interface ResourceUrlsEditor { + toJSON(): MarshalledHandle; + /** Gets the execution context for this URL editor */ + executionContext(): Promise; + /** Adds a displayed URL */ + add(url: string | ReferenceExpression, options?: AddOptions): ResourceUrlsEditorPromise; + /** Adds a displayed URL for a specific endpoint */ + addForEndpoint(endpoint: Awaitable, url: string | ReferenceExpression, options?: AddForEndpointOptions): ResourceUrlsEditorPromise; +} + +export interface ResourceUrlsEditorPromise extends PromiseLike { + /** Gets the execution context for this URL editor */ + executionContext(): Promise; + /** Adds a displayed URL */ + add(url: string | ReferenceExpression, options?: AddOptions): ResourceUrlsEditorPromise; + /** Adds a displayed URL for a specific endpoint */ + addForEndpoint(endpoint: Awaitable, url: string | ReferenceExpression, options?: AddForEndpointOptions): ResourceUrlsEditorPromise; +} + +// ============================================================================ +// ResourceUrlsEditorImpl +// ============================================================================ + +/** + * Type class for ResourceUrlsEditor. + */ +class ResourceUrlsEditorImpl implements ResourceUrlsEditor { + constructor(private _handle: ResourceUrlsEditorHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + async executionContext(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceUrlsEditor.executionContext', + { context: this._handle } + ); + return new DistributedApplicationExecutionContextImpl(handle, this._client); + } + + /** @internal */ + async _addInternal(url: string | ReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { context: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceUrlsEditor.add', + rpcArgs + ); + return this; + } + + add(url: string | ReferenceExpression, options?: AddOptions): ResourceUrlsEditorPromise { + const displayText = options?.displayText; + return new ResourceUrlsEditorPromiseImpl(this._addInternal(url, displayText), this._client); + } + + /** @internal */ + async _addForEndpointInternal(endpoint: Awaitable, url: string | ReferenceExpression, displayText?: string): Promise { + endpoint = isPromiseLike(endpoint) ? await endpoint : endpoint; + const rpcArgs: Record = { context: this._handle, endpoint, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceUrlsEditor.addForEndpoint', + rpcArgs + ); + return this; + } + + addForEndpoint(endpoint: Awaitable, url: string | ReferenceExpression, options?: AddForEndpointOptions): ResourceUrlsEditorPromise { + const displayText = options?.displayText; + return new ResourceUrlsEditorPromiseImpl(this._addForEndpointInternal(endpoint, url, displayText), this._client); + } + +} + +/** + * Thenable wrapper for ResourceUrlsEditor that enables fluent chaining. + */ +class ResourceUrlsEditorPromiseImpl implements ResourceUrlsEditorPromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: ResourceUrlsEditor) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + executionContext(): Promise { + return this._promise.then(obj => obj.executionContext()); + } + + add(url: string | ReferenceExpression, options?: AddOptions): ResourceUrlsEditorPromise { + return new ResourceUrlsEditorPromiseImpl(this._promise.then(obj => obj.add(url, options)), this._client); + } + + addForEndpoint(endpoint: Awaitable, url: string | ReferenceExpression, options?: AddForEndpointOptions): ResourceUrlsEditorPromise { + return new ResourceUrlsEditorPromiseImpl(this._promise.then(obj => obj.addForEndpoint(endpoint, url, options)), this._client); + } + +} + +// ============================================================================ +// UpdateCommandStateContext +// ============================================================================ + +export interface UpdateCommandStateContext { + toJSON(): MarshalledHandle; + /** Gets the ServiceProvider property */ + serviceProvider: { + get: () => Promise; + set: (value: Awaitable) => Promise; + }; +} + +// ============================================================================ +// UpdateCommandStateContextImpl +// ============================================================================ + +/** + * Type class for UpdateCommandStateContext. + */ +class UpdateCommandStateContextImpl implements UpdateCommandStateContext { + constructor(private _handle: UpdateCommandStateContextHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + serviceProvider = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/UpdateCommandStateContext.serviceProvider', + { context: this._handle } + ); + return new ServiceProviderImpl(handle, this._client); + }, + set: async (value: Awaitable): Promise => { + value = isPromiseLike(value) ? await value : value; + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/UpdateCommandStateContext.setServiceProvider', + { context: this._handle, value } + ); + } + }; + +} + +// ============================================================================ +// AspireStore +// ============================================================================ + +export interface AspireStore { + toJSON(): MarshalledHandle; + /** Gets a deterministic file path for the specified file contents */ + getFileNameWithContent(filenameTemplate: string, sourceFilename: string): Promise; +} + +export interface AspireStorePromise extends PromiseLike { + /** Gets a deterministic file path for the specified file contents */ + getFileNameWithContent(filenameTemplate: string, sourceFilename: string): Promise; +} + +// ============================================================================ +// AspireStoreImpl +// ============================================================================ + +/** + * Type class for AspireStore. + */ +class AspireStoreImpl implements AspireStore { + constructor(private _handle: IAspireStoreHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + async getFileNameWithContent(filenameTemplate: string, sourceFilename: string): Promise { + const rpcArgs: Record = { aspireStore: this._handle, filenameTemplate, sourceFilename }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getFileNameWithContent', + rpcArgs + ); + } + +} + +/** + * Thenable wrapper for AspireStore that enables fluent chaining. + */ +class AspireStorePromiseImpl implements AspireStorePromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: AspireStore) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + getFileNameWithContent(filenameTemplate: string, sourceFilename: string): Promise { + return this._promise.then(obj => obj.getFileNameWithContent(filenameTemplate, sourceFilename)); + } + +} + +// ============================================================================ +// Configuration +// ============================================================================ + +export interface Configuration { + toJSON(): MarshalledHandle; + /** Gets a configuration value by key */ + getConfigValue(key: string): Promise; + /** Gets a connection string by name */ + getConnectionString(name: string): Promise; + /** Gets a configuration section by key */ + getSection(key: string): Promise; + /** Gets child configuration sections */ + getChildren(): Promise; + /** Checks whether a configuration section exists */ + exists(key: string): Promise; +} + +export interface ConfigurationPromise extends PromiseLike { + /** Gets a configuration value by key */ + getConfigValue(key: string): Promise; + /** Gets a connection string by name */ + getConnectionString(name: string): Promise; + /** Gets a configuration section by key */ + getSection(key: string): Promise; + /** Gets child configuration sections */ + getChildren(): Promise; + /** Checks whether a configuration section exists */ + exists(key: string): Promise; +} + +// ============================================================================ +// ConfigurationImpl +// ============================================================================ + +/** + * Type class for Configuration. + */ +class ConfigurationImpl implements Configuration { + constructor(private _handle: IConfigurationHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + async getConfigValue(key: string): Promise { + const rpcArgs: Record = { configuration: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConfigValue', + rpcArgs + ); + } + + async getConnectionString(name: string): Promise { + const rpcArgs: Record = { configuration: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionString', + rpcArgs + ); + } + + async getSection(key: string): Promise { + const rpcArgs: Record = { configuration: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getSection', + rpcArgs + ); + } + + async getChildren(): Promise { + const rpcArgs: Record = { configuration: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getChildren', + rpcArgs + ); + } + + async exists(key: string): Promise { + const rpcArgs: Record = { configuration: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/exists', + rpcArgs + ); + } + +} + +/** + * Thenable wrapper for Configuration that enables fluent chaining. + */ +class ConfigurationPromiseImpl implements ConfigurationPromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: Configuration) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + getConfigValue(key: string): Promise { + return this._promise.then(obj => obj.getConfigValue(key)); + } + + getConnectionString(name: string): Promise { + return this._promise.then(obj => obj.getConnectionString(name)); + } + + getSection(key: string): Promise { + return this._promise.then(obj => obj.getSection(key)); + } + + getChildren(): Promise { + return this._promise.then(obj => obj.getChildren()); + } + + exists(key: string): Promise { + return this._promise.then(obj => obj.exists(key)); + } + +} + +// ============================================================================ +// DistributedApplicationBuilder +// ============================================================================ + +export interface DistributedApplicationBuilder { + toJSON(): MarshalledHandle; + /** Gets the AppHostDirectory property */ + appHostDirectory(): Promise; + /** Gets the Environment property */ + environment(): Promise; + /** Gets the Eventing property */ + eventing(): Promise; + /** Gets the ExecutionContext property */ + executionContext(): Promise; + /** Gets the Pipeline property */ + pipeline(): Promise; + /** Gets the UserSecretsManager property */ + userSecretsManager(): Promise; + /** Builds the distributed application */ + build(): DistributedApplicationPromise; + /** Adds a container registry resource */ + addContainerRegistry(name: string, endpoint: string | ParameterResource | Awaitable, options?: AddContainerRegistryOptions): ContainerRegistryResourcePromise; + /** Adds a container resource */ + addContainer(name: string, image: string | AddContainerOptions): ContainerResourcePromise; + /** Adds a container resource built from a Dockerfile */ + addDockerfile(name: string, contextPath: string, options?: AddDockerfileOptions): ContainerResourcePromise; + /** Adds a container resource built from a programmatically generated Dockerfile */ + addDockerfileBuilder(name: string, contextPath: string, callback: (arg: DockerfileBuilderCallbackContext) => Promise, options?: AddDockerfileBuilderOptions): ContainerResourcePromise; + /** Adds a .NET tool resource */ + addDotnetTool(name: string, packageId: string): DotnetToolResourcePromise; + /** Adds an executable resource */ + addExecutable(name: string, command: string, workingDirectory: string, args: string[]): ExecutableResourcePromise; + /** Adds an external service resource */ + addExternalService(name: string, url: string | ParameterResource | Awaitable): ExternalServiceResourcePromise; + /** Adds a parameter resource */ + addParameter(name: string, options?: AddParameterOptions): ParameterResourcePromise; + /** Adds a parameter sourced from configuration */ + addParameterFromConfiguration(name: string, configurationKey: string, options?: AddParameterFromConfigurationOptions): ParameterResourcePromise; + /** Adds a parameter with a generated default value */ + addParameterWithGeneratedValue(name: string, value: GenerateParameterDefault, options?: AddParameterWithGeneratedValueOptions): ParameterResourcePromise; + /** Adds a connection string resource */ + addConnectionString(name: string, options?: AddConnectionStringOptions): ResourceWithConnectionStringPromise; + /** Adds a .NET project resource */ + addProject(name: string, projectPath: string, options?: AddProjectOptions): ProjectResourcePromise; + /** Adds a C# application resource */ + addCSharpApp(name: string, path: string, options?: AddCSharpAppOptions): CSharpAppResourcePromise; + /** Gets the application configuration */ + getConfiguration(): ConfigurationPromise; + /** Subscribes to the BeforeStart event */ + subscribeBeforeStart(callback: (arg: BeforeStartEvent) => Promise): Promise; + /** Subscribes to the AfterResourcesCreated event */ + subscribeAfterResourcesCreated(callback: (arg: AfterResourcesCreatedEvent) => Promise): Promise; + /** Adds an eventing subscriber */ + addEventingSubscriber(subscribe: (arg: EventingSubscriberRegistrationContext) => Promise): DistributedApplicationBuilderPromise; + /** Attempts to add an eventing subscriber */ + tryAddEventingSubscriber(subscribe: (arg: EventingSubscriberRegistrationContext) => Promise): DistributedApplicationBuilderPromise; + /** Adds an Azure PostgreSQL Flexible Server resource */ + addAzurePostgresFlexibleServer(name: string): AzurePostgresFlexibleServerResourcePromise; + /** Adds an Azure Managed Redis resource */ + addAzureManagedRedis(name: string): AzureManagedRedisResourcePromise; + /** Adds a Node.js application resource */ + addNodeApp(name: string, appDirectory: string, scriptPath: string): NodeAppResourcePromise; + /** Adds a JavaScript application resource */ + addJavaScriptApp(name: string, appDirectory: string, options?: AddJavaScriptAppOptions): JavaScriptAppResourcePromise; + /** Adds a Vite application resource */ + addViteApp(name: string, appDirectory: string, options?: AddViteAppOptions): ViteAppResourcePromise; + /** Adds a Next.js application resource */ + addNextJsApp(name: string, appDirectory: string, options?: AddNextJsAppOptions): NextJsAppResourcePromise; + /** Adds a LikeC4 live architecture diagram to the Aspire application. */ + addAspireC4(options?: AddAspireC4Options): AspireC4ResourcePromise; + /** Adds an Azure Bicep template resource from a file */ + addBicepTemplate(name: string, bicepFile: string): AzureBicepResourcePromise; + /** Adds an Azure Bicep template resource from inline Bicep content */ + addBicepTemplateString(name: string, bicepContent: string): AzureBicepResourcePromise; + /** Adds an Azure provisioning resource to the application model */ + addAzureInfrastructure(name: string, configureInfrastructure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise; + /** Adds Azure provisioning services to the distributed application builder */ + addAzureProvisioning(): DistributedApplicationBuilderPromise; + /** Adds the shared Azure environment resource to the application model */ + addAzureEnvironment(): AzureEnvironmentResourcePromise; + /** Adds an Azure user-assigned identity resource */ + addAzureUserAssignedIdentity(name: string): AzureUserAssignedIdentityResourcePromise; + /** Adds an Azure Key Vault resource */ + addAzureKeyVault(name: string): AzureKeyVaultResourcePromise; + /** Adds a PostgreSQL server resource */ + addPostgres(name: string, options?: AddPostgresOptions): PostgresServerResourcePromise; + /** Adds a Redis container resource */ + addRedis(name: string, options?: AddRedisOptions): RedisResourcePromise; +} + +export interface DistributedApplicationBuilderPromise extends PromiseLike { + /** Gets the AppHostDirectory property */ + appHostDirectory(): Promise; + /** Gets the Environment property */ + environment(): Promise; + /** Gets the Eventing property */ + eventing(): Promise; + /** Gets the ExecutionContext property */ + executionContext(): Promise; + /** Gets the Pipeline property */ + pipeline(): Promise; + /** Gets the UserSecretsManager property */ + userSecretsManager(): Promise; + /** Builds the distributed application */ + build(): DistributedApplicationPromise; + /** Adds a container registry resource */ + addContainerRegistry(name: string, endpoint: string | ParameterResource | Awaitable, options?: AddContainerRegistryOptions): ContainerRegistryResourcePromise; + /** Adds a container resource */ + addContainer(name: string, image: string | AddContainerOptions): ContainerResourcePromise; + /** Adds a container resource built from a Dockerfile */ + addDockerfile(name: string, contextPath: string, options?: AddDockerfileOptions): ContainerResourcePromise; + /** Adds a container resource built from a programmatically generated Dockerfile */ + addDockerfileBuilder(name: string, contextPath: string, callback: (arg: DockerfileBuilderCallbackContext) => Promise, options?: AddDockerfileBuilderOptions): ContainerResourcePromise; + /** Adds a .NET tool resource */ + addDotnetTool(name: string, packageId: string): DotnetToolResourcePromise; + /** Adds an executable resource */ + addExecutable(name: string, command: string, workingDirectory: string, args: string[]): ExecutableResourcePromise; + /** Adds an external service resource */ + addExternalService(name: string, url: string | ParameterResource | Awaitable): ExternalServiceResourcePromise; + /** Adds a parameter resource */ + addParameter(name: string, options?: AddParameterOptions): ParameterResourcePromise; + /** Adds a parameter sourced from configuration */ + addParameterFromConfiguration(name: string, configurationKey: string, options?: AddParameterFromConfigurationOptions): ParameterResourcePromise; + /** Adds a parameter with a generated default value */ + addParameterWithGeneratedValue(name: string, value: GenerateParameterDefault, options?: AddParameterWithGeneratedValueOptions): ParameterResourcePromise; + /** Adds a connection string resource */ + addConnectionString(name: string, options?: AddConnectionStringOptions): ResourceWithConnectionStringPromise; + /** Adds a .NET project resource */ + addProject(name: string, projectPath: string, options?: AddProjectOptions): ProjectResourcePromise; + /** Adds a C# application resource */ + addCSharpApp(name: string, path: string, options?: AddCSharpAppOptions): CSharpAppResourcePromise; + /** Gets the application configuration */ + getConfiguration(): ConfigurationPromise; + /** Subscribes to the BeforeStart event */ + subscribeBeforeStart(callback: (arg: BeforeStartEvent) => Promise): Promise; + /** Subscribes to the AfterResourcesCreated event */ + subscribeAfterResourcesCreated(callback: (arg: AfterResourcesCreatedEvent) => Promise): Promise; + /** Adds an eventing subscriber */ + addEventingSubscriber(subscribe: (arg: EventingSubscriberRegistrationContext) => Promise): DistributedApplicationBuilderPromise; + /** Attempts to add an eventing subscriber */ + tryAddEventingSubscriber(subscribe: (arg: EventingSubscriberRegistrationContext) => Promise): DistributedApplicationBuilderPromise; + /** Adds an Azure PostgreSQL Flexible Server resource */ + addAzurePostgresFlexibleServer(name: string): AzurePostgresFlexibleServerResourcePromise; + /** Adds an Azure Managed Redis resource */ + addAzureManagedRedis(name: string): AzureManagedRedisResourcePromise; + /** Adds a Node.js application resource */ + addNodeApp(name: string, appDirectory: string, scriptPath: string): NodeAppResourcePromise; + /** Adds a JavaScript application resource */ + addJavaScriptApp(name: string, appDirectory: string, options?: AddJavaScriptAppOptions): JavaScriptAppResourcePromise; + /** Adds a Vite application resource */ + addViteApp(name: string, appDirectory: string, options?: AddViteAppOptions): ViteAppResourcePromise; + /** Adds a Next.js application resource */ + addNextJsApp(name: string, appDirectory: string, options?: AddNextJsAppOptions): NextJsAppResourcePromise; + /** Adds a LikeC4 live architecture diagram to the Aspire application. */ + addAspireC4(options?: AddAspireC4Options): AspireC4ResourcePromise; + /** Adds an Azure Bicep template resource from a file */ + addBicepTemplate(name: string, bicepFile: string): AzureBicepResourcePromise; + /** Adds an Azure Bicep template resource from inline Bicep content */ + addBicepTemplateString(name: string, bicepContent: string): AzureBicepResourcePromise; + /** Adds an Azure provisioning resource to the application model */ + addAzureInfrastructure(name: string, configureInfrastructure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise; + /** Adds Azure provisioning services to the distributed application builder */ + addAzureProvisioning(): DistributedApplicationBuilderPromise; + /** Adds the shared Azure environment resource to the application model */ + addAzureEnvironment(): AzureEnvironmentResourcePromise; + /** Adds an Azure user-assigned identity resource */ + addAzureUserAssignedIdentity(name: string): AzureUserAssignedIdentityResourcePromise; + /** Adds an Azure Key Vault resource */ + addAzureKeyVault(name: string): AzureKeyVaultResourcePromise; + /** Adds a PostgreSQL server resource */ + addPostgres(name: string, options?: AddPostgresOptions): PostgresServerResourcePromise; + /** Adds a Redis container resource */ + addRedis(name: string, options?: AddRedisOptions): RedisResourcePromise; +} + +// ============================================================================ +// DistributedApplicationBuilderImpl +// ============================================================================ + +/** + * Type class for DistributedApplicationBuilder. + */ +class DistributedApplicationBuilderImpl implements DistributedApplicationBuilder { + constructor(private _handle: IDistributedApplicationBuilderHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + async appHostDirectory(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting/IDistributedApplicationBuilder.appHostDirectory', + { context: this._handle } + ); + } + + async environment(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting/IDistributedApplicationBuilder.environment', + { context: this._handle } + ); + return new HostEnvironmentImpl(handle, this._client); + } + + async eventing(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting/IDistributedApplicationBuilder.eventing', + { context: this._handle } + ); + return new DistributedApplicationEventingImpl(handle, this._client); + } + + async executionContext(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting/IDistributedApplicationBuilder.executionContext', + { context: this._handle } + ); + return new DistributedApplicationExecutionContextImpl(handle, this._client); + } + + async pipeline(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting/IDistributedApplicationBuilder.pipeline', + { context: this._handle } + ); + return new DistributedApplicationPipelineImpl(handle, this._client); + } + + async userSecretsManager(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting/IDistributedApplicationBuilder.userSecretsManager', + { context: this._handle } + ); + return new UserSecretsManagerImpl(handle, this._client); + } + + /** @internal */ + async _buildInternal(): Promise { + const rpcArgs: Record = { context: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/build', + rpcArgs + ); + return new DistributedApplicationImpl(result, this._client); + } + + build(): DistributedApplicationPromise { + const flushAndBuild = async () => { await this._client.flushPendingPromises(); return this._buildInternal(); }; + return new DistributedApplicationPromiseImpl(flushAndBuild(), this._client, false); + } + + /** @internal */ + async _addContainerRegistryInternal(name: string, endpoint: string | ParameterResource | Awaitable, repository?: string | ParameterResource | Awaitable): Promise { + endpoint = isPromiseLike(endpoint) ? await endpoint : endpoint; + repository = isPromiseLike(repository) ? await repository : repository; + const rpcArgs: Record = { builder: this._handle, name, endpoint }; + if (repository !== undefined) rpcArgs.repository = repository; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addContainerRegistry', + rpcArgs + ); + return new ContainerRegistryResourceImpl(result, this._client); + } + + addContainerRegistry(name: string, endpoint: string | ParameterResource | Awaitable, options?: AddContainerRegistryOptions): ContainerRegistryResourcePromise { + let repository = options?.repository; + return new ContainerRegistryResourcePromiseImpl(this._addContainerRegistryInternal(name, endpoint, repository), this._client); + } + + /** @internal */ + async _addContainerInternal(name: string, image: string | AddContainerOptions): Promise { + const rpcArgs: Record = { builder: this._handle, name, image }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addContainer', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + addContainer(name: string, image: string | AddContainerOptions): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._addContainerInternal(name, image), this._client); + } + + /** @internal */ + async _addDockerfileInternal(name: string, contextPath: string, dockerfilePath?: string, stage?: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, contextPath }; + if (dockerfilePath !== undefined) rpcArgs.dockerfilePath = dockerfilePath; + if (stage !== undefined) rpcArgs.stage = stage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addDockerfile', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + addDockerfile(name: string, contextPath: string, options?: AddDockerfileOptions): ContainerResourcePromise { + const dockerfilePath = options?.dockerfilePath; + const stage = options?.stage; + return new ContainerResourcePromiseImpl(this._addDockerfileInternal(name, contextPath, dockerfilePath, stage), this._client); + } + + /** @internal */ + async _addDockerfileBuilderInternal(name: string, contextPath: string, callback: (arg: DockerfileBuilderCallbackContext) => Promise, stage?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as DockerfileBuilderCallbackContextHandle; + const arg = new DockerfileBuilderCallbackContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, contextPath, callback: callbackId }; + if (stage !== undefined) rpcArgs.stage = stage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addDockerfileBuilder', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + addDockerfileBuilder(name: string, contextPath: string, callback: (arg: DockerfileBuilderCallbackContext) => Promise, options?: AddDockerfileBuilderOptions): ContainerResourcePromise { + const stage = options?.stage; + return new ContainerResourcePromiseImpl(this._addDockerfileBuilderInternal(name, contextPath, callback, stage), this._client); + } + + /** @internal */ + async _addDotnetToolInternal(name: string, packageId: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, packageId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addDotnetTool', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + addDotnetTool(name: string, packageId: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._addDotnetToolInternal(name, packageId), this._client); + } + + /** @internal */ + async _addExecutableInternal(name: string, command: string, workingDirectory: string, args: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, name, command, workingDirectory, args }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addExecutable', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + addExecutable(name: string, command: string, workingDirectory: string, args: string[]): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._addExecutableInternal(name, command, workingDirectory, args), this._client); + } + + /** @internal */ + async _addExternalServiceInternal(name: string, url: string | ParameterResource | Awaitable): Promise { + url = isPromiseLike(url) ? await url : url; + const rpcArgs: Record = { builder: this._handle, name, url }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addExternalService', + rpcArgs + ); + return new ExternalServiceResourceImpl(result, this._client); + } + + addExternalService(name: string, url: string | ParameterResource | Awaitable): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._addExternalServiceInternal(name, url), this._client); + } + + /** @internal */ + async _addParameterInternal(name: string, value?: string, publishValueAsDefault?: boolean, secret?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (value !== undefined) rpcArgs.value = value; + if (publishValueAsDefault !== undefined) rpcArgs.publishValueAsDefault = publishValueAsDefault; + if (secret !== undefined) rpcArgs.secret = secret; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addParameter', + rpcArgs + ); + return new ParameterResourceImpl(result, this._client); + } + + addParameter(name: string, options?: AddParameterOptions): ParameterResourcePromise { + const value = options?.value; + const publishValueAsDefault = options?.publishValueAsDefault; + const secret = options?.secret; + return new ParameterResourcePromiseImpl(this._addParameterInternal(name, value, publishValueAsDefault, secret), this._client); + } + + /** @internal */ + async _addParameterFromConfigurationInternal(name: string, configurationKey: string, secret?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, name, configurationKey }; + if (secret !== undefined) rpcArgs.secret = secret; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addParameterFromConfiguration', + rpcArgs + ); + return new ParameterResourceImpl(result, this._client); + } + + addParameterFromConfiguration(name: string, configurationKey: string, options?: AddParameterFromConfigurationOptions): ParameterResourcePromise { + const secret = options?.secret; + return new ParameterResourcePromiseImpl(this._addParameterFromConfigurationInternal(name, configurationKey, secret), this._client); + } + + /** @internal */ + async _addParameterWithGeneratedValueInternal(name: string, value: GenerateParameterDefault, secret?: boolean, persist?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + if (secret !== undefined) rpcArgs.secret = secret; + if (persist !== undefined) rpcArgs.persist = persist; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addParameterWithGeneratedValue', + rpcArgs + ); + return new ParameterResourceImpl(result, this._client); + } + + addParameterWithGeneratedValue(name: string, value: GenerateParameterDefault, options?: AddParameterWithGeneratedValueOptions): ParameterResourcePromise { + const secret = options?.secret; + const persist = options?.persist; + return new ParameterResourcePromiseImpl(this._addParameterWithGeneratedValueInternal(name, value, secret, persist), this._client); + } + + /** @internal */ + async _addConnectionStringInternal(name: string, environmentVariableNameOrExpression?: string | ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (environmentVariableNameOrExpression !== undefined) rpcArgs.environmentVariableNameOrExpression = environmentVariableNameOrExpression; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addConnectionString', + rpcArgs + ); + return new ResourceWithConnectionStringImpl(result, this._client); + } + + addConnectionString(name: string, options?: AddConnectionStringOptions): ResourceWithConnectionStringPromise { + const environmentVariableNameOrExpression = options?.environmentVariableNameOrExpression; + return new ResourceWithConnectionStringPromiseImpl(this._addConnectionStringInternal(name, environmentVariableNameOrExpression), this._client); + } + + /** @internal */ + async _addProjectInternal(name: string, projectPath: string, launchProfileOrOptions?: string | ProjectResourceOptions | Awaitable): Promise { + launchProfileOrOptions = isPromiseLike(launchProfileOrOptions) ? await launchProfileOrOptions : launchProfileOrOptions; + const rpcArgs: Record = { builder: this._handle, name, projectPath }; + if (launchProfileOrOptions !== undefined) rpcArgs.launchProfileOrOptions = launchProfileOrOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addProject', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + addProject(name: string, projectPath: string, options?: AddProjectOptions): ProjectResourcePromise { + let launchProfileOrOptions = options?.launchProfileOrOptions; + return new ProjectResourcePromiseImpl(this._addProjectInternal(name, projectPath, launchProfileOrOptions), this._client); + } + + /** @internal */ + async _addCSharpAppInternal(name: string, path: string, options?: Awaitable): Promise { + options = isPromiseLike(options) ? await options : options; + const rpcArgs: Record = { builder: this._handle, name, path }; + if (options !== undefined) rpcArgs.options = options; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addCSharpApp', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + addCSharpApp(name: string, path: string, optionsBag?: AddCSharpAppOptions): CSharpAppResourcePromise { + let options = optionsBag?.options; + return new CSharpAppResourcePromiseImpl(this._addCSharpAppInternal(name, path, options), this._client); + } + + /** @internal */ + async _getConfigurationInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getConfiguration', + rpcArgs + ); + return new ConfigurationImpl(result, this._client); + } + + getConfiguration(): ConfigurationPromise { + return new ConfigurationPromiseImpl(this._getConfigurationInternal(), this._client); + } + + async subscribeBeforeStart(callback: (arg: BeforeStartEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeStartEventHandle; + const arg = new BeforeStartEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + return await this._client.invokeCapability( + 'Aspire.Hosting/subscribeBeforeStart', + rpcArgs + ); + } + + async subscribeAfterResourcesCreated(callback: (arg: AfterResourcesCreatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as AfterResourcesCreatedEventHandle; + const arg = new AfterResourcesCreatedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + return await this._client.invokeCapability( + 'Aspire.Hosting/subscribeAfterResourcesCreated', + rpcArgs + ); + } + + /** @internal */ + async _addEventingSubscriberInternal(subscribe: (arg: EventingSubscriberRegistrationContext) => Promise): Promise { + const subscribeId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EventingSubscriberRegistrationContextHandle; + const arg = new EventingSubscriberRegistrationContextImpl(argHandle, this._client); + await subscribe(arg); + }); + const rpcArgs: Record = { builder: this._handle, subscribe: subscribeId }; + await this._client.invokeCapability( + 'Aspire.Hosting/addEventingSubscriber', + rpcArgs + ); + return this; + } + + addEventingSubscriber(subscribe: (arg: EventingSubscriberRegistrationContext) => Promise): DistributedApplicationBuilderPromise { + return new DistributedApplicationBuilderPromiseImpl(this._addEventingSubscriberInternal(subscribe), this._client); + } + + /** @internal */ + async _tryAddEventingSubscriberInternal(subscribe: (arg: EventingSubscriberRegistrationContext) => Promise): Promise { + const subscribeId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EventingSubscriberRegistrationContextHandle; + const arg = new EventingSubscriberRegistrationContextImpl(argHandle, this._client); + await subscribe(arg); + }); + const rpcArgs: Record = { builder: this._handle, subscribe: subscribeId }; + await this._client.invokeCapability( + 'Aspire.Hosting/tryAddEventingSubscriber', + rpcArgs + ); + return this; + } + + tryAddEventingSubscriber(subscribe: (arg: EventingSubscriberRegistrationContext) => Promise): DistributedApplicationBuilderPromise { + return new DistributedApplicationBuilderPromiseImpl(this._tryAddEventingSubscriberInternal(subscribe), this._client); + } + + /** @internal */ + async _addAzurePostgresFlexibleServerInternal(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.PostgreSQL/addAzurePostgresFlexibleServer', + rpcArgs + ); + return new AzurePostgresFlexibleServerResourceImpl(result, this._client); + } + + addAzurePostgresFlexibleServer(name: string): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._addAzurePostgresFlexibleServerInternal(name), this._client); + } + + /** @internal */ + async _addAzureManagedRedisInternal(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Redis/addAzureManagedRedis', + rpcArgs + ); + return new AzureManagedRedisResourceImpl(result, this._client); + } + + addAzureManagedRedis(name: string): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._addAzureManagedRedisInternal(name), this._client); + } + + /** @internal */ + async _addNodeAppInternal(name: string, appDirectory: string, scriptPath: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, appDirectory, scriptPath }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/addNodeApp', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + addNodeApp(name: string, appDirectory: string, scriptPath: string): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._addNodeAppInternal(name, appDirectory, scriptPath), this._client); + } + + /** @internal */ + async _addJavaScriptAppInternal(name: string, appDirectory: string, runScriptName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, appDirectory }; + if (runScriptName !== undefined) rpcArgs.runScriptName = runScriptName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/addJavaScriptApp', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + addJavaScriptApp(name: string, appDirectory: string, options?: AddJavaScriptAppOptions): JavaScriptAppResourcePromise { + const runScriptName = options?.runScriptName; + return new JavaScriptAppResourcePromiseImpl(this._addJavaScriptAppInternal(name, appDirectory, runScriptName), this._client); + } + + /** @internal */ + async _addViteAppInternal(name: string, appDirectory: string, runScriptName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, appDirectory }; + if (runScriptName !== undefined) rpcArgs.runScriptName = runScriptName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/addViteApp', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + addViteApp(name: string, appDirectory: string, options?: AddViteAppOptions): ViteAppResourcePromise { + const runScriptName = options?.runScriptName; + return new ViteAppResourcePromiseImpl(this._addViteAppInternal(name, appDirectory, runScriptName), this._client); + } + + /** @internal */ + async _addNextJsAppInternal(name: string, appDirectory: string, runScriptName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, appDirectory }; + if (runScriptName !== undefined) rpcArgs.runScriptName = runScriptName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/addNextJsApp', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + addNextJsApp(name: string, appDirectory: string, options?: AddNextJsAppOptions): NextJsAppResourcePromise { + const runScriptName = options?.runScriptName; + return new NextJsAppResourcePromiseImpl(this._addNextJsAppInternal(name, appDirectory, runScriptName), this._client); + } + + /** @internal */ + async _addAspireC4Internal(name?: string, port?: number, configure?: (obj: AspireC4DiagramOptions) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as AspireC4DiagramOptionsHandle; + const obj = new AspireC4DiagramOptionsImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + const rpcArgs: Record = { builder: this._handle }; + if (name !== undefined) rpcArgs.name = name; + if (port !== undefined) rpcArgs.port = port; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/addAspireC4', + rpcArgs + ); + return new AspireC4ResourceImpl(result, this._client); + } + + addAspireC4(options?: AddAspireC4Options): AspireC4ResourcePromise { + const name = options?.name; + const port = options?.port; + const configure = options?.configure; + return new AspireC4ResourcePromiseImpl(this._addAspireC4Internal(name, port, configure), this._client); + } + + /** @internal */ + async _addBicepTemplateInternal(name: string, bicepFile: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, bicepFile }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/addBicepTemplate', + rpcArgs + ); + return new AzureBicepResourceImpl(result, this._client); + } + + addBicepTemplate(name: string, bicepFile: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._addBicepTemplateInternal(name, bicepFile), this._client); + } + + /** @internal */ + async _addBicepTemplateStringInternal(name: string, bicepContent: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, bicepContent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/addBicepTemplateString', + rpcArgs + ); + return new AzureBicepResourceImpl(result, this._client); + } + + addBicepTemplateString(name: string, bicepContent: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._addBicepTemplateStringInternal(name, bicepContent), this._client); + } + + /** @internal */ + async _addAzureInfrastructureInternal(name: string, configureInfrastructure: (obj: AzureResourceInfrastructure) => Promise): Promise { + const configureInfrastructureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as AzureResourceInfrastructureHandle; + const obj = new AzureResourceInfrastructureImpl(objHandle, this._client); + await configureInfrastructure(obj); + }); + const rpcArgs: Record = { builder: this._handle, name, configureInfrastructure: configureInfrastructureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/addAzureInfrastructure', + rpcArgs + ); + return new AzureProvisioningResourceImpl(result, this._client); + } + + addAzureInfrastructure(name: string, configureInfrastructure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._addAzureInfrastructureInternal(name, configureInfrastructure), this._client); + } + + /** @internal */ + async _addAzureProvisioningInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/addAzureProvisioning', + rpcArgs + ); + return new DistributedApplicationBuilderImpl(result, this._client); + } + + addAzureProvisioning(): DistributedApplicationBuilderPromise { + return new DistributedApplicationBuilderPromiseImpl(this._addAzureProvisioningInternal(), this._client); + } + + /** @internal */ + async _addAzureEnvironmentInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/addAzureEnvironment', + rpcArgs + ); + return new AzureEnvironmentResourceImpl(result, this._client); + } + + addAzureEnvironment(): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromiseImpl(this._addAzureEnvironmentInternal(), this._client); + } + + /** @internal */ + async _addAzureUserAssignedIdentityInternal(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/addAzureUserAssignedIdentity', + rpcArgs + ); + return new AzureUserAssignedIdentityResourceImpl(result, this._client); + } + + addAzureUserAssignedIdentity(name: string): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._addAzureUserAssignedIdentityInternal(name), this._client); + } + + /** @internal */ + async _addAzureKeyVaultInternal(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.KeyVault/addAzureKeyVault', + rpcArgs + ); + return new AzureKeyVaultResourceImpl(result, this._client); + } + + addAzureKeyVault(name: string): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._addAzureKeyVaultInternal(name), this._client); + } + + /** @internal */ + async _addPostgresInternal(name: string, userName?: Awaitable, password?: Awaitable, port?: number): Promise { + userName = isPromiseLike(userName) ? await userName : userName; + password = isPromiseLike(password) ? await password : password; + const rpcArgs: Record = { builder: this._handle, name }; + if (userName !== undefined) rpcArgs.userName = userName; + if (password !== undefined) rpcArgs.password = password; + if (port !== undefined) rpcArgs.port = port; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.PostgreSQL/addPostgres', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + addPostgres(name: string, options?: AddPostgresOptions): PostgresServerResourcePromise { + let userName = options?.userName; + let password = options?.password; + const port = options?.port; + return new PostgresServerResourcePromiseImpl(this._addPostgresInternal(name, userName, password, port), this._client); + } + + /** @internal */ + async _addRedisInternal(name: string, port?: number, password?: Awaitable): Promise { + password = isPromiseLike(password) ? await password : password; + const rpcArgs: Record = { builder: this._handle, name }; + if (port !== undefined) rpcArgs.port = port; + if (password !== undefined) rpcArgs.password = password; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Redis/addRedis', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + addRedis(name: string, options?: AddRedisOptions): RedisResourcePromise { + const port = options?.port; + let password = options?.password; + return new RedisResourcePromiseImpl(this._addRedisInternal(name, port, password), this._client); + } + +} + +/** + * Thenable wrapper for DistributedApplicationBuilder that enables fluent chaining. + */ +class DistributedApplicationBuilderPromiseImpl implements DistributedApplicationBuilderPromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: DistributedApplicationBuilder) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + appHostDirectory(): Promise { + return this._promise.then(obj => obj.appHostDirectory()); + } + + environment(): Promise { + return this._promise.then(obj => obj.environment()); + } + + eventing(): Promise { + return this._promise.then(obj => obj.eventing()); + } + + executionContext(): Promise { + return this._promise.then(obj => obj.executionContext()); + } + + pipeline(): Promise { + return this._promise.then(obj => obj.pipeline()); + } + + userSecretsManager(): Promise { + return this._promise.then(obj => obj.userSecretsManager()); + } + + build(): DistributedApplicationPromise { + return new DistributedApplicationPromiseImpl(this._promise.then(obj => obj.build()), this._client); + } + + addContainerRegistry(name: string, endpoint: string | ParameterResource | Awaitable, options?: AddContainerRegistryOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.addContainerRegistry(name, endpoint, options)), this._client); + } + + addContainer(name: string, image: string | AddContainerOptions): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.addContainer(name, image)), this._client); + } + + addDockerfile(name: string, contextPath: string, options?: AddDockerfileOptions): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.addDockerfile(name, contextPath, options)), this._client); + } + + addDockerfileBuilder(name: string, contextPath: string, callback: (arg: DockerfileBuilderCallbackContext) => Promise, options?: AddDockerfileBuilderOptions): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.addDockerfileBuilder(name, contextPath, callback, options)), this._client); + } + + addDotnetTool(name: string, packageId: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.addDotnetTool(name, packageId)), this._client); + } + + addExecutable(name: string, command: string, workingDirectory: string, args: string[]): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.addExecutable(name, command, workingDirectory, args)), this._client); + } + + addExternalService(name: string, url: string | ParameterResource | Awaitable): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.addExternalService(name, url)), this._client); + } + + addParameter(name: string, options?: AddParameterOptions): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.addParameter(name, options)), this._client); + } + + addParameterFromConfiguration(name: string, configurationKey: string, options?: AddParameterFromConfigurationOptions): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.addParameterFromConfiguration(name, configurationKey, options)), this._client); + } + + addParameterWithGeneratedValue(name: string, value: GenerateParameterDefault, options?: AddParameterWithGeneratedValueOptions): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.addParameterWithGeneratedValue(name, value, options)), this._client); + } + + addConnectionString(name: string, options?: AddConnectionStringOptions): ResourceWithConnectionStringPromise { + return new ResourceWithConnectionStringPromiseImpl(this._promise.then(obj => obj.addConnectionString(name, options)), this._client); + } + + addProject(name: string, projectPath: string, options?: AddProjectOptions): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.addProject(name, projectPath, options)), this._client); + } + + addCSharpApp(name: string, path: string, options?: AddCSharpAppOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.addCSharpApp(name, path, options)), this._client); + } + + getConfiguration(): ConfigurationPromise { + return new ConfigurationPromiseImpl(this._promise.then(obj => obj.getConfiguration()), this._client); + } + + subscribeBeforeStart(callback: (arg: BeforeStartEvent) => Promise): Promise { + return this._promise.then(obj => obj.subscribeBeforeStart(callback)); + } + + subscribeAfterResourcesCreated(callback: (arg: AfterResourcesCreatedEvent) => Promise): Promise { + return this._promise.then(obj => obj.subscribeAfterResourcesCreated(callback)); + } + + addEventingSubscriber(subscribe: (arg: EventingSubscriberRegistrationContext) => Promise): DistributedApplicationBuilderPromise { + return new DistributedApplicationBuilderPromiseImpl(this._promise.then(obj => obj.addEventingSubscriber(subscribe)), this._client); + } + + tryAddEventingSubscriber(subscribe: (arg: EventingSubscriberRegistrationContext) => Promise): DistributedApplicationBuilderPromise { + return new DistributedApplicationBuilderPromiseImpl(this._promise.then(obj => obj.tryAddEventingSubscriber(subscribe)), this._client); + } + + addAzurePostgresFlexibleServer(name: string): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._promise.then(obj => obj.addAzurePostgresFlexibleServer(name)), this._client); + } + + addAzureManagedRedis(name: string): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._promise.then(obj => obj.addAzureManagedRedis(name)), this._client); + } + + addNodeApp(name: string, appDirectory: string, scriptPath: string): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.addNodeApp(name, appDirectory, scriptPath)), this._client); + } + + addJavaScriptApp(name: string, appDirectory: string, options?: AddJavaScriptAppOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.addJavaScriptApp(name, appDirectory, options)), this._client); + } + + addViteApp(name: string, appDirectory: string, options?: AddViteAppOptions): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.addViteApp(name, appDirectory, options)), this._client); + } + + addNextJsApp(name: string, appDirectory: string, options?: AddNextJsAppOptions): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.addNextJsApp(name, appDirectory, options)), this._client); + } + + addAspireC4(options?: AddAspireC4Options): AspireC4ResourcePromise { + return new AspireC4ResourcePromiseImpl(this._promise.then(obj => obj.addAspireC4(options)), this._client); + } + + addBicepTemplate(name: string, bicepFile: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._promise.then(obj => obj.addBicepTemplate(name, bicepFile)), this._client); + } + + addBicepTemplateString(name: string, bicepContent: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._promise.then(obj => obj.addBicepTemplateString(name, bicepContent)), this._client); + } + + addAzureInfrastructure(name: string, configureInfrastructure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._promise.then(obj => obj.addAzureInfrastructure(name, configureInfrastructure)), this._client); + } + + addAzureProvisioning(): DistributedApplicationBuilderPromise { + return new DistributedApplicationBuilderPromiseImpl(this._promise.then(obj => obj.addAzureProvisioning()), this._client); + } + + addAzureEnvironment(): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromiseImpl(this._promise.then(obj => obj.addAzureEnvironment()), this._client); + } + + addAzureUserAssignedIdentity(name: string): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._promise.then(obj => obj.addAzureUserAssignedIdentity(name)), this._client); + } + + addAzureKeyVault(name: string): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._promise.then(obj => obj.addAzureKeyVault(name)), this._client); + } + + addPostgres(name: string, options?: AddPostgresOptions): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.addPostgres(name, options)), this._client); + } + + addRedis(name: string, options?: AddRedisOptions): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.addRedis(name, options)), this._client); + } + +} + +// ============================================================================ +// DistributedApplicationEventing +// ============================================================================ + +export interface DistributedApplicationEventing { + toJSON(): MarshalledHandle; + /** Invokes the Unsubscribe method */ + unsubscribe(subscription: DistributedApplicationEventSubscriptionHandle): DistributedApplicationEventingPromise; +} + +export interface DistributedApplicationEventingPromise extends PromiseLike { + /** Invokes the Unsubscribe method */ + unsubscribe(subscription: DistributedApplicationEventSubscriptionHandle): DistributedApplicationEventingPromise; +} + +// ============================================================================ +// DistributedApplicationEventingImpl +// ============================================================================ + +/** + * Type class for DistributedApplicationEventing. + */ +class DistributedApplicationEventingImpl implements DistributedApplicationEventing { + constructor(private _handle: IDistributedApplicationEventingHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** @internal */ + async _unsubscribeInternal(subscription: DistributedApplicationEventSubscriptionHandle): Promise { + const rpcArgs: Record = { context: this._handle, subscription }; + await this._client.invokeCapability( + 'Aspire.Hosting.Eventing/IDistributedApplicationEventing.unsubscribe', + rpcArgs + ); + return this; + } + + unsubscribe(subscription: DistributedApplicationEventSubscriptionHandle): DistributedApplicationEventingPromise { + return new DistributedApplicationEventingPromiseImpl(this._unsubscribeInternal(subscription), this._client); + } + +} + +/** + * Thenable wrapper for DistributedApplicationEventing that enables fluent chaining. + */ +class DistributedApplicationEventingPromiseImpl implements DistributedApplicationEventingPromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: DistributedApplicationEventing) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + unsubscribe(subscription: DistributedApplicationEventSubscriptionHandle): DistributedApplicationEventingPromise { + return new DistributedApplicationEventingPromiseImpl(this._promise.then(obj => obj.unsubscribe(subscription)), this._client); + } + +} + +// ============================================================================ +// DistributedApplicationPipeline +// ============================================================================ + +export interface DistributedApplicationPipeline { + toJSON(): MarshalledHandle; + /** Disables publish and deploy validation for unconsumed build-only containers. */ + disableBuildOnlyContainerValidation(): DistributedApplicationPipelinePromise; + /** Adds a pipeline step to the application */ + addStep(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: AddStepOptions): DistributedApplicationPipelinePromise; + /** Configures the application pipeline via a callback */ + configure(callback: (arg: PipelineConfigurationContext) => Promise): DistributedApplicationPipelinePromise; +} + +export interface DistributedApplicationPipelinePromise extends PromiseLike { + /** Disables publish and deploy validation for unconsumed build-only containers. */ + disableBuildOnlyContainerValidation(): DistributedApplicationPipelinePromise; + /** Adds a pipeline step to the application */ + addStep(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: AddStepOptions): DistributedApplicationPipelinePromise; + /** Configures the application pipeline via a callback */ + configure(callback: (arg: PipelineConfigurationContext) => Promise): DistributedApplicationPipelinePromise; +} + +// ============================================================================ +// DistributedApplicationPipelineImpl +// ============================================================================ + +/** + * Type class for DistributedApplicationPipeline. + */ +class DistributedApplicationPipelineImpl implements DistributedApplicationPipeline { + constructor(private _handle: IDistributedApplicationPipelineHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** @internal */ + async _disableBuildOnlyContainerValidationInternal(): Promise { + const rpcArgs: Record = { pipeline: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/disableBuildOnlyContainerValidation', + rpcArgs + ); + return new DistributedApplicationPipelineImpl(result, this._client); + } + + disableBuildOnlyContainerValidation(): DistributedApplicationPipelinePromise { + return new DistributedApplicationPipelinePromiseImpl(this._disableBuildOnlyContainerValidationInternal(), this._client); + } + + /** @internal */ + async _addStepInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[]): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { pipeline: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + await this._client.invokeCapability( + 'Aspire.Hosting/addStep', + rpcArgs + ); + return this; + } + + addStep(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: AddStepOptions): DistributedApplicationPipelinePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + return new DistributedApplicationPipelinePromiseImpl(this._addStepInternal(stepName, callback, dependsOn, requiredBy), this._client); + } + + /** @internal */ + async _configureInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { pipeline: this._handle, callback: callbackId }; + await this._client.invokeCapability( + 'Aspire.Hosting/configure', + rpcArgs + ); + return this; + } + + configure(callback: (arg: PipelineConfigurationContext) => Promise): DistributedApplicationPipelinePromise { + return new DistributedApplicationPipelinePromiseImpl(this._configureInternal(callback), this._client); + } + +} + +/** + * Thenable wrapper for DistributedApplicationPipeline that enables fluent chaining. + */ +class DistributedApplicationPipelinePromiseImpl implements DistributedApplicationPipelinePromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: DistributedApplicationPipeline) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + disableBuildOnlyContainerValidation(): DistributedApplicationPipelinePromise { + return new DistributedApplicationPipelinePromiseImpl(this._promise.then(obj => obj.disableBuildOnlyContainerValidation()), this._client); + } + + addStep(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: AddStepOptions): DistributedApplicationPipelinePromise { + return new DistributedApplicationPipelinePromiseImpl(this._promise.then(obj => obj.addStep(stepName, callback, options)), this._client); + } + + configure(callback: (arg: PipelineConfigurationContext) => Promise): DistributedApplicationPipelinePromise { + return new DistributedApplicationPipelinePromiseImpl(this._promise.then(obj => obj.configure(callback)), this._client); + } + +} + +// ============================================================================ +// ExecutionConfigurationBuilder +// ============================================================================ + +export interface ExecutionConfigurationBuilder { + toJSON(): MarshalledHandle; + /** Builds the execution configuration */ + build(executionContext: Awaitable, options?: BuildOptions): ExecutionConfigurationResultPromise; + /** Adds an HTTPS certificate configuration gatherer */ + withHttpsCertificateConfig(configContextFactory: (arg: HttpsCertificateInfo) => Promise): ExecutionConfigurationBuilderPromise; + /** Adds an arguments configuration gatherer */ + withArgumentsConfig(): ExecutionConfigurationBuilderPromise; + /** Adds an environment variables configuration gatherer */ + withEnvironmentVariablesConfig(): ExecutionConfigurationBuilderPromise; + /** Adds a certificate trust configuration gatherer */ + withCertificateTrustConfig(configContextFactory: (arg: CertificateTrustScope) => Promise): ExecutionConfigurationBuilderPromise; +} + +export interface ExecutionConfigurationBuilderPromise extends PromiseLike { + /** Builds the execution configuration */ + build(executionContext: Awaitable, options?: BuildOptions): ExecutionConfigurationResultPromise; + /** Adds an HTTPS certificate configuration gatherer */ + withHttpsCertificateConfig(configContextFactory: (arg: HttpsCertificateInfo) => Promise): ExecutionConfigurationBuilderPromise; + /** Adds an arguments configuration gatherer */ + withArgumentsConfig(): ExecutionConfigurationBuilderPromise; + /** Adds an environment variables configuration gatherer */ + withEnvironmentVariablesConfig(): ExecutionConfigurationBuilderPromise; + /** Adds a certificate trust configuration gatherer */ + withCertificateTrustConfig(configContextFactory: (arg: CertificateTrustScope) => Promise): ExecutionConfigurationBuilderPromise; +} + +// ============================================================================ +// ExecutionConfigurationBuilderImpl +// ============================================================================ + +/** + * Type class for ExecutionConfigurationBuilder. + */ +class ExecutionConfigurationBuilderImpl implements ExecutionConfigurationBuilder { + constructor(private _handle: IExecutionConfigurationBuilderHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** @internal */ + async _buildInternal(executionContext: Awaitable, resourceLogger?: Awaitable, cancellationToken?: AbortSignal | CancellationToken): Promise { + executionContext = isPromiseLike(executionContext) ? await executionContext : executionContext; + resourceLogger = isPromiseLike(resourceLogger) ? await resourceLogger : resourceLogger; + const rpcArgs: Record = { builder: this._handle, executionContext }; + if (resourceLogger !== undefined) rpcArgs.resourceLogger = resourceLogger; + if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); + const result = await this._client.invokeCapability( + 'Aspire.Hosting/buildExecutionConfiguration', + rpcArgs + ); + return new ExecutionConfigurationResultImpl(result, this._client); + } + + build(executionContext: Awaitable, options?: BuildOptions): ExecutionConfigurationResultPromise { + let resourceLogger = options?.resourceLogger; + const cancellationToken = options?.cancellationToken; + const flushAndBuild = async () => { await this._client.flushPendingPromises(); return this._buildInternal(executionContext, resourceLogger, cancellationToken); }; + return new ExecutionConfigurationResultPromiseImpl(flushAndBuild(), this._client, false); + } + + /** @internal */ + async _withHttpsCertificateConfigInternal(configContextFactory: (arg: HttpsCertificateInfo) => Promise): Promise { + const configContextFactoryId = registerCallback(async (argData: unknown) => { + const arg = wrapIfHandle(argData) as HttpsCertificateInfo; + return await configContextFactory(arg); + }); + const rpcArgs: Record = { builder: this._handle, configContextFactory: configContextFactoryId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsCertificateConfigExport', + rpcArgs + ); + return new ExecutionConfigurationBuilderImpl(result, this._client); + } + + withHttpsCertificateConfig(configContextFactory: (arg: HttpsCertificateInfo) => Promise): ExecutionConfigurationBuilderPromise { + return new ExecutionConfigurationBuilderPromiseImpl(this._withHttpsCertificateConfigInternal(configContextFactory), this._client); + } + + /** @internal */ + async _withArgumentsConfigInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgumentsConfig', + rpcArgs + ); + return new ExecutionConfigurationBuilderImpl(result, this._client); + } + + withArgumentsConfig(): ExecutionConfigurationBuilderPromise { + return new ExecutionConfigurationBuilderPromiseImpl(this._withArgumentsConfigInternal(), this._client); + } + + /** @internal */ + async _withEnvironmentVariablesConfigInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentVariablesConfig', + rpcArgs + ); + return new ExecutionConfigurationBuilderImpl(result, this._client); + } + + withEnvironmentVariablesConfig(): ExecutionConfigurationBuilderPromise { + return new ExecutionConfigurationBuilderPromiseImpl(this._withEnvironmentVariablesConfigInternal(), this._client); + } + + /** @internal */ + async _withCertificateTrustConfigInternal(configContextFactory: (arg: CertificateTrustScope) => Promise): Promise { + const configContextFactoryId = registerCallback(async (argData: unknown) => { + const arg = wrapIfHandle(argData) as CertificateTrustScope; + return await configContextFactory(arg); + }); + const rpcArgs: Record = { builder: this._handle, configContextFactory: configContextFactoryId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCertificateTrustConfig', + rpcArgs + ); + return new ExecutionConfigurationBuilderImpl(result, this._client); + } + + withCertificateTrustConfig(configContextFactory: (arg: CertificateTrustScope) => Promise): ExecutionConfigurationBuilderPromise { + return new ExecutionConfigurationBuilderPromiseImpl(this._withCertificateTrustConfigInternal(configContextFactory), this._client); + } + +} + +/** + * Thenable wrapper for ExecutionConfigurationBuilder that enables fluent chaining. + */ +class ExecutionConfigurationBuilderPromiseImpl implements ExecutionConfigurationBuilderPromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: ExecutionConfigurationBuilder) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + build(executionContext: Awaitable, options?: BuildOptions): ExecutionConfigurationResultPromise { + return new ExecutionConfigurationResultPromiseImpl(this._promise.then(obj => obj.build(executionContext, options)), this._client); + } + + withHttpsCertificateConfig(configContextFactory: (arg: HttpsCertificateInfo) => Promise): ExecutionConfigurationBuilderPromise { + return new ExecutionConfigurationBuilderPromiseImpl(this._promise.then(obj => obj.withHttpsCertificateConfig(configContextFactory)), this._client); + } + + withArgumentsConfig(): ExecutionConfigurationBuilderPromise { + return new ExecutionConfigurationBuilderPromiseImpl(this._promise.then(obj => obj.withArgumentsConfig()), this._client); + } + + withEnvironmentVariablesConfig(): ExecutionConfigurationBuilderPromise { + return new ExecutionConfigurationBuilderPromiseImpl(this._promise.then(obj => obj.withEnvironmentVariablesConfig()), this._client); + } + + withCertificateTrustConfig(configContextFactory: (arg: CertificateTrustScope) => Promise): ExecutionConfigurationBuilderPromise { + return new ExecutionConfigurationBuilderPromiseImpl(this._promise.then(obj => obj.withCertificateTrustConfig(configContextFactory)), this._client); + } + +} + +// ============================================================================ +// ExecutionConfigurationResult +// ============================================================================ + +export interface ExecutionConfigurationResult { + toJSON(): MarshalledHandle; + /** Gets certificate trust execution-configuration data */ + getCertificateTrustData(): Promise; + /** Gets HTTPS certificate execution-configuration data */ + getHttpsCertificateData(): Promise; +} + +export interface ExecutionConfigurationResultPromise extends PromiseLike { + /** Gets certificate trust execution-configuration data */ + getCertificateTrustData(): Promise; + /** Gets HTTPS certificate execution-configuration data */ + getHttpsCertificateData(): Promise; +} + +// ============================================================================ +// ExecutionConfigurationResultImpl +// ============================================================================ + +/** + * Type class for ExecutionConfigurationResult. + */ +class ExecutionConfigurationResultImpl implements ExecutionConfigurationResult { + constructor(private _handle: IExecutionConfigurationResultHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + async getCertificateTrustData(): Promise { + const rpcArgs: Record = { configuration: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getCertificateTrustData', + rpcArgs + ); + } + + async getHttpsCertificateData(): Promise { + const rpcArgs: Record = { configuration: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getHttpsCertificateData', + rpcArgs + ); + } + +} + +/** + * Thenable wrapper for ExecutionConfigurationResult that enables fluent chaining. + */ +class ExecutionConfigurationResultPromiseImpl implements ExecutionConfigurationResultPromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: ExecutionConfigurationResult) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + getCertificateTrustData(): Promise { + return this._promise.then(obj => obj.getCertificateTrustData()); + } + + getHttpsCertificateData(): Promise { + return this._promise.then(obj => obj.getHttpsCertificateData()); + } + +} + +// ============================================================================ +// HostEnvironment +// ============================================================================ + +export interface HostEnvironment { + toJSON(): MarshalledHandle; + /** Checks if running in Development environment */ + isDevelopment(): Promise; + /** Checks if running in Production environment */ + isProduction(): Promise; + /** Checks if running in Staging environment */ + isStaging(): Promise; + /** Checks if the environment matches the specified name */ + isEnvironment(environmentName: string): Promise; +} + +export interface HostEnvironmentPromise extends PromiseLike { + /** Checks if running in Development environment */ + isDevelopment(): Promise; + /** Checks if running in Production environment */ + isProduction(): Promise; + /** Checks if running in Staging environment */ + isStaging(): Promise; + /** Checks if the environment matches the specified name */ + isEnvironment(environmentName: string): Promise; +} + +// ============================================================================ +// HostEnvironmentImpl +// ============================================================================ + +/** + * Type class for HostEnvironment. + */ +class HostEnvironmentImpl implements HostEnvironment { + constructor(private _handle: IHostEnvironmentHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + async isDevelopment(): Promise { + const rpcArgs: Record = { environment: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/isDevelopment', + rpcArgs + ); + } + + async isProduction(): Promise { + const rpcArgs: Record = { environment: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/isProduction', + rpcArgs + ); + } + + async isStaging(): Promise { + const rpcArgs: Record = { environment: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/isStaging', + rpcArgs + ); + } + + async isEnvironment(environmentName: string): Promise { + const rpcArgs: Record = { environment: this._handle, environmentName }; + return await this._client.invokeCapability( + 'Aspire.Hosting/isEnvironment', + rpcArgs + ); + } + +} + +/** + * Thenable wrapper for HostEnvironment that enables fluent chaining. + */ +class HostEnvironmentPromiseImpl implements HostEnvironmentPromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: HostEnvironment) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + isDevelopment(): Promise { + return this._promise.then(obj => obj.isDevelopment()); + } + + isProduction(): Promise { + return this._promise.then(obj => obj.isProduction()); + } + + isStaging(): Promise { + return this._promise.then(obj => obj.isStaging()); + } + + isEnvironment(environmentName: string): Promise { + return this._promise.then(obj => obj.isEnvironment(environmentName)); + } + +} + +// ============================================================================ +// Logger +// ============================================================================ + +export interface Logger { + toJSON(): MarshalledHandle; + /** Logs an information message */ + logInformation(message: string): LoggerPromise; + /** Logs a warning message */ + logWarning(message: string): LoggerPromise; + /** Logs an error message */ + logError(message: string): LoggerPromise; + /** Logs a debug message */ + logDebug(message: string): LoggerPromise; + /** Logs a message with specified level */ + log(level: string, message: string): LoggerPromise; +} + +export interface LoggerPromise extends PromiseLike { + /** Logs an information message */ + logInformation(message: string): LoggerPromise; + /** Logs a warning message */ + logWarning(message: string): LoggerPromise; + /** Logs an error message */ + logError(message: string): LoggerPromise; + /** Logs a debug message */ + logDebug(message: string): LoggerPromise; + /** Logs a message with specified level */ + log(level: string, message: string): LoggerPromise; +} + +// ============================================================================ +// LoggerImpl +// ============================================================================ + +/** + * Type class for Logger. + */ +class LoggerImpl implements Logger { + constructor(private _handle: ILoggerHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** @internal */ + async _logInformationInternal(message: string): Promise { + const rpcArgs: Record = { logger: this._handle, message }; + await this._client.invokeCapability( + 'Aspire.Hosting/logInformation', + rpcArgs + ); + return this; + } + + logInformation(message: string): LoggerPromise { + return new LoggerPromiseImpl(this._logInformationInternal(message), this._client); + } + + /** @internal */ + async _logWarningInternal(message: string): Promise { + const rpcArgs: Record = { logger: this._handle, message }; + await this._client.invokeCapability( + 'Aspire.Hosting/logWarning', + rpcArgs + ); + return this; + } + + logWarning(message: string): LoggerPromise { + return new LoggerPromiseImpl(this._logWarningInternal(message), this._client); + } + + /** @internal */ + async _logErrorInternal(message: string): Promise { + const rpcArgs: Record = { logger: this._handle, message }; + await this._client.invokeCapability( + 'Aspire.Hosting/logError', + rpcArgs + ); + return this; + } + + logError(message: string): LoggerPromise { + return new LoggerPromiseImpl(this._logErrorInternal(message), this._client); + } + + /** @internal */ + async _logDebugInternal(message: string): Promise { + const rpcArgs: Record = { logger: this._handle, message }; + await this._client.invokeCapability( + 'Aspire.Hosting/logDebug', + rpcArgs + ); + return this; + } + + logDebug(message: string): LoggerPromise { + return new LoggerPromiseImpl(this._logDebugInternal(message), this._client); + } + + /** @internal */ + async _logInternal(level: string, message: string): Promise { + const rpcArgs: Record = { logger: this._handle, level, message }; + await this._client.invokeCapability( + 'Aspire.Hosting/log', + rpcArgs + ); + return this; + } + + log(level: string, message: string): LoggerPromise { + return new LoggerPromiseImpl(this._logInternal(level, message), this._client); + } + +} + +/** + * Thenable wrapper for Logger that enables fluent chaining. + */ +class LoggerPromiseImpl implements LoggerPromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: Logger) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + logInformation(message: string): LoggerPromise { + return new LoggerPromiseImpl(this._promise.then(obj => obj.logInformation(message)), this._client); + } + + logWarning(message: string): LoggerPromise { + return new LoggerPromiseImpl(this._promise.then(obj => obj.logWarning(message)), this._client); + } + + logError(message: string): LoggerPromise { + return new LoggerPromiseImpl(this._promise.then(obj => obj.logError(message)), this._client); + } + + logDebug(message: string): LoggerPromise { + return new LoggerPromiseImpl(this._promise.then(obj => obj.logDebug(message)), this._client); + } + + log(level: string, message: string): LoggerPromise { + return new LoggerPromiseImpl(this._promise.then(obj => obj.log(level, message)), this._client); + } + +} + +// ============================================================================ +// LoggerFactory +// ============================================================================ + +export interface LoggerFactory { + toJSON(): MarshalledHandle; + /** Creates a logger for a category */ + createLogger(categoryName: string): LoggerPromise; +} + +export interface LoggerFactoryPromise extends PromiseLike { + /** Creates a logger for a category */ + createLogger(categoryName: string): LoggerPromise; +} + +// ============================================================================ +// LoggerFactoryImpl +// ============================================================================ + +/** + * Type class for LoggerFactory. + */ +class LoggerFactoryImpl implements LoggerFactory { + constructor(private _handle: ILoggerFactoryHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** @internal */ + async _createLoggerInternal(categoryName: string): Promise { + const rpcArgs: Record = { loggerFactory: this._handle, categoryName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/createLogger', + rpcArgs + ); + return new LoggerImpl(result, this._client); + } + + createLogger(categoryName: string): LoggerPromise { + return new LoggerPromiseImpl(this._createLoggerInternal(categoryName), this._client); + } + +} + +/** + * Thenable wrapper for LoggerFactory that enables fluent chaining. + */ +class LoggerFactoryPromiseImpl implements LoggerFactoryPromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: LoggerFactory) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + createLogger(categoryName: string): LoggerPromise { + return new LoggerPromiseImpl(this._promise.then(obj => obj.createLogger(categoryName)), this._client); + } + +} + +// ============================================================================ +// ReportingStep +// ============================================================================ + +export interface ReportingStep { + toJSON(): MarshalledHandle; + /** Creates a reporting task with plain-text status text */ + createTask(statusText: string, options?: CreateTaskOptions): ReportingTaskPromise; + /** Creates a reporting task with Markdown-formatted status text */ + createMarkdownTask(markdownString: string, options?: CreateMarkdownTaskOptions): ReportingTaskPromise; + /** Logs a plain-text message for the reporting step */ + logStep(level: string, message: string): ReportingStepPromise; + /** Logs a Markdown-formatted message for the reporting step */ + logStepMarkdown(level: string, markdownString: string): ReportingStepPromise; + /** Completes the reporting step with plain-text completion text */ + completeStep(completionText: string, options?: CompleteStepOptions): ReportingStepPromise; + /** Completes the reporting step with Markdown-formatted completion text */ + completeStepMarkdown(markdownString: string, options?: CompleteStepMarkdownOptions): ReportingStepPromise; +} + +export interface ReportingStepPromise extends PromiseLike { + /** Creates a reporting task with plain-text status text */ + createTask(statusText: string, options?: CreateTaskOptions): ReportingTaskPromise; + /** Creates a reporting task with Markdown-formatted status text */ + createMarkdownTask(markdownString: string, options?: CreateMarkdownTaskOptions): ReportingTaskPromise; + /** Logs a plain-text message for the reporting step */ + logStep(level: string, message: string): ReportingStepPromise; + /** Logs a Markdown-formatted message for the reporting step */ + logStepMarkdown(level: string, markdownString: string): ReportingStepPromise; + /** Completes the reporting step with plain-text completion text */ + completeStep(completionText: string, options?: CompleteStepOptions): ReportingStepPromise; + /** Completes the reporting step with Markdown-formatted completion text */ + completeStepMarkdown(markdownString: string, options?: CompleteStepMarkdownOptions): ReportingStepPromise; +} + +// ============================================================================ +// ReportingStepImpl +// ============================================================================ + +/** + * Type class for ReportingStep. + */ +class ReportingStepImpl implements ReportingStep { + constructor(private _handle: IReportingStepHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** @internal */ + async _createTaskInternal(statusText: string, cancellationToken?: AbortSignal | CancellationToken): Promise { + const rpcArgs: Record = { reportingStep: this._handle, statusText }; + if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); + const result = await this._client.invokeCapability( + 'Aspire.Hosting/createTask', + rpcArgs + ); + return new ReportingTaskImpl(result, this._client); + } + + createTask(statusText: string, options?: CreateTaskOptions): ReportingTaskPromise { + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromiseImpl(this._createTaskInternal(statusText, cancellationToken), this._client); + } + + /** @internal */ + async _createMarkdownTaskInternal(markdownString: string, cancellationToken?: AbortSignal | CancellationToken): Promise { + const rpcArgs: Record = { reportingStep: this._handle, markdownString }; + if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); + const result = await this._client.invokeCapability( + 'Aspire.Hosting/createMarkdownTask', + rpcArgs + ); + return new ReportingTaskImpl(result, this._client); + } + + createMarkdownTask(markdownString: string, options?: CreateMarkdownTaskOptions): ReportingTaskPromise { + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromiseImpl(this._createMarkdownTaskInternal(markdownString, cancellationToken), this._client); + } + + /** @internal */ + async _logStepInternal(level: string, message: string): Promise { + const rpcArgs: Record = { reportingStep: this._handle, level, message }; + await this._client.invokeCapability( + 'Aspire.Hosting/logStep', + rpcArgs + ); + return this; + } + + logStep(level: string, message: string): ReportingStepPromise { + return new ReportingStepPromiseImpl(this._logStepInternal(level, message), this._client); + } + + /** @internal */ + async _logStepMarkdownInternal(level: string, markdownString: string): Promise { + const rpcArgs: Record = { reportingStep: this._handle, level, markdownString }; + await this._client.invokeCapability( + 'Aspire.Hosting/logStepMarkdown', + rpcArgs + ); + return this; + } + + logStepMarkdown(level: string, markdownString: string): ReportingStepPromise { + return new ReportingStepPromiseImpl(this._logStepMarkdownInternal(level, markdownString), this._client); + } + + /** @internal */ + async _completeStepInternal(completionText: string, completionState?: string, cancellationToken?: AbortSignal | CancellationToken): Promise { + const rpcArgs: Record = { reportingStep: this._handle, completionText }; + if (completionState !== undefined) rpcArgs.completionState = completionState; + if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); + await this._client.invokeCapability( + 'Aspire.Hosting/completeStep', + rpcArgs + ); + return this; + } + + completeStep(completionText: string, options?: CompleteStepOptions): ReportingStepPromise { + const completionState = options?.completionState; + const cancellationToken = options?.cancellationToken; + return new ReportingStepPromiseImpl(this._completeStepInternal(completionText, completionState, cancellationToken), this._client); + } + + /** @internal */ + async _completeStepMarkdownInternal(markdownString: string, completionState?: string, cancellationToken?: AbortSignal | CancellationToken): Promise { + const rpcArgs: Record = { reportingStep: this._handle, markdownString }; + if (completionState !== undefined) rpcArgs.completionState = completionState; + if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); + await this._client.invokeCapability( + 'Aspire.Hosting/completeStepMarkdown', + rpcArgs + ); + return this; + } + + completeStepMarkdown(markdownString: string, options?: CompleteStepMarkdownOptions): ReportingStepPromise { + const completionState = options?.completionState; + const cancellationToken = options?.cancellationToken; + return new ReportingStepPromiseImpl(this._completeStepMarkdownInternal(markdownString, completionState, cancellationToken), this._client); + } + +} + +/** + * Thenable wrapper for ReportingStep that enables fluent chaining. + */ +class ReportingStepPromiseImpl implements ReportingStepPromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: ReportingStep) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + createTask(statusText: string, options?: CreateTaskOptions): ReportingTaskPromise { + return new ReportingTaskPromiseImpl(this._promise.then(obj => obj.createTask(statusText, options)), this._client); + } + + createMarkdownTask(markdownString: string, options?: CreateMarkdownTaskOptions): ReportingTaskPromise { + return new ReportingTaskPromiseImpl(this._promise.then(obj => obj.createMarkdownTask(markdownString, options)), this._client); + } + + logStep(level: string, message: string): ReportingStepPromise { + return new ReportingStepPromiseImpl(this._promise.then(obj => obj.logStep(level, message)), this._client); + } + + logStepMarkdown(level: string, markdownString: string): ReportingStepPromise { + return new ReportingStepPromiseImpl(this._promise.then(obj => obj.logStepMarkdown(level, markdownString)), this._client); + } + + completeStep(completionText: string, options?: CompleteStepOptions): ReportingStepPromise { + return new ReportingStepPromiseImpl(this._promise.then(obj => obj.completeStep(completionText, options)), this._client); + } + + completeStepMarkdown(markdownString: string, options?: CompleteStepMarkdownOptions): ReportingStepPromise { + return new ReportingStepPromiseImpl(this._promise.then(obj => obj.completeStepMarkdown(markdownString, options)), this._client); + } + +} + +// ============================================================================ +// ReportingTask +// ============================================================================ + +export interface ReportingTask { + toJSON(): MarshalledHandle; + /** Updates the reporting task with plain-text status text */ + updateTask(statusText: string, options?: UpdateTaskOptions): ReportingTaskPromise; + /** Updates the reporting task with Markdown-formatted status text */ + updateTaskMarkdown(markdownString: string, options?: UpdateTaskMarkdownOptions): ReportingTaskPromise; + /** Completes the reporting task with plain-text completion text */ + completeTask(options?: CompleteTaskOptions): ReportingTaskPromise; + /** Completes the reporting task with Markdown-formatted completion text */ + completeTaskMarkdown(markdownString: string, options?: CompleteTaskMarkdownOptions): ReportingTaskPromise; +} + +export interface ReportingTaskPromise extends PromiseLike { + /** Updates the reporting task with plain-text status text */ + updateTask(statusText: string, options?: UpdateTaskOptions): ReportingTaskPromise; + /** Updates the reporting task with Markdown-formatted status text */ + updateTaskMarkdown(markdownString: string, options?: UpdateTaskMarkdownOptions): ReportingTaskPromise; + /** Completes the reporting task with plain-text completion text */ + completeTask(options?: CompleteTaskOptions): ReportingTaskPromise; + /** Completes the reporting task with Markdown-formatted completion text */ + completeTaskMarkdown(markdownString: string, options?: CompleteTaskMarkdownOptions): ReportingTaskPromise; +} + +// ============================================================================ +// ReportingTaskImpl +// ============================================================================ + +/** + * Type class for ReportingTask. + */ +class ReportingTaskImpl implements ReportingTask { + constructor(private _handle: IReportingTaskHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** @internal */ + async _updateTaskInternal(statusText: string, cancellationToken?: AbortSignal | CancellationToken): Promise { + const rpcArgs: Record = { reportingTask: this._handle, statusText }; + if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); + await this._client.invokeCapability( + 'Aspire.Hosting/updateTask', + rpcArgs + ); + return this; + } + + updateTask(statusText: string, options?: UpdateTaskOptions): ReportingTaskPromise { + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromiseImpl(this._updateTaskInternal(statusText, cancellationToken), this._client); + } + + /** @internal */ + async _updateTaskMarkdownInternal(markdownString: string, cancellationToken?: AbortSignal | CancellationToken): Promise { + const rpcArgs: Record = { reportingTask: this._handle, markdownString }; + if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); + await this._client.invokeCapability( + 'Aspire.Hosting/updateTaskMarkdown', + rpcArgs + ); + return this; + } + + updateTaskMarkdown(markdownString: string, options?: UpdateTaskMarkdownOptions): ReportingTaskPromise { + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromiseImpl(this._updateTaskMarkdownInternal(markdownString, cancellationToken), this._client); + } + + /** @internal */ + async _completeTaskInternal(completionMessage?: string, completionState?: string, cancellationToken?: AbortSignal | CancellationToken): Promise { + const rpcArgs: Record = { reportingTask: this._handle }; + if (completionMessage !== undefined) rpcArgs.completionMessage = completionMessage; + if (completionState !== undefined) rpcArgs.completionState = completionState; + if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); + await this._client.invokeCapability( + 'Aspire.Hosting/completeTask', + rpcArgs + ); + return this; + } + + completeTask(options?: CompleteTaskOptions): ReportingTaskPromise { + const completionMessage = options?.completionMessage; + const completionState = options?.completionState; + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromiseImpl(this._completeTaskInternal(completionMessage, completionState, cancellationToken), this._client); + } + + /** @internal */ + async _completeTaskMarkdownInternal(markdownString: string, completionState?: string, cancellationToken?: AbortSignal | CancellationToken): Promise { + const rpcArgs: Record = { reportingTask: this._handle, markdownString }; + if (completionState !== undefined) rpcArgs.completionState = completionState; + if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); + await this._client.invokeCapability( + 'Aspire.Hosting/completeTaskMarkdown', + rpcArgs + ); + return this; + } + + completeTaskMarkdown(markdownString: string, options?: CompleteTaskMarkdownOptions): ReportingTaskPromise { + const completionState = options?.completionState; + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromiseImpl(this._completeTaskMarkdownInternal(markdownString, completionState, cancellationToken), this._client); + } + +} + +/** + * Thenable wrapper for ReportingTask that enables fluent chaining. + */ +class ReportingTaskPromiseImpl implements ReportingTaskPromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: ReportingTask) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + updateTask(statusText: string, options?: UpdateTaskOptions): ReportingTaskPromise { + return new ReportingTaskPromiseImpl(this._promise.then(obj => obj.updateTask(statusText, options)), this._client); + } + + updateTaskMarkdown(markdownString: string, options?: UpdateTaskMarkdownOptions): ReportingTaskPromise { + return new ReportingTaskPromiseImpl(this._promise.then(obj => obj.updateTaskMarkdown(markdownString, options)), this._client); + } + + completeTask(options?: CompleteTaskOptions): ReportingTaskPromise { + return new ReportingTaskPromiseImpl(this._promise.then(obj => obj.completeTask(options)), this._client); + } + + completeTaskMarkdown(markdownString: string, options?: CompleteTaskMarkdownOptions): ReportingTaskPromise { + return new ReportingTaskPromiseImpl(this._promise.then(obj => obj.completeTaskMarkdown(markdownString, options)), this._client); + } + +} + +// ============================================================================ +// ServiceProvider +// ============================================================================ + +export interface ServiceProvider { + toJSON(): MarshalledHandle; + /** Gets the distributed application eventing service from the service provider */ + getEventing(): DistributedApplicationEventingPromise; + /** Gets the logger factory from the service provider */ + getLoggerFactory(): LoggerFactoryPromise; + /** Gets the resource logger service from the service provider */ + getResourceLoggerService(): ResourceLoggerServicePromise; + /** Gets the distributed application model from the service provider */ + getDistributedApplicationModel(): DistributedApplicationModelPromise; + /** Gets the resource notification service from the service provider */ + getResourceNotificationService(): ResourceNotificationServicePromise; + /** Gets the Aspire store from the service provider */ + getAspireStore(): AspireStorePromise; + /** Gets the user secrets manager from the service provider */ + getUserSecretsManager(): UserSecretsManagerPromise; +} + +export interface ServiceProviderPromise extends PromiseLike { + /** Gets the distributed application eventing service from the service provider */ + getEventing(): DistributedApplicationEventingPromise; + /** Gets the logger factory from the service provider */ + getLoggerFactory(): LoggerFactoryPromise; + /** Gets the resource logger service from the service provider */ + getResourceLoggerService(): ResourceLoggerServicePromise; + /** Gets the distributed application model from the service provider */ + getDistributedApplicationModel(): DistributedApplicationModelPromise; + /** Gets the resource notification service from the service provider */ + getResourceNotificationService(): ResourceNotificationServicePromise; + /** Gets the Aspire store from the service provider */ + getAspireStore(): AspireStorePromise; + /** Gets the user secrets manager from the service provider */ + getUserSecretsManager(): UserSecretsManagerPromise; +} + +// ============================================================================ +// ServiceProviderImpl +// ============================================================================ + +/** + * Type class for ServiceProvider. + */ +class ServiceProviderImpl implements ServiceProvider { + constructor(private _handle: IServiceProviderHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** @internal */ + async _getEventingInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getEventing', + rpcArgs + ); + return new DistributedApplicationEventingImpl(result, this._client); + } + + getEventing(): DistributedApplicationEventingPromise { + return new DistributedApplicationEventingPromiseImpl(this._getEventingInternal(), this._client); + } + + /** @internal */ + async _getLoggerFactoryInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getLoggerFactory', + rpcArgs + ); + return new LoggerFactoryImpl(result, this._client); + } + + getLoggerFactory(): LoggerFactoryPromise { + return new LoggerFactoryPromiseImpl(this._getLoggerFactoryInternal(), this._client); + } + + /** @internal */ + async _getResourceLoggerServiceInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getResourceLoggerService', + rpcArgs + ); + return new ResourceLoggerServiceImpl(result, this._client); + } + + getResourceLoggerService(): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromiseImpl(this._getResourceLoggerServiceInternal(), this._client); + } + + /** @internal */ + async _getDistributedApplicationModelInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getDistributedApplicationModel', + rpcArgs + ); + return new DistributedApplicationModelImpl(result, this._client); + } + + getDistributedApplicationModel(): DistributedApplicationModelPromise { + return new DistributedApplicationModelPromiseImpl(this._getDistributedApplicationModelInternal(), this._client); + } + + /** @internal */ + async _getResourceNotificationServiceInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getResourceNotificationService', + rpcArgs + ); + return new ResourceNotificationServiceImpl(result, this._client); + } + + getResourceNotificationService(): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromiseImpl(this._getResourceNotificationServiceInternal(), this._client); + } + + /** @internal */ + async _getAspireStoreInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getAspireStore', + rpcArgs + ); + return new AspireStoreImpl(result, this._client); + } + + getAspireStore(): AspireStorePromise { + return new AspireStorePromiseImpl(this._getAspireStoreInternal(), this._client); + } + + /** @internal */ + async _getUserSecretsManagerInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getUserSecretsManager', + rpcArgs + ); + return new UserSecretsManagerImpl(result, this._client); + } + + getUserSecretsManager(): UserSecretsManagerPromise { + return new UserSecretsManagerPromiseImpl(this._getUserSecretsManagerInternal(), this._client); + } + +} + +/** + * Thenable wrapper for ServiceProvider that enables fluent chaining. + */ +class ServiceProviderPromiseImpl implements ServiceProviderPromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: ServiceProvider) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + getEventing(): DistributedApplicationEventingPromise { + return new DistributedApplicationEventingPromiseImpl(this._promise.then(obj => obj.getEventing()), this._client); + } + + getLoggerFactory(): LoggerFactoryPromise { + return new LoggerFactoryPromiseImpl(this._promise.then(obj => obj.getLoggerFactory()), this._client); + } + + getResourceLoggerService(): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromiseImpl(this._promise.then(obj => obj.getResourceLoggerService()), this._client); + } + + getDistributedApplicationModel(): DistributedApplicationModelPromise { + return new DistributedApplicationModelPromiseImpl(this._promise.then(obj => obj.getDistributedApplicationModel()), this._client); + } + + getResourceNotificationService(): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromiseImpl(this._promise.then(obj => obj.getResourceNotificationService()), this._client); + } + + getAspireStore(): AspireStorePromise { + return new AspireStorePromiseImpl(this._promise.then(obj => obj.getAspireStore()), this._client); + } + + getUserSecretsManager(): UserSecretsManagerPromise { + return new UserSecretsManagerPromiseImpl(this._promise.then(obj => obj.getUserSecretsManager()), this._client); + } + +} + +// ============================================================================ +// UserSecretsManager +// ============================================================================ + +export interface UserSecretsManager { + toJSON(): MarshalledHandle; + /** Gets the IsAvailable property */ + isAvailable(): Promise; + /** Gets the FilePath property */ + filePath(): Promise; + /** Attempts to set a user secret value */ + trySetSecret(name: string, value: string): Promise; + /** Attempts to delete a user secret value */ + tryDeleteSecret(name: string): Promise; + /** Saves state to user secrets from a JSON string */ + saveStateJson(json: string, options?: SaveStateJsonOptions): UserSecretsManagerPromise; + /** Gets a secret value if it exists, or sets it to the provided value if it does not */ + getOrSetSecret(resourceBuilder: Awaitable, name: string, value: string): UserSecretsManagerPromise; +} + +export interface UserSecretsManagerPromise extends PromiseLike { + /** Gets the IsAvailable property */ + isAvailable(): Promise; + /** Gets the FilePath property */ + filePath(): Promise; + /** Attempts to set a user secret value */ + trySetSecret(name: string, value: string): Promise; + /** Attempts to delete a user secret value */ + tryDeleteSecret(name: string): Promise; + /** Saves state to user secrets from a JSON string */ + saveStateJson(json: string, options?: SaveStateJsonOptions): UserSecretsManagerPromise; + /** Gets a secret value if it exists, or sets it to the provided value if it does not */ + getOrSetSecret(resourceBuilder: Awaitable, name: string, value: string): UserSecretsManagerPromise; +} + +// ============================================================================ +// UserSecretsManagerImpl +// ============================================================================ + +/** + * Type class for UserSecretsManager. + */ +class UserSecretsManagerImpl implements UserSecretsManager { + constructor(private _handle: IUserSecretsManagerHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + async isAvailable(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting/IUserSecretsManager.isAvailable', + { context: this._handle } + ); + } + + async filePath(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting/IUserSecretsManager.filePath', + { context: this._handle } + ); + } + + async trySetSecret(name: string, value: string): Promise { + const rpcArgs: Record = { context: this._handle, name, value }; + return await this._client.invokeCapability( + 'Aspire.Hosting/IUserSecretsManager.trySetSecret', + rpcArgs + ); + } + + async tryDeleteSecret(name: string): Promise { + const rpcArgs: Record = { context: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting/IUserSecretsManager.tryDeleteSecret', + rpcArgs + ); + } + + /** @internal */ + async _saveStateJsonInternal(json: string, cancellationToken?: AbortSignal | CancellationToken): Promise { + const rpcArgs: Record = { userSecretsManager: this._handle, json }; + if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); + await this._client.invokeCapability( + 'Aspire.Hosting/saveStateJson', + rpcArgs + ); + return this; + } + + saveStateJson(json: string, options?: SaveStateJsonOptions): UserSecretsManagerPromise { + const cancellationToken = options?.cancellationToken; + return new UserSecretsManagerPromiseImpl(this._saveStateJsonInternal(json, cancellationToken), this._client); + } + + /** @internal */ + async _getOrSetSecretInternal(resourceBuilder: Awaitable, name: string, value: string): Promise { + resourceBuilder = isPromiseLike(resourceBuilder) ? await resourceBuilder : resourceBuilder; + const rpcArgs: Record = { userSecretsManager: this._handle, resourceBuilder, name, value }; + await this._client.invokeCapability( + 'Aspire.Hosting/getOrSetSecret', + rpcArgs + ); + return this; + } + + getOrSetSecret(resourceBuilder: Awaitable, name: string, value: string): UserSecretsManagerPromise { + return new UserSecretsManagerPromiseImpl(this._getOrSetSecretInternal(resourceBuilder, name, value), this._client); + } + +} + +/** + * Thenable wrapper for UserSecretsManager that enables fluent chaining. + */ +class UserSecretsManagerPromiseImpl implements UserSecretsManagerPromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: UserSecretsManager) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + isAvailable(): Promise { + return this._promise.then(obj => obj.isAvailable()); + } + + filePath(): Promise { + return this._promise.then(obj => obj.filePath()); + } + + trySetSecret(name: string, value: string): Promise { + return this._promise.then(obj => obj.trySetSecret(name, value)); + } + + tryDeleteSecret(name: string): Promise { + return this._promise.then(obj => obj.tryDeleteSecret(name)); + } + + saveStateJson(json: string, options?: SaveStateJsonOptions): UserSecretsManagerPromise { + return new UserSecretsManagerPromiseImpl(this._promise.then(obj => obj.saveStateJson(json, options)), this._client); + } + + getOrSetSecret(resourceBuilder: Awaitable, name: string, value: string): UserSecretsManagerPromise { + return new UserSecretsManagerPromiseImpl(this._promise.then(obj => obj.getOrSetSecret(resourceBuilder, name, value)), this._client); + } + +} + +// ============================================================================ +// AspireC4Resource +// ============================================================================ + +export interface AspireC4Resource { + toJSON(): MarshalledHandle; + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): AspireC4ResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AspireC4ResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AspireC4ResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): AspireC4ResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): AspireC4ResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AspireC4ResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): AspireC4ResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): AspireC4ResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): AspireC4ResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AspireC4ResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): AspireC4ResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): AspireC4ResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): AspireC4ResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): AspireC4ResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): AspireC4ResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AspireC4ResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AspireC4ResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AspireC4ResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AspireC4ResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AspireC4ResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AspireC4ResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): AspireC4ResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): AspireC4ResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): AspireC4ResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): AspireC4ResourcePromise; + /** Switches the LikeC4 server to a local JavaScript package manager CLI. */ + withLocalCLI(options?: WithLocalCLIOptions): AspireC4ResourcePromise; + /** Hides the LikeC4 server resource from the Aspire dashboard. */ + withHideFromDashboard(options?: WithHideFromDashboardOptions): AspireC4ResourcePromise; + /** Registers an additional .c4 source file. */ + withAdditionalDSLFile(sourcePath: string): AspireC4ResourcePromise; + /** Registers an additional folder of .c4 source files. */ + withAdditionalDSLFolder(folderPath: string): AspireC4ResourcePromise; + /** Registers an image alias folder for LikeC4. */ + withImageAliasFolder(aliasKey: string, folderPath: string): AspireC4ResourcePromise; + /** Disables automatic generation of likec4.config.json. */ + withoutConfigFileGeneration(): AspireC4ResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): AspireC4ResourcePromise; +} + +export interface AspireC4ResourcePromise extends PromiseLike { + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): AspireC4ResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AspireC4ResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AspireC4ResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): AspireC4ResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): AspireC4ResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AspireC4ResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): AspireC4ResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): AspireC4ResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): AspireC4ResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AspireC4ResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): AspireC4ResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): AspireC4ResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): AspireC4ResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): AspireC4ResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): AspireC4ResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AspireC4ResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AspireC4ResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AspireC4ResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AspireC4ResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AspireC4ResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AspireC4ResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): AspireC4ResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): AspireC4ResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): AspireC4ResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): AspireC4ResourcePromise; + /** Switches the LikeC4 server to a local JavaScript package manager CLI. */ + withLocalCLI(options?: WithLocalCLIOptions): AspireC4ResourcePromise; + /** Hides the LikeC4 server resource from the Aspire dashboard. */ + withHideFromDashboard(options?: WithHideFromDashboardOptions): AspireC4ResourcePromise; + /** Registers an additional .c4 source file. */ + withAdditionalDSLFile(sourcePath: string): AspireC4ResourcePromise; + /** Registers an additional folder of .c4 source files. */ + withAdditionalDSLFolder(folderPath: string): AspireC4ResourcePromise; + /** Registers an image alias folder for LikeC4. */ + withImageAliasFolder(aliasKey: string, folderPath: string): AspireC4ResourcePromise; + /** Disables automatic generation of likec4.config.json. */ + withoutConfigFileGeneration(): AspireC4ResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): AspireC4ResourcePromise; +} + +// ============================================================================ +// AspireC4ResourceImpl +// ============================================================================ + +class AspireC4ResourceImpl extends ResourceBuilderBase implements AspireC4Resource { + constructor(handle: AspireC4ResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: Awaitable): Promise { + registry = isPromiseLike(registry) ? await registry : registry; + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new AspireC4ResourceImpl(result, this._client); + } + + withContainerRegistry(registry: Awaitable): AspireC4ResourcePromise { + return new AspireC4ResourcePromiseImpl(this._withContainerRegistryInternal(registry), this._client); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new AspireC4ResourceImpl(result, this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AspireC4ResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new AspireC4ResourcePromiseImpl(this._withDockerfileBaseImageInternal(buildImage, runtimeImage), this._client); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new AspireC4ResourceImpl(result, this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AspireC4ResourcePromise { + const helpLink = options?.helpLink; + return new AspireC4ResourcePromiseImpl(this._withRequiredCommandInternal(command, helpLink), this._client); + } + + /** @internal */ + private async _withUrlsInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrls', + rpcArgs + ); + return new AspireC4ResourceImpl(result, this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): AspireC4ResourcePromise { + return new AspireC4ResourcePromiseImpl(this._withUrlsInternal(callback), this._client); + } + + /** @internal */ + private async _withUrlInternal(url: string | ReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new AspireC4ResourceImpl(result, this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): AspireC4ResourcePromise { + const displayText = options?.displayText; + return new AspireC4ResourcePromiseImpl(this._withUrlInternal(url, displayText), this._client); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new AspireC4ResourceImpl(result, this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AspireC4ResourcePromise { + return new AspireC4ResourcePromiseImpl(this._withUrlForEndpointInternal(endpointName, callback), this._client); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new AspireC4ResourceImpl(result, this._client); + } + + excludeFromManifest(): AspireC4ResourcePromise { + return new AspireC4ResourcePromiseImpl(this._excludeFromManifestInternal(), this._client); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new AspireC4ResourceImpl(result, this._client); + } + + withExplicitStart(): AspireC4ResourcePromise { + return new AspireC4ResourcePromiseImpl(this._withExplicitStartInternal(), this._client); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new AspireC4ResourceImpl(result, this._client); + } + + withHealthCheck(key: string): AspireC4ResourcePromise { + return new AspireC4ResourcePromiseImpl(this._withHealthCheckInternal(key), this._client); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContextImpl(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new AspireC4ResourceImpl(result, this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AspireC4ResourcePromise { + const commandOptions = options?.commandOptions; + return new AspireC4ResourcePromiseImpl(this._withCommandInternal(name, displayName, executeCommand, commandOptions), this._client); + } + + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: Awaitable, type: string): Promise { + resourceBuilder = isPromiseLike(resourceBuilder) ? await resourceBuilder : resourceBuilder; + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AspireC4ResourceImpl(result, this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): AspireC4ResourcePromise { + return new AspireC4ResourcePromiseImpl(this._withRelationshipInternal(resourceBuilder, type), this._client); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: Awaitable): Promise { + parent = isPromiseLike(parent) ? await parent : parent; + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new AspireC4ResourceImpl(result, this._client); + } + + withParentRelationship(parent: Awaitable): AspireC4ResourcePromise { + return new AspireC4ResourcePromiseImpl(this._withParentRelationshipInternal(parent), this._client); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: Awaitable): Promise { + child = isPromiseLike(child) ? await child : child; + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', + rpcArgs + ); + return new AspireC4ResourceImpl(result, this._client); + } + + withChildRelationship(child: Awaitable): AspireC4ResourcePromise { + return new AspireC4ResourcePromiseImpl(this._withChildRelationshipInternal(child), this._client); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new AspireC4ResourceImpl(result, this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): AspireC4ResourcePromise { + const iconVariant = options?.iconVariant; + return new AspireC4ResourcePromiseImpl(this._withIconNameInternal(iconName, iconVariant), this._client); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new AspireC4ResourceImpl(result, this._client); + } + + excludeFromMcp(): AspireC4ResourcePromise { + return new AspireC4ResourcePromiseImpl(this._excludeFromMcpInternal(), this._client); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new AspireC4ResourceImpl(result, this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AspireC4ResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new AspireC4ResourcePromiseImpl(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description), this._client); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new AspireC4ResourceImpl(result, this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AspireC4ResourcePromise { + return new AspireC4ResourcePromiseImpl(this._withPipelineConfigurationInternal(callback), this._client); + } + + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); + } + + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new AspireC4ResourceImpl(result, this._client); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AspireC4ResourcePromise { + return new AspireC4ResourcePromiseImpl(this._onBeforeResourceStartedInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new AspireC4ResourceImpl(result, this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AspireC4ResourcePromise { + return new AspireC4ResourcePromiseImpl(this._onResourceStoppedInternal(callback), this._client); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new AspireC4ResourceImpl(result, this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AspireC4ResourcePromise { + return new AspireC4ResourcePromiseImpl(this._onInitializeResourceInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new AspireC4ResourceImpl(result, this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AspireC4ResourcePromise { + return new AspireC4ResourcePromiseImpl(this._onResourceReadyInternal(callback), this._client); + } + + async createExecutionConfiguration(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/createExecutionConfiguration', + rpcArgs + ); + } + + /** @internal */ + private async _withLikeC4DetailsInternal(label?: string, technology?: string, description?: string, summary?: string, icon?: string, configure?: (obj: LikeC4NodeDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4NodeDetailsAnnotationHandle; + const obj = new LikeC4NodeDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + const rpcArgs: Record = { builder: this._handle }; + if (label !== undefined) rpcArgs.label = label; + if (technology !== undefined) rpcArgs.technology = technology; + if (description !== undefined) rpcArgs.description = description; + if (summary !== undefined) rpcArgs.summary = summary; + if (icon !== undefined) rpcArgs.icon = icon; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4DetailsParameters', + rpcArgs + ); + return new AspireC4ResourceImpl(result, this._client); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): AspireC4ResourcePromise { + const label = options?.label; + const technology = options?.technology; + const description = options?.description; + const summary = options?.summary; + const icon = options?.icon; + const configure = options?.configure; + return new AspireC4ResourcePromiseImpl(this._withLikeC4DetailsInternal(label, technology, description, summary, icon, configure), this._client); + } + + /** @internal */ + private async _withLikeC4ReferenceInternal(target: Awaitable, configure?: (obj: LikeC4RelationshipDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4RelationshipDetailsAnnotationHandle; + const obj = new LikeC4RelationshipDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target }; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Reference', + rpcArgs + ); + return new AspireC4ResourceImpl(result, this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): AspireC4ResourcePromise { + const configure = options?.configure; + return new AspireC4ResourcePromiseImpl(this._withLikeC4ReferenceInternal(target, configure), this._client); + } + + /** @internal */ + private async _withLikeC4GroupInternal(groupName: string): Promise { + const rpcArgs: Record = { builder: this._handle, groupName }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Group', + rpcArgs + ); + return new AspireC4ResourceImpl(result, this._client); + } + + withLikeC4Group(groupName: string): AspireC4ResourcePromise { + return new AspireC4ResourcePromiseImpl(this._withLikeC4GroupInternal(groupName), this._client); + } + + /** @internal */ + private async _excludeFromLikeC4Internal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/excludeFromLikeC4', + rpcArgs + ); + return new AspireC4ResourceImpl(result, this._client); + } + + excludeFromLikeC4(): AspireC4ResourcePromise { + return new AspireC4ResourcePromiseImpl(this._excludeFromLikeC4Internal(), this._client); + } + + /** @internal */ + private async _withLocalCLIInternal(runtime?: LocalCLIRuntime): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (runtime !== undefined) rpcArgs.runtime = runtime; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLocalCLI', + rpcArgs + ); + return new AspireC4ResourceImpl(result, this._client); + } + + withLocalCLI(options?: WithLocalCLIOptions): AspireC4ResourcePromise { + const runtime = options?.runtime; + return new AspireC4ResourcePromiseImpl(this._withLocalCLIInternal(runtime), this._client); + } + + /** @internal */ + private async _withHideFromDashboardInternal(displayName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (displayName !== undefined) rpcArgs.displayName = displayName; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withHideFromDashboard', + rpcArgs + ); + return new AspireC4ResourceImpl(result, this._client); + } + + withHideFromDashboard(options?: WithHideFromDashboardOptions): AspireC4ResourcePromise { + const displayName = options?.displayName; + return new AspireC4ResourcePromiseImpl(this._withHideFromDashboardInternal(displayName), this._client); + } + + /** @internal */ + private async _withAdditionalDSLFileInternal(sourcePath: string): Promise { + const rpcArgs: Record = { builder: this._handle, sourcePath }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withAdditionalDSLFile', + rpcArgs + ); + return new AspireC4ResourceImpl(result, this._client); + } + + withAdditionalDSLFile(sourcePath: string): AspireC4ResourcePromise { + return new AspireC4ResourcePromiseImpl(this._withAdditionalDSLFileInternal(sourcePath), this._client); + } + + /** @internal */ + private async _withAdditionalDSLFolderInternal(folderPath: string): Promise { + const rpcArgs: Record = { builder: this._handle, folderPath }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withAdditionalDSLFolder', + rpcArgs + ); + return new AspireC4ResourceImpl(result, this._client); + } + + withAdditionalDSLFolder(folderPath: string): AspireC4ResourcePromise { + return new AspireC4ResourcePromiseImpl(this._withAdditionalDSLFolderInternal(folderPath), this._client); + } + + /** @internal */ + private async _withImageAliasFolderInternal(aliasKey: string, folderPath: string): Promise { + const rpcArgs: Record = { builder: this._handle, aliasKey, folderPath }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withImageAliasFolder', + rpcArgs + ); + return new AspireC4ResourceImpl(result, this._client); + } + + withImageAliasFolder(aliasKey: string, folderPath: string): AspireC4ResourcePromise { + return new AspireC4ResourcePromiseImpl(this._withImageAliasFolderInternal(aliasKey, folderPath), this._client); + } + + /** @internal */ + private async _withoutConfigFileGenerationInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withoutConfigFileGeneration', + rpcArgs + ); + return new AspireC4ResourceImpl(result, this._client); + } + + withoutConfigFileGeneration(): AspireC4ResourcePromise { + return new AspireC4ResourcePromiseImpl(this._withoutConfigFileGenerationInternal(), this._client); + } + + /** @internal */ + private async _withRoleAssignmentsInternal(target: Awaitable, roles: AzureKeyVaultRole[]): Promise { + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target, roles }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.KeyVault/withKeyVaultRoleAssignments', + rpcArgs + ); + return new AspireC4ResourceImpl(result, this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): AspireC4ResourcePromise { + return new AspireC4ResourcePromiseImpl(this._withRoleAssignmentsInternal(target, roles), this._client); + } + +} + +/** + * Thenable wrapper for AspireC4Resource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +class AspireC4ResourcePromiseImpl implements AspireC4ResourcePromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: AspireC4Resource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + withContainerRegistry(registry: Awaitable): AspireC4ResourcePromise { + return new AspireC4ResourcePromiseImpl(this._promise.then(obj => obj.withContainerRegistry(registry)), this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AspireC4ResourcePromise { + return new AspireC4ResourcePromiseImpl(this._promise.then(obj => obj.withDockerfileBaseImage(options)), this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AspireC4ResourcePromise { + return new AspireC4ResourcePromiseImpl(this._promise.then(obj => obj.withRequiredCommand(command, options)), this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): AspireC4ResourcePromise { + return new AspireC4ResourcePromiseImpl(this._promise.then(obj => obj.withUrls(callback)), this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): AspireC4ResourcePromise { + return new AspireC4ResourcePromiseImpl(this._promise.then(obj => obj.withUrl(url, options)), this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AspireC4ResourcePromise { + return new AspireC4ResourcePromiseImpl(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback)), this._client); + } + + excludeFromManifest(): AspireC4ResourcePromise { + return new AspireC4ResourcePromiseImpl(this._promise.then(obj => obj.excludeFromManifest()), this._client); + } + + withExplicitStart(): AspireC4ResourcePromise { + return new AspireC4ResourcePromiseImpl(this._promise.then(obj => obj.withExplicitStart()), this._client); + } + + withHealthCheck(key: string): AspireC4ResourcePromise { + return new AspireC4ResourcePromiseImpl(this._promise.then(obj => obj.withHealthCheck(key)), this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AspireC4ResourcePromise { + return new AspireC4ResourcePromiseImpl(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options)), this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): AspireC4ResourcePromise { + return new AspireC4ResourcePromiseImpl(this._promise.then(obj => obj.withRelationship(resourceBuilder, type)), this._client); + } + + withParentRelationship(parent: Awaitable): AspireC4ResourcePromise { + return new AspireC4ResourcePromiseImpl(this._promise.then(obj => obj.withParentRelationship(parent)), this._client); + } + + withChildRelationship(child: Awaitable): AspireC4ResourcePromise { + return new AspireC4ResourcePromiseImpl(this._promise.then(obj => obj.withChildRelationship(child)), this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): AspireC4ResourcePromise { + return new AspireC4ResourcePromiseImpl(this._promise.then(obj => obj.withIconName(iconName, options)), this._client); + } + + excludeFromMcp(): AspireC4ResourcePromise { + return new AspireC4ResourcePromiseImpl(this._promise.then(obj => obj.excludeFromMcp()), this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AspireC4ResourcePromise { + return new AspireC4ResourcePromiseImpl(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options)), this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AspireC4ResourcePromise { + return new AspireC4ResourcePromiseImpl(this._promise.then(obj => obj.withPipelineConfiguration(callback)), this._client); + } + + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AspireC4ResourcePromise { + return new AspireC4ResourcePromiseImpl(this._promise.then(obj => obj.onBeforeResourceStarted(callback)), this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AspireC4ResourcePromise { + return new AspireC4ResourcePromiseImpl(this._promise.then(obj => obj.onResourceStopped(callback)), this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AspireC4ResourcePromise { + return new AspireC4ResourcePromiseImpl(this._promise.then(obj => obj.onInitializeResource(callback)), this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AspireC4ResourcePromise { + return new AspireC4ResourcePromiseImpl(this._promise.then(obj => obj.onResourceReady(callback)), this._client); + } + + createExecutionConfiguration(): Promise { + return this._promise.then(obj => obj.createExecutionConfiguration()); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): AspireC4ResourcePromise { + return new AspireC4ResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Details(options)), this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): AspireC4ResourcePromise { + return new AspireC4ResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Reference(target, options)), this._client); + } + + withLikeC4Group(groupName: string): AspireC4ResourcePromise { + return new AspireC4ResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Group(groupName)), this._client); + } + + excludeFromLikeC4(): AspireC4ResourcePromise { + return new AspireC4ResourcePromiseImpl(this._promise.then(obj => obj.excludeFromLikeC4()), this._client); + } + + withLocalCLI(options?: WithLocalCLIOptions): AspireC4ResourcePromise { + return new AspireC4ResourcePromiseImpl(this._promise.then(obj => obj.withLocalCLI(options)), this._client); + } + + withHideFromDashboard(options?: WithHideFromDashboardOptions): AspireC4ResourcePromise { + return new AspireC4ResourcePromiseImpl(this._promise.then(obj => obj.withHideFromDashboard(options)), this._client); + } + + withAdditionalDSLFile(sourcePath: string): AspireC4ResourcePromise { + return new AspireC4ResourcePromiseImpl(this._promise.then(obj => obj.withAdditionalDSLFile(sourcePath)), this._client); + } + + withAdditionalDSLFolder(folderPath: string): AspireC4ResourcePromise { + return new AspireC4ResourcePromiseImpl(this._promise.then(obj => obj.withAdditionalDSLFolder(folderPath)), this._client); + } + + withImageAliasFolder(aliasKey: string, folderPath: string): AspireC4ResourcePromise { + return new AspireC4ResourcePromiseImpl(this._promise.then(obj => obj.withImageAliasFolder(aliasKey, folderPath)), this._client); + } + + withoutConfigFileGeneration(): AspireC4ResourcePromise { + return new AspireC4ResourcePromiseImpl(this._promise.then(obj => obj.withoutConfigFileGeneration()), this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): AspireC4ResourcePromise { + return new AspireC4ResourcePromiseImpl(this._promise.then(obj => obj.withRoleAssignments(target, roles)), this._client); + } + +} + +// ============================================================================ +// AzureBicepResource +// ============================================================================ + +export interface AzureBicepResource { + toJSON(): MarshalledHandle; + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): AzureBicepResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureBicepResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureBicepResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureBicepResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): AzureBicepResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureBicepResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): AzureBicepResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): AzureBicepResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): AzureBicepResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureBicepResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): AzureBicepResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): AzureBicepResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): AzureBicepResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): AzureBicepResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): AzureBicepResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureBicepResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureBicepResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureBicepResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureBicepResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureBicepResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureBicepResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): AzureBicepResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): AzureBicepResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): AzureBicepResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): AzureBicepResourcePromise; + /** Gets an output reference from an Azure Bicep template resource */ + getOutput(name: string): Promise; + /** Adds a Bicep parameter */ + withParameter(name: string, options?: WithParameterOptions): AzureBicepResourcePromise; + /** Publishes an Azure resource to the manifest as a connection string */ + publishAsConnectionString(): AzureBicepResourcePromise; + /** Gets the normalized Bicep identifier for an Azure resource */ + getBicepIdentifier(): Promise; + /** Clears the default Azure role assignments from a resource */ + clearDefaultRoleAssignments(): AzureBicepResourcePromise; + /** Determines whether a resource is marked as existing */ + isExisting(): Promise; + /** Marks an Azure resource as existing in run mode */ + runAsExisting(name: string | ParameterResource | Awaitable, options?: RunAsExistingOptions): AzureBicepResourcePromise; + /** Marks an Azure resource as existing in publish mode */ + publishAsExisting(name: string | ParameterResource | Awaitable, options?: PublishAsExistingOptions): AzureBicepResourcePromise; + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource | Awaitable, options?: AsExistingOptions): AzureBicepResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): AzureBicepResourcePromise; +} + +export interface AzureBicepResourcePromise extends PromiseLike { + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): AzureBicepResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureBicepResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureBicepResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureBicepResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): AzureBicepResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureBicepResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): AzureBicepResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): AzureBicepResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): AzureBicepResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureBicepResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): AzureBicepResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): AzureBicepResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): AzureBicepResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): AzureBicepResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): AzureBicepResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureBicepResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureBicepResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureBicepResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureBicepResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureBicepResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureBicepResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): AzureBicepResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): AzureBicepResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): AzureBicepResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): AzureBicepResourcePromise; + /** Gets an output reference from an Azure Bicep template resource */ + getOutput(name: string): Promise; + /** Adds a Bicep parameter */ + withParameter(name: string, options?: WithParameterOptions): AzureBicepResourcePromise; + /** Publishes an Azure resource to the manifest as a connection string */ + publishAsConnectionString(): AzureBicepResourcePromise; + /** Gets the normalized Bicep identifier for an Azure resource */ + getBicepIdentifier(): Promise; + /** Clears the default Azure role assignments from a resource */ + clearDefaultRoleAssignments(): AzureBicepResourcePromise; + /** Determines whether a resource is marked as existing */ + isExisting(): Promise; + /** Marks an Azure resource as existing in run mode */ + runAsExisting(name: string | ParameterResource | Awaitable, options?: RunAsExistingOptions): AzureBicepResourcePromise; + /** Marks an Azure resource as existing in publish mode */ + publishAsExisting(name: string | ParameterResource | Awaitable, options?: PublishAsExistingOptions): AzureBicepResourcePromise; + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource | Awaitable, options?: AsExistingOptions): AzureBicepResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): AzureBicepResourcePromise; +} + +// ============================================================================ +// AzureBicepResourceImpl +// ============================================================================ + +class AzureBicepResourceImpl extends ResourceBuilderBase implements AzureBicepResource { + constructor(handle: AzureBicepResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: Awaitable): Promise { + registry = isPromiseLike(registry) ? await registry : registry; + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new AzureBicepResourceImpl(result, this._client); + } + + withContainerRegistry(registry: Awaitable): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._withContainerRegistryInternal(registry), this._client); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new AzureBicepResourceImpl(result, this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureBicepResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new AzureBicepResourcePromiseImpl(this._withDockerfileBaseImageInternal(buildImage, runtimeImage), this._client); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new AzureBicepResourceImpl(result, this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureBicepResourcePromise { + const helpLink = options?.helpLink; + return new AzureBicepResourcePromiseImpl(this._withRequiredCommandInternal(command, helpLink), this._client); + } + + /** @internal */ + private async _withUrlsInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrls', + rpcArgs + ); + return new AzureBicepResourceImpl(result, this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._withUrlsInternal(callback), this._client); + } + + /** @internal */ + private async _withUrlInternal(url: string | ReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new AzureBicepResourceImpl(result, this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): AzureBicepResourcePromise { + const displayText = options?.displayText; + return new AzureBicepResourcePromiseImpl(this._withUrlInternal(url, displayText), this._client); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new AzureBicepResourceImpl(result, this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._withUrlForEndpointInternal(endpointName, callback), this._client); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new AzureBicepResourceImpl(result, this._client); + } + + excludeFromManifest(): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._excludeFromManifestInternal(), this._client); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new AzureBicepResourceImpl(result, this._client); + } + + withExplicitStart(): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._withExplicitStartInternal(), this._client); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new AzureBicepResourceImpl(result, this._client); + } + + withHealthCheck(key: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._withHealthCheckInternal(key), this._client); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContextImpl(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new AzureBicepResourceImpl(result, this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureBicepResourcePromise { + const commandOptions = options?.commandOptions; + return new AzureBicepResourcePromiseImpl(this._withCommandInternal(name, displayName, executeCommand, commandOptions), this._client); + } + + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: Awaitable, type: string): Promise { + resourceBuilder = isPromiseLike(resourceBuilder) ? await resourceBuilder : resourceBuilder; + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureBicepResourceImpl(result, this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._withRelationshipInternal(resourceBuilder, type), this._client); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: Awaitable): Promise { + parent = isPromiseLike(parent) ? await parent : parent; + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new AzureBicepResourceImpl(result, this._client); + } + + withParentRelationship(parent: Awaitable): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._withParentRelationshipInternal(parent), this._client); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: Awaitable): Promise { + child = isPromiseLike(child) ? await child : child; + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', + rpcArgs + ); + return new AzureBicepResourceImpl(result, this._client); + } + + withChildRelationship(child: Awaitable): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._withChildRelationshipInternal(child), this._client); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new AzureBicepResourceImpl(result, this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): AzureBicepResourcePromise { + const iconVariant = options?.iconVariant; + return new AzureBicepResourcePromiseImpl(this._withIconNameInternal(iconName, iconVariant), this._client); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new AzureBicepResourceImpl(result, this._client); + } + + excludeFromMcp(): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._excludeFromMcpInternal(), this._client); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new AzureBicepResourceImpl(result, this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureBicepResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new AzureBicepResourcePromiseImpl(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description), this._client); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new AzureBicepResourceImpl(result, this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._withPipelineConfigurationInternal(callback), this._client); + } + + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); + } + + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new AzureBicepResourceImpl(result, this._client); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._onBeforeResourceStartedInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new AzureBicepResourceImpl(result, this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._onResourceStoppedInternal(callback), this._client); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new AzureBicepResourceImpl(result, this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._onInitializeResourceInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new AzureBicepResourceImpl(result, this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._onResourceReadyInternal(callback), this._client); + } + + async createExecutionConfiguration(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/createExecutionConfiguration', + rpcArgs + ); + } + + /** @internal */ + private async _withLikeC4DetailsInternal(label?: string, technology?: string, description?: string, summary?: string, icon?: string, configure?: (obj: LikeC4NodeDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4NodeDetailsAnnotationHandle; + const obj = new LikeC4NodeDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + const rpcArgs: Record = { builder: this._handle }; + if (label !== undefined) rpcArgs.label = label; + if (technology !== undefined) rpcArgs.technology = technology; + if (description !== undefined) rpcArgs.description = description; + if (summary !== undefined) rpcArgs.summary = summary; + if (icon !== undefined) rpcArgs.icon = icon; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4DetailsParameters', + rpcArgs + ); + return new AzureBicepResourceImpl(result, this._client); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): AzureBicepResourcePromise { + const label = options?.label; + const technology = options?.technology; + const description = options?.description; + const summary = options?.summary; + const icon = options?.icon; + const configure = options?.configure; + return new AzureBicepResourcePromiseImpl(this._withLikeC4DetailsInternal(label, technology, description, summary, icon, configure), this._client); + } + + /** @internal */ + private async _withLikeC4ReferenceInternal(target: Awaitable, configure?: (obj: LikeC4RelationshipDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4RelationshipDetailsAnnotationHandle; + const obj = new LikeC4RelationshipDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target }; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Reference', + rpcArgs + ); + return new AzureBicepResourceImpl(result, this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): AzureBicepResourcePromise { + const configure = options?.configure; + return new AzureBicepResourcePromiseImpl(this._withLikeC4ReferenceInternal(target, configure), this._client); + } + + /** @internal */ + private async _withLikeC4GroupInternal(groupName: string): Promise { + const rpcArgs: Record = { builder: this._handle, groupName }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Group', + rpcArgs + ); + return new AzureBicepResourceImpl(result, this._client); + } + + withLikeC4Group(groupName: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._withLikeC4GroupInternal(groupName), this._client); + } + + /** @internal */ + private async _excludeFromLikeC4Internal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/excludeFromLikeC4', + rpcArgs + ); + return new AzureBicepResourceImpl(result, this._client); + } + + excludeFromLikeC4(): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._excludeFromLikeC4Internal(), this._client); + } + + async getOutput(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/getOutput', + rpcArgs + ); + } + + /** @internal */ + private async _withParameterInternal(name: string, value?: string | string[] | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | BicepOutputReference | ReferenceExpression | EndpointReference | Awaitable): Promise { + value = isPromiseLike(value) ? await value : value; + const rpcArgs: Record = { builder: this._handle, name }; + if (value !== undefined) rpcArgs.value = value; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameter', + rpcArgs + ); + return new AzureBicepResourceImpl(result, this._client); + } + + withParameter(name: string, options?: WithParameterOptions): AzureBicepResourcePromise { + let value = options?.value; + return new AzureBicepResourcePromiseImpl(this._withParameterInternal(name, value), this._client); + } + + /** @internal */ + private async _publishAsConnectionStringInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/publishAsConnectionString', + rpcArgs + ); + return new AzureBicepResourceImpl(result, this._client); + } + + publishAsConnectionString(): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._publishAsConnectionStringInternal(), this._client); + } + + async getBicepIdentifier(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/getBicepIdentifier', + rpcArgs + ); + } + + /** @internal */ + private async _clearDefaultRoleAssignmentsInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/clearDefaultRoleAssignments', + rpcArgs + ); + return new AzureBicepResourceImpl(result, this._client); + } + + clearDefaultRoleAssignments(): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._clearDefaultRoleAssignmentsInternal(), this._client); + } + + async isExisting(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/isExisting', + rpcArgs + ); + } + + /** @internal */ + private async _runAsExistingInternal(name: string | ParameterResource | Awaitable, resourceGroup?: string | ParameterResource | Awaitable): Promise { + name = isPromiseLike(name) ? await name : name; + resourceGroup = isPromiseLike(resourceGroup) ? await resourceGroup : resourceGroup; + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/runAsExisting', + rpcArgs + ); + return new AzureBicepResourceImpl(result, this._client); + } + + runAsExisting(name: string | ParameterResource | Awaitable, options?: RunAsExistingOptions): AzureBicepResourcePromise { + let resourceGroup = options?.resourceGroup; + return new AzureBicepResourcePromiseImpl(this._runAsExistingInternal(name, resourceGroup), this._client); + } + + /** @internal */ + private async _publishAsExistingInternal(name: string | ParameterResource | Awaitable, resourceGroup?: string | ParameterResource | Awaitable): Promise { + name = isPromiseLike(name) ? await name : name; + resourceGroup = isPromiseLike(resourceGroup) ? await resourceGroup : resourceGroup; + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/publishAsExisting', + rpcArgs + ); + return new AzureBicepResourceImpl(result, this._client); + } + + publishAsExisting(name: string | ParameterResource | Awaitable, options?: PublishAsExistingOptions): AzureBicepResourcePromise { + let resourceGroup = options?.resourceGroup; + return new AzureBicepResourcePromiseImpl(this._publishAsExistingInternal(name, resourceGroup), this._client); + } + + /** @internal */ + private async _asExistingInternal(name: string | ParameterResource | Awaitable, resourceGroup?: string | ParameterResource | Awaitable): Promise { + name = isPromiseLike(name) ? await name : name; + resourceGroup = isPromiseLike(resourceGroup) ? await resourceGroup : resourceGroup; + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/asExisting', + rpcArgs + ); + return new AzureBicepResourceImpl(result, this._client); + } + + asExisting(name: string | ParameterResource | Awaitable, options?: AsExistingOptions): AzureBicepResourcePromise { + let resourceGroup = options?.resourceGroup; + return new AzureBicepResourcePromiseImpl(this._asExistingInternal(name, resourceGroup), this._client); + } + + /** @internal */ + private async _withRoleAssignmentsInternal(target: Awaitable, roles: AzureKeyVaultRole[]): Promise { + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target, roles }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.KeyVault/withKeyVaultRoleAssignments', + rpcArgs + ); + return new AzureBicepResourceImpl(result, this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._withRoleAssignmentsInternal(target, roles), this._client); + } + +} + +/** + * Thenable wrapper for AzureBicepResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +class AzureBicepResourcePromiseImpl implements AzureBicepResourcePromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: AzureBicepResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + withContainerRegistry(registry: Awaitable): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._promise.then(obj => obj.withContainerRegistry(registry)), this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._promise.then(obj => obj.withDockerfileBaseImage(options)), this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._promise.then(obj => obj.withRequiredCommand(command, options)), this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._promise.then(obj => obj.withUrls(callback)), this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._promise.then(obj => obj.withUrl(url, options)), this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback)), this._client); + } + + excludeFromManifest(): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._promise.then(obj => obj.excludeFromManifest()), this._client); + } + + withExplicitStart(): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._promise.then(obj => obj.withExplicitStart()), this._client); + } + + withHealthCheck(key: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._promise.then(obj => obj.withHealthCheck(key)), this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options)), this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._promise.then(obj => obj.withRelationship(resourceBuilder, type)), this._client); + } + + withParentRelationship(parent: Awaitable): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._promise.then(obj => obj.withParentRelationship(parent)), this._client); + } + + withChildRelationship(child: Awaitable): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._promise.then(obj => obj.withChildRelationship(child)), this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._promise.then(obj => obj.withIconName(iconName, options)), this._client); + } + + excludeFromMcp(): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._promise.then(obj => obj.excludeFromMcp()), this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options)), this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._promise.then(obj => obj.withPipelineConfiguration(callback)), this._client); + } + + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._promise.then(obj => obj.onBeforeResourceStarted(callback)), this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._promise.then(obj => obj.onResourceStopped(callback)), this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._promise.then(obj => obj.onInitializeResource(callback)), this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._promise.then(obj => obj.onResourceReady(callback)), this._client); + } + + createExecutionConfiguration(): Promise { + return this._promise.then(obj => obj.createExecutionConfiguration()); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Details(options)), this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Reference(target, options)), this._client); + } + + withLikeC4Group(groupName: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Group(groupName)), this._client); + } + + excludeFromLikeC4(): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._promise.then(obj => obj.excludeFromLikeC4()), this._client); + } + + getOutput(name: string): Promise { + return this._promise.then(obj => obj.getOutput(name)); + } + + withParameter(name: string, options?: WithParameterOptions): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._promise.then(obj => obj.withParameter(name, options)), this._client); + } + + publishAsConnectionString(): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._promise.then(obj => obj.publishAsConnectionString()), this._client); + } + + getBicepIdentifier(): Promise { + return this._promise.then(obj => obj.getBicepIdentifier()); + } + + clearDefaultRoleAssignments(): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._promise.then(obj => obj.clearDefaultRoleAssignments()), this._client); + } + + isExisting(): Promise { + return this._promise.then(obj => obj.isExisting()); + } + + runAsExisting(name: string | ParameterResource | Awaitable, options?: RunAsExistingOptions): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._promise.then(obj => obj.runAsExisting(name, options)), this._client); + } + + publishAsExisting(name: string | ParameterResource | Awaitable, options?: PublishAsExistingOptions): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._promise.then(obj => obj.publishAsExisting(name, options)), this._client); + } + + asExisting(name: string | ParameterResource | Awaitable, options?: AsExistingOptions): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._promise.then(obj => obj.asExisting(name, options)), this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): AzureBicepResourcePromise { + return new AzureBicepResourcePromiseImpl(this._promise.then(obj => obj.withRoleAssignments(target, roles)), this._client); + } + +} + +// ============================================================================ +// AzureEnvironmentResource +// ============================================================================ + +export interface AzureEnvironmentResource { + toJSON(): MarshalledHandle; + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): AzureEnvironmentResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureEnvironmentResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureEnvironmentResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureEnvironmentResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): AzureEnvironmentResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureEnvironmentResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): AzureEnvironmentResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): AzureEnvironmentResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): AzureEnvironmentResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureEnvironmentResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): AzureEnvironmentResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): AzureEnvironmentResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): AzureEnvironmentResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): AzureEnvironmentResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): AzureEnvironmentResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureEnvironmentResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureEnvironmentResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureEnvironmentResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureEnvironmentResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureEnvironmentResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureEnvironmentResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): AzureEnvironmentResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): AzureEnvironmentResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): AzureEnvironmentResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): AzureEnvironmentResourcePromise; + /** Sets the Azure location for the shared Azure environment resource */ + withLocation(location: Awaitable): AzureEnvironmentResourcePromise; + /** Sets the Azure resource group for the shared Azure environment resource */ + withResourceGroup(resourceGroup: Awaitable): AzureEnvironmentResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): AzureEnvironmentResourcePromise; +} + +export interface AzureEnvironmentResourcePromise extends PromiseLike { + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): AzureEnvironmentResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureEnvironmentResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureEnvironmentResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureEnvironmentResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): AzureEnvironmentResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureEnvironmentResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): AzureEnvironmentResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): AzureEnvironmentResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): AzureEnvironmentResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureEnvironmentResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): AzureEnvironmentResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): AzureEnvironmentResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): AzureEnvironmentResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): AzureEnvironmentResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): AzureEnvironmentResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureEnvironmentResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureEnvironmentResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureEnvironmentResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureEnvironmentResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureEnvironmentResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureEnvironmentResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): AzureEnvironmentResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): AzureEnvironmentResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): AzureEnvironmentResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): AzureEnvironmentResourcePromise; + /** Sets the Azure location for the shared Azure environment resource */ + withLocation(location: Awaitable): AzureEnvironmentResourcePromise; + /** Sets the Azure resource group for the shared Azure environment resource */ + withResourceGroup(resourceGroup: Awaitable): AzureEnvironmentResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): AzureEnvironmentResourcePromise; +} + +// ============================================================================ +// AzureEnvironmentResourceImpl +// ============================================================================ + +class AzureEnvironmentResourceImpl extends ResourceBuilderBase implements AzureEnvironmentResource { + constructor(handle: AzureEnvironmentResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: Awaitable): Promise { + registry = isPromiseLike(registry) ? await registry : registry; + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new AzureEnvironmentResourceImpl(result, this._client); + } + + withContainerRegistry(registry: Awaitable): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromiseImpl(this._withContainerRegistryInternal(registry), this._client); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new AzureEnvironmentResourceImpl(result, this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureEnvironmentResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new AzureEnvironmentResourcePromiseImpl(this._withDockerfileBaseImageInternal(buildImage, runtimeImage), this._client); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new AzureEnvironmentResourceImpl(result, this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureEnvironmentResourcePromise { + const helpLink = options?.helpLink; + return new AzureEnvironmentResourcePromiseImpl(this._withRequiredCommandInternal(command, helpLink), this._client); + } + + /** @internal */ + private async _withUrlsInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrls', + rpcArgs + ); + return new AzureEnvironmentResourceImpl(result, this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromiseImpl(this._withUrlsInternal(callback), this._client); + } + + /** @internal */ + private async _withUrlInternal(url: string | ReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new AzureEnvironmentResourceImpl(result, this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): AzureEnvironmentResourcePromise { + const displayText = options?.displayText; + return new AzureEnvironmentResourcePromiseImpl(this._withUrlInternal(url, displayText), this._client); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new AzureEnvironmentResourceImpl(result, this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromiseImpl(this._withUrlForEndpointInternal(endpointName, callback), this._client); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new AzureEnvironmentResourceImpl(result, this._client); + } + + excludeFromManifest(): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromiseImpl(this._excludeFromManifestInternal(), this._client); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new AzureEnvironmentResourceImpl(result, this._client); + } + + withExplicitStart(): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromiseImpl(this._withExplicitStartInternal(), this._client); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new AzureEnvironmentResourceImpl(result, this._client); + } + + withHealthCheck(key: string): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromiseImpl(this._withHealthCheckInternal(key), this._client); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContextImpl(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new AzureEnvironmentResourceImpl(result, this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureEnvironmentResourcePromise { + const commandOptions = options?.commandOptions; + return new AzureEnvironmentResourcePromiseImpl(this._withCommandInternal(name, displayName, executeCommand, commandOptions), this._client); + } + + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: Awaitable, type: string): Promise { + resourceBuilder = isPromiseLike(resourceBuilder) ? await resourceBuilder : resourceBuilder; + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureEnvironmentResourceImpl(result, this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromiseImpl(this._withRelationshipInternal(resourceBuilder, type), this._client); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: Awaitable): Promise { + parent = isPromiseLike(parent) ? await parent : parent; + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new AzureEnvironmentResourceImpl(result, this._client); + } + + withParentRelationship(parent: Awaitable): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromiseImpl(this._withParentRelationshipInternal(parent), this._client); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: Awaitable): Promise { + child = isPromiseLike(child) ? await child : child; + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', + rpcArgs + ); + return new AzureEnvironmentResourceImpl(result, this._client); + } + + withChildRelationship(child: Awaitable): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromiseImpl(this._withChildRelationshipInternal(child), this._client); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new AzureEnvironmentResourceImpl(result, this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): AzureEnvironmentResourcePromise { + const iconVariant = options?.iconVariant; + return new AzureEnvironmentResourcePromiseImpl(this._withIconNameInternal(iconName, iconVariant), this._client); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new AzureEnvironmentResourceImpl(result, this._client); + } + + excludeFromMcp(): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromiseImpl(this._excludeFromMcpInternal(), this._client); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new AzureEnvironmentResourceImpl(result, this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureEnvironmentResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new AzureEnvironmentResourcePromiseImpl(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description), this._client); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new AzureEnvironmentResourceImpl(result, this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromiseImpl(this._withPipelineConfigurationInternal(callback), this._client); + } + + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); + } + + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new AzureEnvironmentResourceImpl(result, this._client); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromiseImpl(this._onBeforeResourceStartedInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new AzureEnvironmentResourceImpl(result, this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromiseImpl(this._onResourceStoppedInternal(callback), this._client); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new AzureEnvironmentResourceImpl(result, this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromiseImpl(this._onInitializeResourceInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new AzureEnvironmentResourceImpl(result, this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromiseImpl(this._onResourceReadyInternal(callback), this._client); + } + + async createExecutionConfiguration(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/createExecutionConfiguration', + rpcArgs + ); + } + + /** @internal */ + private async _withLikeC4DetailsInternal(label?: string, technology?: string, description?: string, summary?: string, icon?: string, configure?: (obj: LikeC4NodeDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4NodeDetailsAnnotationHandle; + const obj = new LikeC4NodeDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + const rpcArgs: Record = { builder: this._handle }; + if (label !== undefined) rpcArgs.label = label; + if (technology !== undefined) rpcArgs.technology = technology; + if (description !== undefined) rpcArgs.description = description; + if (summary !== undefined) rpcArgs.summary = summary; + if (icon !== undefined) rpcArgs.icon = icon; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4DetailsParameters', + rpcArgs + ); + return new AzureEnvironmentResourceImpl(result, this._client); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): AzureEnvironmentResourcePromise { + const label = options?.label; + const technology = options?.technology; + const description = options?.description; + const summary = options?.summary; + const icon = options?.icon; + const configure = options?.configure; + return new AzureEnvironmentResourcePromiseImpl(this._withLikeC4DetailsInternal(label, technology, description, summary, icon, configure), this._client); + } + + /** @internal */ + private async _withLikeC4ReferenceInternal(target: Awaitable, configure?: (obj: LikeC4RelationshipDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4RelationshipDetailsAnnotationHandle; + const obj = new LikeC4RelationshipDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target }; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Reference', + rpcArgs + ); + return new AzureEnvironmentResourceImpl(result, this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): AzureEnvironmentResourcePromise { + const configure = options?.configure; + return new AzureEnvironmentResourcePromiseImpl(this._withLikeC4ReferenceInternal(target, configure), this._client); + } + + /** @internal */ + private async _withLikeC4GroupInternal(groupName: string): Promise { + const rpcArgs: Record = { builder: this._handle, groupName }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Group', + rpcArgs + ); + return new AzureEnvironmentResourceImpl(result, this._client); + } + + withLikeC4Group(groupName: string): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromiseImpl(this._withLikeC4GroupInternal(groupName), this._client); + } + + /** @internal */ + private async _excludeFromLikeC4Internal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/excludeFromLikeC4', + rpcArgs + ); + return new AzureEnvironmentResourceImpl(result, this._client); + } + + excludeFromLikeC4(): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromiseImpl(this._excludeFromLikeC4Internal(), this._client); + } + + /** @internal */ + private async _withLocationInternal(location: Awaitable): Promise { + location = isPromiseLike(location) ? await location : location; + const rpcArgs: Record = { builder: this._handle, location }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withLocation', + rpcArgs + ); + return new AzureEnvironmentResourceImpl(result, this._client); + } + + withLocation(location: Awaitable): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromiseImpl(this._withLocationInternal(location), this._client); + } + + /** @internal */ + private async _withResourceGroupInternal(resourceGroup: Awaitable): Promise { + resourceGroup = isPromiseLike(resourceGroup) ? await resourceGroup : resourceGroup; + const rpcArgs: Record = { builder: this._handle, resourceGroup }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withResourceGroup', + rpcArgs + ); + return new AzureEnvironmentResourceImpl(result, this._client); + } + + withResourceGroup(resourceGroup: Awaitable): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromiseImpl(this._withResourceGroupInternal(resourceGroup), this._client); + } + + /** @internal */ + private async _withRoleAssignmentsInternal(target: Awaitable, roles: AzureKeyVaultRole[]): Promise { + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target, roles }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.KeyVault/withKeyVaultRoleAssignments', + rpcArgs + ); + return new AzureEnvironmentResourceImpl(result, this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromiseImpl(this._withRoleAssignmentsInternal(target, roles), this._client); + } + +} + +/** + * Thenable wrapper for AzureEnvironmentResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +class AzureEnvironmentResourcePromiseImpl implements AzureEnvironmentResourcePromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: AzureEnvironmentResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + withContainerRegistry(registry: Awaitable): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromiseImpl(this._promise.then(obj => obj.withContainerRegistry(registry)), this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromiseImpl(this._promise.then(obj => obj.withDockerfileBaseImage(options)), this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromiseImpl(this._promise.then(obj => obj.withRequiredCommand(command, options)), this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromiseImpl(this._promise.then(obj => obj.withUrls(callback)), this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromiseImpl(this._promise.then(obj => obj.withUrl(url, options)), this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromiseImpl(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback)), this._client); + } + + excludeFromManifest(): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromiseImpl(this._promise.then(obj => obj.excludeFromManifest()), this._client); + } + + withExplicitStart(): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromiseImpl(this._promise.then(obj => obj.withExplicitStart()), this._client); + } + + withHealthCheck(key: string): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromiseImpl(this._promise.then(obj => obj.withHealthCheck(key)), this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromiseImpl(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options)), this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromiseImpl(this._promise.then(obj => obj.withRelationship(resourceBuilder, type)), this._client); + } + + withParentRelationship(parent: Awaitable): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromiseImpl(this._promise.then(obj => obj.withParentRelationship(parent)), this._client); + } + + withChildRelationship(child: Awaitable): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromiseImpl(this._promise.then(obj => obj.withChildRelationship(child)), this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromiseImpl(this._promise.then(obj => obj.withIconName(iconName, options)), this._client); + } + + excludeFromMcp(): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromiseImpl(this._promise.then(obj => obj.excludeFromMcp()), this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromiseImpl(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options)), this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromiseImpl(this._promise.then(obj => obj.withPipelineConfiguration(callback)), this._client); + } + + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromiseImpl(this._promise.then(obj => obj.onBeforeResourceStarted(callback)), this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromiseImpl(this._promise.then(obj => obj.onResourceStopped(callback)), this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromiseImpl(this._promise.then(obj => obj.onInitializeResource(callback)), this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromiseImpl(this._promise.then(obj => obj.onResourceReady(callback)), this._client); + } + + createExecutionConfiguration(): Promise { + return this._promise.then(obj => obj.createExecutionConfiguration()); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Details(options)), this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Reference(target, options)), this._client); + } + + withLikeC4Group(groupName: string): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Group(groupName)), this._client); + } + + excludeFromLikeC4(): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromiseImpl(this._promise.then(obj => obj.excludeFromLikeC4()), this._client); + } + + withLocation(location: Awaitable): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromiseImpl(this._promise.then(obj => obj.withLocation(location)), this._client); + } + + withResourceGroup(resourceGroup: Awaitable): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromiseImpl(this._promise.then(obj => obj.withResourceGroup(resourceGroup)), this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromiseImpl(this._promise.then(obj => obj.withRoleAssignments(target, roles)), this._client); + } + +} + +// ============================================================================ +// AzureKeyVaultResource +// ============================================================================ + +export interface AzureKeyVaultResource { + toJSON(): MarshalledHandle; + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): AzureKeyVaultResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureKeyVaultResourcePromise; + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): AzureKeyVaultResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureKeyVaultResourcePromise; + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureKeyVaultResourcePromise; + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise; + /** Updates a named endpoint via callback */ + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): AzureKeyVaultResourcePromise; + /** Updates an HTTP endpoint via callback */ + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): AzureKeyVaultResourcePromise; + /** Updates an HTTPS endpoint via callback */ + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): AzureKeyVaultResourcePromise; + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): AzureKeyVaultResourcePromise; + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): AzureKeyVaultResourcePromise; + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): AzureKeyVaultResourcePromise; + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): AzureKeyVaultResourcePromise; + /** Gets an endpoint reference */ + getEndpoint(name: string): Promise; + /** Configures resource for HTTP/2 */ + asHttp2Service(): AzureKeyVaultResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureKeyVaultResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): AzureKeyVaultResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureKeyVaultResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): AzureKeyVaultResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): AzureKeyVaultResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): AzureKeyVaultResourcePromise; + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): AzureKeyVaultResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureKeyVaultResourcePromise; + /** Adds an HTTP resource command */ + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): AzureKeyVaultResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): AzureKeyVaultResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): AzureKeyVaultResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): AzureKeyVaultResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): AzureKeyVaultResourcePromise; + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): AzureKeyVaultResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): AzureKeyVaultResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureKeyVaultResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureKeyVaultResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureKeyVaultResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureKeyVaultResourcePromise; + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureKeyVaultResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureKeyVaultResourcePromise; + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): AzureKeyVaultResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureKeyVaultResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): AzureKeyVaultResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): AzureKeyVaultResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): AzureKeyVaultResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): AzureKeyVaultResourcePromise; + /** Gets an output reference from an Azure Bicep template resource */ + getOutput(name: string): Promise; + /** Adds a Bicep parameter */ + withParameter(name: string, options?: WithParameterOptions): AzureKeyVaultResourcePromise; + /** Configures the Azure provisioning infrastructure callback */ + configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzureKeyVaultResourcePromise; + /** Publishes an Azure resource to the manifest as a connection string */ + publishAsConnectionString(): AzureKeyVaultResourcePromise; + /** Gets the normalized Bicep identifier for an Azure resource */ + getBicepIdentifier(): Promise; + /** Clears the default Azure role assignments from a resource */ + clearDefaultRoleAssignments(): AzureKeyVaultResourcePromise; + /** Determines whether a resource is marked as existing */ + isExisting(): Promise; + /** Marks an Azure resource as existing in run mode */ + runAsExisting(name: string | ParameterResource | Awaitable, options?: RunAsExistingOptions): AzureKeyVaultResourcePromise; + /** Marks an Azure resource as existing in publish mode */ + publishAsExisting(name: string | ParameterResource | Awaitable, options?: PublishAsExistingOptions): AzureKeyVaultResourcePromise; + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource | Awaitable, options?: AsExistingOptions): AzureKeyVaultResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): AzureKeyVaultResourcePromise; + /** Gets a secret reference from the Azure Key Vault */ + getSecret(secretName: string): Promise; + /** Adds a secret to the Azure Key Vault */ + addSecret(name: string, value: ParameterResource | ReferenceExpression | Awaitable, options?: AddSecretOptions): AzureKeyVaultSecretResourcePromise; +} + +export interface AzureKeyVaultResourcePromise extends PromiseLike { + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): AzureKeyVaultResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureKeyVaultResourcePromise; + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): AzureKeyVaultResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureKeyVaultResourcePromise; + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureKeyVaultResourcePromise; + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise; + /** Updates a named endpoint via callback */ + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): AzureKeyVaultResourcePromise; + /** Updates an HTTP endpoint via callback */ + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): AzureKeyVaultResourcePromise; + /** Updates an HTTPS endpoint via callback */ + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): AzureKeyVaultResourcePromise; + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): AzureKeyVaultResourcePromise; + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): AzureKeyVaultResourcePromise; + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): AzureKeyVaultResourcePromise; + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): AzureKeyVaultResourcePromise; + /** Gets an endpoint reference */ + getEndpoint(name: string): Promise; + /** Configures resource for HTTP/2 */ + asHttp2Service(): AzureKeyVaultResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureKeyVaultResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): AzureKeyVaultResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureKeyVaultResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): AzureKeyVaultResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): AzureKeyVaultResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): AzureKeyVaultResourcePromise; + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): AzureKeyVaultResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureKeyVaultResourcePromise; + /** Adds an HTTP resource command */ + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): AzureKeyVaultResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): AzureKeyVaultResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): AzureKeyVaultResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): AzureKeyVaultResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): AzureKeyVaultResourcePromise; + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): AzureKeyVaultResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): AzureKeyVaultResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureKeyVaultResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureKeyVaultResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureKeyVaultResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureKeyVaultResourcePromise; + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureKeyVaultResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureKeyVaultResourcePromise; + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): AzureKeyVaultResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureKeyVaultResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): AzureKeyVaultResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): AzureKeyVaultResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): AzureKeyVaultResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): AzureKeyVaultResourcePromise; + /** Gets an output reference from an Azure Bicep template resource */ + getOutput(name: string): Promise; + /** Adds a Bicep parameter */ + withParameter(name: string, options?: WithParameterOptions): AzureKeyVaultResourcePromise; + /** Configures the Azure provisioning infrastructure callback */ + configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzureKeyVaultResourcePromise; + /** Publishes an Azure resource to the manifest as a connection string */ + publishAsConnectionString(): AzureKeyVaultResourcePromise; + /** Gets the normalized Bicep identifier for an Azure resource */ + getBicepIdentifier(): Promise; + /** Clears the default Azure role assignments from a resource */ + clearDefaultRoleAssignments(): AzureKeyVaultResourcePromise; + /** Determines whether a resource is marked as existing */ + isExisting(): Promise; + /** Marks an Azure resource as existing in run mode */ + runAsExisting(name: string | ParameterResource | Awaitable, options?: RunAsExistingOptions): AzureKeyVaultResourcePromise; + /** Marks an Azure resource as existing in publish mode */ + publishAsExisting(name: string | ParameterResource | Awaitable, options?: PublishAsExistingOptions): AzureKeyVaultResourcePromise; + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource | Awaitable, options?: AsExistingOptions): AzureKeyVaultResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): AzureKeyVaultResourcePromise; + /** Gets a secret reference from the Azure Key Vault */ + getSecret(secretName: string): Promise; + /** Adds a secret to the Azure Key Vault */ + addSecret(name: string, value: ParameterResource | ReferenceExpression | Awaitable, options?: AddSecretOptions): AzureKeyVaultSecretResourcePromise; +} + +// ============================================================================ +// AzureKeyVaultResourceImpl +// ============================================================================ + +class AzureKeyVaultResourceImpl extends ResourceBuilderBase implements AzureKeyVaultResource { + constructor(handle: AzureKeyVaultResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: Awaitable): Promise { + registry = isPromiseLike(registry) ? await registry : registry; + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new AzureKeyVaultResourceImpl(result, this._client); + } + + withContainerRegistry(registry: Awaitable): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._withContainerRegistryInternal(registry), this._client); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new AzureKeyVaultResourceImpl(result, this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureKeyVaultResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new AzureKeyVaultResourcePromiseImpl(this._withDockerfileBaseImageInternal(buildImage, runtimeImage), this._client); + } + + /** @internal */ + private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withMcpServer', + rpcArgs + ); + return new AzureKeyVaultResourceImpl(result, this._client); + } + + withMcpServer(options?: WithMcpServerOptions): AzureKeyVaultResourcePromise { + const path = options?.path; + const endpointName = options?.endpointName; + return new AzureKeyVaultResourcePromiseImpl(this._withMcpServerInternal(path, endpointName), this._client); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new AzureKeyVaultResourceImpl(result, this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureKeyVaultResourcePromise { + const helpLink = options?.helpLink; + return new AzureKeyVaultResourcePromiseImpl(this._withRequiredCommandInternal(command, helpLink), this._client); + } + + /** @internal */ + private async _withConnectionPropertyInternal(name: string, value: string | ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withConnectionProperty', + rpcArgs + ); + return new AzureKeyVaultResourceImpl(result, this._client); + } + + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._withConnectionPropertyInternal(name, value), this._client); + } + + async getConnectionProperty(key: string): Promise { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + + /** @internal */ + private async _withEndpointCallbackInternal(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpointCallback', + rpcArgs + ); + return new AzureKeyVaultResourceImpl(result, this._client); + } + + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): AzureKeyVaultResourcePromise { + const createIfNotExists = options?.createIfNotExists; + return new AzureKeyVaultResourcePromiseImpl(this._withEndpointCallbackInternal(endpointName, callback, createIfNotExists), this._client); + } + + /** @internal */ + private async _withHttpEndpointCallbackInternal(callback: (obj: EndpointUpdateContext) => Promise, name?: string, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + if (name !== undefined) rpcArgs.name = name; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpEndpointCallback', + rpcArgs + ); + return new AzureKeyVaultResourceImpl(result, this._client); + } + + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): AzureKeyVaultResourcePromise { + const name = options?.name; + const createIfNotExists = options?.createIfNotExists; + return new AzureKeyVaultResourcePromiseImpl(this._withHttpEndpointCallbackInternal(callback, name, createIfNotExists), this._client); + } + + /** @internal */ + private async _withHttpsEndpointCallbackInternal(callback: (obj: EndpointUpdateContext) => Promise, name?: string, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + if (name !== undefined) rpcArgs.name = name; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsEndpointCallback', + rpcArgs + ); + return new AzureKeyVaultResourceImpl(result, this._client); + } + + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): AzureKeyVaultResourcePromise { + const name = options?.name; + const createIfNotExists = options?.createIfNotExists; + return new AzureKeyVaultResourcePromiseImpl(this._withHttpsEndpointCallbackInternal(callback, name, createIfNotExists), this._client); + } + + /** @internal */ + private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (scheme !== undefined) rpcArgs.scheme = scheme; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + if (isExternal !== undefined) rpcArgs.isExternal = isExternal; + if (protocol !== undefined) rpcArgs.protocol = protocol; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpoint', + rpcArgs + ); + return new AzureKeyVaultResourceImpl(result, this._client); + } + + withEndpoint(options?: WithEndpointOptions): AzureKeyVaultResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const scheme = options?.scheme; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + const isExternal = options?.isExternal; + const protocol = options?.protocol; + return new AzureKeyVaultResourcePromiseImpl(this._withEndpointInternal(port, targetPort, scheme, name, env, isProxied, isExternal, protocol), this._client); + } + + /** @internal */ + private async _withHttpEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpEndpoint', + rpcArgs + ); + return new AzureKeyVaultResourceImpl(result, this._client); + } + + withHttpEndpoint(options?: WithHttpEndpointOptions): AzureKeyVaultResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new AzureKeyVaultResourcePromiseImpl(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied), this._client); + } + + /** @internal */ + private async _withHttpsEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsEndpoint', + rpcArgs + ); + return new AzureKeyVaultResourceImpl(result, this._client); + } + + withHttpsEndpoint(options?: WithHttpsEndpointOptions): AzureKeyVaultResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new AzureKeyVaultResourcePromiseImpl(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied), this._client); + } + + /** @internal */ + private async _withExternalHttpEndpointsInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExternalHttpEndpoints', + rpcArgs + ); + return new AzureKeyVaultResourceImpl(result, this._client); + } + + withExternalHttpEndpoints(): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._withExternalHttpEndpointsInternal(), this._client); + } + + async getEndpoint(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getEndpoint', + rpcArgs + ); + } + + /** @internal */ + private async _asHttp2ServiceInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/asHttp2Service', + rpcArgs + ); + return new AzureKeyVaultResourceImpl(result, this._client); + } + + asHttp2Service(): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._asHttp2ServiceInternal(), this._client); + } + + /** @internal */ + private async _withUrlsInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrls', + rpcArgs + ); + return new AzureKeyVaultResourceImpl(result, this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._withUrlsInternal(callback), this._client); + } + + /** @internal */ + private async _withUrlInternal(url: string | ReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new AzureKeyVaultResourceImpl(result, this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): AzureKeyVaultResourcePromise { + const displayText = options?.displayText; + return new AzureKeyVaultResourcePromiseImpl(this._withUrlInternal(url, displayText), this._client); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new AzureKeyVaultResourceImpl(result, this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._withUrlForEndpointInternal(endpointName, callback), this._client); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new AzureKeyVaultResourceImpl(result, this._client); + } + + excludeFromManifest(): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._excludeFromManifestInternal(), this._client); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new AzureKeyVaultResourceImpl(result, this._client); + } + + withExplicitStart(): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._withExplicitStartInternal(), this._client); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new AzureKeyVaultResourceImpl(result, this._client); + } + + withHealthCheck(key: string): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._withHealthCheckInternal(key), this._client); + } + + /** @internal */ + private async _withHttpHealthCheckInternal(path?: string, statusCode?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (statusCode !== undefined) rpcArgs.statusCode = statusCode; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpHealthCheck', + rpcArgs + ); + return new AzureKeyVaultResourceImpl(result, this._client); + } + + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): AzureKeyVaultResourcePromise { + const path = options?.path; + const statusCode = options?.statusCode; + const endpointName = options?.endpointName; + return new AzureKeyVaultResourcePromiseImpl(this._withHttpHealthCheckInternal(path, statusCode, endpointName), this._client); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContextImpl(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new AzureKeyVaultResourceImpl(result, this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureKeyVaultResourcePromise { + const commandOptions = options?.commandOptions; + return new AzureKeyVaultResourcePromiseImpl(this._withCommandInternal(name, displayName, executeCommand, commandOptions), this._client); + } + + /** @internal */ + private async _withHttpCommandInternal(path: string, displayName: string, options?: HttpCommandExportOptions): Promise { + const rpcArgs: Record = { builder: this._handle, path, displayName }; + if (options !== undefined) rpcArgs.options = options; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpCommand', + rpcArgs + ); + return new AzureKeyVaultResourceImpl(result, this._client); + } + + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._withHttpCommandInternal(path, displayName, options), this._client); + } + + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: Awaitable, type: string): Promise { + resourceBuilder = isPromiseLike(resourceBuilder) ? await resourceBuilder : resourceBuilder; + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureKeyVaultResourceImpl(result, this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._withRelationshipInternal(resourceBuilder, type), this._client); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: Awaitable): Promise { + parent = isPromiseLike(parent) ? await parent : parent; + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new AzureKeyVaultResourceImpl(result, this._client); + } + + withParentRelationship(parent: Awaitable): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._withParentRelationshipInternal(parent), this._client); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: Awaitable): Promise { + child = isPromiseLike(child) ? await child : child; + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', + rpcArgs + ); + return new AzureKeyVaultResourceImpl(result, this._client); + } + + withChildRelationship(child: Awaitable): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._withChildRelationshipInternal(child), this._client); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new AzureKeyVaultResourceImpl(result, this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): AzureKeyVaultResourcePromise { + const iconVariant = options?.iconVariant; + return new AzureKeyVaultResourcePromiseImpl(this._withIconNameInternal(iconName, iconVariant), this._client); + } + + /** @internal */ + private async _withHttpProbeInternal(probeType: ProbeType, path?: string, initialDelaySeconds?: number, periodSeconds?: number, timeoutSeconds?: number, failureThreshold?: number, successThreshold?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, probeType }; + if (path !== undefined) rpcArgs.path = path; + if (initialDelaySeconds !== undefined) rpcArgs.initialDelaySeconds = initialDelaySeconds; + if (periodSeconds !== undefined) rpcArgs.periodSeconds = periodSeconds; + if (timeoutSeconds !== undefined) rpcArgs.timeoutSeconds = timeoutSeconds; + if (failureThreshold !== undefined) rpcArgs.failureThreshold = failureThreshold; + if (successThreshold !== undefined) rpcArgs.successThreshold = successThreshold; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpProbe', + rpcArgs + ); + return new AzureKeyVaultResourceImpl(result, this._client); + } + + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): AzureKeyVaultResourcePromise { + const path = options?.path; + const initialDelaySeconds = options?.initialDelaySeconds; + const periodSeconds = options?.periodSeconds; + const timeoutSeconds = options?.timeoutSeconds; + const failureThreshold = options?.failureThreshold; + const successThreshold = options?.successThreshold; + const endpointName = options?.endpointName; + return new AzureKeyVaultResourcePromiseImpl(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName), this._client); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new AzureKeyVaultResourceImpl(result, this._client); + } + + excludeFromMcp(): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._excludeFromMcpInternal(), this._client); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new AzureKeyVaultResourceImpl(result, this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureKeyVaultResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new AzureKeyVaultResourcePromiseImpl(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description), this._client); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new AzureKeyVaultResourceImpl(result, this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._withPipelineConfigurationInternal(callback), this._client); + } + + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); + } + + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new AzureKeyVaultResourceImpl(result, this._client); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._onBeforeResourceStartedInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new AzureKeyVaultResourceImpl(result, this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._onResourceStoppedInternal(callback), this._client); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onConnectionStringAvailable', + rpcArgs + ); + return new AzureKeyVaultResourceImpl(result, this._client); + } + + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._onConnectionStringAvailableInternal(callback), this._client); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new AzureKeyVaultResourceImpl(result, this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._onInitializeResourceInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceEndpointsAllocated', + rpcArgs + ); + return new AzureKeyVaultResourceImpl(result, this._client); + } + + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._onResourceEndpointsAllocatedInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new AzureKeyVaultResourceImpl(result, this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._onResourceReadyInternal(callback), this._client); + } + + async createExecutionConfiguration(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/createExecutionConfiguration', + rpcArgs + ); + } + + /** @internal */ + private async _withLikeC4DetailsInternal(label?: string, technology?: string, description?: string, summary?: string, icon?: string, configure?: (obj: LikeC4NodeDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4NodeDetailsAnnotationHandle; + const obj = new LikeC4NodeDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + const rpcArgs: Record = { builder: this._handle }; + if (label !== undefined) rpcArgs.label = label; + if (technology !== undefined) rpcArgs.technology = technology; + if (description !== undefined) rpcArgs.description = description; + if (summary !== undefined) rpcArgs.summary = summary; + if (icon !== undefined) rpcArgs.icon = icon; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4DetailsParameters', + rpcArgs + ); + return new AzureKeyVaultResourceImpl(result, this._client); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): AzureKeyVaultResourcePromise { + const label = options?.label; + const technology = options?.technology; + const description = options?.description; + const summary = options?.summary; + const icon = options?.icon; + const configure = options?.configure; + return new AzureKeyVaultResourcePromiseImpl(this._withLikeC4DetailsInternal(label, technology, description, summary, icon, configure), this._client); + } + + /** @internal */ + private async _withLikeC4ReferenceInternal(target: Awaitable, configure?: (obj: LikeC4RelationshipDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4RelationshipDetailsAnnotationHandle; + const obj = new LikeC4RelationshipDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target }; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Reference', + rpcArgs + ); + return new AzureKeyVaultResourceImpl(result, this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): AzureKeyVaultResourcePromise { + const configure = options?.configure; + return new AzureKeyVaultResourcePromiseImpl(this._withLikeC4ReferenceInternal(target, configure), this._client); + } + + /** @internal */ + private async _withLikeC4GroupInternal(groupName: string): Promise { + const rpcArgs: Record = { builder: this._handle, groupName }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Group', + rpcArgs + ); + return new AzureKeyVaultResourceImpl(result, this._client); + } + + withLikeC4Group(groupName: string): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._withLikeC4GroupInternal(groupName), this._client); + } + + /** @internal */ + private async _excludeFromLikeC4Internal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/excludeFromLikeC4', + rpcArgs + ); + return new AzureKeyVaultResourceImpl(result, this._client); + } + + excludeFromLikeC4(): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._excludeFromLikeC4Internal(), this._client); + } + + async getOutput(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/getOutput', + rpcArgs + ); + } + + /** @internal */ + private async _withParameterInternal(name: string, value?: string | string[] | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | BicepOutputReference | ReferenceExpression | EndpointReference | Awaitable): Promise { + value = isPromiseLike(value) ? await value : value; + const rpcArgs: Record = { builder: this._handle, name }; + if (value !== undefined) rpcArgs.value = value; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameter', + rpcArgs + ); + return new AzureKeyVaultResourceImpl(result, this._client); + } + + withParameter(name: string, options?: WithParameterOptions): AzureKeyVaultResourcePromise { + let value = options?.value; + return new AzureKeyVaultResourcePromiseImpl(this._withParameterInternal(name, value), this._client); + } + + /** @internal */ + private async _configureInfrastructureInternal(configure: (obj: AzureResourceInfrastructure) => Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as AzureResourceInfrastructureHandle; + const obj = new AzureResourceInfrastructureImpl(objHandle, this._client); + await configure(obj); + }); + const rpcArgs: Record = { builder: this._handle, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/configureInfrastructure', + rpcArgs + ); + return new AzureKeyVaultResourceImpl(result, this._client); + } + + configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._configureInfrastructureInternal(configure), this._client); + } + + /** @internal */ + private async _publishAsConnectionStringInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/publishAsConnectionString', + rpcArgs + ); + return new AzureKeyVaultResourceImpl(result, this._client); + } + + publishAsConnectionString(): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._publishAsConnectionStringInternal(), this._client); + } + + async getBicepIdentifier(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/getBicepIdentifier', + rpcArgs + ); + } + + /** @internal */ + private async _clearDefaultRoleAssignmentsInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/clearDefaultRoleAssignments', + rpcArgs + ); + return new AzureKeyVaultResourceImpl(result, this._client); + } + + clearDefaultRoleAssignments(): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._clearDefaultRoleAssignmentsInternal(), this._client); + } + + async isExisting(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/isExisting', + rpcArgs + ); + } + + /** @internal */ + private async _runAsExistingInternal(name: string | ParameterResource | Awaitable, resourceGroup?: string | ParameterResource | Awaitable): Promise { + name = isPromiseLike(name) ? await name : name; + resourceGroup = isPromiseLike(resourceGroup) ? await resourceGroup : resourceGroup; + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/runAsExisting', + rpcArgs + ); + return new AzureKeyVaultResourceImpl(result, this._client); + } + + runAsExisting(name: string | ParameterResource | Awaitable, options?: RunAsExistingOptions): AzureKeyVaultResourcePromise { + let resourceGroup = options?.resourceGroup; + return new AzureKeyVaultResourcePromiseImpl(this._runAsExistingInternal(name, resourceGroup), this._client); + } + + /** @internal */ + private async _publishAsExistingInternal(name: string | ParameterResource | Awaitable, resourceGroup?: string | ParameterResource | Awaitable): Promise { + name = isPromiseLike(name) ? await name : name; + resourceGroup = isPromiseLike(resourceGroup) ? await resourceGroup : resourceGroup; + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/publishAsExisting', + rpcArgs + ); + return new AzureKeyVaultResourceImpl(result, this._client); + } + + publishAsExisting(name: string | ParameterResource | Awaitable, options?: PublishAsExistingOptions): AzureKeyVaultResourcePromise { + let resourceGroup = options?.resourceGroup; + return new AzureKeyVaultResourcePromiseImpl(this._publishAsExistingInternal(name, resourceGroup), this._client); + } + + /** @internal */ + private async _asExistingInternal(name: string | ParameterResource | Awaitable, resourceGroup?: string | ParameterResource | Awaitable): Promise { + name = isPromiseLike(name) ? await name : name; + resourceGroup = isPromiseLike(resourceGroup) ? await resourceGroup : resourceGroup; + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/asExisting', + rpcArgs + ); + return new AzureKeyVaultResourceImpl(result, this._client); + } + + asExisting(name: string | ParameterResource | Awaitable, options?: AsExistingOptions): AzureKeyVaultResourcePromise { + let resourceGroup = options?.resourceGroup; + return new AzureKeyVaultResourcePromiseImpl(this._asExistingInternal(name, resourceGroup), this._client); + } + + /** @internal */ + private async _withRoleAssignmentsInternal(target: Awaitable, roles: AzureKeyVaultRole[]): Promise { + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target, roles }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.KeyVault/withKeyVaultRoleAssignments', + rpcArgs + ); + return new AzureKeyVaultResourceImpl(result, this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._withRoleAssignmentsInternal(target, roles), this._client); + } + + async getSecret(secretName: string): Promise { + const rpcArgs: Record = { builder: this._handle, secretName }; + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure.KeyVault/getSecret', + rpcArgs + ); + } + + /** @internal */ + private async _addSecretInternal(name: string, value: ParameterResource | ReferenceExpression | Awaitable, secretName?: string): Promise { + value = isPromiseLike(value) ? await value : value; + const rpcArgs: Record = { builder: this._handle, name, value }; + if (secretName !== undefined) rpcArgs.secretName = secretName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.KeyVault/addSecret', + rpcArgs + ); + return new AzureKeyVaultSecretResourceImpl(result, this._client); + } + + addSecret(name: string, value: ParameterResource | ReferenceExpression | Awaitable, options?: AddSecretOptions): AzureKeyVaultSecretResourcePromise { + const secretName = options?.secretName; + return new AzureKeyVaultSecretResourcePromiseImpl(this._addSecretInternal(name, value, secretName), this._client); + } + +} + +/** + * Thenable wrapper for AzureKeyVaultResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +class AzureKeyVaultResourcePromiseImpl implements AzureKeyVaultResourcePromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: AzureKeyVaultResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + withContainerRegistry(registry: Awaitable): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._promise.then(obj => obj.withContainerRegistry(registry)), this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._promise.then(obj => obj.withDockerfileBaseImage(options)), this._client); + } + + withMcpServer(options?: WithMcpServerOptions): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._promise.then(obj => obj.withMcpServer(options)), this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._promise.then(obj => obj.withRequiredCommand(command, options)), this._client); + } + + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._promise.then(obj => obj.withConnectionProperty(name, value)), this._client); + } + + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._promise.then(obj => obj.withEndpointCallback(endpointName, callback, options)), this._client); + } + + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._promise.then(obj => obj.withHttpEndpointCallback(callback, options)), this._client); + } + + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._promise.then(obj => obj.withHttpsEndpointCallback(callback, options)), this._client); + } + + withEndpoint(options?: WithEndpointOptions): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._promise.then(obj => obj.withEndpoint(options)), this._client); + } + + withHttpEndpoint(options?: WithHttpEndpointOptions): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._promise.then(obj => obj.withHttpEndpoint(options)), this._client); + } + + withHttpsEndpoint(options?: WithHttpsEndpointOptions): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._promise.then(obj => obj.withHttpsEndpoint(options)), this._client); + } + + withExternalHttpEndpoints(): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._promise.then(obj => obj.withExternalHttpEndpoints()), this._client); + } + + getEndpoint(name: string): Promise { + return this._promise.then(obj => obj.getEndpoint(name)); + } + + asHttp2Service(): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._promise.then(obj => obj.asHttp2Service()), this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._promise.then(obj => obj.withUrls(callback)), this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._promise.then(obj => obj.withUrl(url, options)), this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback)), this._client); + } + + excludeFromManifest(): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._promise.then(obj => obj.excludeFromManifest()), this._client); + } + + withExplicitStart(): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._promise.then(obj => obj.withExplicitStart()), this._client); + } + + withHealthCheck(key: string): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._promise.then(obj => obj.withHealthCheck(key)), this._client); + } + + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._promise.then(obj => obj.withHttpHealthCheck(options)), this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options)), this._client); + } + + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._promise.then(obj => obj.withHttpCommand(path, displayName, options)), this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._promise.then(obj => obj.withRelationship(resourceBuilder, type)), this._client); + } + + withParentRelationship(parent: Awaitable): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._promise.then(obj => obj.withParentRelationship(parent)), this._client); + } + + withChildRelationship(child: Awaitable): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._promise.then(obj => obj.withChildRelationship(child)), this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._promise.then(obj => obj.withIconName(iconName, options)), this._client); + } + + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._promise.then(obj => obj.withHttpProbe(probeType, options)), this._client); + } + + excludeFromMcp(): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._promise.then(obj => obj.excludeFromMcp()), this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options)), this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._promise.then(obj => obj.withPipelineConfiguration(callback)), this._client); + } + + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._promise.then(obj => obj.onBeforeResourceStarted(callback)), this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._promise.then(obj => obj.onResourceStopped(callback)), this._client); + } + + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._promise.then(obj => obj.onConnectionStringAvailable(callback)), this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._promise.then(obj => obj.onInitializeResource(callback)), this._client); + } + + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback)), this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._promise.then(obj => obj.onResourceReady(callback)), this._client); + } + + createExecutionConfiguration(): Promise { + return this._promise.then(obj => obj.createExecutionConfiguration()); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Details(options)), this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Reference(target, options)), this._client); + } + + withLikeC4Group(groupName: string): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Group(groupName)), this._client); + } + + excludeFromLikeC4(): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._promise.then(obj => obj.excludeFromLikeC4()), this._client); + } + + getOutput(name: string): Promise { + return this._promise.then(obj => obj.getOutput(name)); + } + + withParameter(name: string, options?: WithParameterOptions): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._promise.then(obj => obj.withParameter(name, options)), this._client); + } + + configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._promise.then(obj => obj.configureInfrastructure(configure)), this._client); + } + + publishAsConnectionString(): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._promise.then(obj => obj.publishAsConnectionString()), this._client); + } + + getBicepIdentifier(): Promise { + return this._promise.then(obj => obj.getBicepIdentifier()); + } + + clearDefaultRoleAssignments(): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._promise.then(obj => obj.clearDefaultRoleAssignments()), this._client); + } + + isExisting(): Promise { + return this._promise.then(obj => obj.isExisting()); + } + + runAsExisting(name: string | ParameterResource | Awaitable, options?: RunAsExistingOptions): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._promise.then(obj => obj.runAsExisting(name, options)), this._client); + } + + publishAsExisting(name: string | ParameterResource | Awaitable, options?: PublishAsExistingOptions): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._promise.then(obj => obj.publishAsExisting(name, options)), this._client); + } + + asExisting(name: string | ParameterResource | Awaitable, options?: AsExistingOptions): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._promise.then(obj => obj.asExisting(name, options)), this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromiseImpl(this._promise.then(obj => obj.withRoleAssignments(target, roles)), this._client); + } + + getSecret(secretName: string): Promise { + return this._promise.then(obj => obj.getSecret(secretName)); + } + + addSecret(name: string, value: ParameterResource | ReferenceExpression | Awaitable, options?: AddSecretOptions): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromiseImpl(this._promise.then(obj => obj.addSecret(name, value, options)), this._client); + } + +} + +// ============================================================================ +// AzureKeyVaultSecretResource +// ============================================================================ + +export interface AzureKeyVaultSecretResource { + toJSON(): MarshalledHandle; + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): AzureKeyVaultSecretResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureKeyVaultSecretResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureKeyVaultSecretResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureKeyVaultSecretResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): AzureKeyVaultSecretResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureKeyVaultSecretResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): AzureKeyVaultSecretResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): AzureKeyVaultSecretResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): AzureKeyVaultSecretResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureKeyVaultSecretResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): AzureKeyVaultSecretResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): AzureKeyVaultSecretResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): AzureKeyVaultSecretResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): AzureKeyVaultSecretResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): AzureKeyVaultSecretResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureKeyVaultSecretResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureKeyVaultSecretResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureKeyVaultSecretResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureKeyVaultSecretResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureKeyVaultSecretResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureKeyVaultSecretResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): AzureKeyVaultSecretResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): AzureKeyVaultSecretResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): AzureKeyVaultSecretResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): AzureKeyVaultSecretResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): AzureKeyVaultSecretResourcePromise; +} + +export interface AzureKeyVaultSecretResourcePromise extends PromiseLike { + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): AzureKeyVaultSecretResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureKeyVaultSecretResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureKeyVaultSecretResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureKeyVaultSecretResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): AzureKeyVaultSecretResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureKeyVaultSecretResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): AzureKeyVaultSecretResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): AzureKeyVaultSecretResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): AzureKeyVaultSecretResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureKeyVaultSecretResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): AzureKeyVaultSecretResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): AzureKeyVaultSecretResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): AzureKeyVaultSecretResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): AzureKeyVaultSecretResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): AzureKeyVaultSecretResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureKeyVaultSecretResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureKeyVaultSecretResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureKeyVaultSecretResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureKeyVaultSecretResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureKeyVaultSecretResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureKeyVaultSecretResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): AzureKeyVaultSecretResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): AzureKeyVaultSecretResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): AzureKeyVaultSecretResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): AzureKeyVaultSecretResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): AzureKeyVaultSecretResourcePromise; +} + +// ============================================================================ +// AzureKeyVaultSecretResourceImpl +// ============================================================================ + +class AzureKeyVaultSecretResourceImpl extends ResourceBuilderBase implements AzureKeyVaultSecretResource { + constructor(handle: AzureKeyVaultSecretResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: Awaitable): Promise { + registry = isPromiseLike(registry) ? await registry : registry; + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new AzureKeyVaultSecretResourceImpl(result, this._client); + } + + withContainerRegistry(registry: Awaitable): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromiseImpl(this._withContainerRegistryInternal(registry), this._client); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new AzureKeyVaultSecretResourceImpl(result, this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureKeyVaultSecretResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new AzureKeyVaultSecretResourcePromiseImpl(this._withDockerfileBaseImageInternal(buildImage, runtimeImage), this._client); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new AzureKeyVaultSecretResourceImpl(result, this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureKeyVaultSecretResourcePromise { + const helpLink = options?.helpLink; + return new AzureKeyVaultSecretResourcePromiseImpl(this._withRequiredCommandInternal(command, helpLink), this._client); + } + + /** @internal */ + private async _withUrlsInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrls', + rpcArgs + ); + return new AzureKeyVaultSecretResourceImpl(result, this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromiseImpl(this._withUrlsInternal(callback), this._client); + } + + /** @internal */ + private async _withUrlInternal(url: string | ReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new AzureKeyVaultSecretResourceImpl(result, this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): AzureKeyVaultSecretResourcePromise { + const displayText = options?.displayText; + return new AzureKeyVaultSecretResourcePromiseImpl(this._withUrlInternal(url, displayText), this._client); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new AzureKeyVaultSecretResourceImpl(result, this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromiseImpl(this._withUrlForEndpointInternal(endpointName, callback), this._client); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new AzureKeyVaultSecretResourceImpl(result, this._client); + } + + excludeFromManifest(): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromiseImpl(this._excludeFromManifestInternal(), this._client); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new AzureKeyVaultSecretResourceImpl(result, this._client); + } + + withExplicitStart(): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromiseImpl(this._withExplicitStartInternal(), this._client); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new AzureKeyVaultSecretResourceImpl(result, this._client); + } + + withHealthCheck(key: string): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromiseImpl(this._withHealthCheckInternal(key), this._client); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContextImpl(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new AzureKeyVaultSecretResourceImpl(result, this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureKeyVaultSecretResourcePromise { + const commandOptions = options?.commandOptions; + return new AzureKeyVaultSecretResourcePromiseImpl(this._withCommandInternal(name, displayName, executeCommand, commandOptions), this._client); + } + + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: Awaitable, type: string): Promise { + resourceBuilder = isPromiseLike(resourceBuilder) ? await resourceBuilder : resourceBuilder; + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureKeyVaultSecretResourceImpl(result, this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromiseImpl(this._withRelationshipInternal(resourceBuilder, type), this._client); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: Awaitable): Promise { + parent = isPromiseLike(parent) ? await parent : parent; + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new AzureKeyVaultSecretResourceImpl(result, this._client); + } + + withParentRelationship(parent: Awaitable): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromiseImpl(this._withParentRelationshipInternal(parent), this._client); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: Awaitable): Promise { + child = isPromiseLike(child) ? await child : child; + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', + rpcArgs + ); + return new AzureKeyVaultSecretResourceImpl(result, this._client); + } + + withChildRelationship(child: Awaitable): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromiseImpl(this._withChildRelationshipInternal(child), this._client); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new AzureKeyVaultSecretResourceImpl(result, this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): AzureKeyVaultSecretResourcePromise { + const iconVariant = options?.iconVariant; + return new AzureKeyVaultSecretResourcePromiseImpl(this._withIconNameInternal(iconName, iconVariant), this._client); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new AzureKeyVaultSecretResourceImpl(result, this._client); + } + + excludeFromMcp(): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromiseImpl(this._excludeFromMcpInternal(), this._client); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new AzureKeyVaultSecretResourceImpl(result, this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureKeyVaultSecretResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new AzureKeyVaultSecretResourcePromiseImpl(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description), this._client); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new AzureKeyVaultSecretResourceImpl(result, this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromiseImpl(this._withPipelineConfigurationInternal(callback), this._client); + } + + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); + } + + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new AzureKeyVaultSecretResourceImpl(result, this._client); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromiseImpl(this._onBeforeResourceStartedInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new AzureKeyVaultSecretResourceImpl(result, this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromiseImpl(this._onResourceStoppedInternal(callback), this._client); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new AzureKeyVaultSecretResourceImpl(result, this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromiseImpl(this._onInitializeResourceInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new AzureKeyVaultSecretResourceImpl(result, this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromiseImpl(this._onResourceReadyInternal(callback), this._client); + } + + async createExecutionConfiguration(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/createExecutionConfiguration', + rpcArgs + ); + } + + /** @internal */ + private async _withLikeC4DetailsInternal(label?: string, technology?: string, description?: string, summary?: string, icon?: string, configure?: (obj: LikeC4NodeDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4NodeDetailsAnnotationHandle; + const obj = new LikeC4NodeDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + const rpcArgs: Record = { builder: this._handle }; + if (label !== undefined) rpcArgs.label = label; + if (technology !== undefined) rpcArgs.technology = technology; + if (description !== undefined) rpcArgs.description = description; + if (summary !== undefined) rpcArgs.summary = summary; + if (icon !== undefined) rpcArgs.icon = icon; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4DetailsParameters', + rpcArgs + ); + return new AzureKeyVaultSecretResourceImpl(result, this._client); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): AzureKeyVaultSecretResourcePromise { + const label = options?.label; + const technology = options?.technology; + const description = options?.description; + const summary = options?.summary; + const icon = options?.icon; + const configure = options?.configure; + return new AzureKeyVaultSecretResourcePromiseImpl(this._withLikeC4DetailsInternal(label, technology, description, summary, icon, configure), this._client); + } + + /** @internal */ + private async _withLikeC4ReferenceInternal(target: Awaitable, configure?: (obj: LikeC4RelationshipDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4RelationshipDetailsAnnotationHandle; + const obj = new LikeC4RelationshipDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target }; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Reference', + rpcArgs + ); + return new AzureKeyVaultSecretResourceImpl(result, this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): AzureKeyVaultSecretResourcePromise { + const configure = options?.configure; + return new AzureKeyVaultSecretResourcePromiseImpl(this._withLikeC4ReferenceInternal(target, configure), this._client); + } + + /** @internal */ + private async _withLikeC4GroupInternal(groupName: string): Promise { + const rpcArgs: Record = { builder: this._handle, groupName }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Group', + rpcArgs + ); + return new AzureKeyVaultSecretResourceImpl(result, this._client); + } + + withLikeC4Group(groupName: string): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromiseImpl(this._withLikeC4GroupInternal(groupName), this._client); + } + + /** @internal */ + private async _excludeFromLikeC4Internal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/excludeFromLikeC4', + rpcArgs + ); + return new AzureKeyVaultSecretResourceImpl(result, this._client); + } + + excludeFromLikeC4(): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromiseImpl(this._excludeFromLikeC4Internal(), this._client); + } + + /** @internal */ + private async _withRoleAssignmentsInternal(target: Awaitable, roles: AzureKeyVaultRole[]): Promise { + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target, roles }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.KeyVault/withKeyVaultRoleAssignments', + rpcArgs + ); + return new AzureKeyVaultSecretResourceImpl(result, this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromiseImpl(this._withRoleAssignmentsInternal(target, roles), this._client); + } + +} + +/** + * Thenable wrapper for AzureKeyVaultSecretResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +class AzureKeyVaultSecretResourcePromiseImpl implements AzureKeyVaultSecretResourcePromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: AzureKeyVaultSecretResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + withContainerRegistry(registry: Awaitable): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromiseImpl(this._promise.then(obj => obj.withContainerRegistry(registry)), this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromiseImpl(this._promise.then(obj => obj.withDockerfileBaseImage(options)), this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromiseImpl(this._promise.then(obj => obj.withRequiredCommand(command, options)), this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromiseImpl(this._promise.then(obj => obj.withUrls(callback)), this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromiseImpl(this._promise.then(obj => obj.withUrl(url, options)), this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromiseImpl(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback)), this._client); + } + + excludeFromManifest(): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromiseImpl(this._promise.then(obj => obj.excludeFromManifest()), this._client); + } + + withExplicitStart(): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromiseImpl(this._promise.then(obj => obj.withExplicitStart()), this._client); + } + + withHealthCheck(key: string): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromiseImpl(this._promise.then(obj => obj.withHealthCheck(key)), this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromiseImpl(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options)), this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromiseImpl(this._promise.then(obj => obj.withRelationship(resourceBuilder, type)), this._client); + } + + withParentRelationship(parent: Awaitable): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromiseImpl(this._promise.then(obj => obj.withParentRelationship(parent)), this._client); + } + + withChildRelationship(child: Awaitable): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromiseImpl(this._promise.then(obj => obj.withChildRelationship(child)), this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromiseImpl(this._promise.then(obj => obj.withIconName(iconName, options)), this._client); + } + + excludeFromMcp(): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromiseImpl(this._promise.then(obj => obj.excludeFromMcp()), this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromiseImpl(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options)), this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromiseImpl(this._promise.then(obj => obj.withPipelineConfiguration(callback)), this._client); + } + + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromiseImpl(this._promise.then(obj => obj.onBeforeResourceStarted(callback)), this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromiseImpl(this._promise.then(obj => obj.onResourceStopped(callback)), this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromiseImpl(this._promise.then(obj => obj.onInitializeResource(callback)), this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromiseImpl(this._promise.then(obj => obj.onResourceReady(callback)), this._client); + } + + createExecutionConfiguration(): Promise { + return this._promise.then(obj => obj.createExecutionConfiguration()); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Details(options)), this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Reference(target, options)), this._client); + } + + withLikeC4Group(groupName: string): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Group(groupName)), this._client); + } + + excludeFromLikeC4(): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromiseImpl(this._promise.then(obj => obj.excludeFromLikeC4()), this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromiseImpl(this._promise.then(obj => obj.withRoleAssignments(target, roles)), this._client); + } + +} + +// ============================================================================ +// AzureManagedRedisResource +// ============================================================================ + +export interface AzureManagedRedisResource { + toJSON(): MarshalledHandle; + /** Gets the NameOutputReference property */ + nameOutputReference(): Promise; + /** Gets the Id property */ + id(): Promise; + /** Gets the UseAccessKeyAuthentication property */ + useAccessKeyAuthentication(): Promise; + /** Gets the ConnectionStringExpression property */ + connectionStringExpression(): Promise; + /** Gets the HostName property */ + hostName(): Promise; + /** Gets the Port property */ + port(): Promise; + /** Gets the Password property */ + password(): Promise; + /** Gets the UriExpression property */ + uriExpression(): Promise; + /** Gets the Parameters property */ + parameters(): Promise>; + /** Gets the Outputs property */ + outputs(): Promise>; + /** Gets the SecretOutputs property */ + secretOutputs(): Promise>; + /** Gets the Name property */ + name(): Promise; + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): AzureManagedRedisResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureManagedRedisResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureManagedRedisResourcePromise; + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureManagedRedisResourcePromise; + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureManagedRedisResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): AzureManagedRedisResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureManagedRedisResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): AzureManagedRedisResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): AzureManagedRedisResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): AzureManagedRedisResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureManagedRedisResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): AzureManagedRedisResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): AzureManagedRedisResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): AzureManagedRedisResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): AzureManagedRedisResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): AzureManagedRedisResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureManagedRedisResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureManagedRedisResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureManagedRedisResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureManagedRedisResourcePromise; + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureManagedRedisResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureManagedRedisResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureManagedRedisResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Configures Azure Managed Redis to run in a local container */ + runAsContainer(options?: RunAsContainerOptions): AzureManagedRedisResourcePromise; + /** Configures Azure Managed Redis to use access key authentication */ + withAccessKeyAuthentication(options?: WithAccessKeyAuthenticationOptions): AzureManagedRedisResourcePromise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): AzureManagedRedisResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): AzureManagedRedisResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): AzureManagedRedisResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): AzureManagedRedisResourcePromise; + /** Gets an output reference from an Azure Bicep template resource */ + getOutput(name: string): Promise; + /** Adds a Bicep parameter */ + withParameter(name: string, options?: WithParameterOptions): AzureManagedRedisResourcePromise; + /** Configures the Azure provisioning infrastructure callback */ + configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzureManagedRedisResourcePromise; + /** Publishes an Azure resource to the manifest as a connection string */ + publishAsConnectionString(): AzureManagedRedisResourcePromise; + /** Gets the normalized Bicep identifier for an Azure resource */ + getBicepIdentifier(): Promise; + /** Clears the default Azure role assignments from a resource */ + clearDefaultRoleAssignments(): AzureManagedRedisResourcePromise; + /** Determines whether a resource is marked as existing */ + isExisting(): Promise; + /** Marks an Azure resource as existing in run mode */ + runAsExisting(name: string | ParameterResource | Awaitable, options?: RunAsExistingOptions): AzureManagedRedisResourcePromise; + /** Marks an Azure resource as existing in publish mode */ + publishAsExisting(name: string | ParameterResource | Awaitable, options?: PublishAsExistingOptions): AzureManagedRedisResourcePromise; + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource | Awaitable, options?: AsExistingOptions): AzureManagedRedisResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): AzureManagedRedisResourcePromise; +} + +export interface AzureManagedRedisResourcePromise extends PromiseLike { + /** Gets the NameOutputReference property */ + nameOutputReference(): Promise; + /** Gets the Id property */ + id(): Promise; + /** Gets the UseAccessKeyAuthentication property */ + useAccessKeyAuthentication(): Promise; + /** Gets the ConnectionStringExpression property */ + connectionStringExpression(): Promise; + /** Gets the HostName property */ + hostName(): Promise; + /** Gets the Port property */ + port(): Promise; + /** Gets the Password property */ + password(): Promise; + /** Gets the UriExpression property */ + uriExpression(): Promise; + /** Gets the Parameters property */ + parameters(): Promise>; + /** Gets the Outputs property */ + outputs(): Promise>; + /** Gets the SecretOutputs property */ + secretOutputs(): Promise>; + /** Gets the Name property */ + name(): Promise; + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): AzureManagedRedisResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureManagedRedisResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureManagedRedisResourcePromise; + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureManagedRedisResourcePromise; + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureManagedRedisResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): AzureManagedRedisResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureManagedRedisResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): AzureManagedRedisResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): AzureManagedRedisResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): AzureManagedRedisResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureManagedRedisResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): AzureManagedRedisResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): AzureManagedRedisResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): AzureManagedRedisResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): AzureManagedRedisResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): AzureManagedRedisResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureManagedRedisResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureManagedRedisResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureManagedRedisResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureManagedRedisResourcePromise; + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureManagedRedisResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureManagedRedisResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureManagedRedisResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Configures Azure Managed Redis to run in a local container */ + runAsContainer(options?: RunAsContainerOptions): AzureManagedRedisResourcePromise; + /** Configures Azure Managed Redis to use access key authentication */ + withAccessKeyAuthentication(options?: WithAccessKeyAuthenticationOptions): AzureManagedRedisResourcePromise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): AzureManagedRedisResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): AzureManagedRedisResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): AzureManagedRedisResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): AzureManagedRedisResourcePromise; + /** Gets an output reference from an Azure Bicep template resource */ + getOutput(name: string): Promise; + /** Adds a Bicep parameter */ + withParameter(name: string, options?: WithParameterOptions): AzureManagedRedisResourcePromise; + /** Configures the Azure provisioning infrastructure callback */ + configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzureManagedRedisResourcePromise; + /** Publishes an Azure resource to the manifest as a connection string */ + publishAsConnectionString(): AzureManagedRedisResourcePromise; + /** Gets the normalized Bicep identifier for an Azure resource */ + getBicepIdentifier(): Promise; + /** Clears the default Azure role assignments from a resource */ + clearDefaultRoleAssignments(): AzureManagedRedisResourcePromise; + /** Determines whether a resource is marked as existing */ + isExisting(): Promise; + /** Marks an Azure resource as existing in run mode */ + runAsExisting(name: string | ParameterResource | Awaitable, options?: RunAsExistingOptions): AzureManagedRedisResourcePromise; + /** Marks an Azure resource as existing in publish mode */ + publishAsExisting(name: string | ParameterResource | Awaitable, options?: PublishAsExistingOptions): AzureManagedRedisResourcePromise; + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource | Awaitable, options?: AsExistingOptions): AzureManagedRedisResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): AzureManagedRedisResourcePromise; +} + +// ============================================================================ +// AzureManagedRedisResourceImpl +// ============================================================================ + +class AzureManagedRedisResourceImpl extends ResourceBuilderBase implements AzureManagedRedisResource { + constructor(handle: AzureManagedRedisResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + async nameOutputReference(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/AzureManagedRedisResource.nameOutputReference', + { context: this._handle } + ); + return new BicepOutputReferenceImpl(handle, this._client); + } + + async id(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/AzureManagedRedisResource.id', + { context: this._handle } + ); + return new BicepOutputReferenceImpl(handle, this._client); + } + + async useAccessKeyAuthentication(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/AzureManagedRedisResource.useAccessKeyAuthentication', + { context: this._handle } + ); + } + + async connectionStringExpression(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/AzureManagedRedisResource.connectionStringExpression', + { context: this._handle } + ); + } + + async hostName(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/AzureManagedRedisResource.hostName', + { context: this._handle } + ); + } + + async port(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/AzureManagedRedisResource.port', + { context: this._handle } + ); + } + + async password(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/AzureManagedRedisResource.password', + { context: this._handle } + ); + } + + async uriExpression(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/AzureManagedRedisResource.uriExpression', + { context: this._handle } + ); + } + + private _parameters?: AspireDict; + async parameters(): Promise> { + if (!this._parameters) { + this._parameters = new AspireDict( + this._handle, + this._client, + 'Aspire.Hosting.Azure/AzureManagedRedisResource.parameters', + 'Aspire.Hosting.Azure/AzureManagedRedisResource.parameters' + ); + } + return this._parameters; + } + + private _outputs?: AspireDict; + async outputs(): Promise> { + if (!this._outputs) { + this._outputs = new AspireDict( + this._handle, + this._client, + 'Aspire.Hosting.Azure/AzureManagedRedisResource.outputs', + 'Aspire.Hosting.Azure/AzureManagedRedisResource.outputs' + ); + } + return this._outputs; + } + + private _secretOutputs?: AspireDict; + async secretOutputs(): Promise> { + if (!this._secretOutputs) { + this._secretOutputs = new AspireDict( + this._handle, + this._client, + 'Aspire.Hosting.Azure/AzureManagedRedisResource.secretOutputs', + 'Aspire.Hosting.Azure/AzureManagedRedisResource.secretOutputs' + ); + } + return this._secretOutputs; + } + + async name(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/AzureManagedRedisResource.name', + { context: this._handle } + ); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: Awaitable): Promise { + registry = isPromiseLike(registry) ? await registry : registry; + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new AzureManagedRedisResourceImpl(result, this._client); + } + + withContainerRegistry(registry: Awaitable): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._withContainerRegistryInternal(registry), this._client); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new AzureManagedRedisResourceImpl(result, this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureManagedRedisResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new AzureManagedRedisResourcePromiseImpl(this._withDockerfileBaseImageInternal(buildImage, runtimeImage), this._client); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new AzureManagedRedisResourceImpl(result, this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureManagedRedisResourcePromise { + const helpLink = options?.helpLink; + return new AzureManagedRedisResourcePromiseImpl(this._withRequiredCommandInternal(command, helpLink), this._client); + } + + /** @internal */ + private async _withConnectionPropertyInternal(name: string, value: string | ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withConnectionProperty', + rpcArgs + ); + return new AzureManagedRedisResourceImpl(result, this._client); + } + + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._withConnectionPropertyInternal(name, value), this._client); + } + + async getConnectionProperty(key: string): Promise { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + + /** @internal */ + private async _withUrlsInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrls', + rpcArgs + ); + return new AzureManagedRedisResourceImpl(result, this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._withUrlsInternal(callback), this._client); + } + + /** @internal */ + private async _withUrlInternal(url: string | ReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new AzureManagedRedisResourceImpl(result, this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): AzureManagedRedisResourcePromise { + const displayText = options?.displayText; + return new AzureManagedRedisResourcePromiseImpl(this._withUrlInternal(url, displayText), this._client); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new AzureManagedRedisResourceImpl(result, this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._withUrlForEndpointInternal(endpointName, callback), this._client); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new AzureManagedRedisResourceImpl(result, this._client); + } + + excludeFromManifest(): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._excludeFromManifestInternal(), this._client); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new AzureManagedRedisResourceImpl(result, this._client); + } + + withExplicitStart(): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._withExplicitStartInternal(), this._client); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new AzureManagedRedisResourceImpl(result, this._client); + } + + withHealthCheck(key: string): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._withHealthCheckInternal(key), this._client); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContextImpl(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new AzureManagedRedisResourceImpl(result, this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureManagedRedisResourcePromise { + const commandOptions = options?.commandOptions; + return new AzureManagedRedisResourcePromiseImpl(this._withCommandInternal(name, displayName, executeCommand, commandOptions), this._client); + } + + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: Awaitable, type: string): Promise { + resourceBuilder = isPromiseLike(resourceBuilder) ? await resourceBuilder : resourceBuilder; + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureManagedRedisResourceImpl(result, this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._withRelationshipInternal(resourceBuilder, type), this._client); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: Awaitable): Promise { + parent = isPromiseLike(parent) ? await parent : parent; + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new AzureManagedRedisResourceImpl(result, this._client); + } + + withParentRelationship(parent: Awaitable): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._withParentRelationshipInternal(parent), this._client); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: Awaitable): Promise { + child = isPromiseLike(child) ? await child : child; + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', + rpcArgs + ); + return new AzureManagedRedisResourceImpl(result, this._client); + } + + withChildRelationship(child: Awaitable): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._withChildRelationshipInternal(child), this._client); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new AzureManagedRedisResourceImpl(result, this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): AzureManagedRedisResourcePromise { + const iconVariant = options?.iconVariant; + return new AzureManagedRedisResourcePromiseImpl(this._withIconNameInternal(iconName, iconVariant), this._client); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new AzureManagedRedisResourceImpl(result, this._client); + } + + excludeFromMcp(): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._excludeFromMcpInternal(), this._client); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new AzureManagedRedisResourceImpl(result, this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureManagedRedisResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new AzureManagedRedisResourcePromiseImpl(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description), this._client); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new AzureManagedRedisResourceImpl(result, this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._withPipelineConfigurationInternal(callback), this._client); + } + + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); + } + + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new AzureManagedRedisResourceImpl(result, this._client); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._onBeforeResourceStartedInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new AzureManagedRedisResourceImpl(result, this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._onResourceStoppedInternal(callback), this._client); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onConnectionStringAvailable', + rpcArgs + ); + return new AzureManagedRedisResourceImpl(result, this._client); + } + + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._onConnectionStringAvailableInternal(callback), this._client); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new AzureManagedRedisResourceImpl(result, this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._onInitializeResourceInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new AzureManagedRedisResourceImpl(result, this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._onResourceReadyInternal(callback), this._client); + } + + async createExecutionConfiguration(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/createExecutionConfiguration', + rpcArgs + ); + } + + /** @internal */ + private async _runAsContainerInternal(configureContainer?: (obj: RedisResource) => Promise): Promise { + const configureContainerId = configureContainer ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as RedisResourceHandle; + const obj = new RedisResourceImpl(objHandle, this._client); + await configureContainer(obj); + }) : undefined; + const rpcArgs: Record = { builder: this._handle }; + if (configureContainer !== undefined) rpcArgs.configureContainer = configureContainerId; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Redis/runAsContainer', + rpcArgs + ); + return new AzureManagedRedisResourceImpl(result, this._client); + } + + runAsContainer(options?: RunAsContainerOptions): AzureManagedRedisResourcePromise { + const configureContainer = options?.configureContainer; + return new AzureManagedRedisResourcePromiseImpl(this._runAsContainerInternal(configureContainer), this._client); + } + + /** @internal */ + private async _withAccessKeyAuthenticationInternal(keyVaultBuilder?: Awaitable): Promise { + keyVaultBuilder = isPromiseLike(keyVaultBuilder) ? await keyVaultBuilder : keyVaultBuilder; + const rpcArgs: Record = { builder: this._handle }; + if (keyVaultBuilder !== undefined) rpcArgs.keyVaultBuilder = keyVaultBuilder; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Redis/withAccessKeyAuthentication', + rpcArgs + ); + return new AzureManagedRedisResourceImpl(result, this._client); + } + + withAccessKeyAuthentication(options?: WithAccessKeyAuthenticationOptions): AzureManagedRedisResourcePromise { + let keyVaultBuilder = options?.keyVaultBuilder; + return new AzureManagedRedisResourcePromiseImpl(this._withAccessKeyAuthenticationInternal(keyVaultBuilder), this._client); + } + + /** @internal */ + private async _withLikeC4DetailsInternal(label?: string, technology?: string, description?: string, summary?: string, icon?: string, configure?: (obj: LikeC4NodeDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4NodeDetailsAnnotationHandle; + const obj = new LikeC4NodeDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + const rpcArgs: Record = { builder: this._handle }; + if (label !== undefined) rpcArgs.label = label; + if (technology !== undefined) rpcArgs.technology = technology; + if (description !== undefined) rpcArgs.description = description; + if (summary !== undefined) rpcArgs.summary = summary; + if (icon !== undefined) rpcArgs.icon = icon; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4DetailsParameters', + rpcArgs + ); + return new AzureManagedRedisResourceImpl(result, this._client); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): AzureManagedRedisResourcePromise { + const label = options?.label; + const technology = options?.technology; + const description = options?.description; + const summary = options?.summary; + const icon = options?.icon; + const configure = options?.configure; + return new AzureManagedRedisResourcePromiseImpl(this._withLikeC4DetailsInternal(label, technology, description, summary, icon, configure), this._client); + } + + /** @internal */ + private async _withLikeC4ReferenceInternal(target: Awaitable, configure?: (obj: LikeC4RelationshipDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4RelationshipDetailsAnnotationHandle; + const obj = new LikeC4RelationshipDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target }; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Reference', + rpcArgs + ); + return new AzureManagedRedisResourceImpl(result, this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): AzureManagedRedisResourcePromise { + const configure = options?.configure; + return new AzureManagedRedisResourcePromiseImpl(this._withLikeC4ReferenceInternal(target, configure), this._client); + } + + /** @internal */ + private async _withLikeC4GroupInternal(groupName: string): Promise { + const rpcArgs: Record = { builder: this._handle, groupName }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Group', + rpcArgs + ); + return new AzureManagedRedisResourceImpl(result, this._client); + } + + withLikeC4Group(groupName: string): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._withLikeC4GroupInternal(groupName), this._client); + } + + /** @internal */ + private async _excludeFromLikeC4Internal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/excludeFromLikeC4', + rpcArgs + ); + return new AzureManagedRedisResourceImpl(result, this._client); + } + + excludeFromLikeC4(): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._excludeFromLikeC4Internal(), this._client); + } + + async getOutput(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/getOutput', + rpcArgs + ); + } + + /** @internal */ + private async _withParameterInternal(name: string, value?: string | string[] | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | BicepOutputReference | ReferenceExpression | EndpointReference | Awaitable): Promise { + value = isPromiseLike(value) ? await value : value; + const rpcArgs: Record = { builder: this._handle, name }; + if (value !== undefined) rpcArgs.value = value; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameter', + rpcArgs + ); + return new AzureManagedRedisResourceImpl(result, this._client); + } + + withParameter(name: string, options?: WithParameterOptions): AzureManagedRedisResourcePromise { + let value = options?.value; + return new AzureManagedRedisResourcePromiseImpl(this._withParameterInternal(name, value), this._client); + } + + /** @internal */ + private async _configureInfrastructureInternal(configure: (obj: AzureResourceInfrastructure) => Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as AzureResourceInfrastructureHandle; + const obj = new AzureResourceInfrastructureImpl(objHandle, this._client); + await configure(obj); + }); + const rpcArgs: Record = { builder: this._handle, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/configureInfrastructure', + rpcArgs + ); + return new AzureManagedRedisResourceImpl(result, this._client); + } + + configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._configureInfrastructureInternal(configure), this._client); + } + + /** @internal */ + private async _publishAsConnectionStringInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/publishAsConnectionString', + rpcArgs + ); + return new AzureManagedRedisResourceImpl(result, this._client); + } + + publishAsConnectionString(): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._publishAsConnectionStringInternal(), this._client); + } + + async getBicepIdentifier(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/getBicepIdentifier', + rpcArgs + ); + } + + /** @internal */ + private async _clearDefaultRoleAssignmentsInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/clearDefaultRoleAssignments', + rpcArgs + ); + return new AzureManagedRedisResourceImpl(result, this._client); + } + + clearDefaultRoleAssignments(): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._clearDefaultRoleAssignmentsInternal(), this._client); + } + + async isExisting(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/isExisting', + rpcArgs + ); + } + + /** @internal */ + private async _runAsExistingInternal(name: string | ParameterResource | Awaitable, resourceGroup?: string | ParameterResource | Awaitable): Promise { + name = isPromiseLike(name) ? await name : name; + resourceGroup = isPromiseLike(resourceGroup) ? await resourceGroup : resourceGroup; + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/runAsExisting', + rpcArgs + ); + return new AzureManagedRedisResourceImpl(result, this._client); + } + + runAsExisting(name: string | ParameterResource | Awaitable, options?: RunAsExistingOptions): AzureManagedRedisResourcePromise { + let resourceGroup = options?.resourceGroup; + return new AzureManagedRedisResourcePromiseImpl(this._runAsExistingInternal(name, resourceGroup), this._client); + } + + /** @internal */ + private async _publishAsExistingInternal(name: string | ParameterResource | Awaitable, resourceGroup?: string | ParameterResource | Awaitable): Promise { + name = isPromiseLike(name) ? await name : name; + resourceGroup = isPromiseLike(resourceGroup) ? await resourceGroup : resourceGroup; + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/publishAsExisting', + rpcArgs + ); + return new AzureManagedRedisResourceImpl(result, this._client); + } + + publishAsExisting(name: string | ParameterResource | Awaitable, options?: PublishAsExistingOptions): AzureManagedRedisResourcePromise { + let resourceGroup = options?.resourceGroup; + return new AzureManagedRedisResourcePromiseImpl(this._publishAsExistingInternal(name, resourceGroup), this._client); + } + + /** @internal */ + private async _asExistingInternal(name: string | ParameterResource | Awaitable, resourceGroup?: string | ParameterResource | Awaitable): Promise { + name = isPromiseLike(name) ? await name : name; + resourceGroup = isPromiseLike(resourceGroup) ? await resourceGroup : resourceGroup; + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/asExisting', + rpcArgs + ); + return new AzureManagedRedisResourceImpl(result, this._client); + } + + asExisting(name: string | ParameterResource | Awaitable, options?: AsExistingOptions): AzureManagedRedisResourcePromise { + let resourceGroup = options?.resourceGroup; + return new AzureManagedRedisResourcePromiseImpl(this._asExistingInternal(name, resourceGroup), this._client); + } + + /** @internal */ + private async _withRoleAssignmentsInternal(target: Awaitable, roles: AzureKeyVaultRole[]): Promise { + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target, roles }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.KeyVault/withKeyVaultRoleAssignments', + rpcArgs + ); + return new AzureManagedRedisResourceImpl(result, this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._withRoleAssignmentsInternal(target, roles), this._client); + } + +} + +/** + * Thenable wrapper for AzureManagedRedisResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +class AzureManagedRedisResourcePromiseImpl implements AzureManagedRedisResourcePromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: AzureManagedRedisResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + nameOutputReference(): Promise { + return this._promise.then(obj => obj.nameOutputReference()); + } + + id(): Promise { + return this._promise.then(obj => obj.id()); + } + + useAccessKeyAuthentication(): Promise { + return this._promise.then(obj => obj.useAccessKeyAuthentication()); + } + + connectionStringExpression(): Promise { + return this._promise.then(obj => obj.connectionStringExpression()); + } + + hostName(): Promise { + return this._promise.then(obj => obj.hostName()); + } + + port(): Promise { + return this._promise.then(obj => obj.port()); + } + + password(): Promise { + return this._promise.then(obj => obj.password()); + } + + uriExpression(): Promise { + return this._promise.then(obj => obj.uriExpression()); + } + + parameters(): Promise> { + return this._promise.then(obj => obj.parameters()); + } + + outputs(): Promise> { + return this._promise.then(obj => obj.outputs()); + } + + secretOutputs(): Promise> { + return this._promise.then(obj => obj.secretOutputs()); + } + + name(): Promise { + return this._promise.then(obj => obj.name()); + } + + withContainerRegistry(registry: Awaitable): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._promise.then(obj => obj.withContainerRegistry(registry)), this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._promise.then(obj => obj.withDockerfileBaseImage(options)), this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._promise.then(obj => obj.withRequiredCommand(command, options)), this._client); + } + + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._promise.then(obj => obj.withConnectionProperty(name, value)), this._client); + } + + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._promise.then(obj => obj.withUrls(callback)), this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._promise.then(obj => obj.withUrl(url, options)), this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback)), this._client); + } + + excludeFromManifest(): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._promise.then(obj => obj.excludeFromManifest()), this._client); + } + + withExplicitStart(): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._promise.then(obj => obj.withExplicitStart()), this._client); + } + + withHealthCheck(key: string): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._promise.then(obj => obj.withHealthCheck(key)), this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options)), this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._promise.then(obj => obj.withRelationship(resourceBuilder, type)), this._client); + } + + withParentRelationship(parent: Awaitable): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._promise.then(obj => obj.withParentRelationship(parent)), this._client); + } + + withChildRelationship(child: Awaitable): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._promise.then(obj => obj.withChildRelationship(child)), this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._promise.then(obj => obj.withIconName(iconName, options)), this._client); + } + + excludeFromMcp(): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._promise.then(obj => obj.excludeFromMcp()), this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options)), this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._promise.then(obj => obj.withPipelineConfiguration(callback)), this._client); + } + + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._promise.then(obj => obj.onBeforeResourceStarted(callback)), this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._promise.then(obj => obj.onResourceStopped(callback)), this._client); + } + + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._promise.then(obj => obj.onConnectionStringAvailable(callback)), this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._promise.then(obj => obj.onInitializeResource(callback)), this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._promise.then(obj => obj.onResourceReady(callback)), this._client); + } + + createExecutionConfiguration(): Promise { + return this._promise.then(obj => obj.createExecutionConfiguration()); + } + + runAsContainer(options?: RunAsContainerOptions): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._promise.then(obj => obj.runAsContainer(options)), this._client); + } + + withAccessKeyAuthentication(options?: WithAccessKeyAuthenticationOptions): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._promise.then(obj => obj.withAccessKeyAuthentication(options)), this._client); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Details(options)), this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Reference(target, options)), this._client); + } + + withLikeC4Group(groupName: string): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Group(groupName)), this._client); + } + + excludeFromLikeC4(): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._promise.then(obj => obj.excludeFromLikeC4()), this._client); + } + + getOutput(name: string): Promise { + return this._promise.then(obj => obj.getOutput(name)); + } + + withParameter(name: string, options?: WithParameterOptions): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._promise.then(obj => obj.withParameter(name, options)), this._client); + } + + configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._promise.then(obj => obj.configureInfrastructure(configure)), this._client); + } + + publishAsConnectionString(): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._promise.then(obj => obj.publishAsConnectionString()), this._client); + } + + getBicepIdentifier(): Promise { + return this._promise.then(obj => obj.getBicepIdentifier()); + } + + clearDefaultRoleAssignments(): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._promise.then(obj => obj.clearDefaultRoleAssignments()), this._client); + } + + isExisting(): Promise { + return this._promise.then(obj => obj.isExisting()); + } + + runAsExisting(name: string | ParameterResource | Awaitable, options?: RunAsExistingOptions): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._promise.then(obj => obj.runAsExisting(name, options)), this._client); + } + + publishAsExisting(name: string | ParameterResource | Awaitable, options?: PublishAsExistingOptions): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._promise.then(obj => obj.publishAsExisting(name, options)), this._client); + } + + asExisting(name: string | ParameterResource | Awaitable, options?: AsExistingOptions): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._promise.then(obj => obj.asExisting(name, options)), this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromiseImpl(this._promise.then(obj => obj.withRoleAssignments(target, roles)), this._client); + } + +} + +// ============================================================================ +// AzurePostgresFlexibleServerDatabaseResource +// ============================================================================ + +export interface AzurePostgresFlexibleServerDatabaseResource { + toJSON(): MarshalledHandle; + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Adds a Postgres MCP server container */ + withPostgresMcp(options?: WithPostgresMcpOptions): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): AzurePostgresFlexibleServerDatabaseResourcePromise; +} + +export interface AzurePostgresFlexibleServerDatabaseResourcePromise extends PromiseLike { + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Adds a Postgres MCP server container */ + withPostgresMcp(options?: WithPostgresMcpOptions): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): AzurePostgresFlexibleServerDatabaseResourcePromise; +} + +// ============================================================================ +// AzurePostgresFlexibleServerDatabaseResourceImpl +// ============================================================================ + +class AzurePostgresFlexibleServerDatabaseResourceImpl extends ResourceBuilderBase implements AzurePostgresFlexibleServerDatabaseResource { + constructor(handle: AzurePostgresFlexibleServerDatabaseResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: Awaitable): Promise { + registry = isPromiseLike(registry) ? await registry : registry; + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new AzurePostgresFlexibleServerDatabaseResourceImpl(result, this._client); + } + + withContainerRegistry(registry: Awaitable): AzurePostgresFlexibleServerDatabaseResourcePromise { + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._withContainerRegistryInternal(registry), this._client); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new AzurePostgresFlexibleServerDatabaseResourceImpl(result, this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzurePostgresFlexibleServerDatabaseResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._withDockerfileBaseImageInternal(buildImage, runtimeImage), this._client); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new AzurePostgresFlexibleServerDatabaseResourceImpl(result, this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzurePostgresFlexibleServerDatabaseResourcePromise { + const helpLink = options?.helpLink; + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._withRequiredCommandInternal(command, helpLink), this._client); + } + + /** @internal */ + private async _withConnectionPropertyInternal(name: string, value: string | ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withConnectionProperty', + rpcArgs + ); + return new AzurePostgresFlexibleServerDatabaseResourceImpl(result, this._client); + } + + withConnectionProperty(name: string, value: string | ReferenceExpression): AzurePostgresFlexibleServerDatabaseResourcePromise { + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._withConnectionPropertyInternal(name, value), this._client); + } + + async getConnectionProperty(key: string): Promise { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + + /** @internal */ + private async _withUrlsInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrls', + rpcArgs + ); + return new AzurePostgresFlexibleServerDatabaseResourceImpl(result, this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzurePostgresFlexibleServerDatabaseResourcePromise { + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._withUrlsInternal(callback), this._client); + } + + /** @internal */ + private async _withUrlInternal(url: string | ReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new AzurePostgresFlexibleServerDatabaseResourceImpl(result, this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): AzurePostgresFlexibleServerDatabaseResourcePromise { + const displayText = options?.displayText; + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._withUrlInternal(url, displayText), this._client); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new AzurePostgresFlexibleServerDatabaseResourceImpl(result, this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzurePostgresFlexibleServerDatabaseResourcePromise { + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._withUrlForEndpointInternal(endpointName, callback), this._client); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new AzurePostgresFlexibleServerDatabaseResourceImpl(result, this._client); + } + + excludeFromManifest(): AzurePostgresFlexibleServerDatabaseResourcePromise { + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._excludeFromManifestInternal(), this._client); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new AzurePostgresFlexibleServerDatabaseResourceImpl(result, this._client); + } + + withExplicitStart(): AzurePostgresFlexibleServerDatabaseResourcePromise { + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._withExplicitStartInternal(), this._client); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new AzurePostgresFlexibleServerDatabaseResourceImpl(result, this._client); + } + + withHealthCheck(key: string): AzurePostgresFlexibleServerDatabaseResourcePromise { + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._withHealthCheckInternal(key), this._client); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContextImpl(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new AzurePostgresFlexibleServerDatabaseResourceImpl(result, this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzurePostgresFlexibleServerDatabaseResourcePromise { + const commandOptions = options?.commandOptions; + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._withCommandInternal(name, displayName, executeCommand, commandOptions), this._client); + } + + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: Awaitable, type: string): Promise { + resourceBuilder = isPromiseLike(resourceBuilder) ? await resourceBuilder : resourceBuilder; + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzurePostgresFlexibleServerDatabaseResourceImpl(result, this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): AzurePostgresFlexibleServerDatabaseResourcePromise { + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._withRelationshipInternal(resourceBuilder, type), this._client); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: Awaitable): Promise { + parent = isPromiseLike(parent) ? await parent : parent; + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new AzurePostgresFlexibleServerDatabaseResourceImpl(result, this._client); + } + + withParentRelationship(parent: Awaitable): AzurePostgresFlexibleServerDatabaseResourcePromise { + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._withParentRelationshipInternal(parent), this._client); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: Awaitable): Promise { + child = isPromiseLike(child) ? await child : child; + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', + rpcArgs + ); + return new AzurePostgresFlexibleServerDatabaseResourceImpl(result, this._client); + } + + withChildRelationship(child: Awaitable): AzurePostgresFlexibleServerDatabaseResourcePromise { + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._withChildRelationshipInternal(child), this._client); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new AzurePostgresFlexibleServerDatabaseResourceImpl(result, this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): AzurePostgresFlexibleServerDatabaseResourcePromise { + const iconVariant = options?.iconVariant; + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._withIconNameInternal(iconName, iconVariant), this._client); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new AzurePostgresFlexibleServerDatabaseResourceImpl(result, this._client); + } + + excludeFromMcp(): AzurePostgresFlexibleServerDatabaseResourcePromise { + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._excludeFromMcpInternal(), this._client); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new AzurePostgresFlexibleServerDatabaseResourceImpl(result, this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzurePostgresFlexibleServerDatabaseResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description), this._client); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new AzurePostgresFlexibleServerDatabaseResourceImpl(result, this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzurePostgresFlexibleServerDatabaseResourcePromise { + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._withPipelineConfigurationInternal(callback), this._client); + } + + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); + } + + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new AzurePostgresFlexibleServerDatabaseResourceImpl(result, this._client); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzurePostgresFlexibleServerDatabaseResourcePromise { + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._onBeforeResourceStartedInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new AzurePostgresFlexibleServerDatabaseResourceImpl(result, this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzurePostgresFlexibleServerDatabaseResourcePromise { + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._onResourceStoppedInternal(callback), this._client); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onConnectionStringAvailable', + rpcArgs + ); + return new AzurePostgresFlexibleServerDatabaseResourceImpl(result, this._client); + } + + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzurePostgresFlexibleServerDatabaseResourcePromise { + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._onConnectionStringAvailableInternal(callback), this._client); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new AzurePostgresFlexibleServerDatabaseResourceImpl(result, this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzurePostgresFlexibleServerDatabaseResourcePromise { + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._onInitializeResourceInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new AzurePostgresFlexibleServerDatabaseResourceImpl(result, this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzurePostgresFlexibleServerDatabaseResourcePromise { + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._onResourceReadyInternal(callback), this._client); + } + + async createExecutionConfiguration(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/createExecutionConfiguration', + rpcArgs + ); + } + + /** @internal */ + private async _withPostgresMcpInternal(configureContainer?: (obj: PostgresMcpContainerResource) => Promise, containerName?: string): Promise { + const configureContainerId = configureContainer ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PostgresMcpContainerResourceHandle; + const obj = new PostgresMcpContainerResourceImpl(objHandle, this._client); + await configureContainer(obj); + }) : undefined; + const rpcArgs: Record = { builder: this._handle }; + if (configureContainer !== undefined) rpcArgs.configureContainer = configureContainerId; + if (containerName !== undefined) rpcArgs.containerName = containerName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.PostgreSQL/withPostgresMcp', + rpcArgs + ); + return new AzurePostgresFlexibleServerDatabaseResourceImpl(result, this._client); + } + + withPostgresMcp(options?: WithPostgresMcpOptions): AzurePostgresFlexibleServerDatabaseResourcePromise { + const configureContainer = options?.configureContainer; + const containerName = options?.containerName; + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._withPostgresMcpInternal(configureContainer, containerName), this._client); + } + + /** @internal */ + private async _withLikeC4DetailsInternal(label?: string, technology?: string, description?: string, summary?: string, icon?: string, configure?: (obj: LikeC4NodeDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4NodeDetailsAnnotationHandle; + const obj = new LikeC4NodeDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + const rpcArgs: Record = { builder: this._handle }; + if (label !== undefined) rpcArgs.label = label; + if (technology !== undefined) rpcArgs.technology = technology; + if (description !== undefined) rpcArgs.description = description; + if (summary !== undefined) rpcArgs.summary = summary; + if (icon !== undefined) rpcArgs.icon = icon; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4DetailsParameters', + rpcArgs + ); + return new AzurePostgresFlexibleServerDatabaseResourceImpl(result, this._client); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): AzurePostgresFlexibleServerDatabaseResourcePromise { + const label = options?.label; + const technology = options?.technology; + const description = options?.description; + const summary = options?.summary; + const icon = options?.icon; + const configure = options?.configure; + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._withLikeC4DetailsInternal(label, technology, description, summary, icon, configure), this._client); + } + + /** @internal */ + private async _withLikeC4ReferenceInternal(target: Awaitable, configure?: (obj: LikeC4RelationshipDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4RelationshipDetailsAnnotationHandle; + const obj = new LikeC4RelationshipDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target }; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Reference', + rpcArgs + ); + return new AzurePostgresFlexibleServerDatabaseResourceImpl(result, this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): AzurePostgresFlexibleServerDatabaseResourcePromise { + const configure = options?.configure; + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._withLikeC4ReferenceInternal(target, configure), this._client); + } + + /** @internal */ + private async _withLikeC4GroupInternal(groupName: string): Promise { + const rpcArgs: Record = { builder: this._handle, groupName }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Group', + rpcArgs + ); + return new AzurePostgresFlexibleServerDatabaseResourceImpl(result, this._client); + } + + withLikeC4Group(groupName: string): AzurePostgresFlexibleServerDatabaseResourcePromise { + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._withLikeC4GroupInternal(groupName), this._client); + } + + /** @internal */ + private async _excludeFromLikeC4Internal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/excludeFromLikeC4', + rpcArgs + ); + return new AzurePostgresFlexibleServerDatabaseResourceImpl(result, this._client); + } + + excludeFromLikeC4(): AzurePostgresFlexibleServerDatabaseResourcePromise { + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._excludeFromLikeC4Internal(), this._client); + } + + /** @internal */ + private async _withRoleAssignmentsInternal(target: Awaitable, roles: AzureKeyVaultRole[]): Promise { + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target, roles }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.KeyVault/withKeyVaultRoleAssignments', + rpcArgs + ); + return new AzurePostgresFlexibleServerDatabaseResourceImpl(result, this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): AzurePostgresFlexibleServerDatabaseResourcePromise { + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._withRoleAssignmentsInternal(target, roles), this._client); + } + +} + +/** + * Thenable wrapper for AzurePostgresFlexibleServerDatabaseResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +class AzurePostgresFlexibleServerDatabaseResourcePromiseImpl implements AzurePostgresFlexibleServerDatabaseResourcePromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: AzurePostgresFlexibleServerDatabaseResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + withContainerRegistry(registry: Awaitable): AzurePostgresFlexibleServerDatabaseResourcePromise { + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withContainerRegistry(registry)), this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzurePostgresFlexibleServerDatabaseResourcePromise { + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withDockerfileBaseImage(options)), this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzurePostgresFlexibleServerDatabaseResourcePromise { + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withRequiredCommand(command, options)), this._client); + } + + withConnectionProperty(name: string, value: string | ReferenceExpression): AzurePostgresFlexibleServerDatabaseResourcePromise { + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withConnectionProperty(name, value)), this._client); + } + + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzurePostgresFlexibleServerDatabaseResourcePromise { + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withUrls(callback)), this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): AzurePostgresFlexibleServerDatabaseResourcePromise { + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withUrl(url, options)), this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzurePostgresFlexibleServerDatabaseResourcePromise { + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback)), this._client); + } + + excludeFromManifest(): AzurePostgresFlexibleServerDatabaseResourcePromise { + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._promise.then(obj => obj.excludeFromManifest()), this._client); + } + + withExplicitStart(): AzurePostgresFlexibleServerDatabaseResourcePromise { + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withExplicitStart()), this._client); + } + + withHealthCheck(key: string): AzurePostgresFlexibleServerDatabaseResourcePromise { + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withHealthCheck(key)), this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzurePostgresFlexibleServerDatabaseResourcePromise { + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options)), this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): AzurePostgresFlexibleServerDatabaseResourcePromise { + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withRelationship(resourceBuilder, type)), this._client); + } + + withParentRelationship(parent: Awaitable): AzurePostgresFlexibleServerDatabaseResourcePromise { + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withParentRelationship(parent)), this._client); + } + + withChildRelationship(child: Awaitable): AzurePostgresFlexibleServerDatabaseResourcePromise { + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withChildRelationship(child)), this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): AzurePostgresFlexibleServerDatabaseResourcePromise { + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withIconName(iconName, options)), this._client); + } + + excludeFromMcp(): AzurePostgresFlexibleServerDatabaseResourcePromise { + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._promise.then(obj => obj.excludeFromMcp()), this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzurePostgresFlexibleServerDatabaseResourcePromise { + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options)), this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzurePostgresFlexibleServerDatabaseResourcePromise { + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withPipelineConfiguration(callback)), this._client); + } + + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzurePostgresFlexibleServerDatabaseResourcePromise { + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._promise.then(obj => obj.onBeforeResourceStarted(callback)), this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzurePostgresFlexibleServerDatabaseResourcePromise { + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._promise.then(obj => obj.onResourceStopped(callback)), this._client); + } + + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzurePostgresFlexibleServerDatabaseResourcePromise { + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._promise.then(obj => obj.onConnectionStringAvailable(callback)), this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzurePostgresFlexibleServerDatabaseResourcePromise { + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._promise.then(obj => obj.onInitializeResource(callback)), this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzurePostgresFlexibleServerDatabaseResourcePromise { + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._promise.then(obj => obj.onResourceReady(callback)), this._client); + } + + createExecutionConfiguration(): Promise { + return this._promise.then(obj => obj.createExecutionConfiguration()); + } + + withPostgresMcp(options?: WithPostgresMcpOptions): AzurePostgresFlexibleServerDatabaseResourcePromise { + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withPostgresMcp(options)), this._client); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): AzurePostgresFlexibleServerDatabaseResourcePromise { + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Details(options)), this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): AzurePostgresFlexibleServerDatabaseResourcePromise { + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Reference(target, options)), this._client); + } + + withLikeC4Group(groupName: string): AzurePostgresFlexibleServerDatabaseResourcePromise { + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Group(groupName)), this._client); + } + + excludeFromLikeC4(): AzurePostgresFlexibleServerDatabaseResourcePromise { + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._promise.then(obj => obj.excludeFromLikeC4()), this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): AzurePostgresFlexibleServerDatabaseResourcePromise { + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withRoleAssignments(target, roles)), this._client); + } + +} + +// ============================================================================ +// AzurePostgresFlexibleServerResource +// ============================================================================ + +export interface AzurePostgresFlexibleServerResource { + toJSON(): MarshalledHandle; + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): AzurePostgresFlexibleServerResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzurePostgresFlexibleServerResourcePromise; + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): AzurePostgresFlexibleServerResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzurePostgresFlexibleServerResourcePromise; + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzurePostgresFlexibleServerResourcePromise; + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise; + /** Updates a named endpoint via callback */ + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): AzurePostgresFlexibleServerResourcePromise; + /** Updates an HTTP endpoint via callback */ + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): AzurePostgresFlexibleServerResourcePromise; + /** Updates an HTTPS endpoint via callback */ + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): AzurePostgresFlexibleServerResourcePromise; + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): AzurePostgresFlexibleServerResourcePromise; + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): AzurePostgresFlexibleServerResourcePromise; + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): AzurePostgresFlexibleServerResourcePromise; + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): AzurePostgresFlexibleServerResourcePromise; + /** Gets an endpoint reference */ + getEndpoint(name: string): Promise; + /** Configures resource for HTTP/2 */ + asHttp2Service(): AzurePostgresFlexibleServerResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzurePostgresFlexibleServerResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): AzurePostgresFlexibleServerResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzurePostgresFlexibleServerResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): AzurePostgresFlexibleServerResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): AzurePostgresFlexibleServerResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): AzurePostgresFlexibleServerResourcePromise; + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): AzurePostgresFlexibleServerResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzurePostgresFlexibleServerResourcePromise; + /** Adds an HTTP resource command */ + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): AzurePostgresFlexibleServerResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): AzurePostgresFlexibleServerResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): AzurePostgresFlexibleServerResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): AzurePostgresFlexibleServerResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): AzurePostgresFlexibleServerResourcePromise; + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): AzurePostgresFlexibleServerResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): AzurePostgresFlexibleServerResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzurePostgresFlexibleServerResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzurePostgresFlexibleServerResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzurePostgresFlexibleServerResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzurePostgresFlexibleServerResourcePromise; + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzurePostgresFlexibleServerResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzurePostgresFlexibleServerResourcePromise; + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): AzurePostgresFlexibleServerResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzurePostgresFlexibleServerResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Adds an Azure PostgreSQL database */ + addDatabase(name: string, options?: AddDatabaseOptions): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Configures the Azure PostgreSQL Flexible Server resource to run locally in a container */ + runAsContainer(options?: RunAsContainer1Options): AzurePostgresFlexibleServerResourcePromise; + /** Configures password authentication for Azure PostgreSQL Flexible Server */ + withPasswordAuthentication(options?: WithPasswordAuthenticationOptions): AzurePostgresFlexibleServerResourcePromise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): AzurePostgresFlexibleServerResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): AzurePostgresFlexibleServerResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): AzurePostgresFlexibleServerResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): AzurePostgresFlexibleServerResourcePromise; + /** Gets an output reference from an Azure Bicep template resource */ + getOutput(name: string): Promise; + /** Adds a Bicep parameter */ + withParameter(name: string, options?: WithParameterOptions): AzurePostgresFlexibleServerResourcePromise; + /** Configures the Azure provisioning infrastructure callback */ + configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzurePostgresFlexibleServerResourcePromise; + /** Publishes an Azure resource to the manifest as a connection string */ + publishAsConnectionString(): AzurePostgresFlexibleServerResourcePromise; + /** Gets the normalized Bicep identifier for an Azure resource */ + getBicepIdentifier(): Promise; + /** Clears the default Azure role assignments from a resource */ + clearDefaultRoleAssignments(): AzurePostgresFlexibleServerResourcePromise; + /** Determines whether a resource is marked as existing */ + isExisting(): Promise; + /** Marks an Azure resource as existing in run mode */ + runAsExisting(name: string | ParameterResource | Awaitable, options?: RunAsExistingOptions): AzurePostgresFlexibleServerResourcePromise; + /** Marks an Azure resource as existing in publish mode */ + publishAsExisting(name: string | ParameterResource | Awaitable, options?: PublishAsExistingOptions): AzurePostgresFlexibleServerResourcePromise; + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource | Awaitable, options?: AsExistingOptions): AzurePostgresFlexibleServerResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): AzurePostgresFlexibleServerResourcePromise; +} + +export interface AzurePostgresFlexibleServerResourcePromise extends PromiseLike { + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): AzurePostgresFlexibleServerResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzurePostgresFlexibleServerResourcePromise; + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): AzurePostgresFlexibleServerResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzurePostgresFlexibleServerResourcePromise; + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzurePostgresFlexibleServerResourcePromise; + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise; + /** Updates a named endpoint via callback */ + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): AzurePostgresFlexibleServerResourcePromise; + /** Updates an HTTP endpoint via callback */ + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): AzurePostgresFlexibleServerResourcePromise; + /** Updates an HTTPS endpoint via callback */ + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): AzurePostgresFlexibleServerResourcePromise; + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): AzurePostgresFlexibleServerResourcePromise; + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): AzurePostgresFlexibleServerResourcePromise; + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): AzurePostgresFlexibleServerResourcePromise; + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): AzurePostgresFlexibleServerResourcePromise; + /** Gets an endpoint reference */ + getEndpoint(name: string): Promise; + /** Configures resource for HTTP/2 */ + asHttp2Service(): AzurePostgresFlexibleServerResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzurePostgresFlexibleServerResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): AzurePostgresFlexibleServerResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzurePostgresFlexibleServerResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): AzurePostgresFlexibleServerResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): AzurePostgresFlexibleServerResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): AzurePostgresFlexibleServerResourcePromise; + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): AzurePostgresFlexibleServerResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzurePostgresFlexibleServerResourcePromise; + /** Adds an HTTP resource command */ + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): AzurePostgresFlexibleServerResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): AzurePostgresFlexibleServerResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): AzurePostgresFlexibleServerResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): AzurePostgresFlexibleServerResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): AzurePostgresFlexibleServerResourcePromise; + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): AzurePostgresFlexibleServerResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): AzurePostgresFlexibleServerResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzurePostgresFlexibleServerResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzurePostgresFlexibleServerResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzurePostgresFlexibleServerResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzurePostgresFlexibleServerResourcePromise; + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzurePostgresFlexibleServerResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzurePostgresFlexibleServerResourcePromise; + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): AzurePostgresFlexibleServerResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzurePostgresFlexibleServerResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Adds an Azure PostgreSQL database */ + addDatabase(name: string, options?: AddDatabaseOptions): AzurePostgresFlexibleServerDatabaseResourcePromise; + /** Configures the Azure PostgreSQL Flexible Server resource to run locally in a container */ + runAsContainer(options?: RunAsContainer1Options): AzurePostgresFlexibleServerResourcePromise; + /** Configures password authentication for Azure PostgreSQL Flexible Server */ + withPasswordAuthentication(options?: WithPasswordAuthenticationOptions): AzurePostgresFlexibleServerResourcePromise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): AzurePostgresFlexibleServerResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): AzurePostgresFlexibleServerResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): AzurePostgresFlexibleServerResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): AzurePostgresFlexibleServerResourcePromise; + /** Gets an output reference from an Azure Bicep template resource */ + getOutput(name: string): Promise; + /** Adds a Bicep parameter */ + withParameter(name: string, options?: WithParameterOptions): AzurePostgresFlexibleServerResourcePromise; + /** Configures the Azure provisioning infrastructure callback */ + configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzurePostgresFlexibleServerResourcePromise; + /** Publishes an Azure resource to the manifest as a connection string */ + publishAsConnectionString(): AzurePostgresFlexibleServerResourcePromise; + /** Gets the normalized Bicep identifier for an Azure resource */ + getBicepIdentifier(): Promise; + /** Clears the default Azure role assignments from a resource */ + clearDefaultRoleAssignments(): AzurePostgresFlexibleServerResourcePromise; + /** Determines whether a resource is marked as existing */ + isExisting(): Promise; + /** Marks an Azure resource as existing in run mode */ + runAsExisting(name: string | ParameterResource | Awaitable, options?: RunAsExistingOptions): AzurePostgresFlexibleServerResourcePromise; + /** Marks an Azure resource as existing in publish mode */ + publishAsExisting(name: string | ParameterResource | Awaitable, options?: PublishAsExistingOptions): AzurePostgresFlexibleServerResourcePromise; + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource | Awaitable, options?: AsExistingOptions): AzurePostgresFlexibleServerResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): AzurePostgresFlexibleServerResourcePromise; +} + +// ============================================================================ +// AzurePostgresFlexibleServerResourceImpl +// ============================================================================ + +class AzurePostgresFlexibleServerResourceImpl extends ResourceBuilderBase implements AzurePostgresFlexibleServerResource { + constructor(handle: AzurePostgresFlexibleServerResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: Awaitable): Promise { + registry = isPromiseLike(registry) ? await registry : registry; + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new AzurePostgresFlexibleServerResourceImpl(result, this._client); + } + + withContainerRegistry(registry: Awaitable): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._withContainerRegistryInternal(registry), this._client); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new AzurePostgresFlexibleServerResourceImpl(result, this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzurePostgresFlexibleServerResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._withDockerfileBaseImageInternal(buildImage, runtimeImage), this._client); + } + + /** @internal */ + private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withMcpServer', + rpcArgs + ); + return new AzurePostgresFlexibleServerResourceImpl(result, this._client); + } + + withMcpServer(options?: WithMcpServerOptions): AzurePostgresFlexibleServerResourcePromise { + const path = options?.path; + const endpointName = options?.endpointName; + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._withMcpServerInternal(path, endpointName), this._client); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new AzurePostgresFlexibleServerResourceImpl(result, this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzurePostgresFlexibleServerResourcePromise { + const helpLink = options?.helpLink; + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._withRequiredCommandInternal(command, helpLink), this._client); + } + + /** @internal */ + private async _withConnectionPropertyInternal(name: string, value: string | ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withConnectionProperty', + rpcArgs + ); + return new AzurePostgresFlexibleServerResourceImpl(result, this._client); + } + + withConnectionProperty(name: string, value: string | ReferenceExpression): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._withConnectionPropertyInternal(name, value), this._client); + } + + async getConnectionProperty(key: string): Promise { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + + /** @internal */ + private async _withEndpointCallbackInternal(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpointCallback', + rpcArgs + ); + return new AzurePostgresFlexibleServerResourceImpl(result, this._client); + } + + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): AzurePostgresFlexibleServerResourcePromise { + const createIfNotExists = options?.createIfNotExists; + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._withEndpointCallbackInternal(endpointName, callback, createIfNotExists), this._client); + } + + /** @internal */ + private async _withHttpEndpointCallbackInternal(callback: (obj: EndpointUpdateContext) => Promise, name?: string, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + if (name !== undefined) rpcArgs.name = name; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpEndpointCallback', + rpcArgs + ); + return new AzurePostgresFlexibleServerResourceImpl(result, this._client); + } + + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): AzurePostgresFlexibleServerResourcePromise { + const name = options?.name; + const createIfNotExists = options?.createIfNotExists; + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._withHttpEndpointCallbackInternal(callback, name, createIfNotExists), this._client); + } + + /** @internal */ + private async _withHttpsEndpointCallbackInternal(callback: (obj: EndpointUpdateContext) => Promise, name?: string, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + if (name !== undefined) rpcArgs.name = name; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsEndpointCallback', + rpcArgs + ); + return new AzurePostgresFlexibleServerResourceImpl(result, this._client); + } + + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): AzurePostgresFlexibleServerResourcePromise { + const name = options?.name; + const createIfNotExists = options?.createIfNotExists; + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._withHttpsEndpointCallbackInternal(callback, name, createIfNotExists), this._client); + } + + /** @internal */ + private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (scheme !== undefined) rpcArgs.scheme = scheme; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + if (isExternal !== undefined) rpcArgs.isExternal = isExternal; + if (protocol !== undefined) rpcArgs.protocol = protocol; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpoint', + rpcArgs + ); + return new AzurePostgresFlexibleServerResourceImpl(result, this._client); + } + + withEndpoint(options?: WithEndpointOptions): AzurePostgresFlexibleServerResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const scheme = options?.scheme; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + const isExternal = options?.isExternal; + const protocol = options?.protocol; + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._withEndpointInternal(port, targetPort, scheme, name, env, isProxied, isExternal, protocol), this._client); + } + + /** @internal */ + private async _withHttpEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpEndpoint', + rpcArgs + ); + return new AzurePostgresFlexibleServerResourceImpl(result, this._client); + } + + withHttpEndpoint(options?: WithHttpEndpointOptions): AzurePostgresFlexibleServerResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied), this._client); + } + + /** @internal */ + private async _withHttpsEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsEndpoint', + rpcArgs + ); + return new AzurePostgresFlexibleServerResourceImpl(result, this._client); + } + + withHttpsEndpoint(options?: WithHttpsEndpointOptions): AzurePostgresFlexibleServerResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied), this._client); + } + + /** @internal */ + private async _withExternalHttpEndpointsInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExternalHttpEndpoints', + rpcArgs + ); + return new AzurePostgresFlexibleServerResourceImpl(result, this._client); + } + + withExternalHttpEndpoints(): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._withExternalHttpEndpointsInternal(), this._client); + } + + async getEndpoint(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getEndpoint', + rpcArgs + ); + } + + /** @internal */ + private async _asHttp2ServiceInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/asHttp2Service', + rpcArgs + ); + return new AzurePostgresFlexibleServerResourceImpl(result, this._client); + } + + asHttp2Service(): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._asHttp2ServiceInternal(), this._client); + } + + /** @internal */ + private async _withUrlsInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrls', + rpcArgs + ); + return new AzurePostgresFlexibleServerResourceImpl(result, this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._withUrlsInternal(callback), this._client); + } + + /** @internal */ + private async _withUrlInternal(url: string | ReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new AzurePostgresFlexibleServerResourceImpl(result, this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): AzurePostgresFlexibleServerResourcePromise { + const displayText = options?.displayText; + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._withUrlInternal(url, displayText), this._client); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new AzurePostgresFlexibleServerResourceImpl(result, this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._withUrlForEndpointInternal(endpointName, callback), this._client); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new AzurePostgresFlexibleServerResourceImpl(result, this._client); + } + + excludeFromManifest(): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._excludeFromManifestInternal(), this._client); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new AzurePostgresFlexibleServerResourceImpl(result, this._client); + } + + withExplicitStart(): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._withExplicitStartInternal(), this._client); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new AzurePostgresFlexibleServerResourceImpl(result, this._client); + } + + withHealthCheck(key: string): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._withHealthCheckInternal(key), this._client); + } + + /** @internal */ + private async _withHttpHealthCheckInternal(path?: string, statusCode?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (statusCode !== undefined) rpcArgs.statusCode = statusCode; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpHealthCheck', + rpcArgs + ); + return new AzurePostgresFlexibleServerResourceImpl(result, this._client); + } + + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): AzurePostgresFlexibleServerResourcePromise { + const path = options?.path; + const statusCode = options?.statusCode; + const endpointName = options?.endpointName; + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._withHttpHealthCheckInternal(path, statusCode, endpointName), this._client); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContextImpl(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new AzurePostgresFlexibleServerResourceImpl(result, this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzurePostgresFlexibleServerResourcePromise { + const commandOptions = options?.commandOptions; + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._withCommandInternal(name, displayName, executeCommand, commandOptions), this._client); + } + + /** @internal */ + private async _withHttpCommandInternal(path: string, displayName: string, options?: HttpCommandExportOptions): Promise { + const rpcArgs: Record = { builder: this._handle, path, displayName }; + if (options !== undefined) rpcArgs.options = options; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpCommand', + rpcArgs + ); + return new AzurePostgresFlexibleServerResourceImpl(result, this._client); + } + + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._withHttpCommandInternal(path, displayName, options), this._client); + } + + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: Awaitable, type: string): Promise { + resourceBuilder = isPromiseLike(resourceBuilder) ? await resourceBuilder : resourceBuilder; + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzurePostgresFlexibleServerResourceImpl(result, this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._withRelationshipInternal(resourceBuilder, type), this._client); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: Awaitable): Promise { + parent = isPromiseLike(parent) ? await parent : parent; + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new AzurePostgresFlexibleServerResourceImpl(result, this._client); + } + + withParentRelationship(parent: Awaitable): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._withParentRelationshipInternal(parent), this._client); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: Awaitable): Promise { + child = isPromiseLike(child) ? await child : child; + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', + rpcArgs + ); + return new AzurePostgresFlexibleServerResourceImpl(result, this._client); + } + + withChildRelationship(child: Awaitable): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._withChildRelationshipInternal(child), this._client); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new AzurePostgresFlexibleServerResourceImpl(result, this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): AzurePostgresFlexibleServerResourcePromise { + const iconVariant = options?.iconVariant; + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._withIconNameInternal(iconName, iconVariant), this._client); + } + + /** @internal */ + private async _withHttpProbeInternal(probeType: ProbeType, path?: string, initialDelaySeconds?: number, periodSeconds?: number, timeoutSeconds?: number, failureThreshold?: number, successThreshold?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, probeType }; + if (path !== undefined) rpcArgs.path = path; + if (initialDelaySeconds !== undefined) rpcArgs.initialDelaySeconds = initialDelaySeconds; + if (periodSeconds !== undefined) rpcArgs.periodSeconds = periodSeconds; + if (timeoutSeconds !== undefined) rpcArgs.timeoutSeconds = timeoutSeconds; + if (failureThreshold !== undefined) rpcArgs.failureThreshold = failureThreshold; + if (successThreshold !== undefined) rpcArgs.successThreshold = successThreshold; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpProbe', + rpcArgs + ); + return new AzurePostgresFlexibleServerResourceImpl(result, this._client); + } + + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): AzurePostgresFlexibleServerResourcePromise { + const path = options?.path; + const initialDelaySeconds = options?.initialDelaySeconds; + const periodSeconds = options?.periodSeconds; + const timeoutSeconds = options?.timeoutSeconds; + const failureThreshold = options?.failureThreshold; + const successThreshold = options?.successThreshold; + const endpointName = options?.endpointName; + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName), this._client); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new AzurePostgresFlexibleServerResourceImpl(result, this._client); + } + + excludeFromMcp(): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._excludeFromMcpInternal(), this._client); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new AzurePostgresFlexibleServerResourceImpl(result, this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzurePostgresFlexibleServerResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description), this._client); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new AzurePostgresFlexibleServerResourceImpl(result, this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._withPipelineConfigurationInternal(callback), this._client); + } + + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); + } + + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new AzurePostgresFlexibleServerResourceImpl(result, this._client); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._onBeforeResourceStartedInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new AzurePostgresFlexibleServerResourceImpl(result, this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._onResourceStoppedInternal(callback), this._client); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onConnectionStringAvailable', + rpcArgs + ); + return new AzurePostgresFlexibleServerResourceImpl(result, this._client); + } + + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._onConnectionStringAvailableInternal(callback), this._client); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new AzurePostgresFlexibleServerResourceImpl(result, this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._onInitializeResourceInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceEndpointsAllocated', + rpcArgs + ); + return new AzurePostgresFlexibleServerResourceImpl(result, this._client); + } + + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._onResourceEndpointsAllocatedInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new AzurePostgresFlexibleServerResourceImpl(result, this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._onResourceReadyInternal(callback), this._client); + } + + async createExecutionConfiguration(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/createExecutionConfiguration', + rpcArgs + ); + } + + /** @internal */ + private async _addDatabaseInternal(name: string, databaseName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (databaseName !== undefined) rpcArgs.databaseName = databaseName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.PostgreSQL/addDatabase', + rpcArgs + ); + return new AzurePostgresFlexibleServerDatabaseResourceImpl(result, this._client); + } + + addDatabase(name: string, options?: AddDatabaseOptions): AzurePostgresFlexibleServerDatabaseResourcePromise { + const databaseName = options?.databaseName; + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._addDatabaseInternal(name, databaseName), this._client); + } + + /** @internal */ + private async _runAsContainerInternal(configureContainer?: (obj: PostgresServerResource) => Promise): Promise { + const configureContainerId = configureContainer ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PostgresServerResourceHandle; + const obj = new PostgresServerResourceImpl(objHandle, this._client); + await configureContainer(obj); + }) : undefined; + const rpcArgs: Record = { builder: this._handle }; + if (configureContainer !== undefined) rpcArgs.configureContainer = configureContainerId; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.PostgreSQL/runAsContainer', + rpcArgs + ); + return new AzurePostgresFlexibleServerResourceImpl(result, this._client); + } + + runAsContainer(options?: RunAsContainer1Options): AzurePostgresFlexibleServerResourcePromise { + const configureContainer = options?.configureContainer; + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._runAsContainerInternal(configureContainer), this._client); + } + + /** @internal */ + private async _withPasswordAuthenticationInternal(keyVaultBuilder?: Awaitable, userName?: Awaitable, password?: Awaitable): Promise { + keyVaultBuilder = isPromiseLike(keyVaultBuilder) ? await keyVaultBuilder : keyVaultBuilder; + userName = isPromiseLike(userName) ? await userName : userName; + password = isPromiseLike(password) ? await password : password; + const rpcArgs: Record = { builder: this._handle }; + if (keyVaultBuilder !== undefined) rpcArgs.keyVaultBuilder = keyVaultBuilder; + if (userName !== undefined) rpcArgs.userName = userName; + if (password !== undefined) rpcArgs.password = password; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.PostgreSQL/withPasswordAuthentication', + rpcArgs + ); + return new AzurePostgresFlexibleServerResourceImpl(result, this._client); + } + + withPasswordAuthentication(options?: WithPasswordAuthenticationOptions): AzurePostgresFlexibleServerResourcePromise { + let keyVaultBuilder = options?.keyVaultBuilder; + let userName = options?.userName; + let password = options?.password; + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._withPasswordAuthenticationInternal(keyVaultBuilder, userName, password), this._client); + } + + /** @internal */ + private async _withLikeC4DetailsInternal(label?: string, technology?: string, description?: string, summary?: string, icon?: string, configure?: (obj: LikeC4NodeDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4NodeDetailsAnnotationHandle; + const obj = new LikeC4NodeDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + const rpcArgs: Record = { builder: this._handle }; + if (label !== undefined) rpcArgs.label = label; + if (technology !== undefined) rpcArgs.technology = technology; + if (description !== undefined) rpcArgs.description = description; + if (summary !== undefined) rpcArgs.summary = summary; + if (icon !== undefined) rpcArgs.icon = icon; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4DetailsParameters', + rpcArgs + ); + return new AzurePostgresFlexibleServerResourceImpl(result, this._client); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): AzurePostgresFlexibleServerResourcePromise { + const label = options?.label; + const technology = options?.technology; + const description = options?.description; + const summary = options?.summary; + const icon = options?.icon; + const configure = options?.configure; + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._withLikeC4DetailsInternal(label, technology, description, summary, icon, configure), this._client); + } + + /** @internal */ + private async _withLikeC4ReferenceInternal(target: Awaitable, configure?: (obj: LikeC4RelationshipDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4RelationshipDetailsAnnotationHandle; + const obj = new LikeC4RelationshipDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target }; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Reference', + rpcArgs + ); + return new AzurePostgresFlexibleServerResourceImpl(result, this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): AzurePostgresFlexibleServerResourcePromise { + const configure = options?.configure; + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._withLikeC4ReferenceInternal(target, configure), this._client); + } + + /** @internal */ + private async _withLikeC4GroupInternal(groupName: string): Promise { + const rpcArgs: Record = { builder: this._handle, groupName }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Group', + rpcArgs + ); + return new AzurePostgresFlexibleServerResourceImpl(result, this._client); + } + + withLikeC4Group(groupName: string): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._withLikeC4GroupInternal(groupName), this._client); + } + + /** @internal */ + private async _excludeFromLikeC4Internal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/excludeFromLikeC4', + rpcArgs + ); + return new AzurePostgresFlexibleServerResourceImpl(result, this._client); + } + + excludeFromLikeC4(): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._excludeFromLikeC4Internal(), this._client); + } + + async getOutput(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/getOutput', + rpcArgs + ); + } + + /** @internal */ + private async _withParameterInternal(name: string, value?: string | string[] | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | BicepOutputReference | ReferenceExpression | EndpointReference | Awaitable): Promise { + value = isPromiseLike(value) ? await value : value; + const rpcArgs: Record = { builder: this._handle, name }; + if (value !== undefined) rpcArgs.value = value; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameter', + rpcArgs + ); + return new AzurePostgresFlexibleServerResourceImpl(result, this._client); + } + + withParameter(name: string, options?: WithParameterOptions): AzurePostgresFlexibleServerResourcePromise { + let value = options?.value; + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._withParameterInternal(name, value), this._client); + } + + /** @internal */ + private async _configureInfrastructureInternal(configure: (obj: AzureResourceInfrastructure) => Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as AzureResourceInfrastructureHandle; + const obj = new AzureResourceInfrastructureImpl(objHandle, this._client); + await configure(obj); + }); + const rpcArgs: Record = { builder: this._handle, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/configureInfrastructure', + rpcArgs + ); + return new AzurePostgresFlexibleServerResourceImpl(result, this._client); + } + + configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._configureInfrastructureInternal(configure), this._client); + } + + /** @internal */ + private async _publishAsConnectionStringInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/publishAsConnectionString', + rpcArgs + ); + return new AzurePostgresFlexibleServerResourceImpl(result, this._client); + } + + publishAsConnectionString(): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._publishAsConnectionStringInternal(), this._client); + } + + async getBicepIdentifier(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/getBicepIdentifier', + rpcArgs + ); + } + + /** @internal */ + private async _clearDefaultRoleAssignmentsInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/clearDefaultRoleAssignments', + rpcArgs + ); + return new AzurePostgresFlexibleServerResourceImpl(result, this._client); + } + + clearDefaultRoleAssignments(): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._clearDefaultRoleAssignmentsInternal(), this._client); + } + + async isExisting(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/isExisting', + rpcArgs + ); + } + + /** @internal */ + private async _runAsExistingInternal(name: string | ParameterResource | Awaitable, resourceGroup?: string | ParameterResource | Awaitable): Promise { + name = isPromiseLike(name) ? await name : name; + resourceGroup = isPromiseLike(resourceGroup) ? await resourceGroup : resourceGroup; + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/runAsExisting', + rpcArgs + ); + return new AzurePostgresFlexibleServerResourceImpl(result, this._client); + } + + runAsExisting(name: string | ParameterResource | Awaitable, options?: RunAsExistingOptions): AzurePostgresFlexibleServerResourcePromise { + let resourceGroup = options?.resourceGroup; + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._runAsExistingInternal(name, resourceGroup), this._client); + } + + /** @internal */ + private async _publishAsExistingInternal(name: string | ParameterResource | Awaitable, resourceGroup?: string | ParameterResource | Awaitable): Promise { + name = isPromiseLike(name) ? await name : name; + resourceGroup = isPromiseLike(resourceGroup) ? await resourceGroup : resourceGroup; + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/publishAsExisting', + rpcArgs + ); + return new AzurePostgresFlexibleServerResourceImpl(result, this._client); + } + + publishAsExisting(name: string | ParameterResource | Awaitable, options?: PublishAsExistingOptions): AzurePostgresFlexibleServerResourcePromise { + let resourceGroup = options?.resourceGroup; + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._publishAsExistingInternal(name, resourceGroup), this._client); + } + + /** @internal */ + private async _asExistingInternal(name: string | ParameterResource | Awaitable, resourceGroup?: string | ParameterResource | Awaitable): Promise { + name = isPromiseLike(name) ? await name : name; + resourceGroup = isPromiseLike(resourceGroup) ? await resourceGroup : resourceGroup; + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/asExisting', + rpcArgs + ); + return new AzurePostgresFlexibleServerResourceImpl(result, this._client); + } + + asExisting(name: string | ParameterResource | Awaitable, options?: AsExistingOptions): AzurePostgresFlexibleServerResourcePromise { + let resourceGroup = options?.resourceGroup; + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._asExistingInternal(name, resourceGroup), this._client); + } + + /** @internal */ + private async _withRoleAssignmentsInternal(target: Awaitable, roles: AzureKeyVaultRole[]): Promise { + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target, roles }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.KeyVault/withKeyVaultRoleAssignments', + rpcArgs + ); + return new AzurePostgresFlexibleServerResourceImpl(result, this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._withRoleAssignmentsInternal(target, roles), this._client); + } + +} + +/** + * Thenable wrapper for AzurePostgresFlexibleServerResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +class AzurePostgresFlexibleServerResourcePromiseImpl implements AzurePostgresFlexibleServerResourcePromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: AzurePostgresFlexibleServerResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + withContainerRegistry(registry: Awaitable): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._promise.then(obj => obj.withContainerRegistry(registry)), this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._promise.then(obj => obj.withDockerfileBaseImage(options)), this._client); + } + + withMcpServer(options?: WithMcpServerOptions): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._promise.then(obj => obj.withMcpServer(options)), this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._promise.then(obj => obj.withRequiredCommand(command, options)), this._client); + } + + withConnectionProperty(name: string, value: string | ReferenceExpression): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._promise.then(obj => obj.withConnectionProperty(name, value)), this._client); + } + + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._promise.then(obj => obj.withEndpointCallback(endpointName, callback, options)), this._client); + } + + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._promise.then(obj => obj.withHttpEndpointCallback(callback, options)), this._client); + } + + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._promise.then(obj => obj.withHttpsEndpointCallback(callback, options)), this._client); + } + + withEndpoint(options?: WithEndpointOptions): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._promise.then(obj => obj.withEndpoint(options)), this._client); + } + + withHttpEndpoint(options?: WithHttpEndpointOptions): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._promise.then(obj => obj.withHttpEndpoint(options)), this._client); + } + + withHttpsEndpoint(options?: WithHttpsEndpointOptions): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._promise.then(obj => obj.withHttpsEndpoint(options)), this._client); + } + + withExternalHttpEndpoints(): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._promise.then(obj => obj.withExternalHttpEndpoints()), this._client); + } + + getEndpoint(name: string): Promise { + return this._promise.then(obj => obj.getEndpoint(name)); + } + + asHttp2Service(): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._promise.then(obj => obj.asHttp2Service()), this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._promise.then(obj => obj.withUrls(callback)), this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._promise.then(obj => obj.withUrl(url, options)), this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback)), this._client); + } + + excludeFromManifest(): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._promise.then(obj => obj.excludeFromManifest()), this._client); + } + + withExplicitStart(): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._promise.then(obj => obj.withExplicitStart()), this._client); + } + + withHealthCheck(key: string): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._promise.then(obj => obj.withHealthCheck(key)), this._client); + } + + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._promise.then(obj => obj.withHttpHealthCheck(options)), this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options)), this._client); + } + + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._promise.then(obj => obj.withHttpCommand(path, displayName, options)), this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._promise.then(obj => obj.withRelationship(resourceBuilder, type)), this._client); + } + + withParentRelationship(parent: Awaitable): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._promise.then(obj => obj.withParentRelationship(parent)), this._client); + } + + withChildRelationship(child: Awaitable): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._promise.then(obj => obj.withChildRelationship(child)), this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._promise.then(obj => obj.withIconName(iconName, options)), this._client); + } + + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._promise.then(obj => obj.withHttpProbe(probeType, options)), this._client); + } + + excludeFromMcp(): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._promise.then(obj => obj.excludeFromMcp()), this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options)), this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._promise.then(obj => obj.withPipelineConfiguration(callback)), this._client); + } + + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._promise.then(obj => obj.onBeforeResourceStarted(callback)), this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._promise.then(obj => obj.onResourceStopped(callback)), this._client); + } + + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._promise.then(obj => obj.onConnectionStringAvailable(callback)), this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._promise.then(obj => obj.onInitializeResource(callback)), this._client); + } + + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback)), this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._promise.then(obj => obj.onResourceReady(callback)), this._client); + } + + createExecutionConfiguration(): Promise { + return this._promise.then(obj => obj.createExecutionConfiguration()); + } + + addDatabase(name: string, options?: AddDatabaseOptions): AzurePostgresFlexibleServerDatabaseResourcePromise { + return new AzurePostgresFlexibleServerDatabaseResourcePromiseImpl(this._promise.then(obj => obj.addDatabase(name, options)), this._client); + } + + runAsContainer(options?: RunAsContainer1Options): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._promise.then(obj => obj.runAsContainer(options)), this._client); + } + + withPasswordAuthentication(options?: WithPasswordAuthenticationOptions): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._promise.then(obj => obj.withPasswordAuthentication(options)), this._client); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Details(options)), this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Reference(target, options)), this._client); + } + + withLikeC4Group(groupName: string): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Group(groupName)), this._client); + } + + excludeFromLikeC4(): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._promise.then(obj => obj.excludeFromLikeC4()), this._client); + } + + getOutput(name: string): Promise { + return this._promise.then(obj => obj.getOutput(name)); + } + + withParameter(name: string, options?: WithParameterOptions): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._promise.then(obj => obj.withParameter(name, options)), this._client); + } + + configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._promise.then(obj => obj.configureInfrastructure(configure)), this._client); + } + + publishAsConnectionString(): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._promise.then(obj => obj.publishAsConnectionString()), this._client); + } + + getBicepIdentifier(): Promise { + return this._promise.then(obj => obj.getBicepIdentifier()); + } + + clearDefaultRoleAssignments(): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._promise.then(obj => obj.clearDefaultRoleAssignments()), this._client); + } + + isExisting(): Promise { + return this._promise.then(obj => obj.isExisting()); + } + + runAsExisting(name: string | ParameterResource | Awaitable, options?: RunAsExistingOptions): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._promise.then(obj => obj.runAsExisting(name, options)), this._client); + } + + publishAsExisting(name: string | ParameterResource | Awaitable, options?: PublishAsExistingOptions): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._promise.then(obj => obj.publishAsExisting(name, options)), this._client); + } + + asExisting(name: string | ParameterResource | Awaitable, options?: AsExistingOptions): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._promise.then(obj => obj.asExisting(name, options)), this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): AzurePostgresFlexibleServerResourcePromise { + return new AzurePostgresFlexibleServerResourcePromiseImpl(this._promise.then(obj => obj.withRoleAssignments(target, roles)), this._client); + } + +} + +// ============================================================================ +// AzureProvisioningResource +// ============================================================================ + +export interface AzureProvisioningResource { + toJSON(): MarshalledHandle; + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): AzureProvisioningResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureProvisioningResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureProvisioningResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureProvisioningResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): AzureProvisioningResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureProvisioningResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): AzureProvisioningResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): AzureProvisioningResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): AzureProvisioningResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureProvisioningResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): AzureProvisioningResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): AzureProvisioningResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): AzureProvisioningResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): AzureProvisioningResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): AzureProvisioningResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureProvisioningResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureProvisioningResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureProvisioningResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureProvisioningResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureProvisioningResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureProvisioningResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): AzureProvisioningResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): AzureProvisioningResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): AzureProvisioningResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): AzureProvisioningResourcePromise; + /** Gets an output reference from an Azure Bicep template resource */ + getOutput(name: string): Promise; + /** Adds a Bicep parameter */ + withParameter(name: string, options?: WithParameterOptions): AzureProvisioningResourcePromise; + /** Configures the Azure provisioning infrastructure callback */ + configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise; + /** Publishes an Azure resource to the manifest as a connection string */ + publishAsConnectionString(): AzureProvisioningResourcePromise; + /** Gets the normalized Bicep identifier for an Azure resource */ + getBicepIdentifier(): Promise; + /** Clears the default Azure role assignments from a resource */ + clearDefaultRoleAssignments(): AzureProvisioningResourcePromise; + /** Determines whether a resource is marked as existing */ + isExisting(): Promise; + /** Marks an Azure resource as existing in run mode */ + runAsExisting(name: string | ParameterResource | Awaitable, options?: RunAsExistingOptions): AzureProvisioningResourcePromise; + /** Marks an Azure resource as existing in publish mode */ + publishAsExisting(name: string | ParameterResource | Awaitable, options?: PublishAsExistingOptions): AzureProvisioningResourcePromise; + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource | Awaitable, options?: AsExistingOptions): AzureProvisioningResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): AzureProvisioningResourcePromise; +} + +export interface AzureProvisioningResourcePromise extends PromiseLike { + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): AzureProvisioningResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureProvisioningResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureProvisioningResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureProvisioningResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): AzureProvisioningResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureProvisioningResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): AzureProvisioningResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): AzureProvisioningResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): AzureProvisioningResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureProvisioningResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): AzureProvisioningResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): AzureProvisioningResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): AzureProvisioningResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): AzureProvisioningResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): AzureProvisioningResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureProvisioningResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureProvisioningResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureProvisioningResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureProvisioningResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureProvisioningResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureProvisioningResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): AzureProvisioningResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): AzureProvisioningResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): AzureProvisioningResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): AzureProvisioningResourcePromise; + /** Gets an output reference from an Azure Bicep template resource */ + getOutput(name: string): Promise; + /** Adds a Bicep parameter */ + withParameter(name: string, options?: WithParameterOptions): AzureProvisioningResourcePromise; + /** Configures the Azure provisioning infrastructure callback */ + configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise; + /** Publishes an Azure resource to the manifest as a connection string */ + publishAsConnectionString(): AzureProvisioningResourcePromise; + /** Gets the normalized Bicep identifier for an Azure resource */ + getBicepIdentifier(): Promise; + /** Clears the default Azure role assignments from a resource */ + clearDefaultRoleAssignments(): AzureProvisioningResourcePromise; + /** Determines whether a resource is marked as existing */ + isExisting(): Promise; + /** Marks an Azure resource as existing in run mode */ + runAsExisting(name: string | ParameterResource | Awaitable, options?: RunAsExistingOptions): AzureProvisioningResourcePromise; + /** Marks an Azure resource as existing in publish mode */ + publishAsExisting(name: string | ParameterResource | Awaitable, options?: PublishAsExistingOptions): AzureProvisioningResourcePromise; + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource | Awaitable, options?: AsExistingOptions): AzureProvisioningResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): AzureProvisioningResourcePromise; +} + +// ============================================================================ +// AzureProvisioningResourceImpl +// ============================================================================ + +class AzureProvisioningResourceImpl extends ResourceBuilderBase implements AzureProvisioningResource { + constructor(handle: AzureProvisioningResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: Awaitable): Promise { + registry = isPromiseLike(registry) ? await registry : registry; + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new AzureProvisioningResourceImpl(result, this._client); + } + + withContainerRegistry(registry: Awaitable): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._withContainerRegistryInternal(registry), this._client); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new AzureProvisioningResourceImpl(result, this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureProvisioningResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new AzureProvisioningResourcePromiseImpl(this._withDockerfileBaseImageInternal(buildImage, runtimeImage), this._client); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new AzureProvisioningResourceImpl(result, this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureProvisioningResourcePromise { + const helpLink = options?.helpLink; + return new AzureProvisioningResourcePromiseImpl(this._withRequiredCommandInternal(command, helpLink), this._client); + } + + /** @internal */ + private async _withUrlsInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrls', + rpcArgs + ); + return new AzureProvisioningResourceImpl(result, this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._withUrlsInternal(callback), this._client); + } + + /** @internal */ + private async _withUrlInternal(url: string | ReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new AzureProvisioningResourceImpl(result, this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): AzureProvisioningResourcePromise { + const displayText = options?.displayText; + return new AzureProvisioningResourcePromiseImpl(this._withUrlInternal(url, displayText), this._client); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new AzureProvisioningResourceImpl(result, this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._withUrlForEndpointInternal(endpointName, callback), this._client); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new AzureProvisioningResourceImpl(result, this._client); + } + + excludeFromManifest(): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._excludeFromManifestInternal(), this._client); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new AzureProvisioningResourceImpl(result, this._client); + } + + withExplicitStart(): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._withExplicitStartInternal(), this._client); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new AzureProvisioningResourceImpl(result, this._client); + } + + withHealthCheck(key: string): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._withHealthCheckInternal(key), this._client); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContextImpl(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new AzureProvisioningResourceImpl(result, this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureProvisioningResourcePromise { + const commandOptions = options?.commandOptions; + return new AzureProvisioningResourcePromiseImpl(this._withCommandInternal(name, displayName, executeCommand, commandOptions), this._client); + } + + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: Awaitable, type: string): Promise { + resourceBuilder = isPromiseLike(resourceBuilder) ? await resourceBuilder : resourceBuilder; + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureProvisioningResourceImpl(result, this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._withRelationshipInternal(resourceBuilder, type), this._client); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: Awaitable): Promise { + parent = isPromiseLike(parent) ? await parent : parent; + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new AzureProvisioningResourceImpl(result, this._client); + } + + withParentRelationship(parent: Awaitable): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._withParentRelationshipInternal(parent), this._client); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: Awaitable): Promise { + child = isPromiseLike(child) ? await child : child; + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', + rpcArgs + ); + return new AzureProvisioningResourceImpl(result, this._client); + } + + withChildRelationship(child: Awaitable): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._withChildRelationshipInternal(child), this._client); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new AzureProvisioningResourceImpl(result, this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): AzureProvisioningResourcePromise { + const iconVariant = options?.iconVariant; + return new AzureProvisioningResourcePromiseImpl(this._withIconNameInternal(iconName, iconVariant), this._client); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new AzureProvisioningResourceImpl(result, this._client); + } + + excludeFromMcp(): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._excludeFromMcpInternal(), this._client); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new AzureProvisioningResourceImpl(result, this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureProvisioningResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new AzureProvisioningResourcePromiseImpl(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description), this._client); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new AzureProvisioningResourceImpl(result, this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._withPipelineConfigurationInternal(callback), this._client); + } + + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); + } + + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new AzureProvisioningResourceImpl(result, this._client); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._onBeforeResourceStartedInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new AzureProvisioningResourceImpl(result, this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._onResourceStoppedInternal(callback), this._client); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new AzureProvisioningResourceImpl(result, this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._onInitializeResourceInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new AzureProvisioningResourceImpl(result, this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._onResourceReadyInternal(callback), this._client); + } + + async createExecutionConfiguration(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/createExecutionConfiguration', + rpcArgs + ); + } + + /** @internal */ + private async _withLikeC4DetailsInternal(label?: string, technology?: string, description?: string, summary?: string, icon?: string, configure?: (obj: LikeC4NodeDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4NodeDetailsAnnotationHandle; + const obj = new LikeC4NodeDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + const rpcArgs: Record = { builder: this._handle }; + if (label !== undefined) rpcArgs.label = label; + if (technology !== undefined) rpcArgs.technology = technology; + if (description !== undefined) rpcArgs.description = description; + if (summary !== undefined) rpcArgs.summary = summary; + if (icon !== undefined) rpcArgs.icon = icon; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4DetailsParameters', + rpcArgs + ); + return new AzureProvisioningResourceImpl(result, this._client); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): AzureProvisioningResourcePromise { + const label = options?.label; + const technology = options?.technology; + const description = options?.description; + const summary = options?.summary; + const icon = options?.icon; + const configure = options?.configure; + return new AzureProvisioningResourcePromiseImpl(this._withLikeC4DetailsInternal(label, technology, description, summary, icon, configure), this._client); + } + + /** @internal */ + private async _withLikeC4ReferenceInternal(target: Awaitable, configure?: (obj: LikeC4RelationshipDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4RelationshipDetailsAnnotationHandle; + const obj = new LikeC4RelationshipDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target }; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Reference', + rpcArgs + ); + return new AzureProvisioningResourceImpl(result, this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): AzureProvisioningResourcePromise { + const configure = options?.configure; + return new AzureProvisioningResourcePromiseImpl(this._withLikeC4ReferenceInternal(target, configure), this._client); + } + + /** @internal */ + private async _withLikeC4GroupInternal(groupName: string): Promise { + const rpcArgs: Record = { builder: this._handle, groupName }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Group', + rpcArgs + ); + return new AzureProvisioningResourceImpl(result, this._client); + } + + withLikeC4Group(groupName: string): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._withLikeC4GroupInternal(groupName), this._client); + } + + /** @internal */ + private async _excludeFromLikeC4Internal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/excludeFromLikeC4', + rpcArgs + ); + return new AzureProvisioningResourceImpl(result, this._client); + } + + excludeFromLikeC4(): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._excludeFromLikeC4Internal(), this._client); + } + + async getOutput(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/getOutput', + rpcArgs + ); + } + + /** @internal */ + private async _withParameterInternal(name: string, value?: string | string[] | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | BicepOutputReference | ReferenceExpression | EndpointReference | Awaitable): Promise { + value = isPromiseLike(value) ? await value : value; + const rpcArgs: Record = { builder: this._handle, name }; + if (value !== undefined) rpcArgs.value = value; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameter', + rpcArgs + ); + return new AzureProvisioningResourceImpl(result, this._client); + } + + withParameter(name: string, options?: WithParameterOptions): AzureProvisioningResourcePromise { + let value = options?.value; + return new AzureProvisioningResourcePromiseImpl(this._withParameterInternal(name, value), this._client); + } + + /** @internal */ + private async _configureInfrastructureInternal(configure: (obj: AzureResourceInfrastructure) => Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as AzureResourceInfrastructureHandle; + const obj = new AzureResourceInfrastructureImpl(objHandle, this._client); + await configure(obj); + }); + const rpcArgs: Record = { builder: this._handle, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/configureInfrastructure', + rpcArgs + ); + return new AzureProvisioningResourceImpl(result, this._client); + } + + configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._configureInfrastructureInternal(configure), this._client); + } + + /** @internal */ + private async _publishAsConnectionStringInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/publishAsConnectionString', + rpcArgs + ); + return new AzureProvisioningResourceImpl(result, this._client); + } + + publishAsConnectionString(): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._publishAsConnectionStringInternal(), this._client); + } + + async getBicepIdentifier(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/getBicepIdentifier', + rpcArgs + ); + } + + /** @internal */ + private async _clearDefaultRoleAssignmentsInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/clearDefaultRoleAssignments', + rpcArgs + ); + return new AzureProvisioningResourceImpl(result, this._client); + } + + clearDefaultRoleAssignments(): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._clearDefaultRoleAssignmentsInternal(), this._client); + } + + async isExisting(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/isExisting', + rpcArgs + ); + } + + /** @internal */ + private async _runAsExistingInternal(name: string | ParameterResource | Awaitable, resourceGroup?: string | ParameterResource | Awaitable): Promise { + name = isPromiseLike(name) ? await name : name; + resourceGroup = isPromiseLike(resourceGroup) ? await resourceGroup : resourceGroup; + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/runAsExisting', + rpcArgs + ); + return new AzureProvisioningResourceImpl(result, this._client); + } + + runAsExisting(name: string | ParameterResource | Awaitable, options?: RunAsExistingOptions): AzureProvisioningResourcePromise { + let resourceGroup = options?.resourceGroup; + return new AzureProvisioningResourcePromiseImpl(this._runAsExistingInternal(name, resourceGroup), this._client); + } + + /** @internal */ + private async _publishAsExistingInternal(name: string | ParameterResource | Awaitable, resourceGroup?: string | ParameterResource | Awaitable): Promise { + name = isPromiseLike(name) ? await name : name; + resourceGroup = isPromiseLike(resourceGroup) ? await resourceGroup : resourceGroup; + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/publishAsExisting', + rpcArgs + ); + return new AzureProvisioningResourceImpl(result, this._client); + } + + publishAsExisting(name: string | ParameterResource | Awaitable, options?: PublishAsExistingOptions): AzureProvisioningResourcePromise { + let resourceGroup = options?.resourceGroup; + return new AzureProvisioningResourcePromiseImpl(this._publishAsExistingInternal(name, resourceGroup), this._client); + } + + /** @internal */ + private async _asExistingInternal(name: string | ParameterResource | Awaitable, resourceGroup?: string | ParameterResource | Awaitable): Promise { + name = isPromiseLike(name) ? await name : name; + resourceGroup = isPromiseLike(resourceGroup) ? await resourceGroup : resourceGroup; + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/asExisting', + rpcArgs + ); + return new AzureProvisioningResourceImpl(result, this._client); + } + + asExisting(name: string | ParameterResource | Awaitable, options?: AsExistingOptions): AzureProvisioningResourcePromise { + let resourceGroup = options?.resourceGroup; + return new AzureProvisioningResourcePromiseImpl(this._asExistingInternal(name, resourceGroup), this._client); + } + + /** @internal */ + private async _withRoleAssignmentsInternal(target: Awaitable, roles: AzureKeyVaultRole[]): Promise { + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target, roles }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.KeyVault/withKeyVaultRoleAssignments', + rpcArgs + ); + return new AzureProvisioningResourceImpl(result, this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._withRoleAssignmentsInternal(target, roles), this._client); + } + +} + +/** + * Thenable wrapper for AzureProvisioningResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +class AzureProvisioningResourcePromiseImpl implements AzureProvisioningResourcePromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: AzureProvisioningResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + withContainerRegistry(registry: Awaitable): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._promise.then(obj => obj.withContainerRegistry(registry)), this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._promise.then(obj => obj.withDockerfileBaseImage(options)), this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._promise.then(obj => obj.withRequiredCommand(command, options)), this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._promise.then(obj => obj.withUrls(callback)), this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._promise.then(obj => obj.withUrl(url, options)), this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback)), this._client); + } + + excludeFromManifest(): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._promise.then(obj => obj.excludeFromManifest()), this._client); + } + + withExplicitStart(): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._promise.then(obj => obj.withExplicitStart()), this._client); + } + + withHealthCheck(key: string): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._promise.then(obj => obj.withHealthCheck(key)), this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options)), this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._promise.then(obj => obj.withRelationship(resourceBuilder, type)), this._client); + } + + withParentRelationship(parent: Awaitable): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._promise.then(obj => obj.withParentRelationship(parent)), this._client); + } + + withChildRelationship(child: Awaitable): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._promise.then(obj => obj.withChildRelationship(child)), this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._promise.then(obj => obj.withIconName(iconName, options)), this._client); + } + + excludeFromMcp(): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._promise.then(obj => obj.excludeFromMcp()), this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options)), this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._promise.then(obj => obj.withPipelineConfiguration(callback)), this._client); + } + + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._promise.then(obj => obj.onBeforeResourceStarted(callback)), this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._promise.then(obj => obj.onResourceStopped(callback)), this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._promise.then(obj => obj.onInitializeResource(callback)), this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._promise.then(obj => obj.onResourceReady(callback)), this._client); + } + + createExecutionConfiguration(): Promise { + return this._promise.then(obj => obj.createExecutionConfiguration()); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Details(options)), this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Reference(target, options)), this._client); + } + + withLikeC4Group(groupName: string): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Group(groupName)), this._client); + } + + excludeFromLikeC4(): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._promise.then(obj => obj.excludeFromLikeC4()), this._client); + } + + getOutput(name: string): Promise { + return this._promise.then(obj => obj.getOutput(name)); + } + + withParameter(name: string, options?: WithParameterOptions): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._promise.then(obj => obj.withParameter(name, options)), this._client); + } + + configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._promise.then(obj => obj.configureInfrastructure(configure)), this._client); + } + + publishAsConnectionString(): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._promise.then(obj => obj.publishAsConnectionString()), this._client); + } + + getBicepIdentifier(): Promise { + return this._promise.then(obj => obj.getBicepIdentifier()); + } + + clearDefaultRoleAssignments(): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._promise.then(obj => obj.clearDefaultRoleAssignments()), this._client); + } + + isExisting(): Promise { + return this._promise.then(obj => obj.isExisting()); + } + + runAsExisting(name: string | ParameterResource | Awaitable, options?: RunAsExistingOptions): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._promise.then(obj => obj.runAsExisting(name, options)), this._client); + } + + publishAsExisting(name: string | ParameterResource | Awaitable, options?: PublishAsExistingOptions): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._promise.then(obj => obj.publishAsExisting(name, options)), this._client); + } + + asExisting(name: string | ParameterResource | Awaitable, options?: AsExistingOptions): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._promise.then(obj => obj.asExisting(name, options)), this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromiseImpl(this._promise.then(obj => obj.withRoleAssignments(target, roles)), this._client); + } + +} + +// ============================================================================ +// AzureUserAssignedIdentityResource +// ============================================================================ + +export interface AzureUserAssignedIdentityResource { + toJSON(): MarshalledHandle; + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): AzureUserAssignedIdentityResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureUserAssignedIdentityResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureUserAssignedIdentityResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureUserAssignedIdentityResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): AzureUserAssignedIdentityResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureUserAssignedIdentityResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): AzureUserAssignedIdentityResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): AzureUserAssignedIdentityResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): AzureUserAssignedIdentityResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureUserAssignedIdentityResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): AzureUserAssignedIdentityResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): AzureUserAssignedIdentityResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): AzureUserAssignedIdentityResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): AzureUserAssignedIdentityResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): AzureUserAssignedIdentityResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureUserAssignedIdentityResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureUserAssignedIdentityResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureUserAssignedIdentityResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureUserAssignedIdentityResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureUserAssignedIdentityResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureUserAssignedIdentityResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): AzureUserAssignedIdentityResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): AzureUserAssignedIdentityResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): AzureUserAssignedIdentityResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): AzureUserAssignedIdentityResourcePromise; + /** Gets an output reference from an Azure Bicep template resource */ + getOutput(name: string): Promise; + /** Adds a Bicep parameter */ + withParameter(name: string, options?: WithParameterOptions): AzureUserAssignedIdentityResourcePromise; + /** Configures the Azure provisioning infrastructure callback */ + configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzureUserAssignedIdentityResourcePromise; + /** Publishes an Azure resource to the manifest as a connection string */ + publishAsConnectionString(): AzureUserAssignedIdentityResourcePromise; + /** Gets the normalized Bicep identifier for an Azure resource */ + getBicepIdentifier(): Promise; + /** Clears the default Azure role assignments from a resource */ + clearDefaultRoleAssignments(): AzureUserAssignedIdentityResourcePromise; + /** Determines whether a resource is marked as existing */ + isExisting(): Promise; + /** Marks an Azure resource as existing in run mode */ + runAsExisting(name: string | ParameterResource | Awaitable, options?: RunAsExistingOptions): AzureUserAssignedIdentityResourcePromise; + /** Marks an Azure resource as existing in publish mode */ + publishAsExisting(name: string | ParameterResource | Awaitable, options?: PublishAsExistingOptions): AzureUserAssignedIdentityResourcePromise; + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource | Awaitable, options?: AsExistingOptions): AzureUserAssignedIdentityResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): AzureUserAssignedIdentityResourcePromise; +} + +export interface AzureUserAssignedIdentityResourcePromise extends PromiseLike { + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): AzureUserAssignedIdentityResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureUserAssignedIdentityResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureUserAssignedIdentityResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureUserAssignedIdentityResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): AzureUserAssignedIdentityResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureUserAssignedIdentityResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): AzureUserAssignedIdentityResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): AzureUserAssignedIdentityResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): AzureUserAssignedIdentityResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureUserAssignedIdentityResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): AzureUserAssignedIdentityResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): AzureUserAssignedIdentityResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): AzureUserAssignedIdentityResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): AzureUserAssignedIdentityResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): AzureUserAssignedIdentityResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureUserAssignedIdentityResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureUserAssignedIdentityResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureUserAssignedIdentityResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureUserAssignedIdentityResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureUserAssignedIdentityResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureUserAssignedIdentityResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): AzureUserAssignedIdentityResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): AzureUserAssignedIdentityResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): AzureUserAssignedIdentityResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): AzureUserAssignedIdentityResourcePromise; + /** Gets an output reference from an Azure Bicep template resource */ + getOutput(name: string): Promise; + /** Adds a Bicep parameter */ + withParameter(name: string, options?: WithParameterOptions): AzureUserAssignedIdentityResourcePromise; + /** Configures the Azure provisioning infrastructure callback */ + configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzureUserAssignedIdentityResourcePromise; + /** Publishes an Azure resource to the manifest as a connection string */ + publishAsConnectionString(): AzureUserAssignedIdentityResourcePromise; + /** Gets the normalized Bicep identifier for an Azure resource */ + getBicepIdentifier(): Promise; + /** Clears the default Azure role assignments from a resource */ + clearDefaultRoleAssignments(): AzureUserAssignedIdentityResourcePromise; + /** Determines whether a resource is marked as existing */ + isExisting(): Promise; + /** Marks an Azure resource as existing in run mode */ + runAsExisting(name: string | ParameterResource | Awaitable, options?: RunAsExistingOptions): AzureUserAssignedIdentityResourcePromise; + /** Marks an Azure resource as existing in publish mode */ + publishAsExisting(name: string | ParameterResource | Awaitable, options?: PublishAsExistingOptions): AzureUserAssignedIdentityResourcePromise; + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource | Awaitable, options?: AsExistingOptions): AzureUserAssignedIdentityResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): AzureUserAssignedIdentityResourcePromise; +} + +// ============================================================================ +// AzureUserAssignedIdentityResourceImpl +// ============================================================================ + +class AzureUserAssignedIdentityResourceImpl extends ResourceBuilderBase implements AzureUserAssignedIdentityResource { + constructor(handle: AzureUserAssignedIdentityResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: Awaitable): Promise { + registry = isPromiseLike(registry) ? await registry : registry; + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new AzureUserAssignedIdentityResourceImpl(result, this._client); + } + + withContainerRegistry(registry: Awaitable): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._withContainerRegistryInternal(registry), this._client); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new AzureUserAssignedIdentityResourceImpl(result, this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureUserAssignedIdentityResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new AzureUserAssignedIdentityResourcePromiseImpl(this._withDockerfileBaseImageInternal(buildImage, runtimeImage), this._client); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new AzureUserAssignedIdentityResourceImpl(result, this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureUserAssignedIdentityResourcePromise { + const helpLink = options?.helpLink; + return new AzureUserAssignedIdentityResourcePromiseImpl(this._withRequiredCommandInternal(command, helpLink), this._client); + } + + /** @internal */ + private async _withUrlsInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrls', + rpcArgs + ); + return new AzureUserAssignedIdentityResourceImpl(result, this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._withUrlsInternal(callback), this._client); + } + + /** @internal */ + private async _withUrlInternal(url: string | ReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new AzureUserAssignedIdentityResourceImpl(result, this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): AzureUserAssignedIdentityResourcePromise { + const displayText = options?.displayText; + return new AzureUserAssignedIdentityResourcePromiseImpl(this._withUrlInternal(url, displayText), this._client); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new AzureUserAssignedIdentityResourceImpl(result, this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._withUrlForEndpointInternal(endpointName, callback), this._client); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new AzureUserAssignedIdentityResourceImpl(result, this._client); + } + + excludeFromManifest(): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._excludeFromManifestInternal(), this._client); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new AzureUserAssignedIdentityResourceImpl(result, this._client); + } + + withExplicitStart(): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._withExplicitStartInternal(), this._client); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new AzureUserAssignedIdentityResourceImpl(result, this._client); + } + + withHealthCheck(key: string): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._withHealthCheckInternal(key), this._client); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContextImpl(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new AzureUserAssignedIdentityResourceImpl(result, this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureUserAssignedIdentityResourcePromise { + const commandOptions = options?.commandOptions; + return new AzureUserAssignedIdentityResourcePromiseImpl(this._withCommandInternal(name, displayName, executeCommand, commandOptions), this._client); + } + + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: Awaitable, type: string): Promise { + resourceBuilder = isPromiseLike(resourceBuilder) ? await resourceBuilder : resourceBuilder; + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureUserAssignedIdentityResourceImpl(result, this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._withRelationshipInternal(resourceBuilder, type), this._client); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: Awaitable): Promise { + parent = isPromiseLike(parent) ? await parent : parent; + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new AzureUserAssignedIdentityResourceImpl(result, this._client); + } + + withParentRelationship(parent: Awaitable): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._withParentRelationshipInternal(parent), this._client); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: Awaitable): Promise { + child = isPromiseLike(child) ? await child : child; + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', + rpcArgs + ); + return new AzureUserAssignedIdentityResourceImpl(result, this._client); + } + + withChildRelationship(child: Awaitable): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._withChildRelationshipInternal(child), this._client); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new AzureUserAssignedIdentityResourceImpl(result, this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): AzureUserAssignedIdentityResourcePromise { + const iconVariant = options?.iconVariant; + return new AzureUserAssignedIdentityResourcePromiseImpl(this._withIconNameInternal(iconName, iconVariant), this._client); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new AzureUserAssignedIdentityResourceImpl(result, this._client); + } + + excludeFromMcp(): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._excludeFromMcpInternal(), this._client); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new AzureUserAssignedIdentityResourceImpl(result, this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureUserAssignedIdentityResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new AzureUserAssignedIdentityResourcePromiseImpl(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description), this._client); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new AzureUserAssignedIdentityResourceImpl(result, this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._withPipelineConfigurationInternal(callback), this._client); + } + + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); + } + + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new AzureUserAssignedIdentityResourceImpl(result, this._client); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._onBeforeResourceStartedInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new AzureUserAssignedIdentityResourceImpl(result, this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._onResourceStoppedInternal(callback), this._client); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new AzureUserAssignedIdentityResourceImpl(result, this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._onInitializeResourceInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new AzureUserAssignedIdentityResourceImpl(result, this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._onResourceReadyInternal(callback), this._client); + } + + async createExecutionConfiguration(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/createExecutionConfiguration', + rpcArgs + ); + } + + /** @internal */ + private async _withLikeC4DetailsInternal(label?: string, technology?: string, description?: string, summary?: string, icon?: string, configure?: (obj: LikeC4NodeDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4NodeDetailsAnnotationHandle; + const obj = new LikeC4NodeDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + const rpcArgs: Record = { builder: this._handle }; + if (label !== undefined) rpcArgs.label = label; + if (technology !== undefined) rpcArgs.technology = technology; + if (description !== undefined) rpcArgs.description = description; + if (summary !== undefined) rpcArgs.summary = summary; + if (icon !== undefined) rpcArgs.icon = icon; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4DetailsParameters', + rpcArgs + ); + return new AzureUserAssignedIdentityResourceImpl(result, this._client); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): AzureUserAssignedIdentityResourcePromise { + const label = options?.label; + const technology = options?.technology; + const description = options?.description; + const summary = options?.summary; + const icon = options?.icon; + const configure = options?.configure; + return new AzureUserAssignedIdentityResourcePromiseImpl(this._withLikeC4DetailsInternal(label, technology, description, summary, icon, configure), this._client); + } + + /** @internal */ + private async _withLikeC4ReferenceInternal(target: Awaitable, configure?: (obj: LikeC4RelationshipDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4RelationshipDetailsAnnotationHandle; + const obj = new LikeC4RelationshipDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target }; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Reference', + rpcArgs + ); + return new AzureUserAssignedIdentityResourceImpl(result, this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): AzureUserAssignedIdentityResourcePromise { + const configure = options?.configure; + return new AzureUserAssignedIdentityResourcePromiseImpl(this._withLikeC4ReferenceInternal(target, configure), this._client); + } + + /** @internal */ + private async _withLikeC4GroupInternal(groupName: string): Promise { + const rpcArgs: Record = { builder: this._handle, groupName }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Group', + rpcArgs + ); + return new AzureUserAssignedIdentityResourceImpl(result, this._client); + } + + withLikeC4Group(groupName: string): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._withLikeC4GroupInternal(groupName), this._client); + } + + /** @internal */ + private async _excludeFromLikeC4Internal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/excludeFromLikeC4', + rpcArgs + ); + return new AzureUserAssignedIdentityResourceImpl(result, this._client); + } + + excludeFromLikeC4(): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._excludeFromLikeC4Internal(), this._client); + } + + async getOutput(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/getOutput', + rpcArgs + ); + } + + /** @internal */ + private async _withParameterInternal(name: string, value?: string | string[] | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | BicepOutputReference | ReferenceExpression | EndpointReference | Awaitable): Promise { + value = isPromiseLike(value) ? await value : value; + const rpcArgs: Record = { builder: this._handle, name }; + if (value !== undefined) rpcArgs.value = value; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameter', + rpcArgs + ); + return new AzureUserAssignedIdentityResourceImpl(result, this._client); + } + + withParameter(name: string, options?: WithParameterOptions): AzureUserAssignedIdentityResourcePromise { + let value = options?.value; + return new AzureUserAssignedIdentityResourcePromiseImpl(this._withParameterInternal(name, value), this._client); + } + + /** @internal */ + private async _configureInfrastructureInternal(configure: (obj: AzureResourceInfrastructure) => Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as AzureResourceInfrastructureHandle; + const obj = new AzureResourceInfrastructureImpl(objHandle, this._client); + await configure(obj); + }); + const rpcArgs: Record = { builder: this._handle, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/configureInfrastructure', + rpcArgs + ); + return new AzureUserAssignedIdentityResourceImpl(result, this._client); + } + + configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._configureInfrastructureInternal(configure), this._client); + } + + /** @internal */ + private async _publishAsConnectionStringInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/publishAsConnectionString', + rpcArgs + ); + return new AzureUserAssignedIdentityResourceImpl(result, this._client); + } + + publishAsConnectionString(): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._publishAsConnectionStringInternal(), this._client); + } + + async getBicepIdentifier(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/getBicepIdentifier', + rpcArgs + ); + } + + /** @internal */ + private async _clearDefaultRoleAssignmentsInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/clearDefaultRoleAssignments', + rpcArgs + ); + return new AzureUserAssignedIdentityResourceImpl(result, this._client); + } + + clearDefaultRoleAssignments(): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._clearDefaultRoleAssignmentsInternal(), this._client); + } + + async isExisting(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/isExisting', + rpcArgs + ); + } + + /** @internal */ + private async _runAsExistingInternal(name: string | ParameterResource | Awaitable, resourceGroup?: string | ParameterResource | Awaitable): Promise { + name = isPromiseLike(name) ? await name : name; + resourceGroup = isPromiseLike(resourceGroup) ? await resourceGroup : resourceGroup; + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/runAsExisting', + rpcArgs + ); + return new AzureUserAssignedIdentityResourceImpl(result, this._client); + } + + runAsExisting(name: string | ParameterResource | Awaitable, options?: RunAsExistingOptions): AzureUserAssignedIdentityResourcePromise { + let resourceGroup = options?.resourceGroup; + return new AzureUserAssignedIdentityResourcePromiseImpl(this._runAsExistingInternal(name, resourceGroup), this._client); + } + + /** @internal */ + private async _publishAsExistingInternal(name: string | ParameterResource | Awaitable, resourceGroup?: string | ParameterResource | Awaitable): Promise { + name = isPromiseLike(name) ? await name : name; + resourceGroup = isPromiseLike(resourceGroup) ? await resourceGroup : resourceGroup; + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/publishAsExisting', + rpcArgs + ); + return new AzureUserAssignedIdentityResourceImpl(result, this._client); + } + + publishAsExisting(name: string | ParameterResource | Awaitable, options?: PublishAsExistingOptions): AzureUserAssignedIdentityResourcePromise { + let resourceGroup = options?.resourceGroup; + return new AzureUserAssignedIdentityResourcePromiseImpl(this._publishAsExistingInternal(name, resourceGroup), this._client); + } + + /** @internal */ + private async _asExistingInternal(name: string | ParameterResource | Awaitable, resourceGroup?: string | ParameterResource | Awaitable): Promise { + name = isPromiseLike(name) ? await name : name; + resourceGroup = isPromiseLike(resourceGroup) ? await resourceGroup : resourceGroup; + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/asExisting', + rpcArgs + ); + return new AzureUserAssignedIdentityResourceImpl(result, this._client); + } + + asExisting(name: string | ParameterResource | Awaitable, options?: AsExistingOptions): AzureUserAssignedIdentityResourcePromise { + let resourceGroup = options?.resourceGroup; + return new AzureUserAssignedIdentityResourcePromiseImpl(this._asExistingInternal(name, resourceGroup), this._client); + } + + /** @internal */ + private async _withRoleAssignmentsInternal(target: Awaitable, roles: AzureKeyVaultRole[]): Promise { + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target, roles }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.KeyVault/withKeyVaultRoleAssignments', + rpcArgs + ); + return new AzureUserAssignedIdentityResourceImpl(result, this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._withRoleAssignmentsInternal(target, roles), this._client); + } + +} + +/** + * Thenable wrapper for AzureUserAssignedIdentityResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +class AzureUserAssignedIdentityResourcePromiseImpl implements AzureUserAssignedIdentityResourcePromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: AzureUserAssignedIdentityResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + withContainerRegistry(registry: Awaitable): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._promise.then(obj => obj.withContainerRegistry(registry)), this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._promise.then(obj => obj.withDockerfileBaseImage(options)), this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._promise.then(obj => obj.withRequiredCommand(command, options)), this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._promise.then(obj => obj.withUrls(callback)), this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._promise.then(obj => obj.withUrl(url, options)), this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback)), this._client); + } + + excludeFromManifest(): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._promise.then(obj => obj.excludeFromManifest()), this._client); + } + + withExplicitStart(): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._promise.then(obj => obj.withExplicitStart()), this._client); + } + + withHealthCheck(key: string): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._promise.then(obj => obj.withHealthCheck(key)), this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options)), this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._promise.then(obj => obj.withRelationship(resourceBuilder, type)), this._client); + } + + withParentRelationship(parent: Awaitable): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._promise.then(obj => obj.withParentRelationship(parent)), this._client); + } + + withChildRelationship(child: Awaitable): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._promise.then(obj => obj.withChildRelationship(child)), this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._promise.then(obj => obj.withIconName(iconName, options)), this._client); + } + + excludeFromMcp(): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._promise.then(obj => obj.excludeFromMcp()), this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options)), this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._promise.then(obj => obj.withPipelineConfiguration(callback)), this._client); + } + + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._promise.then(obj => obj.onBeforeResourceStarted(callback)), this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._promise.then(obj => obj.onResourceStopped(callback)), this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._promise.then(obj => obj.onInitializeResource(callback)), this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._promise.then(obj => obj.onResourceReady(callback)), this._client); + } + + createExecutionConfiguration(): Promise { + return this._promise.then(obj => obj.createExecutionConfiguration()); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Details(options)), this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Reference(target, options)), this._client); + } + + withLikeC4Group(groupName: string): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Group(groupName)), this._client); + } + + excludeFromLikeC4(): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._promise.then(obj => obj.excludeFromLikeC4()), this._client); + } + + getOutput(name: string): Promise { + return this._promise.then(obj => obj.getOutput(name)); + } + + withParameter(name: string, options?: WithParameterOptions): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._promise.then(obj => obj.withParameter(name, options)), this._client); + } + + configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._promise.then(obj => obj.configureInfrastructure(configure)), this._client); + } + + publishAsConnectionString(): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._promise.then(obj => obj.publishAsConnectionString()), this._client); + } + + getBicepIdentifier(): Promise { + return this._promise.then(obj => obj.getBicepIdentifier()); + } + + clearDefaultRoleAssignments(): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._promise.then(obj => obj.clearDefaultRoleAssignments()), this._client); + } + + isExisting(): Promise { + return this._promise.then(obj => obj.isExisting()); + } + + runAsExisting(name: string | ParameterResource | Awaitable, options?: RunAsExistingOptions): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._promise.then(obj => obj.runAsExisting(name, options)), this._client); + } + + publishAsExisting(name: string | ParameterResource | Awaitable, options?: PublishAsExistingOptions): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._promise.then(obj => obj.publishAsExisting(name, options)), this._client); + } + + asExisting(name: string | ParameterResource | Awaitable, options?: AsExistingOptions): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._promise.then(obj => obj.asExisting(name, options)), this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromiseImpl(this._promise.then(obj => obj.withRoleAssignments(target, roles)), this._client); + } + +} + +// ============================================================================ +// ContainerRegistryResource +// ============================================================================ + +export interface ContainerRegistryResource { + toJSON(): MarshalledHandle; + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): ContainerRegistryResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ContainerRegistryResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ContainerRegistryResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): ContainerRegistryResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): ContainerRegistryResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ContainerRegistryResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): ContainerRegistryResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): ContainerRegistryResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): ContainerRegistryResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ContainerRegistryResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): ContainerRegistryResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): ContainerRegistryResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): ContainerRegistryResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ContainerRegistryResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ContainerRegistryResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ContainerRegistryResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ContainerRegistryResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ContainerRegistryResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ContainerRegistryResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ContainerRegistryResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ContainerRegistryResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): ContainerRegistryResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): ContainerRegistryResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): ContainerRegistryResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): ContainerRegistryResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): ContainerRegistryResourcePromise; +} + +export interface ContainerRegistryResourcePromise extends PromiseLike { + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): ContainerRegistryResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ContainerRegistryResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ContainerRegistryResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): ContainerRegistryResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): ContainerRegistryResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ContainerRegistryResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): ContainerRegistryResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): ContainerRegistryResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): ContainerRegistryResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ContainerRegistryResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): ContainerRegistryResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): ContainerRegistryResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): ContainerRegistryResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ContainerRegistryResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ContainerRegistryResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ContainerRegistryResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ContainerRegistryResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ContainerRegistryResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ContainerRegistryResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ContainerRegistryResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ContainerRegistryResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): ContainerRegistryResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): ContainerRegistryResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): ContainerRegistryResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): ContainerRegistryResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): ContainerRegistryResourcePromise; +} + +// ============================================================================ +// ContainerRegistryResourceImpl +// ============================================================================ + +class ContainerRegistryResourceImpl extends ResourceBuilderBase implements ContainerRegistryResource { + constructor(handle: ContainerRegistryResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: Awaitable): Promise { + registry = isPromiseLike(registry) ? await registry : registry; + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new ContainerRegistryResourceImpl(result, this._client); + } + + withContainerRegistry(registry: Awaitable): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._withContainerRegistryInternal(registry), this._client); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new ContainerRegistryResourceImpl(result, this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ContainerRegistryResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new ContainerRegistryResourcePromiseImpl(this._withDockerfileBaseImageInternal(buildImage, runtimeImage), this._client); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new ContainerRegistryResourceImpl(result, this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ContainerRegistryResourcePromise { + const helpLink = options?.helpLink; + return new ContainerRegistryResourcePromiseImpl(this._withRequiredCommandInternal(command, helpLink), this._client); + } + + /** @internal */ + private async _withUrlsInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrls', + rpcArgs + ); + return new ContainerRegistryResourceImpl(result, this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._withUrlsInternal(callback), this._client); + } + + /** @internal */ + private async _withUrlInternal(url: string | ReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new ContainerRegistryResourceImpl(result, this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): ContainerRegistryResourcePromise { + const displayText = options?.displayText; + return new ContainerRegistryResourcePromiseImpl(this._withUrlInternal(url, displayText), this._client); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new ContainerRegistryResourceImpl(result, this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._withUrlForEndpointInternal(endpointName, callback), this._client); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new ContainerRegistryResourceImpl(result, this._client); + } + + excludeFromManifest(): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._excludeFromManifestInternal(), this._client); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new ContainerRegistryResourceImpl(result, this._client); + } + + withExplicitStart(): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._withExplicitStartInternal(), this._client); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new ContainerRegistryResourceImpl(result, this._client); + } + + withHealthCheck(key: string): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._withHealthCheckInternal(key), this._client); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContextImpl(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new ContainerRegistryResourceImpl(result, this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ContainerRegistryResourcePromise { + const commandOptions = options?.commandOptions; + return new ContainerRegistryResourcePromiseImpl(this._withCommandInternal(name, displayName, executeCommand, commandOptions), this._client); + } + + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: Awaitable, type: string): Promise { + resourceBuilder = isPromiseLike(resourceBuilder) ? await resourceBuilder : resourceBuilder; + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ContainerRegistryResourceImpl(result, this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._withRelationshipInternal(resourceBuilder, type), this._client); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: Awaitable): Promise { + parent = isPromiseLike(parent) ? await parent : parent; + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new ContainerRegistryResourceImpl(result, this._client); + } + + withParentRelationship(parent: Awaitable): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._withParentRelationshipInternal(parent), this._client); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: Awaitable): Promise { + child = isPromiseLike(child) ? await child : child; + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', + rpcArgs + ); + return new ContainerRegistryResourceImpl(result, this._client); + } + + withChildRelationship(child: Awaitable): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._withChildRelationshipInternal(child), this._client); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new ContainerRegistryResourceImpl(result, this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): ContainerRegistryResourcePromise { + const iconVariant = options?.iconVariant; + return new ContainerRegistryResourcePromiseImpl(this._withIconNameInternal(iconName, iconVariant), this._client); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new ContainerRegistryResourceImpl(result, this._client); + } + + excludeFromMcp(): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._excludeFromMcpInternal(), this._client); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new ContainerRegistryResourceImpl(result, this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ContainerRegistryResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new ContainerRegistryResourcePromiseImpl(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description), this._client); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new ContainerRegistryResourceImpl(result, this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._withPipelineConfigurationInternal(callback), this._client); + } + + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); + } + + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new ContainerRegistryResourceImpl(result, this._client); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._onBeforeResourceStartedInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new ContainerRegistryResourceImpl(result, this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._onResourceStoppedInternal(callback), this._client); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new ContainerRegistryResourceImpl(result, this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._onInitializeResourceInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new ContainerRegistryResourceImpl(result, this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._onResourceReadyInternal(callback), this._client); + } + + async createExecutionConfiguration(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/createExecutionConfiguration', + rpcArgs + ); + } + + /** @internal */ + private async _withLikeC4DetailsInternal(label?: string, technology?: string, description?: string, summary?: string, icon?: string, configure?: (obj: LikeC4NodeDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4NodeDetailsAnnotationHandle; + const obj = new LikeC4NodeDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + const rpcArgs: Record = { builder: this._handle }; + if (label !== undefined) rpcArgs.label = label; + if (technology !== undefined) rpcArgs.technology = technology; + if (description !== undefined) rpcArgs.description = description; + if (summary !== undefined) rpcArgs.summary = summary; + if (icon !== undefined) rpcArgs.icon = icon; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4DetailsParameters', + rpcArgs + ); + return new ContainerRegistryResourceImpl(result, this._client); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): ContainerRegistryResourcePromise { + const label = options?.label; + const technology = options?.technology; + const description = options?.description; + const summary = options?.summary; + const icon = options?.icon; + const configure = options?.configure; + return new ContainerRegistryResourcePromiseImpl(this._withLikeC4DetailsInternal(label, technology, description, summary, icon, configure), this._client); + } + + /** @internal */ + private async _withLikeC4ReferenceInternal(target: Awaitable, configure?: (obj: LikeC4RelationshipDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4RelationshipDetailsAnnotationHandle; + const obj = new LikeC4RelationshipDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target }; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Reference', + rpcArgs + ); + return new ContainerRegistryResourceImpl(result, this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): ContainerRegistryResourcePromise { + const configure = options?.configure; + return new ContainerRegistryResourcePromiseImpl(this._withLikeC4ReferenceInternal(target, configure), this._client); + } + + /** @internal */ + private async _withLikeC4GroupInternal(groupName: string): Promise { + const rpcArgs: Record = { builder: this._handle, groupName }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Group', + rpcArgs + ); + return new ContainerRegistryResourceImpl(result, this._client); + } + + withLikeC4Group(groupName: string): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._withLikeC4GroupInternal(groupName), this._client); + } + + /** @internal */ + private async _excludeFromLikeC4Internal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/excludeFromLikeC4', + rpcArgs + ); + return new ContainerRegistryResourceImpl(result, this._client); + } + + excludeFromLikeC4(): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._excludeFromLikeC4Internal(), this._client); + } + + /** @internal */ + private async _withRoleAssignmentsInternal(target: Awaitable, roles: AzureKeyVaultRole[]): Promise { + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target, roles }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.KeyVault/withKeyVaultRoleAssignments', + rpcArgs + ); + return new ContainerRegistryResourceImpl(result, this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._withRoleAssignmentsInternal(target, roles), this._client); + } + +} + +/** + * Thenable wrapper for ContainerRegistryResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +class ContainerRegistryResourcePromiseImpl implements ContainerRegistryResourcePromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: ContainerRegistryResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + withContainerRegistry(registry: Awaitable): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.withContainerRegistry(registry)), this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.withDockerfileBaseImage(options)), this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.withRequiredCommand(command, options)), this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.withUrls(callback)), this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.withUrl(url, options)), this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback)), this._client); + } + + excludeFromManifest(): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.excludeFromManifest()), this._client); + } + + withExplicitStart(): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.withExplicitStart()), this._client); + } + + withHealthCheck(key: string): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.withHealthCheck(key)), this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options)), this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.withRelationship(resourceBuilder, type)), this._client); + } + + withParentRelationship(parent: Awaitable): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.withParentRelationship(parent)), this._client); + } + + withChildRelationship(child: Awaitable): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.withChildRelationship(child)), this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.withIconName(iconName, options)), this._client); + } + + excludeFromMcp(): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.excludeFromMcp()), this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options)), this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.withPipelineConfiguration(callback)), this._client); + } + + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.onBeforeResourceStarted(callback)), this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.onResourceStopped(callback)), this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.onInitializeResource(callback)), this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.onResourceReady(callback)), this._client); + } + + createExecutionConfiguration(): Promise { + return this._promise.then(obj => obj.createExecutionConfiguration()); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Details(options)), this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Reference(target, options)), this._client); + } + + withLikeC4Group(groupName: string): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Group(groupName)), this._client); + } + + excludeFromLikeC4(): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.excludeFromLikeC4()), this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.withRoleAssignments(target, roles)), this._client); + } + +} + +// ============================================================================ +// ContainerResource +// ============================================================================ + +export interface ContainerResource { + toJSON(): MarshalledHandle; + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): ContainerResourcePromise; + /** Adds a bind mount */ + withBindMount(source: string, target: string, options?: WithBindMountOptions): ContainerResourcePromise; + /** Sets the container entrypoint */ + withEntrypoint(entrypoint: string): ContainerResourcePromise; + /** Sets the container image tag */ + withImageTag(tag: string): ContainerResourcePromise; + /** Sets the container image registry */ + withImageRegistry(registry: string): ContainerResourcePromise; + /** Sets the container image */ + withImage(image: string, options?: WithImageOptions): ContainerResourcePromise; + /** Sets the image SHA256 digest */ + withImageSHA256(sha256: string): ContainerResourcePromise; + /** Adds runtime arguments for the container */ + withContainerRuntimeArgs(args: string[]): ContainerResourcePromise; + /** Sets the lifetime behavior of the container resource */ + withLifetime(lifetime: ContainerLifetime): ContainerResourcePromise; + /** Sets the container image pull policy */ + withImagePullPolicy(pullPolicy: ImagePullPolicy): ContainerResourcePromise; + /** Configures the resource to be published as a container */ + publishAsContainer(): ContainerResourcePromise; + /** Configures the resource to use a Dockerfile */ + withDockerfile(contextPath: string, options?: WithDockerfileOptions): ContainerResourcePromise; + /** Sets the container name */ + withContainerName(name: string): ContainerResourcePromise; + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource | Awaitable): ContainerResourcePromise; + /** Adds a build secret from a parameter resource */ + withBuildSecret(name: string, value: Awaitable): ContainerResourcePromise; + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): ContainerResourcePromise; + /** Configures endpoint proxy support */ + withEndpointProxySupport(proxyEnabled: boolean): ContainerResourcePromise; + /** Configures the resource to use a programmatically generated Dockerfile */ + withDockerfileBuilder(contextPath: string, callback: (arg: DockerfileBuilderCallbackContext) => Promise, options?: WithDockerfileBuilderOptions): ContainerResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ContainerResourcePromise; + /** Adds a network alias for the container */ + withContainerNetworkAlias(alias: string): ContainerResourcePromise; + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): ContainerResourcePromise; + /** Configures OTLP telemetry export */ + withOtlpExporter(options?: WithOtlpExporterOptions): ContainerResourcePromise; + /** Publishes the resource as a connection string */ + publishAsConnectionString(): ContainerResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ContainerResourcePromise; + /** Sets an environment variable */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): ContainerResourcePromise; + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ContainerResourcePromise; + /** Adds arguments */ + withArgs(args: string[]): ContainerResourcePromise; + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): ContainerResourcePromise; + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ContainerResourcePromise; + /** Adds a reference to another resource */ + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): ContainerResourcePromise; + /** Updates a named endpoint via callback */ + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): ContainerResourcePromise; + /** Updates an HTTP endpoint via callback */ + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): ContainerResourcePromise; + /** Updates an HTTPS endpoint via callback */ + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): ContainerResourcePromise; + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): ContainerResourcePromise; + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): ContainerResourcePromise; + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): ContainerResourcePromise; + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): ContainerResourcePromise; + /** Gets an endpoint reference */ + getEndpoint(name: string): Promise; + /** Configures resource for HTTP/2 */ + asHttp2Service(): ContainerResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): ContainerResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): ContainerResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ContainerResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): ContainerResourcePromise; + /** Waits for another resource to be ready */ + waitFor(dependency: Awaitable, options?: WaitForOptions): ContainerResourcePromise; + /** Waits for another resource to start */ + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): ContainerResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): ContainerResourcePromise; + /** Waits for resource completion */ + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): ContainerResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): ContainerResourcePromise; + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ContainerResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ContainerResourcePromise; + /** Adds an HTTP resource command */ + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): ContainerResourcePromise; + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): ContainerResourcePromise; + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): ContainerResourcePromise; + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ContainerResourcePromise; + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): ContainerResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): ContainerResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): ContainerResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): ContainerResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ContainerResourcePromise; + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ContainerResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ContainerResourcePromise; + /** Sets image push options via callback */ + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): ContainerResourcePromise; + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): ContainerResourcePromise; + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): ContainerResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ContainerResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ContainerResourcePromise; + /** Adds a volume */ + withVolume(target: string, options?: WithVolumeOptions): ContainerResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ContainerResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ContainerResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ContainerResourcePromise; + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ContainerResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ContainerResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Create a new reference, while also allowing customization of how a resource appears in the generated LikeC4 diagram. */ + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): ContainerResourcePromise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): ContainerResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): ContainerResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): ContainerResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): ContainerResourcePromise; + /** Associates an Azure user-assigned identity with a compute resource */ + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): ContainerResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): ContainerResourcePromise; +} + +export interface ContainerResourcePromise extends PromiseLike { + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): ContainerResourcePromise; + /** Adds a bind mount */ + withBindMount(source: string, target: string, options?: WithBindMountOptions): ContainerResourcePromise; + /** Sets the container entrypoint */ + withEntrypoint(entrypoint: string): ContainerResourcePromise; + /** Sets the container image tag */ + withImageTag(tag: string): ContainerResourcePromise; + /** Sets the container image registry */ + withImageRegistry(registry: string): ContainerResourcePromise; + /** Sets the container image */ + withImage(image: string, options?: WithImageOptions): ContainerResourcePromise; + /** Sets the image SHA256 digest */ + withImageSHA256(sha256: string): ContainerResourcePromise; + /** Adds runtime arguments for the container */ + withContainerRuntimeArgs(args: string[]): ContainerResourcePromise; + /** Sets the lifetime behavior of the container resource */ + withLifetime(lifetime: ContainerLifetime): ContainerResourcePromise; + /** Sets the container image pull policy */ + withImagePullPolicy(pullPolicy: ImagePullPolicy): ContainerResourcePromise; + /** Configures the resource to be published as a container */ + publishAsContainer(): ContainerResourcePromise; + /** Configures the resource to use a Dockerfile */ + withDockerfile(contextPath: string, options?: WithDockerfileOptions): ContainerResourcePromise; + /** Sets the container name */ + withContainerName(name: string): ContainerResourcePromise; + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource | Awaitable): ContainerResourcePromise; + /** Adds a build secret from a parameter resource */ + withBuildSecret(name: string, value: Awaitable): ContainerResourcePromise; + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): ContainerResourcePromise; + /** Configures endpoint proxy support */ + withEndpointProxySupport(proxyEnabled: boolean): ContainerResourcePromise; + /** Configures the resource to use a programmatically generated Dockerfile */ + withDockerfileBuilder(contextPath: string, callback: (arg: DockerfileBuilderCallbackContext) => Promise, options?: WithDockerfileBuilderOptions): ContainerResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ContainerResourcePromise; + /** Adds a network alias for the container */ + withContainerNetworkAlias(alias: string): ContainerResourcePromise; + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): ContainerResourcePromise; + /** Configures OTLP telemetry export */ + withOtlpExporter(options?: WithOtlpExporterOptions): ContainerResourcePromise; + /** Publishes the resource as a connection string */ + publishAsConnectionString(): ContainerResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ContainerResourcePromise; + /** Sets an environment variable */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): ContainerResourcePromise; + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ContainerResourcePromise; + /** Adds arguments */ + withArgs(args: string[]): ContainerResourcePromise; + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): ContainerResourcePromise; + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ContainerResourcePromise; + /** Adds a reference to another resource */ + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): ContainerResourcePromise; + /** Updates a named endpoint via callback */ + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): ContainerResourcePromise; + /** Updates an HTTP endpoint via callback */ + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): ContainerResourcePromise; + /** Updates an HTTPS endpoint via callback */ + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): ContainerResourcePromise; + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): ContainerResourcePromise; + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): ContainerResourcePromise; + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): ContainerResourcePromise; + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): ContainerResourcePromise; + /** Gets an endpoint reference */ + getEndpoint(name: string): Promise; + /** Configures resource for HTTP/2 */ + asHttp2Service(): ContainerResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): ContainerResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): ContainerResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ContainerResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): ContainerResourcePromise; + /** Waits for another resource to be ready */ + waitFor(dependency: Awaitable, options?: WaitForOptions): ContainerResourcePromise; + /** Waits for another resource to start */ + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): ContainerResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): ContainerResourcePromise; + /** Waits for resource completion */ + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): ContainerResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): ContainerResourcePromise; + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ContainerResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ContainerResourcePromise; + /** Adds an HTTP resource command */ + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): ContainerResourcePromise; + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): ContainerResourcePromise; + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): ContainerResourcePromise; + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ContainerResourcePromise; + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): ContainerResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): ContainerResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): ContainerResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): ContainerResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ContainerResourcePromise; + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ContainerResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ContainerResourcePromise; + /** Sets image push options via callback */ + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): ContainerResourcePromise; + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): ContainerResourcePromise; + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): ContainerResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ContainerResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ContainerResourcePromise; + /** Adds a volume */ + withVolume(target: string, options?: WithVolumeOptions): ContainerResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ContainerResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ContainerResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ContainerResourcePromise; + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ContainerResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ContainerResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Create a new reference, while also allowing customization of how a resource appears in the generated LikeC4 diagram. */ + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): ContainerResourcePromise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): ContainerResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): ContainerResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): ContainerResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): ContainerResourcePromise; + /** Associates an Azure user-assigned identity with a compute resource */ + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): ContainerResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): ContainerResourcePromise; +} + +// ============================================================================ +// ContainerResourceImpl +// ============================================================================ + +class ContainerResourceImpl extends ResourceBuilderBase implements ContainerResource { + constructor(handle: ContainerResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: Awaitable): Promise { + registry = isPromiseLike(registry) ? await registry : registry; + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withContainerRegistry(registry: Awaitable): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withContainerRegistryInternal(registry), this._client); + } + + /** @internal */ + private async _withBindMountInternal(source: string, target: string, isReadOnly?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, source, target }; + if (isReadOnly !== undefined) rpcArgs.isReadOnly = isReadOnly; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBindMount', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withBindMount(source: string, target: string, options?: WithBindMountOptions): ContainerResourcePromise { + const isReadOnly = options?.isReadOnly; + return new ContainerResourcePromiseImpl(this._withBindMountInternal(source, target, isReadOnly), this._client); + } + + /** @internal */ + private async _withEntrypointInternal(entrypoint: string): Promise { + const rpcArgs: Record = { builder: this._handle, entrypoint }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEntrypoint', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withEntrypoint(entrypoint: string): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withEntrypointInternal(entrypoint), this._client); + } + + /** @internal */ + private async _withImageTagInternal(tag: string): Promise { + const rpcArgs: Record = { builder: this._handle, tag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImageTag', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withImageTag(tag: string): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withImageTagInternal(tag), this._client); + } + + /** @internal */ + private async _withImageRegistryInternal(registry: string): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImageRegistry', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withImageRegistry(registry: string): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withImageRegistryInternal(registry), this._client); + } + + /** @internal */ + private async _withImageInternal(image: string, tag?: string): Promise { + const rpcArgs: Record = { builder: this._handle, image }; + if (tag !== undefined) rpcArgs.tag = tag; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImage', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withImage(image: string, options?: WithImageOptions): ContainerResourcePromise { + const tag = options?.tag; + return new ContainerResourcePromiseImpl(this._withImageInternal(image, tag), this._client); + } + + /** @internal */ + private async _withImageSHA256Internal(sha256: string): Promise { + const rpcArgs: Record = { builder: this._handle, sha256 }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImageSHA256', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withImageSHA256(sha256: string): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withImageSHA256Internal(sha256), this._client); + } + + /** @internal */ + private async _withContainerRuntimeArgsInternal(args: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, args }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRuntimeArgs', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withContainerRuntimeArgs(args: string[]): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withContainerRuntimeArgsInternal(args), this._client); + } + + /** @internal */ + private async _withLifetimeInternal(lifetime: ContainerLifetime): Promise { + const rpcArgs: Record = { builder: this._handle, lifetime }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withLifetime', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withLifetime(lifetime: ContainerLifetime): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withLifetimeInternal(lifetime), this._client); + } + + /** @internal */ + private async _withImagePullPolicyInternal(pullPolicy: ImagePullPolicy): Promise { + const rpcArgs: Record = { builder: this._handle, pullPolicy }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImagePullPolicy', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withImagePullPolicy(pullPolicy: ImagePullPolicy): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withImagePullPolicyInternal(pullPolicy), this._client); + } + + /** @internal */ + private async _publishAsContainerInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsContainer', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + publishAsContainer(): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._publishAsContainerInternal(), this._client); + } + + /** @internal */ + private async _withDockerfileInternal(contextPath: string, dockerfilePath?: string, stage?: string): Promise { + const rpcArgs: Record = { builder: this._handle, contextPath }; + if (dockerfilePath !== undefined) rpcArgs.dockerfilePath = dockerfilePath; + if (stage !== undefined) rpcArgs.stage = stage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfile', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withDockerfile(contextPath: string, options?: WithDockerfileOptions): ContainerResourcePromise { + const dockerfilePath = options?.dockerfilePath; + const stage = options?.stage; + return new ContainerResourcePromiseImpl(this._withDockerfileInternal(contextPath, dockerfilePath, stage), this._client); + } + + /** @internal */ + private async _withContainerNameInternal(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerName', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withContainerName(name: string): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withContainerNameInternal(name), this._client); + } + + /** @internal */ + private async _withBuildArgInternal(name: string, value: string | ParameterResource | Awaitable): Promise { + value = isPromiseLike(value) ? await value : value; + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuildArg', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withBuildArg(name: string, value: string | ParameterResource | Awaitable): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withBuildArgInternal(name, value), this._client); + } + + /** @internal */ + private async _withBuildSecretInternal(name: string, value: Awaitable): Promise { + value = isPromiseLike(value) ? await value : value; + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParameterBuildSecret', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withBuildSecret(name: string, value: Awaitable): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withBuildSecretInternal(name, value), this._client); + } + + /** @internal */ + private async _withContainerCertificatePathsInternal(customCertificatesDestination?: string, defaultCertificateBundlePaths?: string[], defaultCertificateDirectoryPaths?: string[]): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (customCertificatesDestination !== undefined) rpcArgs.customCertificatesDestination = customCertificatesDestination; + if (defaultCertificateBundlePaths !== undefined) rpcArgs.defaultCertificateBundlePaths = defaultCertificateBundlePaths; + if (defaultCertificateDirectoryPaths !== undefined) rpcArgs.defaultCertificateDirectoryPaths = defaultCertificateDirectoryPaths; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerCertificatePaths', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): ContainerResourcePromise { + const customCertificatesDestination = options?.customCertificatesDestination; + const defaultCertificateBundlePaths = options?.defaultCertificateBundlePaths; + const defaultCertificateDirectoryPaths = options?.defaultCertificateDirectoryPaths; + return new ContainerResourcePromiseImpl(this._withContainerCertificatePathsInternal(customCertificatesDestination, defaultCertificateBundlePaths, defaultCertificateDirectoryPaths), this._client); + } + + /** @internal */ + private async _withEndpointProxySupportInternal(proxyEnabled: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, proxyEnabled }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpointProxySupport', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withEndpointProxySupport(proxyEnabled: boolean): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withEndpointProxySupportInternal(proxyEnabled), this._client); + } + + /** @internal */ + private async _withDockerfileBuilderInternal(contextPath: string, callback: (arg: DockerfileBuilderCallbackContext) => Promise, stage?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as DockerfileBuilderCallbackContextHandle; + const arg = new DockerfileBuilderCallbackContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, contextPath, callback: callbackId }; + if (stage !== undefined) rpcArgs.stage = stage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBuilder', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withDockerfileBuilder(contextPath: string, callback: (arg: DockerfileBuilderCallbackContext) => Promise, options?: WithDockerfileBuilderOptions): ContainerResourcePromise { + const stage = options?.stage; + return new ContainerResourcePromiseImpl(this._withDockerfileBuilderInternal(contextPath, callback, stage), this._client); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ContainerResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new ContainerResourcePromiseImpl(this._withDockerfileBaseImageInternal(buildImage, runtimeImage), this._client); + } + + /** @internal */ + private async _withContainerNetworkAliasInternal(alias: string): Promise { + const rpcArgs: Record = { builder: this._handle, alias }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerNetworkAlias', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withContainerNetworkAlias(alias: string): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withContainerNetworkAliasInternal(alias), this._client); + } + + /** @internal */ + private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withMcpServer', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withMcpServer(options?: WithMcpServerOptions): ContainerResourcePromise { + const path = options?.path; + const endpointName = options?.endpointName; + return new ContainerResourcePromiseImpl(this._withMcpServerInternal(path, endpointName), this._client); + } + + /** @internal */ + private async _withOtlpExporterInternal(protocol?: OtlpProtocol): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (protocol !== undefined) rpcArgs.protocol = protocol; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporter', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withOtlpExporter(options?: WithOtlpExporterOptions): ContainerResourcePromise { + const protocol = options?.protocol; + return new ContainerResourcePromiseImpl(this._withOtlpExporterInternal(protocol), this._client); + } + + /** @internal */ + private async _publishAsConnectionStringInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsConnectionString', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + publishAsConnectionString(): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._publishAsConnectionStringInternal(), this._client); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ContainerResourcePromise { + const helpLink = options?.helpLink; + return new ContainerResourcePromiseImpl(this._withRequiredCommandInternal(command, helpLink), this._client); + } + + /** @internal */ + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): Promise { + value = isPromiseLike(value) ? await value : value; + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironment', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withEnvironmentInternal(name, value), this._client); + } + + /** @internal */ + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentCallback', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withEnvironmentCallbackInternal(callback), this._client); + } + + /** @internal */ + private async _withArgsInternal(args: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, args }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgs', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withArgs(args: string[]): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withArgsInternal(args), this._client); + } + + /** @internal */ + private async _withArgsCallbackInternal(callback: (obj: CommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; + const obj = new CommandLineArgsCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallback', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withArgsCallbackInternal(callback), this._client); + } + + /** @internal */ + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceEnvironment', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withReferenceEnvironmentInternal(options), this._client); + } + + /** @internal */ + private async _withReferenceInternal(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, connectionName?: string, optional?: boolean, name?: string): Promise { + source = isPromiseLike(source) ? await source : source; + const rpcArgs: Record = { builder: this._handle, source }; + if (connectionName !== undefined) rpcArgs.connectionName = connectionName; + if (optional !== undefined) rpcArgs.optional = optional; + if (name !== undefined) rpcArgs.name = name; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReference', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): ContainerResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new ContainerResourcePromiseImpl(this._withReferenceInternal(source, connectionName, optional, name), this._client); + } + + /** @internal */ + private async _withEndpointCallbackInternal(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpointCallback', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): ContainerResourcePromise { + const createIfNotExists = options?.createIfNotExists; + return new ContainerResourcePromiseImpl(this._withEndpointCallbackInternal(endpointName, callback, createIfNotExists), this._client); + } + + /** @internal */ + private async _withHttpEndpointCallbackInternal(callback: (obj: EndpointUpdateContext) => Promise, name?: string, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + if (name !== undefined) rpcArgs.name = name; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpEndpointCallback', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): ContainerResourcePromise { + const name = options?.name; + const createIfNotExists = options?.createIfNotExists; + return new ContainerResourcePromiseImpl(this._withHttpEndpointCallbackInternal(callback, name, createIfNotExists), this._client); + } + + /** @internal */ + private async _withHttpsEndpointCallbackInternal(callback: (obj: EndpointUpdateContext) => Promise, name?: string, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + if (name !== undefined) rpcArgs.name = name; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsEndpointCallback', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): ContainerResourcePromise { + const name = options?.name; + const createIfNotExists = options?.createIfNotExists; + return new ContainerResourcePromiseImpl(this._withHttpsEndpointCallbackInternal(callback, name, createIfNotExists), this._client); + } + + /** @internal */ + private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (scheme !== undefined) rpcArgs.scheme = scheme; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + if (isExternal !== undefined) rpcArgs.isExternal = isExternal; + if (protocol !== undefined) rpcArgs.protocol = protocol; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpoint', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withEndpoint(options?: WithEndpointOptions): ContainerResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const scheme = options?.scheme; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + const isExternal = options?.isExternal; + const protocol = options?.protocol; + return new ContainerResourcePromiseImpl(this._withEndpointInternal(port, targetPort, scheme, name, env, isProxied, isExternal, protocol), this._client); + } + + /** @internal */ + private async _withHttpEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpEndpoint', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withHttpEndpoint(options?: WithHttpEndpointOptions): ContainerResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new ContainerResourcePromiseImpl(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied), this._client); + } + + /** @internal */ + private async _withHttpsEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsEndpoint', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withHttpsEndpoint(options?: WithHttpsEndpointOptions): ContainerResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new ContainerResourcePromiseImpl(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied), this._client); + } + + /** @internal */ + private async _withExternalHttpEndpointsInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExternalHttpEndpoints', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withExternalHttpEndpoints(): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withExternalHttpEndpointsInternal(), this._client); + } + + async getEndpoint(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getEndpoint', + rpcArgs + ); + } + + /** @internal */ + private async _asHttp2ServiceInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/asHttp2Service', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + asHttp2Service(): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._asHttp2ServiceInternal(), this._client); + } + + /** @internal */ + private async _withUrlsInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrls', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withUrlsInternal(callback), this._client); + } + + /** @internal */ + private async _withUrlInternal(url: string | ReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): ContainerResourcePromise { + const displayText = options?.displayText; + return new ContainerResourcePromiseImpl(this._withUrlInternal(url, displayText), this._client); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withUrlForEndpointInternal(endpointName, callback), this._client); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + excludeFromManifest(): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._excludeFromManifestInternal(), this._client); + } + + /** @internal */ + private async _waitForInternal(dependency: Awaitable, waitBehavior?: WaitBehavior): Promise { + dependency = isPromiseLike(dependency) ? await dependency : dependency; + const rpcArgs: Record = { builder: this._handle, dependency }; + if (waitBehavior !== undefined) rpcArgs.waitBehavior = waitBehavior; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitFor', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + waitFor(dependency: Awaitable, options?: WaitForOptions): ContainerResourcePromise { + const waitBehavior = options?.waitBehavior; + return new ContainerResourcePromiseImpl(this._waitForInternal(dependency, waitBehavior), this._client); + } + + /** @internal */ + private async _waitForStartInternal(dependency: Awaitable, waitBehavior?: WaitBehavior): Promise { + dependency = isPromiseLike(dependency) ? await dependency : dependency; + const rpcArgs: Record = { builder: this._handle, dependency }; + if (waitBehavior !== undefined) rpcArgs.waitBehavior = waitBehavior; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStart', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): ContainerResourcePromise { + const waitBehavior = options?.waitBehavior; + return new ContainerResourcePromiseImpl(this._waitForStartInternal(dependency, waitBehavior), this._client); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withExplicitStart(): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withExplicitStartInternal(), this._client); + } + + /** @internal */ + private async _waitForCompletionInternal(dependency: Awaitable, exitCode?: number): Promise { + dependency = isPromiseLike(dependency) ? await dependency : dependency; + const rpcArgs: Record = { builder: this._handle, dependency }; + if (exitCode !== undefined) rpcArgs.exitCode = exitCode; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceCompletion', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): ContainerResourcePromise { + const exitCode = options?.exitCode; + return new ContainerResourcePromiseImpl(this._waitForCompletionInternal(dependency, exitCode), this._client); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withHealthCheck(key: string): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withHealthCheckInternal(key), this._client); + } + + /** @internal */ + private async _withHttpHealthCheckInternal(path?: string, statusCode?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (statusCode !== undefined) rpcArgs.statusCode = statusCode; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpHealthCheck', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ContainerResourcePromise { + const path = options?.path; + const statusCode = options?.statusCode; + const endpointName = options?.endpointName; + return new ContainerResourcePromiseImpl(this._withHttpHealthCheckInternal(path, statusCode, endpointName), this._client); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContextImpl(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ContainerResourcePromise { + const commandOptions = options?.commandOptions; + return new ContainerResourcePromiseImpl(this._withCommandInternal(name, displayName, executeCommand, commandOptions), this._client); + } + + /** @internal */ + private async _withHttpCommandInternal(path: string, displayName: string, options?: HttpCommandExportOptions): Promise { + const rpcArgs: Record = { builder: this._handle, path, displayName }; + if (options !== undefined) rpcArgs.options = options; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpCommand', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withHttpCommandInternal(path, displayName, options), this._client); + } + + /** @internal */ + private async _withDeveloperCertificateTrustInternal(trust: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, trust }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDeveloperCertificateTrust', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withDeveloperCertificateTrust(trust: boolean): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withDeveloperCertificateTrustInternal(trust), this._client); + } + + /** @internal */ + private async _withCertificateTrustScopeInternal(scope: CertificateTrustScope): Promise { + const rpcArgs: Record = { builder: this._handle, scope }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCertificateTrustScope', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withCertificateTrustScope(scope: CertificateTrustScope): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withCertificateTrustScopeInternal(scope), this._client); + } + + /** @internal */ + private async _withHttpsDeveloperCertificateInternal(password?: Awaitable): Promise { + password = isPromiseLike(password) ? await password : password; + const rpcArgs: Record = { builder: this._handle }; + if (password !== undefined) rpcArgs.password = password; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ContainerResourcePromise { + let password = options?.password; + return new ContainerResourcePromiseImpl(this._withHttpsDeveloperCertificateInternal(password), this._client); + } + + /** @internal */ + private async _withoutHttpsCertificateInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withoutHttpsCertificate', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withoutHttpsCertificate(): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withoutHttpsCertificateInternal(), this._client); + } + + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: Awaitable, type: string): Promise { + resourceBuilder = isPromiseLike(resourceBuilder) ? await resourceBuilder : resourceBuilder; + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withRelationshipInternal(resourceBuilder, type), this._client); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: Awaitable): Promise { + parent = isPromiseLike(parent) ? await parent : parent; + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withParentRelationship(parent: Awaitable): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withParentRelationshipInternal(parent), this._client); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: Awaitable): Promise { + child = isPromiseLike(child) ? await child : child; + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withChildRelationship(child: Awaitable): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withChildRelationshipInternal(child), this._client); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): ContainerResourcePromise { + const iconVariant = options?.iconVariant; + return new ContainerResourcePromiseImpl(this._withIconNameInternal(iconName, iconVariant), this._client); + } + + /** @internal */ + private async _withHttpProbeInternal(probeType: ProbeType, path?: string, initialDelaySeconds?: number, periodSeconds?: number, timeoutSeconds?: number, failureThreshold?: number, successThreshold?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, probeType }; + if (path !== undefined) rpcArgs.path = path; + if (initialDelaySeconds !== undefined) rpcArgs.initialDelaySeconds = initialDelaySeconds; + if (periodSeconds !== undefined) rpcArgs.periodSeconds = periodSeconds; + if (timeoutSeconds !== undefined) rpcArgs.timeoutSeconds = timeoutSeconds; + if (failureThreshold !== undefined) rpcArgs.failureThreshold = failureThreshold; + if (successThreshold !== undefined) rpcArgs.successThreshold = successThreshold; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpProbe', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ContainerResourcePromise { + const path = options?.path; + const initialDelaySeconds = options?.initialDelaySeconds; + const periodSeconds = options?.periodSeconds; + const timeoutSeconds = options?.timeoutSeconds; + const failureThreshold = options?.failureThreshold; + const successThreshold = options?.successThreshold; + const endpointName = options?.endpointName; + return new ContainerResourcePromiseImpl(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName), this._client); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + excludeFromMcp(): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._excludeFromMcpInternal(), this._client); + } + + /** @internal */ + private async _withImagePushOptionsInternal(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ContainerImagePushOptionsCallbackContextHandle; + const arg = new ContainerImagePushOptionsCallbackContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImagePushOptions', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withImagePushOptionsInternal(callback), this._client); + } + + /** @internal */ + private async _withRemoteImageNameInternal(remoteImageName: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageName', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withRemoteImageName(remoteImageName: string): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withRemoteImageNameInternal(remoteImageName), this._client); + } + + /** @internal */ + private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageTag', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withRemoteImageTag(remoteImageTag: string): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withRemoteImageTagInternal(remoteImageTag), this._client); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ContainerResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new ContainerResourcePromiseImpl(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description), this._client); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withPipelineConfigurationInternal(callback), this._client); + } + + /** @internal */ + private async _withVolumeInternal(target: string, name?: string, isReadOnly?: boolean): Promise { + const rpcArgs: Record = { resource: this._handle, target }; + if (name !== undefined) rpcArgs.name = name; + if (isReadOnly !== undefined) rpcArgs.isReadOnly = isReadOnly; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withVolume', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withVolume(target: string, options?: WithVolumeOptions): ContainerResourcePromise { + const name = options?.name; + const isReadOnly = options?.isReadOnly; + return new ContainerResourcePromiseImpl(this._withVolumeInternal(target, name, isReadOnly), this._client); + } + + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); + } + + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._onBeforeResourceStartedInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._onResourceStoppedInternal(callback), this._client); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._onInitializeResourceInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceEndpointsAllocated', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._onResourceEndpointsAllocatedInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._onResourceReadyInternal(callback), this._client); + } + + async createExecutionConfiguration(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/createExecutionConfiguration', + rpcArgs + ); + } + + /** @internal */ + private async _withLikeC4ReferenceWithEnvironmentInternal(source: Awaitable, configure?: (obj: LikeC4RelationshipDetailsAnnotation) => Promise, connectionName?: string, optional?: boolean, skipAspireReference?: boolean): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4RelationshipDetailsAnnotationHandle; + const obj = new LikeC4RelationshipDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + source = isPromiseLike(source) ? await source : source; + const rpcArgs: Record = { builder: this._handle, source }; + if (configure !== undefined) rpcArgs.configure = configureId; + if (connectionName !== undefined) rpcArgs.connectionName = connectionName; + if (optional !== undefined) rpcArgs.optional = optional; + if (skipAspireReference !== undefined) rpcArgs.skipAspireReference = skipAspireReference; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4ReferenceWithEnvironment', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): ContainerResourcePromise { + const configure = options?.configure; + const connectionName = options?.connectionName; + const optional = options?.optional; + const skipAspireReference = options?.skipAspireReference; + return new ContainerResourcePromiseImpl(this._withLikeC4ReferenceWithEnvironmentInternal(source, configure, connectionName, optional, skipAspireReference), this._client); + } + + /** @internal */ + private async _withLikeC4DetailsInternal(label?: string, technology?: string, description?: string, summary?: string, icon?: string, configure?: (obj: LikeC4NodeDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4NodeDetailsAnnotationHandle; + const obj = new LikeC4NodeDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + const rpcArgs: Record = { builder: this._handle }; + if (label !== undefined) rpcArgs.label = label; + if (technology !== undefined) rpcArgs.technology = technology; + if (description !== undefined) rpcArgs.description = description; + if (summary !== undefined) rpcArgs.summary = summary; + if (icon !== undefined) rpcArgs.icon = icon; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4DetailsParameters', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): ContainerResourcePromise { + const label = options?.label; + const technology = options?.technology; + const description = options?.description; + const summary = options?.summary; + const icon = options?.icon; + const configure = options?.configure; + return new ContainerResourcePromiseImpl(this._withLikeC4DetailsInternal(label, technology, description, summary, icon, configure), this._client); + } + + /** @internal */ + private async _withLikeC4ReferenceInternal(target: Awaitable, configure?: (obj: LikeC4RelationshipDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4RelationshipDetailsAnnotationHandle; + const obj = new LikeC4RelationshipDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target }; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Reference', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): ContainerResourcePromise { + const configure = options?.configure; + return new ContainerResourcePromiseImpl(this._withLikeC4ReferenceInternal(target, configure), this._client); + } + + /** @internal */ + private async _withLikeC4GroupInternal(groupName: string): Promise { + const rpcArgs: Record = { builder: this._handle, groupName }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Group', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withLikeC4Group(groupName: string): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withLikeC4GroupInternal(groupName), this._client); + } + + /** @internal */ + private async _excludeFromLikeC4Internal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/excludeFromLikeC4', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + excludeFromLikeC4(): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._excludeFromLikeC4Internal(), this._client); + } + + /** @internal */ + private async _withAzureUserAssignedIdentityInternal(identityResourceBuilder: Awaitable): Promise { + identityResourceBuilder = isPromiseLike(identityResourceBuilder) ? await identityResourceBuilder : identityResourceBuilder; + const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withAzureUserAssignedIdentityInternal(identityResourceBuilder), this._client); + } + + /** @internal */ + private async _withRoleAssignmentsInternal(target: Awaitable, roles: AzureKeyVaultRole[]): Promise { + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target, roles }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.KeyVault/withKeyVaultRoleAssignments', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withRoleAssignmentsInternal(target, roles), this._client); + } + +} + +/** + * Thenable wrapper for ContainerResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +class ContainerResourcePromiseImpl implements ContainerResourcePromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: ContainerResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + withContainerRegistry(registry: Awaitable): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withContainerRegistry(registry)), this._client); + } + + withBindMount(source: string, target: string, options?: WithBindMountOptions): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withBindMount(source, target, options)), this._client); + } + + withEntrypoint(entrypoint: string): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withEntrypoint(entrypoint)), this._client); + } + + withImageTag(tag: string): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withImageTag(tag)), this._client); + } + + withImageRegistry(registry: string): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withImageRegistry(registry)), this._client); + } + + withImage(image: string, options?: WithImageOptions): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withImage(image, options)), this._client); + } + + withImageSHA256(sha256: string): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withImageSHA256(sha256)), this._client); + } + + withContainerRuntimeArgs(args: string[]): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withContainerRuntimeArgs(args)), this._client); + } + + withLifetime(lifetime: ContainerLifetime): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withLifetime(lifetime)), this._client); + } + + withImagePullPolicy(pullPolicy: ImagePullPolicy): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withImagePullPolicy(pullPolicy)), this._client); + } + + publishAsContainer(): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.publishAsContainer()), this._client); + } + + withDockerfile(contextPath: string, options?: WithDockerfileOptions): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withDockerfile(contextPath, options)), this._client); + } + + withContainerName(name: string): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withContainerName(name)), this._client); + } + + withBuildArg(name: string, value: string | ParameterResource | Awaitable): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withBuildArg(name, value)), this._client); + } + + withBuildSecret(name: string, value: Awaitable): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withBuildSecret(name, value)), this._client); + } + + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withContainerCertificatePaths(options)), this._client); + } + + withEndpointProxySupport(proxyEnabled: boolean): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withEndpointProxySupport(proxyEnabled)), this._client); + } + + withDockerfileBuilder(contextPath: string, callback: (arg: DockerfileBuilderCallbackContext) => Promise, options?: WithDockerfileBuilderOptions): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withDockerfileBuilder(contextPath, callback, options)), this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withDockerfileBaseImage(options)), this._client); + } + + withContainerNetworkAlias(alias: string): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withContainerNetworkAlias(alias)), this._client); + } + + withMcpServer(options?: WithMcpServerOptions): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withMcpServer(options)), this._client); + } + + withOtlpExporter(options?: WithOtlpExporterOptions): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withOtlpExporter(options)), this._client); + } + + publishAsConnectionString(): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.publishAsConnectionString()), this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withRequiredCommand(command, options)), this._client); + } + + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withEnvironment(name, value)), this._client); + } + + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentCallback(callback)), this._client); + } + + withArgs(args: string[]): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withArgs(args)), this._client); + } + + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withArgsCallback(callback)), this._client); + } + + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withReferenceEnvironment(options)), this._client); + } + + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withReference(source, options)), this._client); + } + + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withEndpointCallback(endpointName, callback, options)), this._client); + } + + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withHttpEndpointCallback(callback, options)), this._client); + } + + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withHttpsEndpointCallback(callback, options)), this._client); + } + + withEndpoint(options?: WithEndpointOptions): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withEndpoint(options)), this._client); + } + + withHttpEndpoint(options?: WithHttpEndpointOptions): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withHttpEndpoint(options)), this._client); + } + + withHttpsEndpoint(options?: WithHttpsEndpointOptions): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withHttpsEndpoint(options)), this._client); + } + + withExternalHttpEndpoints(): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withExternalHttpEndpoints()), this._client); + } + + getEndpoint(name: string): Promise { + return this._promise.then(obj => obj.getEndpoint(name)); + } + + asHttp2Service(): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.asHttp2Service()), this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withUrls(callback)), this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withUrl(url, options)), this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback)), this._client); + } + + excludeFromManifest(): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.excludeFromManifest()), this._client); + } + + waitFor(dependency: Awaitable, options?: WaitForOptions): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.waitFor(dependency, options)), this._client); + } + + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.waitForStart(dependency, options)), this._client); + } + + withExplicitStart(): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withExplicitStart()), this._client); + } + + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.waitForCompletion(dependency, options)), this._client); + } + + withHealthCheck(key: string): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withHealthCheck(key)), this._client); + } + + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withHttpHealthCheck(options)), this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options)), this._client); + } + + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withHttpCommand(path, displayName, options)), this._client); + } + + withDeveloperCertificateTrust(trust: boolean): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust)), this._client); + } + + withCertificateTrustScope(scope: CertificateTrustScope): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withCertificateTrustScope(scope)), this._client); + } + + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options)), this._client); + } + + withoutHttpsCertificate(): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withoutHttpsCertificate()), this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withRelationship(resourceBuilder, type)), this._client); + } + + withParentRelationship(parent: Awaitable): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withParentRelationship(parent)), this._client); + } + + withChildRelationship(child: Awaitable): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withChildRelationship(child)), this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withIconName(iconName, options)), this._client); + } + + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withHttpProbe(probeType, options)), this._client); + } + + excludeFromMcp(): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.excludeFromMcp()), this._client); + } + + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withImagePushOptions(callback)), this._client); + } + + withRemoteImageName(remoteImageName: string): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withRemoteImageName(remoteImageName)), this._client); + } + + withRemoteImageTag(remoteImageTag: string): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag)), this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options)), this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withPipelineConfiguration(callback)), this._client); + } + + withVolume(target: string, options?: WithVolumeOptions): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withVolume(target, options)), this._client); + } + + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.onBeforeResourceStarted(callback)), this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.onResourceStopped(callback)), this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.onInitializeResource(callback)), this._client); + } + + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback)), this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.onResourceReady(callback)), this._client); + } + + createExecutionConfiguration(): Promise { + return this._promise.then(obj => obj.createExecutionConfiguration()); + } + + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4ReferenceWithEnvironment(source, options)), this._client); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Details(options)), this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Reference(target, options)), this._client); + } + + withLikeC4Group(groupName: string): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Group(groupName)), this._client); + } + + excludeFromLikeC4(): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.excludeFromLikeC4()), this._client); + } + + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withAzureUserAssignedIdentity(identityResourceBuilder)), this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withRoleAssignments(target, roles)), this._client); + } + +} + +// ============================================================================ +// CSharpAppResource +// ============================================================================ + +export interface CSharpAppResource { + toJSON(): MarshalledHandle; + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): CSharpAppResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): CSharpAppResourcePromise; + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): CSharpAppResourcePromise; + /** Configures OTLP telemetry export */ + withOtlpExporter(options?: WithOtlpExporterOptions): CSharpAppResourcePromise; + /** Sets the number of replicas */ + withReplicas(replicas: number): CSharpAppResourcePromise; + /** Disables forwarded headers for the project */ + disableForwardedHeaders(): CSharpAppResourcePromise; + /** Publishes a project as a Docker file with optional container configuration */ + publishAsDockerFile(options?: PublishAsDockerFileOptions): CSharpAppResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): CSharpAppResourcePromise; + /** Sets an environment variable */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): CSharpAppResourcePromise; + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise; + /** Adds arguments */ + withArgs(args: string[]): CSharpAppResourcePromise; + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): CSharpAppResourcePromise; + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): CSharpAppResourcePromise; + /** Adds a reference to another resource */ + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): CSharpAppResourcePromise; + /** Updates a named endpoint via callback */ + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): CSharpAppResourcePromise; + /** Updates an HTTP endpoint via callback */ + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): CSharpAppResourcePromise; + /** Updates an HTTPS endpoint via callback */ + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): CSharpAppResourcePromise; + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): CSharpAppResourcePromise; + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): CSharpAppResourcePromise; + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): CSharpAppResourcePromise; + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): CSharpAppResourcePromise; + /** Gets an endpoint reference */ + getEndpoint(name: string): Promise; + /** Configures resource for HTTP/2 */ + asHttp2Service(): CSharpAppResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): CSharpAppResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): CSharpAppResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): CSharpAppResourcePromise; + /** Configures the resource to copy container files from the specified source during publishing */ + publishWithContainerFiles(source: Awaitable, destinationPath: string): CSharpAppResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): CSharpAppResourcePromise; + /** Waits for another resource to be ready */ + waitFor(dependency: Awaitable, options?: WaitForOptions): CSharpAppResourcePromise; + /** Waits for another resource to start */ + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): CSharpAppResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): CSharpAppResourcePromise; + /** Waits for resource completion */ + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): CSharpAppResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): CSharpAppResourcePromise; + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): CSharpAppResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): CSharpAppResourcePromise; + /** Adds an HTTP resource command */ + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): CSharpAppResourcePromise; + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): CSharpAppResourcePromise; + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): CSharpAppResourcePromise; + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): CSharpAppResourcePromise; + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): CSharpAppResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): CSharpAppResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): CSharpAppResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): CSharpAppResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): CSharpAppResourcePromise; + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): CSharpAppResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): CSharpAppResourcePromise; + /** Sets image push options via callback */ + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): CSharpAppResourcePromise; + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): CSharpAppResourcePromise; + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): CSharpAppResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): CSharpAppResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): CSharpAppResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): CSharpAppResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): CSharpAppResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): CSharpAppResourcePromise; + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): CSharpAppResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): CSharpAppResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Create a new reference, while also allowing customization of how a resource appears in the generated LikeC4 diagram. */ + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): CSharpAppResourcePromise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): CSharpAppResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): CSharpAppResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): CSharpAppResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): CSharpAppResourcePromise; + /** Associates an Azure user-assigned identity with a compute resource */ + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): CSharpAppResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): CSharpAppResourcePromise; +} + +export interface CSharpAppResourcePromise extends PromiseLike { + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): CSharpAppResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): CSharpAppResourcePromise; + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): CSharpAppResourcePromise; + /** Configures OTLP telemetry export */ + withOtlpExporter(options?: WithOtlpExporterOptions): CSharpAppResourcePromise; + /** Sets the number of replicas */ + withReplicas(replicas: number): CSharpAppResourcePromise; + /** Disables forwarded headers for the project */ + disableForwardedHeaders(): CSharpAppResourcePromise; + /** Publishes a project as a Docker file with optional container configuration */ + publishAsDockerFile(options?: PublishAsDockerFileOptions): CSharpAppResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): CSharpAppResourcePromise; + /** Sets an environment variable */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): CSharpAppResourcePromise; + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise; + /** Adds arguments */ + withArgs(args: string[]): CSharpAppResourcePromise; + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): CSharpAppResourcePromise; + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): CSharpAppResourcePromise; + /** Adds a reference to another resource */ + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): CSharpAppResourcePromise; + /** Updates a named endpoint via callback */ + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): CSharpAppResourcePromise; + /** Updates an HTTP endpoint via callback */ + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): CSharpAppResourcePromise; + /** Updates an HTTPS endpoint via callback */ + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): CSharpAppResourcePromise; + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): CSharpAppResourcePromise; + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): CSharpAppResourcePromise; + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): CSharpAppResourcePromise; + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): CSharpAppResourcePromise; + /** Gets an endpoint reference */ + getEndpoint(name: string): Promise; + /** Configures resource for HTTP/2 */ + asHttp2Service(): CSharpAppResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): CSharpAppResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): CSharpAppResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): CSharpAppResourcePromise; + /** Configures the resource to copy container files from the specified source during publishing */ + publishWithContainerFiles(source: Awaitable, destinationPath: string): CSharpAppResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): CSharpAppResourcePromise; + /** Waits for another resource to be ready */ + waitFor(dependency: Awaitable, options?: WaitForOptions): CSharpAppResourcePromise; + /** Waits for another resource to start */ + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): CSharpAppResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): CSharpAppResourcePromise; + /** Waits for resource completion */ + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): CSharpAppResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): CSharpAppResourcePromise; + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): CSharpAppResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): CSharpAppResourcePromise; + /** Adds an HTTP resource command */ + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): CSharpAppResourcePromise; + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): CSharpAppResourcePromise; + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): CSharpAppResourcePromise; + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): CSharpAppResourcePromise; + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): CSharpAppResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): CSharpAppResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): CSharpAppResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): CSharpAppResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): CSharpAppResourcePromise; + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): CSharpAppResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): CSharpAppResourcePromise; + /** Sets image push options via callback */ + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): CSharpAppResourcePromise; + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): CSharpAppResourcePromise; + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): CSharpAppResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): CSharpAppResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): CSharpAppResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): CSharpAppResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): CSharpAppResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): CSharpAppResourcePromise; + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): CSharpAppResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): CSharpAppResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Create a new reference, while also allowing customization of how a resource appears in the generated LikeC4 diagram. */ + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): CSharpAppResourcePromise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): CSharpAppResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): CSharpAppResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): CSharpAppResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): CSharpAppResourcePromise; + /** Associates an Azure user-assigned identity with a compute resource */ + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): CSharpAppResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): CSharpAppResourcePromise; +} + +// ============================================================================ +// CSharpAppResourceImpl +// ============================================================================ + +class CSharpAppResourceImpl extends ResourceBuilderBase implements CSharpAppResource { + constructor(handle: CSharpAppResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: Awaitable): Promise { + registry = isPromiseLike(registry) ? await registry : registry; + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + withContainerRegistry(registry: Awaitable): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._withContainerRegistryInternal(registry), this._client); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): CSharpAppResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new CSharpAppResourcePromiseImpl(this._withDockerfileBaseImageInternal(buildImage, runtimeImage), this._client); + } + + /** @internal */ + private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withMcpServer', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + withMcpServer(options?: WithMcpServerOptions): CSharpAppResourcePromise { + const path = options?.path; + const endpointName = options?.endpointName; + return new CSharpAppResourcePromiseImpl(this._withMcpServerInternal(path, endpointName), this._client); + } + + /** @internal */ + private async _withOtlpExporterInternal(protocol?: OtlpProtocol): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (protocol !== undefined) rpcArgs.protocol = protocol; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporter', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + withOtlpExporter(options?: WithOtlpExporterOptions): CSharpAppResourcePromise { + const protocol = options?.protocol; + return new CSharpAppResourcePromiseImpl(this._withOtlpExporterInternal(protocol), this._client); + } + + /** @internal */ + private async _withReplicasInternal(replicas: number): Promise { + const rpcArgs: Record = { builder: this._handle, replicas }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReplicas', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + withReplicas(replicas: number): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._withReplicasInternal(replicas), this._client); + } + + /** @internal */ + private async _disableForwardedHeadersInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/disableForwardedHeaders', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + disableForwardedHeaders(): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._disableForwardedHeadersInternal(), this._client); + } + + /** @internal */ + private async _publishAsDockerFileInternal(configure?: (obj: ContainerResource) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ContainerResourceHandle; + const obj = new ContainerResourceImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + const rpcArgs: Record = { builder: this._handle }; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishProjectAsDockerFileWithConfigure', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + publishAsDockerFile(options?: PublishAsDockerFileOptions): CSharpAppResourcePromise { + const configure = options?.configure; + return new CSharpAppResourcePromiseImpl(this._publishAsDockerFileInternal(configure), this._client); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): CSharpAppResourcePromise { + const helpLink = options?.helpLink; + return new CSharpAppResourcePromiseImpl(this._withRequiredCommandInternal(command, helpLink), this._client); + } + + /** @internal */ + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): Promise { + value = isPromiseLike(value) ? await value : value; + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironment', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._withEnvironmentInternal(name, value), this._client); + } + + /** @internal */ + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentCallback', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._withEnvironmentCallbackInternal(callback), this._client); + } + + /** @internal */ + private async _withArgsInternal(args: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, args }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgs', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + withArgs(args: string[]): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._withArgsInternal(args), this._client); + } + + /** @internal */ + private async _withArgsCallbackInternal(callback: (obj: CommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; + const obj = new CommandLineArgsCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallback', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._withArgsCallbackInternal(callback), this._client); + } + + /** @internal */ + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceEnvironment', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._withReferenceEnvironmentInternal(options), this._client); + } + + /** @internal */ + private async _withReferenceInternal(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, connectionName?: string, optional?: boolean, name?: string): Promise { + source = isPromiseLike(source) ? await source : source; + const rpcArgs: Record = { builder: this._handle, source }; + if (connectionName !== undefined) rpcArgs.connectionName = connectionName; + if (optional !== undefined) rpcArgs.optional = optional; + if (name !== undefined) rpcArgs.name = name; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReference', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): CSharpAppResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new CSharpAppResourcePromiseImpl(this._withReferenceInternal(source, connectionName, optional, name), this._client); + } + + /** @internal */ + private async _withEndpointCallbackInternal(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpointCallback', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): CSharpAppResourcePromise { + const createIfNotExists = options?.createIfNotExists; + return new CSharpAppResourcePromiseImpl(this._withEndpointCallbackInternal(endpointName, callback, createIfNotExists), this._client); + } + + /** @internal */ + private async _withHttpEndpointCallbackInternal(callback: (obj: EndpointUpdateContext) => Promise, name?: string, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + if (name !== undefined) rpcArgs.name = name; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpEndpointCallback', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): CSharpAppResourcePromise { + const name = options?.name; + const createIfNotExists = options?.createIfNotExists; + return new CSharpAppResourcePromiseImpl(this._withHttpEndpointCallbackInternal(callback, name, createIfNotExists), this._client); + } + + /** @internal */ + private async _withHttpsEndpointCallbackInternal(callback: (obj: EndpointUpdateContext) => Promise, name?: string, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + if (name !== undefined) rpcArgs.name = name; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsEndpointCallback', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): CSharpAppResourcePromise { + const name = options?.name; + const createIfNotExists = options?.createIfNotExists; + return new CSharpAppResourcePromiseImpl(this._withHttpsEndpointCallbackInternal(callback, name, createIfNotExists), this._client); + } + + /** @internal */ + private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (scheme !== undefined) rpcArgs.scheme = scheme; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + if (isExternal !== undefined) rpcArgs.isExternal = isExternal; + if (protocol !== undefined) rpcArgs.protocol = protocol; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpoint', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + withEndpoint(options?: WithEndpointOptions): CSharpAppResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const scheme = options?.scheme; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + const isExternal = options?.isExternal; + const protocol = options?.protocol; + return new CSharpAppResourcePromiseImpl(this._withEndpointInternal(port, targetPort, scheme, name, env, isProxied, isExternal, protocol), this._client); + } + + /** @internal */ + private async _withHttpEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpEndpoint', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + withHttpEndpoint(options?: WithHttpEndpointOptions): CSharpAppResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new CSharpAppResourcePromiseImpl(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied), this._client); + } + + /** @internal */ + private async _withHttpsEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsEndpoint', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + withHttpsEndpoint(options?: WithHttpsEndpointOptions): CSharpAppResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new CSharpAppResourcePromiseImpl(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied), this._client); + } + + /** @internal */ + private async _withExternalHttpEndpointsInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExternalHttpEndpoints', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + withExternalHttpEndpoints(): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._withExternalHttpEndpointsInternal(), this._client); + } + + async getEndpoint(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getEndpoint', + rpcArgs + ); + } + + /** @internal */ + private async _asHttp2ServiceInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/asHttp2Service', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + asHttp2Service(): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._asHttp2ServiceInternal(), this._client); + } + + /** @internal */ + private async _withUrlsInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrls', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._withUrlsInternal(callback), this._client); + } + + /** @internal */ + private async _withUrlInternal(url: string | ReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): CSharpAppResourcePromise { + const displayText = options?.displayText; + return new CSharpAppResourcePromiseImpl(this._withUrlInternal(url, displayText), this._client); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._withUrlForEndpointInternal(endpointName, callback), this._client); + } + + /** @internal */ + private async _publishWithContainerFilesInternal(source: Awaitable, destinationPath: string): Promise { + source = isPromiseLike(source) ? await source : source; + const rpcArgs: Record = { builder: this._handle, source, destinationPath }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishWithContainerFilesFromResource', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + publishWithContainerFiles(source: Awaitable, destinationPath: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._publishWithContainerFilesInternal(source, destinationPath), this._client); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + excludeFromManifest(): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._excludeFromManifestInternal(), this._client); + } + + /** @internal */ + private async _waitForInternal(dependency: Awaitable, waitBehavior?: WaitBehavior): Promise { + dependency = isPromiseLike(dependency) ? await dependency : dependency; + const rpcArgs: Record = { builder: this._handle, dependency }; + if (waitBehavior !== undefined) rpcArgs.waitBehavior = waitBehavior; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitFor', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + waitFor(dependency: Awaitable, options?: WaitForOptions): CSharpAppResourcePromise { + const waitBehavior = options?.waitBehavior; + return new CSharpAppResourcePromiseImpl(this._waitForInternal(dependency, waitBehavior), this._client); + } + + /** @internal */ + private async _waitForStartInternal(dependency: Awaitable, waitBehavior?: WaitBehavior): Promise { + dependency = isPromiseLike(dependency) ? await dependency : dependency; + const rpcArgs: Record = { builder: this._handle, dependency }; + if (waitBehavior !== undefined) rpcArgs.waitBehavior = waitBehavior; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStart', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): CSharpAppResourcePromise { + const waitBehavior = options?.waitBehavior; + return new CSharpAppResourcePromiseImpl(this._waitForStartInternal(dependency, waitBehavior), this._client); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + withExplicitStart(): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._withExplicitStartInternal(), this._client); + } + + /** @internal */ + private async _waitForCompletionInternal(dependency: Awaitable, exitCode?: number): Promise { + dependency = isPromiseLike(dependency) ? await dependency : dependency; + const rpcArgs: Record = { builder: this._handle, dependency }; + if (exitCode !== undefined) rpcArgs.exitCode = exitCode; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceCompletion', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): CSharpAppResourcePromise { + const exitCode = options?.exitCode; + return new CSharpAppResourcePromiseImpl(this._waitForCompletionInternal(dependency, exitCode), this._client); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + withHealthCheck(key: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._withHealthCheckInternal(key), this._client); + } + + /** @internal */ + private async _withHttpHealthCheckInternal(path?: string, statusCode?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (statusCode !== undefined) rpcArgs.statusCode = statusCode; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpHealthCheck', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): CSharpAppResourcePromise { + const path = options?.path; + const statusCode = options?.statusCode; + const endpointName = options?.endpointName; + return new CSharpAppResourcePromiseImpl(this._withHttpHealthCheckInternal(path, statusCode, endpointName), this._client); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContextImpl(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): CSharpAppResourcePromise { + const commandOptions = options?.commandOptions; + return new CSharpAppResourcePromiseImpl(this._withCommandInternal(name, displayName, executeCommand, commandOptions), this._client); + } + + /** @internal */ + private async _withHttpCommandInternal(path: string, displayName: string, options?: HttpCommandExportOptions): Promise { + const rpcArgs: Record = { builder: this._handle, path, displayName }; + if (options !== undefined) rpcArgs.options = options; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpCommand', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._withHttpCommandInternal(path, displayName, options), this._client); + } + + /** @internal */ + private async _withDeveloperCertificateTrustInternal(trust: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, trust }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDeveloperCertificateTrust', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + withDeveloperCertificateTrust(trust: boolean): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._withDeveloperCertificateTrustInternal(trust), this._client); + } + + /** @internal */ + private async _withCertificateTrustScopeInternal(scope: CertificateTrustScope): Promise { + const rpcArgs: Record = { builder: this._handle, scope }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCertificateTrustScope', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + withCertificateTrustScope(scope: CertificateTrustScope): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._withCertificateTrustScopeInternal(scope), this._client); + } + + /** @internal */ + private async _withHttpsDeveloperCertificateInternal(password?: Awaitable): Promise { + password = isPromiseLike(password) ? await password : password; + const rpcArgs: Record = { builder: this._handle }; + if (password !== undefined) rpcArgs.password = password; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): CSharpAppResourcePromise { + let password = options?.password; + return new CSharpAppResourcePromiseImpl(this._withHttpsDeveloperCertificateInternal(password), this._client); + } + + /** @internal */ + private async _withoutHttpsCertificateInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withoutHttpsCertificate', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + withoutHttpsCertificate(): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._withoutHttpsCertificateInternal(), this._client); + } + + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: Awaitable, type: string): Promise { + resourceBuilder = isPromiseLike(resourceBuilder) ? await resourceBuilder : resourceBuilder; + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._withRelationshipInternal(resourceBuilder, type), this._client); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: Awaitable): Promise { + parent = isPromiseLike(parent) ? await parent : parent; + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + withParentRelationship(parent: Awaitable): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._withParentRelationshipInternal(parent), this._client); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: Awaitable): Promise { + child = isPromiseLike(child) ? await child : child; + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + withChildRelationship(child: Awaitable): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._withChildRelationshipInternal(child), this._client); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): CSharpAppResourcePromise { + const iconVariant = options?.iconVariant; + return new CSharpAppResourcePromiseImpl(this._withIconNameInternal(iconName, iconVariant), this._client); + } + + /** @internal */ + private async _withHttpProbeInternal(probeType: ProbeType, path?: string, initialDelaySeconds?: number, periodSeconds?: number, timeoutSeconds?: number, failureThreshold?: number, successThreshold?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, probeType }; + if (path !== undefined) rpcArgs.path = path; + if (initialDelaySeconds !== undefined) rpcArgs.initialDelaySeconds = initialDelaySeconds; + if (periodSeconds !== undefined) rpcArgs.periodSeconds = periodSeconds; + if (timeoutSeconds !== undefined) rpcArgs.timeoutSeconds = timeoutSeconds; + if (failureThreshold !== undefined) rpcArgs.failureThreshold = failureThreshold; + if (successThreshold !== undefined) rpcArgs.successThreshold = successThreshold; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpProbe', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): CSharpAppResourcePromise { + const path = options?.path; + const initialDelaySeconds = options?.initialDelaySeconds; + const periodSeconds = options?.periodSeconds; + const timeoutSeconds = options?.timeoutSeconds; + const failureThreshold = options?.failureThreshold; + const successThreshold = options?.successThreshold; + const endpointName = options?.endpointName; + return new CSharpAppResourcePromiseImpl(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName), this._client); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + excludeFromMcp(): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._excludeFromMcpInternal(), this._client); + } + + /** @internal */ + private async _withImagePushOptionsInternal(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ContainerImagePushOptionsCallbackContextHandle; + const arg = new ContainerImagePushOptionsCallbackContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImagePushOptions', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._withImagePushOptionsInternal(callback), this._client); + } + + /** @internal */ + private async _withRemoteImageNameInternal(remoteImageName: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageName', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + withRemoteImageName(remoteImageName: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._withRemoteImageNameInternal(remoteImageName), this._client); + } + + /** @internal */ + private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageTag', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + withRemoteImageTag(remoteImageTag: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._withRemoteImageTagInternal(remoteImageTag), this._client); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): CSharpAppResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new CSharpAppResourcePromiseImpl(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description), this._client); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._withPipelineConfigurationInternal(callback), this._client); + } + + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); + } + + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._onBeforeResourceStartedInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._onResourceStoppedInternal(callback), this._client); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._onInitializeResourceInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceEndpointsAllocated', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._onResourceEndpointsAllocatedInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._onResourceReadyInternal(callback), this._client); + } + + async createExecutionConfiguration(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/createExecutionConfiguration', + rpcArgs + ); + } + + /** @internal */ + private async _withLikeC4ReferenceWithEnvironmentInternal(source: Awaitable, configure?: (obj: LikeC4RelationshipDetailsAnnotation) => Promise, connectionName?: string, optional?: boolean, skipAspireReference?: boolean): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4RelationshipDetailsAnnotationHandle; + const obj = new LikeC4RelationshipDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + source = isPromiseLike(source) ? await source : source; + const rpcArgs: Record = { builder: this._handle, source }; + if (configure !== undefined) rpcArgs.configure = configureId; + if (connectionName !== undefined) rpcArgs.connectionName = connectionName; + if (optional !== undefined) rpcArgs.optional = optional; + if (skipAspireReference !== undefined) rpcArgs.skipAspireReference = skipAspireReference; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4ReferenceWithEnvironment', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): CSharpAppResourcePromise { + const configure = options?.configure; + const connectionName = options?.connectionName; + const optional = options?.optional; + const skipAspireReference = options?.skipAspireReference; + return new CSharpAppResourcePromiseImpl(this._withLikeC4ReferenceWithEnvironmentInternal(source, configure, connectionName, optional, skipAspireReference), this._client); + } + + /** @internal */ + private async _withLikeC4DetailsInternal(label?: string, technology?: string, description?: string, summary?: string, icon?: string, configure?: (obj: LikeC4NodeDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4NodeDetailsAnnotationHandle; + const obj = new LikeC4NodeDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + const rpcArgs: Record = { builder: this._handle }; + if (label !== undefined) rpcArgs.label = label; + if (technology !== undefined) rpcArgs.technology = technology; + if (description !== undefined) rpcArgs.description = description; + if (summary !== undefined) rpcArgs.summary = summary; + if (icon !== undefined) rpcArgs.icon = icon; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4DetailsParameters', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): CSharpAppResourcePromise { + const label = options?.label; + const technology = options?.technology; + const description = options?.description; + const summary = options?.summary; + const icon = options?.icon; + const configure = options?.configure; + return new CSharpAppResourcePromiseImpl(this._withLikeC4DetailsInternal(label, technology, description, summary, icon, configure), this._client); + } + + /** @internal */ + private async _withLikeC4ReferenceInternal(target: Awaitable, configure?: (obj: LikeC4RelationshipDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4RelationshipDetailsAnnotationHandle; + const obj = new LikeC4RelationshipDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target }; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Reference', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): CSharpAppResourcePromise { + const configure = options?.configure; + return new CSharpAppResourcePromiseImpl(this._withLikeC4ReferenceInternal(target, configure), this._client); + } + + /** @internal */ + private async _withLikeC4GroupInternal(groupName: string): Promise { + const rpcArgs: Record = { builder: this._handle, groupName }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Group', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + withLikeC4Group(groupName: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._withLikeC4GroupInternal(groupName), this._client); + } + + /** @internal */ + private async _excludeFromLikeC4Internal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/excludeFromLikeC4', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + excludeFromLikeC4(): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._excludeFromLikeC4Internal(), this._client); + } + + /** @internal */ + private async _withAzureUserAssignedIdentityInternal(identityResourceBuilder: Awaitable): Promise { + identityResourceBuilder = isPromiseLike(identityResourceBuilder) ? await identityResourceBuilder : identityResourceBuilder; + const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._withAzureUserAssignedIdentityInternal(identityResourceBuilder), this._client); + } + + /** @internal */ + private async _withRoleAssignmentsInternal(target: Awaitable, roles: AzureKeyVaultRole[]): Promise { + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target, roles }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.KeyVault/withKeyVaultRoleAssignments', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._withRoleAssignmentsInternal(target, roles), this._client); + } + +} + +/** + * Thenable wrapper for CSharpAppResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +class CSharpAppResourcePromiseImpl implements CSharpAppResourcePromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: CSharpAppResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + withContainerRegistry(registry: Awaitable): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withContainerRegistry(registry)), this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withDockerfileBaseImage(options)), this._client); + } + + withMcpServer(options?: WithMcpServerOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withMcpServer(options)), this._client); + } + + withOtlpExporter(options?: WithOtlpExporterOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withOtlpExporter(options)), this._client); + } + + withReplicas(replicas: number): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withReplicas(replicas)), this._client); + } + + disableForwardedHeaders(): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.disableForwardedHeaders()), this._client); + } + + publishAsDockerFile(options?: PublishAsDockerFileOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.publishAsDockerFile(options)), this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withRequiredCommand(command, options)), this._client); + } + + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withEnvironment(name, value)), this._client); + } + + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentCallback(callback)), this._client); + } + + withArgs(args: string[]): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withArgs(args)), this._client); + } + + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withArgsCallback(callback)), this._client); + } + + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withReferenceEnvironment(options)), this._client); + } + + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withReference(source, options)), this._client); + } + + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withEndpointCallback(endpointName, callback, options)), this._client); + } + + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withHttpEndpointCallback(callback, options)), this._client); + } + + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withHttpsEndpointCallback(callback, options)), this._client); + } + + withEndpoint(options?: WithEndpointOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withEndpoint(options)), this._client); + } + + withHttpEndpoint(options?: WithHttpEndpointOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withHttpEndpoint(options)), this._client); + } + + withHttpsEndpoint(options?: WithHttpsEndpointOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withHttpsEndpoint(options)), this._client); + } + + withExternalHttpEndpoints(): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withExternalHttpEndpoints()), this._client); + } + + getEndpoint(name: string): Promise { + return this._promise.then(obj => obj.getEndpoint(name)); + } + + asHttp2Service(): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.asHttp2Service()), this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withUrls(callback)), this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withUrl(url, options)), this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback)), this._client); + } + + publishWithContainerFiles(source: Awaitable, destinationPath: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.publishWithContainerFiles(source, destinationPath)), this._client); + } + + excludeFromManifest(): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.excludeFromManifest()), this._client); + } + + waitFor(dependency: Awaitable, options?: WaitForOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.waitFor(dependency, options)), this._client); + } + + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.waitForStart(dependency, options)), this._client); + } + + withExplicitStart(): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withExplicitStart()), this._client); + } + + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.waitForCompletion(dependency, options)), this._client); + } + + withHealthCheck(key: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withHealthCheck(key)), this._client); + } + + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withHttpHealthCheck(options)), this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options)), this._client); + } + + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withHttpCommand(path, displayName, options)), this._client); + } + + withDeveloperCertificateTrust(trust: boolean): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust)), this._client); + } + + withCertificateTrustScope(scope: CertificateTrustScope): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withCertificateTrustScope(scope)), this._client); + } + + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options)), this._client); + } + + withoutHttpsCertificate(): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withoutHttpsCertificate()), this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withRelationship(resourceBuilder, type)), this._client); + } + + withParentRelationship(parent: Awaitable): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withParentRelationship(parent)), this._client); + } + + withChildRelationship(child: Awaitable): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withChildRelationship(child)), this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withIconName(iconName, options)), this._client); + } + + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withHttpProbe(probeType, options)), this._client); + } + + excludeFromMcp(): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.excludeFromMcp()), this._client); + } + + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withImagePushOptions(callback)), this._client); + } + + withRemoteImageName(remoteImageName: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withRemoteImageName(remoteImageName)), this._client); + } + + withRemoteImageTag(remoteImageTag: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag)), this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options)), this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withPipelineConfiguration(callback)), this._client); + } + + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.onBeforeResourceStarted(callback)), this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.onResourceStopped(callback)), this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.onInitializeResource(callback)), this._client); + } + + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback)), this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.onResourceReady(callback)), this._client); + } + + createExecutionConfiguration(): Promise { + return this._promise.then(obj => obj.createExecutionConfiguration()); + } + + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4ReferenceWithEnvironment(source, options)), this._client); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Details(options)), this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Reference(target, options)), this._client); + } + + withLikeC4Group(groupName: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Group(groupName)), this._client); + } + + excludeFromLikeC4(): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.excludeFromLikeC4()), this._client); + } + + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withAzureUserAssignedIdentity(identityResourceBuilder)), this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withRoleAssignments(target, roles)), this._client); + } + +} + +// ============================================================================ +// DotnetToolResource +// ============================================================================ + +export interface DotnetToolResource { + toJSON(): MarshalledHandle; + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): DotnetToolResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): DotnetToolResourcePromise; + /** Sets the tool package ID */ + withToolPackage(packageId: string): DotnetToolResourcePromise; + /** Sets the tool version */ + withToolVersion(version: string): DotnetToolResourcePromise; + /** Allows prerelease tool versions */ + withToolPrerelease(): DotnetToolResourcePromise; + /** Adds a NuGet source for the tool */ + withToolSource(source: string): DotnetToolResourcePromise; + /** Ignores existing NuGet feeds */ + withToolIgnoreExistingFeeds(): DotnetToolResourcePromise; + /** Ignores failed NuGet sources */ + withToolIgnoreFailedSources(): DotnetToolResourcePromise; + /** Publishes an executable as a Docker file */ + publishAsDockerFile(configure: (obj: ContainerResource) => Promise): DotnetToolResourcePromise; + /** Sets the executable command */ + withExecutableCommand(command: string): DotnetToolResourcePromise; + /** Sets the executable working directory */ + withWorkingDirectory(workingDirectory: string): DotnetToolResourcePromise; + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): DotnetToolResourcePromise; + /** Configures OTLP telemetry export */ + withOtlpExporter(options?: WithOtlpExporterOptions): DotnetToolResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): DotnetToolResourcePromise; + /** Sets an environment variable */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): DotnetToolResourcePromise; + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise; + /** Adds arguments */ + withArgs(args: string[]): DotnetToolResourcePromise; + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): DotnetToolResourcePromise; + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): DotnetToolResourcePromise; + /** Adds a reference to another resource */ + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): DotnetToolResourcePromise; + /** Updates a named endpoint via callback */ + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): DotnetToolResourcePromise; + /** Updates an HTTP endpoint via callback */ + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): DotnetToolResourcePromise; + /** Updates an HTTPS endpoint via callback */ + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): DotnetToolResourcePromise; + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): DotnetToolResourcePromise; + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): DotnetToolResourcePromise; + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): DotnetToolResourcePromise; + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): DotnetToolResourcePromise; + /** Gets an endpoint reference */ + getEndpoint(name: string): Promise; + /** Configures resource for HTTP/2 */ + asHttp2Service(): DotnetToolResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): DotnetToolResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): DotnetToolResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): DotnetToolResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): DotnetToolResourcePromise; + /** Waits for another resource to be ready */ + waitFor(dependency: Awaitable, options?: WaitForOptions): DotnetToolResourcePromise; + /** Waits for another resource to start */ + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): DotnetToolResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): DotnetToolResourcePromise; + /** Waits for resource completion */ + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): DotnetToolResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): DotnetToolResourcePromise; + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): DotnetToolResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): DotnetToolResourcePromise; + /** Adds an HTTP resource command */ + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): DotnetToolResourcePromise; + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): DotnetToolResourcePromise; + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): DotnetToolResourcePromise; + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): DotnetToolResourcePromise; + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): DotnetToolResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): DotnetToolResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): DotnetToolResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): DotnetToolResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): DotnetToolResourcePromise; + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): DotnetToolResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): DotnetToolResourcePromise; + /** Sets image push options via callback */ + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): DotnetToolResourcePromise; + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): DotnetToolResourcePromise; + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): DotnetToolResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): DotnetToolResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): DotnetToolResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): DotnetToolResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): DotnetToolResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): DotnetToolResourcePromise; + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): DotnetToolResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): DotnetToolResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Create a new reference, while also allowing customization of how a resource appears in the generated LikeC4 diagram. */ + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): DotnetToolResourcePromise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): DotnetToolResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): DotnetToolResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): DotnetToolResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): DotnetToolResourcePromise; + /** Associates an Azure user-assigned identity with a compute resource */ + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): DotnetToolResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): DotnetToolResourcePromise; +} + +export interface DotnetToolResourcePromise extends PromiseLike { + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): DotnetToolResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): DotnetToolResourcePromise; + /** Sets the tool package ID */ + withToolPackage(packageId: string): DotnetToolResourcePromise; + /** Sets the tool version */ + withToolVersion(version: string): DotnetToolResourcePromise; + /** Allows prerelease tool versions */ + withToolPrerelease(): DotnetToolResourcePromise; + /** Adds a NuGet source for the tool */ + withToolSource(source: string): DotnetToolResourcePromise; + /** Ignores existing NuGet feeds */ + withToolIgnoreExistingFeeds(): DotnetToolResourcePromise; + /** Ignores failed NuGet sources */ + withToolIgnoreFailedSources(): DotnetToolResourcePromise; + /** Publishes an executable as a Docker file */ + publishAsDockerFile(configure: (obj: ContainerResource) => Promise): DotnetToolResourcePromise; + /** Sets the executable command */ + withExecutableCommand(command: string): DotnetToolResourcePromise; + /** Sets the executable working directory */ + withWorkingDirectory(workingDirectory: string): DotnetToolResourcePromise; + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): DotnetToolResourcePromise; + /** Configures OTLP telemetry export */ + withOtlpExporter(options?: WithOtlpExporterOptions): DotnetToolResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): DotnetToolResourcePromise; + /** Sets an environment variable */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): DotnetToolResourcePromise; + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise; + /** Adds arguments */ + withArgs(args: string[]): DotnetToolResourcePromise; + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): DotnetToolResourcePromise; + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): DotnetToolResourcePromise; + /** Adds a reference to another resource */ + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): DotnetToolResourcePromise; + /** Updates a named endpoint via callback */ + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): DotnetToolResourcePromise; + /** Updates an HTTP endpoint via callback */ + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): DotnetToolResourcePromise; + /** Updates an HTTPS endpoint via callback */ + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): DotnetToolResourcePromise; + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): DotnetToolResourcePromise; + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): DotnetToolResourcePromise; + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): DotnetToolResourcePromise; + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): DotnetToolResourcePromise; + /** Gets an endpoint reference */ + getEndpoint(name: string): Promise; + /** Configures resource for HTTP/2 */ + asHttp2Service(): DotnetToolResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): DotnetToolResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): DotnetToolResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): DotnetToolResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): DotnetToolResourcePromise; + /** Waits for another resource to be ready */ + waitFor(dependency: Awaitable, options?: WaitForOptions): DotnetToolResourcePromise; + /** Waits for another resource to start */ + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): DotnetToolResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): DotnetToolResourcePromise; + /** Waits for resource completion */ + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): DotnetToolResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): DotnetToolResourcePromise; + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): DotnetToolResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): DotnetToolResourcePromise; + /** Adds an HTTP resource command */ + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): DotnetToolResourcePromise; + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): DotnetToolResourcePromise; + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): DotnetToolResourcePromise; + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): DotnetToolResourcePromise; + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): DotnetToolResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): DotnetToolResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): DotnetToolResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): DotnetToolResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): DotnetToolResourcePromise; + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): DotnetToolResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): DotnetToolResourcePromise; + /** Sets image push options via callback */ + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): DotnetToolResourcePromise; + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): DotnetToolResourcePromise; + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): DotnetToolResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): DotnetToolResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): DotnetToolResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): DotnetToolResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): DotnetToolResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): DotnetToolResourcePromise; + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): DotnetToolResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): DotnetToolResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Create a new reference, while also allowing customization of how a resource appears in the generated LikeC4 diagram. */ + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): DotnetToolResourcePromise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): DotnetToolResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): DotnetToolResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): DotnetToolResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): DotnetToolResourcePromise; + /** Associates an Azure user-assigned identity with a compute resource */ + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): DotnetToolResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): DotnetToolResourcePromise; +} + +// ============================================================================ +// DotnetToolResourceImpl +// ============================================================================ + +class DotnetToolResourceImpl extends ResourceBuilderBase implements DotnetToolResource { + constructor(handle: DotnetToolResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: Awaitable): Promise { + registry = isPromiseLike(registry) ? await registry : registry; + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + withContainerRegistry(registry: Awaitable): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withContainerRegistryInternal(registry), this._client); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): DotnetToolResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new DotnetToolResourcePromiseImpl(this._withDockerfileBaseImageInternal(buildImage, runtimeImage), this._client); + } + + /** @internal */ + private async _withToolPackageInternal(packageId: string): Promise { + const rpcArgs: Record = { builder: this._handle, packageId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withToolPackage', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + withToolPackage(packageId: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withToolPackageInternal(packageId), this._client); + } + + /** @internal */ + private async _withToolVersionInternal(version: string): Promise { + const rpcArgs: Record = { builder: this._handle, version }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withToolVersion', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + withToolVersion(version: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withToolVersionInternal(version), this._client); + } + + /** @internal */ + private async _withToolPrereleaseInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withToolPrerelease', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + withToolPrerelease(): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withToolPrereleaseInternal(), this._client); + } + + /** @internal */ + private async _withToolSourceInternal(source: string): Promise { + const rpcArgs: Record = { builder: this._handle, source }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withToolSource', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + withToolSource(source: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withToolSourceInternal(source), this._client); + } + + /** @internal */ + private async _withToolIgnoreExistingFeedsInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withToolIgnoreExistingFeeds', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + withToolIgnoreExistingFeeds(): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withToolIgnoreExistingFeedsInternal(), this._client); + } + + /** @internal */ + private async _withToolIgnoreFailedSourcesInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withToolIgnoreFailedSources', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + withToolIgnoreFailedSources(): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withToolIgnoreFailedSourcesInternal(), this._client); + } + + /** @internal */ + private async _publishAsDockerFileInternal(configure: (obj: ContainerResource) => Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ContainerResourceHandle; + const obj = new ContainerResourceImpl(objHandle, this._client); + await configure(obj); + }); + const rpcArgs: Record = { builder: this._handle, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsDockerFile', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + publishAsDockerFile(configure: (obj: ContainerResource) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._publishAsDockerFileInternal(configure), this._client); + } + + /** @internal */ + private async _withExecutableCommandInternal(command: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExecutableCommand', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + withExecutableCommand(command: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withExecutableCommandInternal(command), this._client); + } + + /** @internal */ + private async _withWorkingDirectoryInternal(workingDirectory: string): Promise { + const rpcArgs: Record = { builder: this._handle, workingDirectory }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withWorkingDirectory', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + withWorkingDirectory(workingDirectory: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withWorkingDirectoryInternal(workingDirectory), this._client); + } + + /** @internal */ + private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withMcpServer', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + withMcpServer(options?: WithMcpServerOptions): DotnetToolResourcePromise { + const path = options?.path; + const endpointName = options?.endpointName; + return new DotnetToolResourcePromiseImpl(this._withMcpServerInternal(path, endpointName), this._client); + } + + /** @internal */ + private async _withOtlpExporterInternal(protocol?: OtlpProtocol): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (protocol !== undefined) rpcArgs.protocol = protocol; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporter', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + withOtlpExporter(options?: WithOtlpExporterOptions): DotnetToolResourcePromise { + const protocol = options?.protocol; + return new DotnetToolResourcePromiseImpl(this._withOtlpExporterInternal(protocol), this._client); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): DotnetToolResourcePromise { + const helpLink = options?.helpLink; + return new DotnetToolResourcePromiseImpl(this._withRequiredCommandInternal(command, helpLink), this._client); + } + + /** @internal */ + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): Promise { + value = isPromiseLike(value) ? await value : value; + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironment', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withEnvironmentInternal(name, value), this._client); + } + + /** @internal */ + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentCallback', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withEnvironmentCallbackInternal(callback), this._client); + } + + /** @internal */ + private async _withArgsInternal(args: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, args }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgs', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + withArgs(args: string[]): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withArgsInternal(args), this._client); + } + + /** @internal */ + private async _withArgsCallbackInternal(callback: (obj: CommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; + const obj = new CommandLineArgsCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallback', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withArgsCallbackInternal(callback), this._client); + } + + /** @internal */ + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceEnvironment', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withReferenceEnvironmentInternal(options), this._client); + } + + /** @internal */ + private async _withReferenceInternal(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, connectionName?: string, optional?: boolean, name?: string): Promise { + source = isPromiseLike(source) ? await source : source; + const rpcArgs: Record = { builder: this._handle, source }; + if (connectionName !== undefined) rpcArgs.connectionName = connectionName; + if (optional !== undefined) rpcArgs.optional = optional; + if (name !== undefined) rpcArgs.name = name; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReference', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): DotnetToolResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new DotnetToolResourcePromiseImpl(this._withReferenceInternal(source, connectionName, optional, name), this._client); + } + + /** @internal */ + private async _withEndpointCallbackInternal(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpointCallback', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): DotnetToolResourcePromise { + const createIfNotExists = options?.createIfNotExists; + return new DotnetToolResourcePromiseImpl(this._withEndpointCallbackInternal(endpointName, callback, createIfNotExists), this._client); + } + + /** @internal */ + private async _withHttpEndpointCallbackInternal(callback: (obj: EndpointUpdateContext) => Promise, name?: string, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + if (name !== undefined) rpcArgs.name = name; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpEndpointCallback', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): DotnetToolResourcePromise { + const name = options?.name; + const createIfNotExists = options?.createIfNotExists; + return new DotnetToolResourcePromiseImpl(this._withHttpEndpointCallbackInternal(callback, name, createIfNotExists), this._client); + } + + /** @internal */ + private async _withHttpsEndpointCallbackInternal(callback: (obj: EndpointUpdateContext) => Promise, name?: string, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + if (name !== undefined) rpcArgs.name = name; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsEndpointCallback', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): DotnetToolResourcePromise { + const name = options?.name; + const createIfNotExists = options?.createIfNotExists; + return new DotnetToolResourcePromiseImpl(this._withHttpsEndpointCallbackInternal(callback, name, createIfNotExists), this._client); + } + + /** @internal */ + private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (scheme !== undefined) rpcArgs.scheme = scheme; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + if (isExternal !== undefined) rpcArgs.isExternal = isExternal; + if (protocol !== undefined) rpcArgs.protocol = protocol; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpoint', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + withEndpoint(options?: WithEndpointOptions): DotnetToolResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const scheme = options?.scheme; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + const isExternal = options?.isExternal; + const protocol = options?.protocol; + return new DotnetToolResourcePromiseImpl(this._withEndpointInternal(port, targetPort, scheme, name, env, isProxied, isExternal, protocol), this._client); + } + + /** @internal */ + private async _withHttpEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpEndpoint', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + withHttpEndpoint(options?: WithHttpEndpointOptions): DotnetToolResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new DotnetToolResourcePromiseImpl(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied), this._client); + } + + /** @internal */ + private async _withHttpsEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsEndpoint', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + withHttpsEndpoint(options?: WithHttpsEndpointOptions): DotnetToolResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new DotnetToolResourcePromiseImpl(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied), this._client); + } + + /** @internal */ + private async _withExternalHttpEndpointsInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExternalHttpEndpoints', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + withExternalHttpEndpoints(): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withExternalHttpEndpointsInternal(), this._client); + } + + async getEndpoint(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getEndpoint', + rpcArgs + ); + } + + /** @internal */ + private async _asHttp2ServiceInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/asHttp2Service', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + asHttp2Service(): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._asHttp2ServiceInternal(), this._client); + } + + /** @internal */ + private async _withUrlsInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrls', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withUrlsInternal(callback), this._client); + } + + /** @internal */ + private async _withUrlInternal(url: string | ReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): DotnetToolResourcePromise { + const displayText = options?.displayText; + return new DotnetToolResourcePromiseImpl(this._withUrlInternal(url, displayText), this._client); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withUrlForEndpointInternal(endpointName, callback), this._client); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + excludeFromManifest(): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._excludeFromManifestInternal(), this._client); + } + + /** @internal */ + private async _waitForInternal(dependency: Awaitable, waitBehavior?: WaitBehavior): Promise { + dependency = isPromiseLike(dependency) ? await dependency : dependency; + const rpcArgs: Record = { builder: this._handle, dependency }; + if (waitBehavior !== undefined) rpcArgs.waitBehavior = waitBehavior; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitFor', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + waitFor(dependency: Awaitable, options?: WaitForOptions): DotnetToolResourcePromise { + const waitBehavior = options?.waitBehavior; + return new DotnetToolResourcePromiseImpl(this._waitForInternal(dependency, waitBehavior), this._client); + } + + /** @internal */ + private async _waitForStartInternal(dependency: Awaitable, waitBehavior?: WaitBehavior): Promise { + dependency = isPromiseLike(dependency) ? await dependency : dependency; + const rpcArgs: Record = { builder: this._handle, dependency }; + if (waitBehavior !== undefined) rpcArgs.waitBehavior = waitBehavior; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStart', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): DotnetToolResourcePromise { + const waitBehavior = options?.waitBehavior; + return new DotnetToolResourcePromiseImpl(this._waitForStartInternal(dependency, waitBehavior), this._client); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + withExplicitStart(): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withExplicitStartInternal(), this._client); + } + + /** @internal */ + private async _waitForCompletionInternal(dependency: Awaitable, exitCode?: number): Promise { + dependency = isPromiseLike(dependency) ? await dependency : dependency; + const rpcArgs: Record = { builder: this._handle, dependency }; + if (exitCode !== undefined) rpcArgs.exitCode = exitCode; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceCompletion', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): DotnetToolResourcePromise { + const exitCode = options?.exitCode; + return new DotnetToolResourcePromiseImpl(this._waitForCompletionInternal(dependency, exitCode), this._client); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + withHealthCheck(key: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withHealthCheckInternal(key), this._client); + } + + /** @internal */ + private async _withHttpHealthCheckInternal(path?: string, statusCode?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (statusCode !== undefined) rpcArgs.statusCode = statusCode; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpHealthCheck', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): DotnetToolResourcePromise { + const path = options?.path; + const statusCode = options?.statusCode; + const endpointName = options?.endpointName; + return new DotnetToolResourcePromiseImpl(this._withHttpHealthCheckInternal(path, statusCode, endpointName), this._client); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContextImpl(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): DotnetToolResourcePromise { + const commandOptions = options?.commandOptions; + return new DotnetToolResourcePromiseImpl(this._withCommandInternal(name, displayName, executeCommand, commandOptions), this._client); + } + + /** @internal */ + private async _withHttpCommandInternal(path: string, displayName: string, options?: HttpCommandExportOptions): Promise { + const rpcArgs: Record = { builder: this._handle, path, displayName }; + if (options !== undefined) rpcArgs.options = options; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpCommand', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withHttpCommandInternal(path, displayName, options), this._client); + } + + /** @internal */ + private async _withDeveloperCertificateTrustInternal(trust: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, trust }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDeveloperCertificateTrust', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + withDeveloperCertificateTrust(trust: boolean): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withDeveloperCertificateTrustInternal(trust), this._client); + } + + /** @internal */ + private async _withCertificateTrustScopeInternal(scope: CertificateTrustScope): Promise { + const rpcArgs: Record = { builder: this._handle, scope }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCertificateTrustScope', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + withCertificateTrustScope(scope: CertificateTrustScope): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withCertificateTrustScopeInternal(scope), this._client); + } + + /** @internal */ + private async _withHttpsDeveloperCertificateInternal(password?: Awaitable): Promise { + password = isPromiseLike(password) ? await password : password; + const rpcArgs: Record = { builder: this._handle }; + if (password !== undefined) rpcArgs.password = password; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): DotnetToolResourcePromise { + let password = options?.password; + return new DotnetToolResourcePromiseImpl(this._withHttpsDeveloperCertificateInternal(password), this._client); + } + + /** @internal */ + private async _withoutHttpsCertificateInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withoutHttpsCertificate', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + withoutHttpsCertificate(): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withoutHttpsCertificateInternal(), this._client); + } + + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: Awaitable, type: string): Promise { + resourceBuilder = isPromiseLike(resourceBuilder) ? await resourceBuilder : resourceBuilder; + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withRelationshipInternal(resourceBuilder, type), this._client); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: Awaitable): Promise { + parent = isPromiseLike(parent) ? await parent : parent; + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + withParentRelationship(parent: Awaitable): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withParentRelationshipInternal(parent), this._client); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: Awaitable): Promise { + child = isPromiseLike(child) ? await child : child; + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + withChildRelationship(child: Awaitable): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withChildRelationshipInternal(child), this._client); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): DotnetToolResourcePromise { + const iconVariant = options?.iconVariant; + return new DotnetToolResourcePromiseImpl(this._withIconNameInternal(iconName, iconVariant), this._client); + } + + /** @internal */ + private async _withHttpProbeInternal(probeType: ProbeType, path?: string, initialDelaySeconds?: number, periodSeconds?: number, timeoutSeconds?: number, failureThreshold?: number, successThreshold?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, probeType }; + if (path !== undefined) rpcArgs.path = path; + if (initialDelaySeconds !== undefined) rpcArgs.initialDelaySeconds = initialDelaySeconds; + if (periodSeconds !== undefined) rpcArgs.periodSeconds = periodSeconds; + if (timeoutSeconds !== undefined) rpcArgs.timeoutSeconds = timeoutSeconds; + if (failureThreshold !== undefined) rpcArgs.failureThreshold = failureThreshold; + if (successThreshold !== undefined) rpcArgs.successThreshold = successThreshold; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpProbe', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): DotnetToolResourcePromise { + const path = options?.path; + const initialDelaySeconds = options?.initialDelaySeconds; + const periodSeconds = options?.periodSeconds; + const timeoutSeconds = options?.timeoutSeconds; + const failureThreshold = options?.failureThreshold; + const successThreshold = options?.successThreshold; + const endpointName = options?.endpointName; + return new DotnetToolResourcePromiseImpl(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName), this._client); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + excludeFromMcp(): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._excludeFromMcpInternal(), this._client); + } + + /** @internal */ + private async _withImagePushOptionsInternal(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ContainerImagePushOptionsCallbackContextHandle; + const arg = new ContainerImagePushOptionsCallbackContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImagePushOptions', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withImagePushOptionsInternal(callback), this._client); + } + + /** @internal */ + private async _withRemoteImageNameInternal(remoteImageName: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageName', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + withRemoteImageName(remoteImageName: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withRemoteImageNameInternal(remoteImageName), this._client); + } + + /** @internal */ + private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageTag', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + withRemoteImageTag(remoteImageTag: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withRemoteImageTagInternal(remoteImageTag), this._client); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): DotnetToolResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new DotnetToolResourcePromiseImpl(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description), this._client); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withPipelineConfigurationInternal(callback), this._client); + } + + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); + } + + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._onBeforeResourceStartedInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._onResourceStoppedInternal(callback), this._client); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._onInitializeResourceInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceEndpointsAllocated', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._onResourceEndpointsAllocatedInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._onResourceReadyInternal(callback), this._client); + } + + async createExecutionConfiguration(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/createExecutionConfiguration', + rpcArgs + ); + } + + /** @internal */ + private async _withLikeC4ReferenceWithEnvironmentInternal(source: Awaitable, configure?: (obj: LikeC4RelationshipDetailsAnnotation) => Promise, connectionName?: string, optional?: boolean, skipAspireReference?: boolean): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4RelationshipDetailsAnnotationHandle; + const obj = new LikeC4RelationshipDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + source = isPromiseLike(source) ? await source : source; + const rpcArgs: Record = { builder: this._handle, source }; + if (configure !== undefined) rpcArgs.configure = configureId; + if (connectionName !== undefined) rpcArgs.connectionName = connectionName; + if (optional !== undefined) rpcArgs.optional = optional; + if (skipAspireReference !== undefined) rpcArgs.skipAspireReference = skipAspireReference; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4ReferenceWithEnvironment', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): DotnetToolResourcePromise { + const configure = options?.configure; + const connectionName = options?.connectionName; + const optional = options?.optional; + const skipAspireReference = options?.skipAspireReference; + return new DotnetToolResourcePromiseImpl(this._withLikeC4ReferenceWithEnvironmentInternal(source, configure, connectionName, optional, skipAspireReference), this._client); + } + + /** @internal */ + private async _withLikeC4DetailsInternal(label?: string, technology?: string, description?: string, summary?: string, icon?: string, configure?: (obj: LikeC4NodeDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4NodeDetailsAnnotationHandle; + const obj = new LikeC4NodeDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + const rpcArgs: Record = { builder: this._handle }; + if (label !== undefined) rpcArgs.label = label; + if (technology !== undefined) rpcArgs.technology = technology; + if (description !== undefined) rpcArgs.description = description; + if (summary !== undefined) rpcArgs.summary = summary; + if (icon !== undefined) rpcArgs.icon = icon; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4DetailsParameters', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): DotnetToolResourcePromise { + const label = options?.label; + const technology = options?.technology; + const description = options?.description; + const summary = options?.summary; + const icon = options?.icon; + const configure = options?.configure; + return new DotnetToolResourcePromiseImpl(this._withLikeC4DetailsInternal(label, technology, description, summary, icon, configure), this._client); + } + + /** @internal */ + private async _withLikeC4ReferenceInternal(target: Awaitable, configure?: (obj: LikeC4RelationshipDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4RelationshipDetailsAnnotationHandle; + const obj = new LikeC4RelationshipDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target }; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Reference', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): DotnetToolResourcePromise { + const configure = options?.configure; + return new DotnetToolResourcePromiseImpl(this._withLikeC4ReferenceInternal(target, configure), this._client); + } + + /** @internal */ + private async _withLikeC4GroupInternal(groupName: string): Promise { + const rpcArgs: Record = { builder: this._handle, groupName }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Group', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + withLikeC4Group(groupName: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withLikeC4GroupInternal(groupName), this._client); + } + + /** @internal */ + private async _excludeFromLikeC4Internal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/excludeFromLikeC4', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + excludeFromLikeC4(): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._excludeFromLikeC4Internal(), this._client); + } + + /** @internal */ + private async _withAzureUserAssignedIdentityInternal(identityResourceBuilder: Awaitable): Promise { + identityResourceBuilder = isPromiseLike(identityResourceBuilder) ? await identityResourceBuilder : identityResourceBuilder; + const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withAzureUserAssignedIdentityInternal(identityResourceBuilder), this._client); + } + + /** @internal */ + private async _withRoleAssignmentsInternal(target: Awaitable, roles: AzureKeyVaultRole[]): Promise { + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target, roles }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.KeyVault/withKeyVaultRoleAssignments', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withRoleAssignmentsInternal(target, roles), this._client); + } + +} + +/** + * Thenable wrapper for DotnetToolResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +class DotnetToolResourcePromiseImpl implements DotnetToolResourcePromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: DotnetToolResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + withContainerRegistry(registry: Awaitable): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withContainerRegistry(registry)), this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withDockerfileBaseImage(options)), this._client); + } + + withToolPackage(packageId: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withToolPackage(packageId)), this._client); + } + + withToolVersion(version: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withToolVersion(version)), this._client); + } + + withToolPrerelease(): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withToolPrerelease()), this._client); + } + + withToolSource(source: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withToolSource(source)), this._client); + } + + withToolIgnoreExistingFeeds(): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withToolIgnoreExistingFeeds()), this._client); + } + + withToolIgnoreFailedSources(): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withToolIgnoreFailedSources()), this._client); + } + + publishAsDockerFile(configure: (obj: ContainerResource) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.publishAsDockerFile(configure)), this._client); + } + + withExecutableCommand(command: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withExecutableCommand(command)), this._client); + } + + withWorkingDirectory(workingDirectory: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withWorkingDirectory(workingDirectory)), this._client); + } + + withMcpServer(options?: WithMcpServerOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withMcpServer(options)), this._client); + } + + withOtlpExporter(options?: WithOtlpExporterOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withOtlpExporter(options)), this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withRequiredCommand(command, options)), this._client); + } + + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withEnvironment(name, value)), this._client); + } + + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentCallback(callback)), this._client); + } + + withArgs(args: string[]): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withArgs(args)), this._client); + } + + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withArgsCallback(callback)), this._client); + } + + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withReferenceEnvironment(options)), this._client); + } + + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withReference(source, options)), this._client); + } + + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withEndpointCallback(endpointName, callback, options)), this._client); + } + + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withHttpEndpointCallback(callback, options)), this._client); + } + + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withHttpsEndpointCallback(callback, options)), this._client); + } + + withEndpoint(options?: WithEndpointOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withEndpoint(options)), this._client); + } + + withHttpEndpoint(options?: WithHttpEndpointOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withHttpEndpoint(options)), this._client); + } + + withHttpsEndpoint(options?: WithHttpsEndpointOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withHttpsEndpoint(options)), this._client); + } + + withExternalHttpEndpoints(): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withExternalHttpEndpoints()), this._client); + } + + getEndpoint(name: string): Promise { + return this._promise.then(obj => obj.getEndpoint(name)); + } + + asHttp2Service(): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.asHttp2Service()), this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withUrls(callback)), this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withUrl(url, options)), this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback)), this._client); + } + + excludeFromManifest(): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.excludeFromManifest()), this._client); + } + + waitFor(dependency: Awaitable, options?: WaitForOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.waitFor(dependency, options)), this._client); + } + + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.waitForStart(dependency, options)), this._client); + } + + withExplicitStart(): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withExplicitStart()), this._client); + } + + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.waitForCompletion(dependency, options)), this._client); + } + + withHealthCheck(key: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withHealthCheck(key)), this._client); + } + + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withHttpHealthCheck(options)), this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options)), this._client); + } + + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withHttpCommand(path, displayName, options)), this._client); + } + + withDeveloperCertificateTrust(trust: boolean): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust)), this._client); + } + + withCertificateTrustScope(scope: CertificateTrustScope): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withCertificateTrustScope(scope)), this._client); + } + + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options)), this._client); + } + + withoutHttpsCertificate(): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withoutHttpsCertificate()), this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withRelationship(resourceBuilder, type)), this._client); + } + + withParentRelationship(parent: Awaitable): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withParentRelationship(parent)), this._client); + } + + withChildRelationship(child: Awaitable): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withChildRelationship(child)), this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withIconName(iconName, options)), this._client); + } + + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withHttpProbe(probeType, options)), this._client); + } + + excludeFromMcp(): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.excludeFromMcp()), this._client); + } + + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withImagePushOptions(callback)), this._client); + } + + withRemoteImageName(remoteImageName: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withRemoteImageName(remoteImageName)), this._client); + } + + withRemoteImageTag(remoteImageTag: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag)), this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options)), this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withPipelineConfiguration(callback)), this._client); + } + + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.onBeforeResourceStarted(callback)), this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.onResourceStopped(callback)), this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.onInitializeResource(callback)), this._client); + } + + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback)), this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.onResourceReady(callback)), this._client); + } + + createExecutionConfiguration(): Promise { + return this._promise.then(obj => obj.createExecutionConfiguration()); + } + + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4ReferenceWithEnvironment(source, options)), this._client); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Details(options)), this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Reference(target, options)), this._client); + } + + withLikeC4Group(groupName: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Group(groupName)), this._client); + } + + excludeFromLikeC4(): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.excludeFromLikeC4()), this._client); + } + + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withAzureUserAssignedIdentity(identityResourceBuilder)), this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withRoleAssignments(target, roles)), this._client); + } + +} + +// ============================================================================ +// ExecutableResource +// ============================================================================ + +export interface ExecutableResource { + toJSON(): MarshalledHandle; + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): ExecutableResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ExecutableResourcePromise; + /** Publishes an executable as a Docker file */ + publishAsDockerFile(configure: (obj: ContainerResource) => Promise): ExecutableResourcePromise; + /** Sets the executable command */ + withExecutableCommand(command: string): ExecutableResourcePromise; + /** Sets the executable working directory */ + withWorkingDirectory(workingDirectory: string): ExecutableResourcePromise; + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): ExecutableResourcePromise; + /** Configures OTLP telemetry export */ + withOtlpExporter(options?: WithOtlpExporterOptions): ExecutableResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ExecutableResourcePromise; + /** Sets an environment variable */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): ExecutableResourcePromise; + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise; + /** Adds arguments */ + withArgs(args: string[]): ExecutableResourcePromise; + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): ExecutableResourcePromise; + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ExecutableResourcePromise; + /** Adds a reference to another resource */ + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): ExecutableResourcePromise; + /** Updates a named endpoint via callback */ + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): ExecutableResourcePromise; + /** Updates an HTTP endpoint via callback */ + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): ExecutableResourcePromise; + /** Updates an HTTPS endpoint via callback */ + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): ExecutableResourcePromise; + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): ExecutableResourcePromise; + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): ExecutableResourcePromise; + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): ExecutableResourcePromise; + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): ExecutableResourcePromise; + /** Gets an endpoint reference */ + getEndpoint(name: string): Promise; + /** Configures resource for HTTP/2 */ + asHttp2Service(): ExecutableResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): ExecutableResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): ExecutableResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ExecutableResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): ExecutableResourcePromise; + /** Waits for another resource to be ready */ + waitFor(dependency: Awaitable, options?: WaitForOptions): ExecutableResourcePromise; + /** Waits for another resource to start */ + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): ExecutableResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): ExecutableResourcePromise; + /** Waits for resource completion */ + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): ExecutableResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): ExecutableResourcePromise; + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ExecutableResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ExecutableResourcePromise; + /** Adds an HTTP resource command */ + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): ExecutableResourcePromise; + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): ExecutableResourcePromise; + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): ExecutableResourcePromise; + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ExecutableResourcePromise; + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): ExecutableResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): ExecutableResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): ExecutableResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): ExecutableResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ExecutableResourcePromise; + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ExecutableResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ExecutableResourcePromise; + /** Sets image push options via callback */ + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): ExecutableResourcePromise; + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): ExecutableResourcePromise; + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): ExecutableResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ExecutableResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ExecutableResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ExecutableResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ExecutableResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ExecutableResourcePromise; + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ExecutableResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ExecutableResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Create a new reference, while also allowing customization of how a resource appears in the generated LikeC4 diagram. */ + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): ExecutableResourcePromise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): ExecutableResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): ExecutableResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): ExecutableResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): ExecutableResourcePromise; + /** Associates an Azure user-assigned identity with a compute resource */ + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): ExecutableResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): ExecutableResourcePromise; +} + +export interface ExecutableResourcePromise extends PromiseLike { + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): ExecutableResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ExecutableResourcePromise; + /** Publishes an executable as a Docker file */ + publishAsDockerFile(configure: (obj: ContainerResource) => Promise): ExecutableResourcePromise; + /** Sets the executable command */ + withExecutableCommand(command: string): ExecutableResourcePromise; + /** Sets the executable working directory */ + withWorkingDirectory(workingDirectory: string): ExecutableResourcePromise; + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): ExecutableResourcePromise; + /** Configures OTLP telemetry export */ + withOtlpExporter(options?: WithOtlpExporterOptions): ExecutableResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ExecutableResourcePromise; + /** Sets an environment variable */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): ExecutableResourcePromise; + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise; + /** Adds arguments */ + withArgs(args: string[]): ExecutableResourcePromise; + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): ExecutableResourcePromise; + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ExecutableResourcePromise; + /** Adds a reference to another resource */ + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): ExecutableResourcePromise; + /** Updates a named endpoint via callback */ + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): ExecutableResourcePromise; + /** Updates an HTTP endpoint via callback */ + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): ExecutableResourcePromise; + /** Updates an HTTPS endpoint via callback */ + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): ExecutableResourcePromise; + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): ExecutableResourcePromise; + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): ExecutableResourcePromise; + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): ExecutableResourcePromise; + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): ExecutableResourcePromise; + /** Gets an endpoint reference */ + getEndpoint(name: string): Promise; + /** Configures resource for HTTP/2 */ + asHttp2Service(): ExecutableResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): ExecutableResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): ExecutableResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ExecutableResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): ExecutableResourcePromise; + /** Waits for another resource to be ready */ + waitFor(dependency: Awaitable, options?: WaitForOptions): ExecutableResourcePromise; + /** Waits for another resource to start */ + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): ExecutableResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): ExecutableResourcePromise; + /** Waits for resource completion */ + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): ExecutableResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): ExecutableResourcePromise; + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ExecutableResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ExecutableResourcePromise; + /** Adds an HTTP resource command */ + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): ExecutableResourcePromise; + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): ExecutableResourcePromise; + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): ExecutableResourcePromise; + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ExecutableResourcePromise; + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): ExecutableResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): ExecutableResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): ExecutableResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): ExecutableResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ExecutableResourcePromise; + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ExecutableResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ExecutableResourcePromise; + /** Sets image push options via callback */ + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): ExecutableResourcePromise; + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): ExecutableResourcePromise; + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): ExecutableResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ExecutableResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ExecutableResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ExecutableResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ExecutableResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ExecutableResourcePromise; + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ExecutableResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ExecutableResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Create a new reference, while also allowing customization of how a resource appears in the generated LikeC4 diagram. */ + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): ExecutableResourcePromise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): ExecutableResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): ExecutableResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): ExecutableResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): ExecutableResourcePromise; + /** Associates an Azure user-assigned identity with a compute resource */ + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): ExecutableResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): ExecutableResourcePromise; +} + +// ============================================================================ +// ExecutableResourceImpl +// ============================================================================ + +class ExecutableResourceImpl extends ResourceBuilderBase implements ExecutableResource { + constructor(handle: ExecutableResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: Awaitable): Promise { + registry = isPromiseLike(registry) ? await registry : registry; + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + withContainerRegistry(registry: Awaitable): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._withContainerRegistryInternal(registry), this._client); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ExecutableResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new ExecutableResourcePromiseImpl(this._withDockerfileBaseImageInternal(buildImage, runtimeImage), this._client); + } + + /** @internal */ + private async _publishAsDockerFileInternal(configure: (obj: ContainerResource) => Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ContainerResourceHandle; + const obj = new ContainerResourceImpl(objHandle, this._client); + await configure(obj); + }); + const rpcArgs: Record = { builder: this._handle, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsDockerFile', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + publishAsDockerFile(configure: (obj: ContainerResource) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._publishAsDockerFileInternal(configure), this._client); + } + + /** @internal */ + private async _withExecutableCommandInternal(command: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExecutableCommand', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + withExecutableCommand(command: string): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._withExecutableCommandInternal(command), this._client); + } + + /** @internal */ + private async _withWorkingDirectoryInternal(workingDirectory: string): Promise { + const rpcArgs: Record = { builder: this._handle, workingDirectory }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withWorkingDirectory', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + withWorkingDirectory(workingDirectory: string): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._withWorkingDirectoryInternal(workingDirectory), this._client); + } + + /** @internal */ + private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withMcpServer', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + withMcpServer(options?: WithMcpServerOptions): ExecutableResourcePromise { + const path = options?.path; + const endpointName = options?.endpointName; + return new ExecutableResourcePromiseImpl(this._withMcpServerInternal(path, endpointName), this._client); + } + + /** @internal */ + private async _withOtlpExporterInternal(protocol?: OtlpProtocol): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (protocol !== undefined) rpcArgs.protocol = protocol; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporter', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + withOtlpExporter(options?: WithOtlpExporterOptions): ExecutableResourcePromise { + const protocol = options?.protocol; + return new ExecutableResourcePromiseImpl(this._withOtlpExporterInternal(protocol), this._client); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ExecutableResourcePromise { + const helpLink = options?.helpLink; + return new ExecutableResourcePromiseImpl(this._withRequiredCommandInternal(command, helpLink), this._client); + } + + /** @internal */ + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): Promise { + value = isPromiseLike(value) ? await value : value; + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironment', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._withEnvironmentInternal(name, value), this._client); + } + + /** @internal */ + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentCallback', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._withEnvironmentCallbackInternal(callback), this._client); + } + + /** @internal */ + private async _withArgsInternal(args: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, args }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgs', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + withArgs(args: string[]): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._withArgsInternal(args), this._client); + } + + /** @internal */ + private async _withArgsCallbackInternal(callback: (obj: CommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; + const obj = new CommandLineArgsCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallback', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._withArgsCallbackInternal(callback), this._client); + } + + /** @internal */ + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceEnvironment', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._withReferenceEnvironmentInternal(options), this._client); + } + + /** @internal */ + private async _withReferenceInternal(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, connectionName?: string, optional?: boolean, name?: string): Promise { + source = isPromiseLike(source) ? await source : source; + const rpcArgs: Record = { builder: this._handle, source }; + if (connectionName !== undefined) rpcArgs.connectionName = connectionName; + if (optional !== undefined) rpcArgs.optional = optional; + if (name !== undefined) rpcArgs.name = name; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReference', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): ExecutableResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new ExecutableResourcePromiseImpl(this._withReferenceInternal(source, connectionName, optional, name), this._client); + } + + /** @internal */ + private async _withEndpointCallbackInternal(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpointCallback', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): ExecutableResourcePromise { + const createIfNotExists = options?.createIfNotExists; + return new ExecutableResourcePromiseImpl(this._withEndpointCallbackInternal(endpointName, callback, createIfNotExists), this._client); + } + + /** @internal */ + private async _withHttpEndpointCallbackInternal(callback: (obj: EndpointUpdateContext) => Promise, name?: string, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + if (name !== undefined) rpcArgs.name = name; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpEndpointCallback', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): ExecutableResourcePromise { + const name = options?.name; + const createIfNotExists = options?.createIfNotExists; + return new ExecutableResourcePromiseImpl(this._withHttpEndpointCallbackInternal(callback, name, createIfNotExists), this._client); + } + + /** @internal */ + private async _withHttpsEndpointCallbackInternal(callback: (obj: EndpointUpdateContext) => Promise, name?: string, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + if (name !== undefined) rpcArgs.name = name; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsEndpointCallback', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): ExecutableResourcePromise { + const name = options?.name; + const createIfNotExists = options?.createIfNotExists; + return new ExecutableResourcePromiseImpl(this._withHttpsEndpointCallbackInternal(callback, name, createIfNotExists), this._client); + } + + /** @internal */ + private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (scheme !== undefined) rpcArgs.scheme = scheme; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + if (isExternal !== undefined) rpcArgs.isExternal = isExternal; + if (protocol !== undefined) rpcArgs.protocol = protocol; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpoint', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + withEndpoint(options?: WithEndpointOptions): ExecutableResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const scheme = options?.scheme; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + const isExternal = options?.isExternal; + const protocol = options?.protocol; + return new ExecutableResourcePromiseImpl(this._withEndpointInternal(port, targetPort, scheme, name, env, isProxied, isExternal, protocol), this._client); + } + + /** @internal */ + private async _withHttpEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpEndpoint', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + withHttpEndpoint(options?: WithHttpEndpointOptions): ExecutableResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new ExecutableResourcePromiseImpl(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied), this._client); + } + + /** @internal */ + private async _withHttpsEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsEndpoint', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + withHttpsEndpoint(options?: WithHttpsEndpointOptions): ExecutableResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new ExecutableResourcePromiseImpl(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied), this._client); + } + + /** @internal */ + private async _withExternalHttpEndpointsInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExternalHttpEndpoints', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + withExternalHttpEndpoints(): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._withExternalHttpEndpointsInternal(), this._client); + } + + async getEndpoint(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getEndpoint', + rpcArgs + ); + } + + /** @internal */ + private async _asHttp2ServiceInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/asHttp2Service', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + asHttp2Service(): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._asHttp2ServiceInternal(), this._client); + } + + /** @internal */ + private async _withUrlsInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrls', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._withUrlsInternal(callback), this._client); + } + + /** @internal */ + private async _withUrlInternal(url: string | ReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): ExecutableResourcePromise { + const displayText = options?.displayText; + return new ExecutableResourcePromiseImpl(this._withUrlInternal(url, displayText), this._client); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._withUrlForEndpointInternal(endpointName, callback), this._client); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + excludeFromManifest(): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._excludeFromManifestInternal(), this._client); + } + + /** @internal */ + private async _waitForInternal(dependency: Awaitable, waitBehavior?: WaitBehavior): Promise { + dependency = isPromiseLike(dependency) ? await dependency : dependency; + const rpcArgs: Record = { builder: this._handle, dependency }; + if (waitBehavior !== undefined) rpcArgs.waitBehavior = waitBehavior; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitFor', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + waitFor(dependency: Awaitable, options?: WaitForOptions): ExecutableResourcePromise { + const waitBehavior = options?.waitBehavior; + return new ExecutableResourcePromiseImpl(this._waitForInternal(dependency, waitBehavior), this._client); + } + + /** @internal */ + private async _waitForStartInternal(dependency: Awaitable, waitBehavior?: WaitBehavior): Promise { + dependency = isPromiseLike(dependency) ? await dependency : dependency; + const rpcArgs: Record = { builder: this._handle, dependency }; + if (waitBehavior !== undefined) rpcArgs.waitBehavior = waitBehavior; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStart', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): ExecutableResourcePromise { + const waitBehavior = options?.waitBehavior; + return new ExecutableResourcePromiseImpl(this._waitForStartInternal(dependency, waitBehavior), this._client); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + withExplicitStart(): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._withExplicitStartInternal(), this._client); + } + + /** @internal */ + private async _waitForCompletionInternal(dependency: Awaitable, exitCode?: number): Promise { + dependency = isPromiseLike(dependency) ? await dependency : dependency; + const rpcArgs: Record = { builder: this._handle, dependency }; + if (exitCode !== undefined) rpcArgs.exitCode = exitCode; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceCompletion', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): ExecutableResourcePromise { + const exitCode = options?.exitCode; + return new ExecutableResourcePromiseImpl(this._waitForCompletionInternal(dependency, exitCode), this._client); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + withHealthCheck(key: string): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._withHealthCheckInternal(key), this._client); + } + + /** @internal */ + private async _withHttpHealthCheckInternal(path?: string, statusCode?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (statusCode !== undefined) rpcArgs.statusCode = statusCode; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpHealthCheck', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ExecutableResourcePromise { + const path = options?.path; + const statusCode = options?.statusCode; + const endpointName = options?.endpointName; + return new ExecutableResourcePromiseImpl(this._withHttpHealthCheckInternal(path, statusCode, endpointName), this._client); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContextImpl(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ExecutableResourcePromise { + const commandOptions = options?.commandOptions; + return new ExecutableResourcePromiseImpl(this._withCommandInternal(name, displayName, executeCommand, commandOptions), this._client); + } + + /** @internal */ + private async _withHttpCommandInternal(path: string, displayName: string, options?: HttpCommandExportOptions): Promise { + const rpcArgs: Record = { builder: this._handle, path, displayName }; + if (options !== undefined) rpcArgs.options = options; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpCommand', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._withHttpCommandInternal(path, displayName, options), this._client); + } + + /** @internal */ + private async _withDeveloperCertificateTrustInternal(trust: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, trust }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDeveloperCertificateTrust', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + withDeveloperCertificateTrust(trust: boolean): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._withDeveloperCertificateTrustInternal(trust), this._client); + } + + /** @internal */ + private async _withCertificateTrustScopeInternal(scope: CertificateTrustScope): Promise { + const rpcArgs: Record = { builder: this._handle, scope }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCertificateTrustScope', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + withCertificateTrustScope(scope: CertificateTrustScope): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._withCertificateTrustScopeInternal(scope), this._client); + } + + /** @internal */ + private async _withHttpsDeveloperCertificateInternal(password?: Awaitable): Promise { + password = isPromiseLike(password) ? await password : password; + const rpcArgs: Record = { builder: this._handle }; + if (password !== undefined) rpcArgs.password = password; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ExecutableResourcePromise { + let password = options?.password; + return new ExecutableResourcePromiseImpl(this._withHttpsDeveloperCertificateInternal(password), this._client); + } + + /** @internal */ + private async _withoutHttpsCertificateInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withoutHttpsCertificate', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + withoutHttpsCertificate(): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._withoutHttpsCertificateInternal(), this._client); + } + + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: Awaitable, type: string): Promise { + resourceBuilder = isPromiseLike(resourceBuilder) ? await resourceBuilder : resourceBuilder; + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._withRelationshipInternal(resourceBuilder, type), this._client); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: Awaitable): Promise { + parent = isPromiseLike(parent) ? await parent : parent; + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + withParentRelationship(parent: Awaitable): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._withParentRelationshipInternal(parent), this._client); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: Awaitable): Promise { + child = isPromiseLike(child) ? await child : child; + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + withChildRelationship(child: Awaitable): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._withChildRelationshipInternal(child), this._client); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): ExecutableResourcePromise { + const iconVariant = options?.iconVariant; + return new ExecutableResourcePromiseImpl(this._withIconNameInternal(iconName, iconVariant), this._client); + } + + /** @internal */ + private async _withHttpProbeInternal(probeType: ProbeType, path?: string, initialDelaySeconds?: number, periodSeconds?: number, timeoutSeconds?: number, failureThreshold?: number, successThreshold?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, probeType }; + if (path !== undefined) rpcArgs.path = path; + if (initialDelaySeconds !== undefined) rpcArgs.initialDelaySeconds = initialDelaySeconds; + if (periodSeconds !== undefined) rpcArgs.periodSeconds = periodSeconds; + if (timeoutSeconds !== undefined) rpcArgs.timeoutSeconds = timeoutSeconds; + if (failureThreshold !== undefined) rpcArgs.failureThreshold = failureThreshold; + if (successThreshold !== undefined) rpcArgs.successThreshold = successThreshold; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpProbe', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ExecutableResourcePromise { + const path = options?.path; + const initialDelaySeconds = options?.initialDelaySeconds; + const periodSeconds = options?.periodSeconds; + const timeoutSeconds = options?.timeoutSeconds; + const failureThreshold = options?.failureThreshold; + const successThreshold = options?.successThreshold; + const endpointName = options?.endpointName; + return new ExecutableResourcePromiseImpl(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName), this._client); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + excludeFromMcp(): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._excludeFromMcpInternal(), this._client); + } + + /** @internal */ + private async _withImagePushOptionsInternal(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ContainerImagePushOptionsCallbackContextHandle; + const arg = new ContainerImagePushOptionsCallbackContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImagePushOptions', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._withImagePushOptionsInternal(callback), this._client); + } + + /** @internal */ + private async _withRemoteImageNameInternal(remoteImageName: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageName', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + withRemoteImageName(remoteImageName: string): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._withRemoteImageNameInternal(remoteImageName), this._client); + } + + /** @internal */ + private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageTag', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + withRemoteImageTag(remoteImageTag: string): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._withRemoteImageTagInternal(remoteImageTag), this._client); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ExecutableResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new ExecutableResourcePromiseImpl(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description), this._client); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._withPipelineConfigurationInternal(callback), this._client); + } + + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); + } + + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._onBeforeResourceStartedInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._onResourceStoppedInternal(callback), this._client); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._onInitializeResourceInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceEndpointsAllocated', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._onResourceEndpointsAllocatedInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._onResourceReadyInternal(callback), this._client); + } + + async createExecutionConfiguration(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/createExecutionConfiguration', + rpcArgs + ); + } + + /** @internal */ + private async _withLikeC4ReferenceWithEnvironmentInternal(source: Awaitable, configure?: (obj: LikeC4RelationshipDetailsAnnotation) => Promise, connectionName?: string, optional?: boolean, skipAspireReference?: boolean): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4RelationshipDetailsAnnotationHandle; + const obj = new LikeC4RelationshipDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + source = isPromiseLike(source) ? await source : source; + const rpcArgs: Record = { builder: this._handle, source }; + if (configure !== undefined) rpcArgs.configure = configureId; + if (connectionName !== undefined) rpcArgs.connectionName = connectionName; + if (optional !== undefined) rpcArgs.optional = optional; + if (skipAspireReference !== undefined) rpcArgs.skipAspireReference = skipAspireReference; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4ReferenceWithEnvironment', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): ExecutableResourcePromise { + const configure = options?.configure; + const connectionName = options?.connectionName; + const optional = options?.optional; + const skipAspireReference = options?.skipAspireReference; + return new ExecutableResourcePromiseImpl(this._withLikeC4ReferenceWithEnvironmentInternal(source, configure, connectionName, optional, skipAspireReference), this._client); + } + + /** @internal */ + private async _withLikeC4DetailsInternal(label?: string, technology?: string, description?: string, summary?: string, icon?: string, configure?: (obj: LikeC4NodeDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4NodeDetailsAnnotationHandle; + const obj = new LikeC4NodeDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + const rpcArgs: Record = { builder: this._handle }; + if (label !== undefined) rpcArgs.label = label; + if (technology !== undefined) rpcArgs.technology = technology; + if (description !== undefined) rpcArgs.description = description; + if (summary !== undefined) rpcArgs.summary = summary; + if (icon !== undefined) rpcArgs.icon = icon; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4DetailsParameters', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): ExecutableResourcePromise { + const label = options?.label; + const technology = options?.technology; + const description = options?.description; + const summary = options?.summary; + const icon = options?.icon; + const configure = options?.configure; + return new ExecutableResourcePromiseImpl(this._withLikeC4DetailsInternal(label, technology, description, summary, icon, configure), this._client); + } + + /** @internal */ + private async _withLikeC4ReferenceInternal(target: Awaitable, configure?: (obj: LikeC4RelationshipDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4RelationshipDetailsAnnotationHandle; + const obj = new LikeC4RelationshipDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target }; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Reference', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): ExecutableResourcePromise { + const configure = options?.configure; + return new ExecutableResourcePromiseImpl(this._withLikeC4ReferenceInternal(target, configure), this._client); + } + + /** @internal */ + private async _withLikeC4GroupInternal(groupName: string): Promise { + const rpcArgs: Record = { builder: this._handle, groupName }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Group', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + withLikeC4Group(groupName: string): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._withLikeC4GroupInternal(groupName), this._client); + } + + /** @internal */ + private async _excludeFromLikeC4Internal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/excludeFromLikeC4', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + excludeFromLikeC4(): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._excludeFromLikeC4Internal(), this._client); + } + + /** @internal */ + private async _withAzureUserAssignedIdentityInternal(identityResourceBuilder: Awaitable): Promise { + identityResourceBuilder = isPromiseLike(identityResourceBuilder) ? await identityResourceBuilder : identityResourceBuilder; + const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._withAzureUserAssignedIdentityInternal(identityResourceBuilder), this._client); + } + + /** @internal */ + private async _withRoleAssignmentsInternal(target: Awaitable, roles: AzureKeyVaultRole[]): Promise { + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target, roles }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.KeyVault/withKeyVaultRoleAssignments', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._withRoleAssignmentsInternal(target, roles), this._client); + } + +} + +/** + * Thenable wrapper for ExecutableResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +class ExecutableResourcePromiseImpl implements ExecutableResourcePromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: ExecutableResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + withContainerRegistry(registry: Awaitable): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withContainerRegistry(registry)), this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withDockerfileBaseImage(options)), this._client); + } + + publishAsDockerFile(configure: (obj: ContainerResource) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.publishAsDockerFile(configure)), this._client); + } + + withExecutableCommand(command: string): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withExecutableCommand(command)), this._client); + } + + withWorkingDirectory(workingDirectory: string): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withWorkingDirectory(workingDirectory)), this._client); + } + + withMcpServer(options?: WithMcpServerOptions): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withMcpServer(options)), this._client); + } + + withOtlpExporter(options?: WithOtlpExporterOptions): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withOtlpExporter(options)), this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withRequiredCommand(command, options)), this._client); + } + + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withEnvironment(name, value)), this._client); + } + + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentCallback(callback)), this._client); + } + + withArgs(args: string[]): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withArgs(args)), this._client); + } + + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withArgsCallback(callback)), this._client); + } + + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withReferenceEnvironment(options)), this._client); + } + + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withReference(source, options)), this._client); + } + + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withEndpointCallback(endpointName, callback, options)), this._client); + } + + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withHttpEndpointCallback(callback, options)), this._client); + } + + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withHttpsEndpointCallback(callback, options)), this._client); + } + + withEndpoint(options?: WithEndpointOptions): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withEndpoint(options)), this._client); + } + + withHttpEndpoint(options?: WithHttpEndpointOptions): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withHttpEndpoint(options)), this._client); + } + + withHttpsEndpoint(options?: WithHttpsEndpointOptions): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withHttpsEndpoint(options)), this._client); + } + + withExternalHttpEndpoints(): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withExternalHttpEndpoints()), this._client); + } + + getEndpoint(name: string): Promise { + return this._promise.then(obj => obj.getEndpoint(name)); + } + + asHttp2Service(): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.asHttp2Service()), this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withUrls(callback)), this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withUrl(url, options)), this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback)), this._client); + } + + excludeFromManifest(): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.excludeFromManifest()), this._client); + } + + waitFor(dependency: Awaitable, options?: WaitForOptions): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.waitFor(dependency, options)), this._client); + } + + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.waitForStart(dependency, options)), this._client); + } + + withExplicitStart(): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withExplicitStart()), this._client); + } + + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.waitForCompletion(dependency, options)), this._client); + } + + withHealthCheck(key: string): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withHealthCheck(key)), this._client); + } + + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withHttpHealthCheck(options)), this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options)), this._client); + } + + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withHttpCommand(path, displayName, options)), this._client); + } + + withDeveloperCertificateTrust(trust: boolean): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust)), this._client); + } + + withCertificateTrustScope(scope: CertificateTrustScope): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withCertificateTrustScope(scope)), this._client); + } + + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options)), this._client); + } + + withoutHttpsCertificate(): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withoutHttpsCertificate()), this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withRelationship(resourceBuilder, type)), this._client); + } + + withParentRelationship(parent: Awaitable): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withParentRelationship(parent)), this._client); + } + + withChildRelationship(child: Awaitable): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withChildRelationship(child)), this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withIconName(iconName, options)), this._client); + } + + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withHttpProbe(probeType, options)), this._client); + } + + excludeFromMcp(): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.excludeFromMcp()), this._client); + } + + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withImagePushOptions(callback)), this._client); + } + + withRemoteImageName(remoteImageName: string): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withRemoteImageName(remoteImageName)), this._client); + } + + withRemoteImageTag(remoteImageTag: string): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag)), this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options)), this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withPipelineConfiguration(callback)), this._client); + } + + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.onBeforeResourceStarted(callback)), this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.onResourceStopped(callback)), this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.onInitializeResource(callback)), this._client); + } + + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback)), this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.onResourceReady(callback)), this._client); + } + + createExecutionConfiguration(): Promise { + return this._promise.then(obj => obj.createExecutionConfiguration()); + } + + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4ReferenceWithEnvironment(source, options)), this._client); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Details(options)), this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Reference(target, options)), this._client); + } + + withLikeC4Group(groupName: string): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Group(groupName)), this._client); + } + + excludeFromLikeC4(): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.excludeFromLikeC4()), this._client); + } + + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withAzureUserAssignedIdentity(identityResourceBuilder)), this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withRoleAssignments(target, roles)), this._client); + } + +} + +// ============================================================================ +// ExternalServiceResource +// ============================================================================ + +export interface ExternalServiceResource { + toJSON(): MarshalledHandle; + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): ExternalServiceResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ExternalServiceResourcePromise; + /** Adds an HTTP health check to the external service */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ExternalServiceResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ExternalServiceResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): ExternalServiceResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): ExternalServiceResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ExternalServiceResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): ExternalServiceResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): ExternalServiceResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): ExternalServiceResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ExternalServiceResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): ExternalServiceResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): ExternalServiceResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): ExternalServiceResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ExternalServiceResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ExternalServiceResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ExternalServiceResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ExternalServiceResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ExternalServiceResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ExternalServiceResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ExternalServiceResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ExternalServiceResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): ExternalServiceResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): ExternalServiceResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): ExternalServiceResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): ExternalServiceResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): ExternalServiceResourcePromise; +} + +export interface ExternalServiceResourcePromise extends PromiseLike { + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): ExternalServiceResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ExternalServiceResourcePromise; + /** Adds an HTTP health check to the external service */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ExternalServiceResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ExternalServiceResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): ExternalServiceResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): ExternalServiceResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ExternalServiceResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): ExternalServiceResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): ExternalServiceResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): ExternalServiceResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ExternalServiceResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): ExternalServiceResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): ExternalServiceResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): ExternalServiceResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ExternalServiceResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ExternalServiceResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ExternalServiceResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ExternalServiceResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ExternalServiceResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ExternalServiceResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ExternalServiceResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ExternalServiceResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): ExternalServiceResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): ExternalServiceResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): ExternalServiceResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): ExternalServiceResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): ExternalServiceResourcePromise; +} + +// ============================================================================ +// ExternalServiceResourceImpl +// ============================================================================ + +class ExternalServiceResourceImpl extends ResourceBuilderBase implements ExternalServiceResource { + constructor(handle: ExternalServiceResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: Awaitable): Promise { + registry = isPromiseLike(registry) ? await registry : registry; + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new ExternalServiceResourceImpl(result, this._client); + } + + withContainerRegistry(registry: Awaitable): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._withContainerRegistryInternal(registry), this._client); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new ExternalServiceResourceImpl(result, this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ExternalServiceResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new ExternalServiceResourcePromiseImpl(this._withDockerfileBaseImageInternal(buildImage, runtimeImage), this._client); + } + + /** @internal */ + private async _withHttpHealthCheckInternal(path?: string, statusCode?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (statusCode !== undefined) rpcArgs.statusCode = statusCode; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExternalServiceHttpHealthCheck', + rpcArgs + ); + return new ExternalServiceResourceImpl(result, this._client); + } + + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ExternalServiceResourcePromise { + const path = options?.path; + const statusCode = options?.statusCode; + const endpointName = options?.endpointName; + return new ExternalServiceResourcePromiseImpl(this._withHttpHealthCheckInternal(path, statusCode, endpointName), this._client); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new ExternalServiceResourceImpl(result, this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ExternalServiceResourcePromise { + const helpLink = options?.helpLink; + return new ExternalServiceResourcePromiseImpl(this._withRequiredCommandInternal(command, helpLink), this._client); + } + + /** @internal */ + private async _withUrlsInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrls', + rpcArgs + ); + return new ExternalServiceResourceImpl(result, this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._withUrlsInternal(callback), this._client); + } + + /** @internal */ + private async _withUrlInternal(url: string | ReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new ExternalServiceResourceImpl(result, this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): ExternalServiceResourcePromise { + const displayText = options?.displayText; + return new ExternalServiceResourcePromiseImpl(this._withUrlInternal(url, displayText), this._client); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new ExternalServiceResourceImpl(result, this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._withUrlForEndpointInternal(endpointName, callback), this._client); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new ExternalServiceResourceImpl(result, this._client); + } + + excludeFromManifest(): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._excludeFromManifestInternal(), this._client); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new ExternalServiceResourceImpl(result, this._client); + } + + withExplicitStart(): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._withExplicitStartInternal(), this._client); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new ExternalServiceResourceImpl(result, this._client); + } + + withHealthCheck(key: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._withHealthCheckInternal(key), this._client); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContextImpl(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new ExternalServiceResourceImpl(result, this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ExternalServiceResourcePromise { + const commandOptions = options?.commandOptions; + return new ExternalServiceResourcePromiseImpl(this._withCommandInternal(name, displayName, executeCommand, commandOptions), this._client); + } + + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: Awaitable, type: string): Promise { + resourceBuilder = isPromiseLike(resourceBuilder) ? await resourceBuilder : resourceBuilder; + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ExternalServiceResourceImpl(result, this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._withRelationshipInternal(resourceBuilder, type), this._client); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: Awaitable): Promise { + parent = isPromiseLike(parent) ? await parent : parent; + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new ExternalServiceResourceImpl(result, this._client); + } + + withParentRelationship(parent: Awaitable): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._withParentRelationshipInternal(parent), this._client); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: Awaitable): Promise { + child = isPromiseLike(child) ? await child : child; + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', + rpcArgs + ); + return new ExternalServiceResourceImpl(result, this._client); + } + + withChildRelationship(child: Awaitable): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._withChildRelationshipInternal(child), this._client); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new ExternalServiceResourceImpl(result, this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): ExternalServiceResourcePromise { + const iconVariant = options?.iconVariant; + return new ExternalServiceResourcePromiseImpl(this._withIconNameInternal(iconName, iconVariant), this._client); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new ExternalServiceResourceImpl(result, this._client); + } + + excludeFromMcp(): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._excludeFromMcpInternal(), this._client); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new ExternalServiceResourceImpl(result, this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ExternalServiceResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new ExternalServiceResourcePromiseImpl(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description), this._client); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new ExternalServiceResourceImpl(result, this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._withPipelineConfigurationInternal(callback), this._client); + } + + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); + } + + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new ExternalServiceResourceImpl(result, this._client); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._onBeforeResourceStartedInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new ExternalServiceResourceImpl(result, this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._onResourceStoppedInternal(callback), this._client); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new ExternalServiceResourceImpl(result, this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._onInitializeResourceInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new ExternalServiceResourceImpl(result, this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._onResourceReadyInternal(callback), this._client); + } + + async createExecutionConfiguration(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/createExecutionConfiguration', + rpcArgs + ); + } + + /** @internal */ + private async _withLikeC4DetailsInternal(label?: string, technology?: string, description?: string, summary?: string, icon?: string, configure?: (obj: LikeC4NodeDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4NodeDetailsAnnotationHandle; + const obj = new LikeC4NodeDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + const rpcArgs: Record = { builder: this._handle }; + if (label !== undefined) rpcArgs.label = label; + if (technology !== undefined) rpcArgs.technology = technology; + if (description !== undefined) rpcArgs.description = description; + if (summary !== undefined) rpcArgs.summary = summary; + if (icon !== undefined) rpcArgs.icon = icon; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4DetailsParameters', + rpcArgs + ); + return new ExternalServiceResourceImpl(result, this._client); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): ExternalServiceResourcePromise { + const label = options?.label; + const technology = options?.technology; + const description = options?.description; + const summary = options?.summary; + const icon = options?.icon; + const configure = options?.configure; + return new ExternalServiceResourcePromiseImpl(this._withLikeC4DetailsInternal(label, technology, description, summary, icon, configure), this._client); + } + + /** @internal */ + private async _withLikeC4ReferenceInternal(target: Awaitable, configure?: (obj: LikeC4RelationshipDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4RelationshipDetailsAnnotationHandle; + const obj = new LikeC4RelationshipDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target }; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Reference', + rpcArgs + ); + return new ExternalServiceResourceImpl(result, this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): ExternalServiceResourcePromise { + const configure = options?.configure; + return new ExternalServiceResourcePromiseImpl(this._withLikeC4ReferenceInternal(target, configure), this._client); + } + + /** @internal */ + private async _withLikeC4GroupInternal(groupName: string): Promise { + const rpcArgs: Record = { builder: this._handle, groupName }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Group', + rpcArgs + ); + return new ExternalServiceResourceImpl(result, this._client); + } + + withLikeC4Group(groupName: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._withLikeC4GroupInternal(groupName), this._client); + } + + /** @internal */ + private async _excludeFromLikeC4Internal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/excludeFromLikeC4', + rpcArgs + ); + return new ExternalServiceResourceImpl(result, this._client); + } + + excludeFromLikeC4(): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._excludeFromLikeC4Internal(), this._client); + } + + /** @internal */ + private async _withRoleAssignmentsInternal(target: Awaitable, roles: AzureKeyVaultRole[]): Promise { + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target, roles }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.KeyVault/withKeyVaultRoleAssignments', + rpcArgs + ); + return new ExternalServiceResourceImpl(result, this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._withRoleAssignmentsInternal(target, roles), this._client); + } + +} + +/** + * Thenable wrapper for ExternalServiceResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +class ExternalServiceResourcePromiseImpl implements ExternalServiceResourcePromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: ExternalServiceResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + withContainerRegistry(registry: Awaitable): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withContainerRegistry(registry)), this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withDockerfileBaseImage(options)), this._client); + } + + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withHttpHealthCheck(options)), this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withRequiredCommand(command, options)), this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withUrls(callback)), this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withUrl(url, options)), this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback)), this._client); + } + + excludeFromManifest(): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.excludeFromManifest()), this._client); + } + + withExplicitStart(): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withExplicitStart()), this._client); + } + + withHealthCheck(key: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withHealthCheck(key)), this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options)), this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withRelationship(resourceBuilder, type)), this._client); + } + + withParentRelationship(parent: Awaitable): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withParentRelationship(parent)), this._client); + } + + withChildRelationship(child: Awaitable): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withChildRelationship(child)), this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withIconName(iconName, options)), this._client); + } + + excludeFromMcp(): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.excludeFromMcp()), this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options)), this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withPipelineConfiguration(callback)), this._client); + } + + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.onBeforeResourceStarted(callback)), this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.onResourceStopped(callback)), this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.onInitializeResource(callback)), this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.onResourceReady(callback)), this._client); + } + + createExecutionConfiguration(): Promise { + return this._promise.then(obj => obj.createExecutionConfiguration()); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Details(options)), this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Reference(target, options)), this._client); + } + + withLikeC4Group(groupName: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Group(groupName)), this._client); + } + + excludeFromLikeC4(): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.excludeFromLikeC4()), this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withRoleAssignments(target, roles)), this._client); + } + +} + +// ============================================================================ +// JavaScriptAppResource +// ============================================================================ + +export interface JavaScriptAppResource { + toJSON(): MarshalledHandle; + /** Gets the Command property */ + command(): Promise; + /** Gets the WorkingDirectory property */ + workingDirectory(): Promise; + /** Gets the Name property */ + name(): Promise; + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): JavaScriptAppResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): JavaScriptAppResourcePromise; + /** Publishes an executable as a Docker file */ + publishAsDockerFile(configure: (obj: ContainerResource) => Promise): JavaScriptAppResourcePromise; + /** Sets the executable command */ + withExecutableCommand(command: string): JavaScriptAppResourcePromise; + /** Sets the executable working directory */ + withWorkingDirectory(workingDirectory: string): JavaScriptAppResourcePromise; + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): JavaScriptAppResourcePromise; + /** Configures OTLP telemetry export */ + withOtlpExporter(options?: WithOtlpExporterOptions): JavaScriptAppResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): JavaScriptAppResourcePromise; + /** Sets an environment variable */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): JavaScriptAppResourcePromise; + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): JavaScriptAppResourcePromise; + /** Adds arguments */ + withArgs(args: string[]): JavaScriptAppResourcePromise; + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): JavaScriptAppResourcePromise; + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): JavaScriptAppResourcePromise; + /** Adds a reference to another resource */ + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): JavaScriptAppResourcePromise; + /** Updates a named endpoint via callback */ + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): JavaScriptAppResourcePromise; + /** Updates an HTTP endpoint via callback */ + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): JavaScriptAppResourcePromise; + /** Updates an HTTPS endpoint via callback */ + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): JavaScriptAppResourcePromise; + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): JavaScriptAppResourcePromise; + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): JavaScriptAppResourcePromise; + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): JavaScriptAppResourcePromise; + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): JavaScriptAppResourcePromise; + /** Gets an endpoint reference */ + getEndpoint(name: string): Promise; + /** Configures resource for HTTP/2 */ + asHttp2Service(): JavaScriptAppResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): JavaScriptAppResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): JavaScriptAppResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): JavaScriptAppResourcePromise; + /** Sets the source directory for container files */ + withContainerFilesSource(sourcePath: string): JavaScriptAppResourcePromise; + /** Clears all container file sources */ + clearContainerFilesSources(): JavaScriptAppResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): JavaScriptAppResourcePromise; + /** Waits for another resource to be ready */ + waitFor(dependency: Awaitable, options?: WaitForOptions): JavaScriptAppResourcePromise; + /** Waits for another resource to start */ + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): JavaScriptAppResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): JavaScriptAppResourcePromise; + /** Waits for resource completion */ + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): JavaScriptAppResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): JavaScriptAppResourcePromise; + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): JavaScriptAppResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): JavaScriptAppResourcePromise; + /** Adds an HTTP resource command */ + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): JavaScriptAppResourcePromise; + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): JavaScriptAppResourcePromise; + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): JavaScriptAppResourcePromise; + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): JavaScriptAppResourcePromise; + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): JavaScriptAppResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): JavaScriptAppResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): JavaScriptAppResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): JavaScriptAppResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): JavaScriptAppResourcePromise; + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): JavaScriptAppResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): JavaScriptAppResourcePromise; + /** Sets image push options via callback */ + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): JavaScriptAppResourcePromise; + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): JavaScriptAppResourcePromise; + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): JavaScriptAppResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): JavaScriptAppResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): JavaScriptAppResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): JavaScriptAppResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): JavaScriptAppResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): JavaScriptAppResourcePromise; + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): JavaScriptAppResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): JavaScriptAppResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Publishes the JavaScript application as a standalone static website using YARP. */ + publishAsStaticWebsite(options?: PublishAsStaticWebsiteOptions): JavaScriptAppResourcePromise; + /** Publishes the JavaScript application as a standalone Node.js server that runs a built artifact directly. */ + publishAsNodeServer(entryPoint: string, options?: PublishAsNodeServerOptions): JavaScriptAppResourcePromise; + /** Publishes the JavaScript application as a Node.js server that uses a package manager script at runtime. */ + publishAsNpmScript(options?: PublishAsNpmScriptOptions): JavaScriptAppResourcePromise; + /** Configures npm as the package manager */ + withNpm(options?: WithNpmOptions): JavaScriptAppResourcePromise; + /** Configures Bun as the package manager */ + withBun(options?: WithBunOptions): JavaScriptAppResourcePromise; + /** Configures yarn as the package manager */ + withYarn(options?: WithYarnOptions): JavaScriptAppResourcePromise; + /** Configures pnpm as the package manager */ + withPnpm(options?: WithPnpmOptions): JavaScriptAppResourcePromise; + /** Specifies an npm script to run before starting the application */ + withBuildScript(scriptName: string, options?: WithBuildScriptOptions): JavaScriptAppResourcePromise; + /** Specifies an npm script to run during development */ + withRunScript(scriptName: string, options?: WithRunScriptOptions): JavaScriptAppResourcePromise; + /** Configures a browser debugger for the JavaScript application */ + withBrowserDebugger(options?: WithBrowserDebuggerOptions): JavaScriptAppResourcePromise; + /** Create a new reference, while also allowing customization of how a resource appears in the generated LikeC4 diagram. */ + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): JavaScriptAppResourcePromise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): JavaScriptAppResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): JavaScriptAppResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): JavaScriptAppResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): JavaScriptAppResourcePromise; + /** Associates an Azure user-assigned identity with a compute resource */ + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): JavaScriptAppResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): JavaScriptAppResourcePromise; +} + +export interface JavaScriptAppResourcePromise extends PromiseLike { + /** Gets the Command property */ + command(): Promise; + /** Gets the WorkingDirectory property */ + workingDirectory(): Promise; + /** Gets the Name property */ + name(): Promise; + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): JavaScriptAppResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): JavaScriptAppResourcePromise; + /** Publishes an executable as a Docker file */ + publishAsDockerFile(configure: (obj: ContainerResource) => Promise): JavaScriptAppResourcePromise; + /** Sets the executable command */ + withExecutableCommand(command: string): JavaScriptAppResourcePromise; + /** Sets the executable working directory */ + withWorkingDirectory(workingDirectory: string): JavaScriptAppResourcePromise; + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): JavaScriptAppResourcePromise; + /** Configures OTLP telemetry export */ + withOtlpExporter(options?: WithOtlpExporterOptions): JavaScriptAppResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): JavaScriptAppResourcePromise; + /** Sets an environment variable */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): JavaScriptAppResourcePromise; + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): JavaScriptAppResourcePromise; + /** Adds arguments */ + withArgs(args: string[]): JavaScriptAppResourcePromise; + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): JavaScriptAppResourcePromise; + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): JavaScriptAppResourcePromise; + /** Adds a reference to another resource */ + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): JavaScriptAppResourcePromise; + /** Updates a named endpoint via callback */ + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): JavaScriptAppResourcePromise; + /** Updates an HTTP endpoint via callback */ + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): JavaScriptAppResourcePromise; + /** Updates an HTTPS endpoint via callback */ + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): JavaScriptAppResourcePromise; + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): JavaScriptAppResourcePromise; + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): JavaScriptAppResourcePromise; + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): JavaScriptAppResourcePromise; + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): JavaScriptAppResourcePromise; + /** Gets an endpoint reference */ + getEndpoint(name: string): Promise; + /** Configures resource for HTTP/2 */ + asHttp2Service(): JavaScriptAppResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): JavaScriptAppResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): JavaScriptAppResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): JavaScriptAppResourcePromise; + /** Sets the source directory for container files */ + withContainerFilesSource(sourcePath: string): JavaScriptAppResourcePromise; + /** Clears all container file sources */ + clearContainerFilesSources(): JavaScriptAppResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): JavaScriptAppResourcePromise; + /** Waits for another resource to be ready */ + waitFor(dependency: Awaitable, options?: WaitForOptions): JavaScriptAppResourcePromise; + /** Waits for another resource to start */ + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): JavaScriptAppResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): JavaScriptAppResourcePromise; + /** Waits for resource completion */ + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): JavaScriptAppResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): JavaScriptAppResourcePromise; + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): JavaScriptAppResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): JavaScriptAppResourcePromise; + /** Adds an HTTP resource command */ + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): JavaScriptAppResourcePromise; + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): JavaScriptAppResourcePromise; + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): JavaScriptAppResourcePromise; + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): JavaScriptAppResourcePromise; + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): JavaScriptAppResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): JavaScriptAppResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): JavaScriptAppResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): JavaScriptAppResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): JavaScriptAppResourcePromise; + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): JavaScriptAppResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): JavaScriptAppResourcePromise; + /** Sets image push options via callback */ + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): JavaScriptAppResourcePromise; + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): JavaScriptAppResourcePromise; + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): JavaScriptAppResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): JavaScriptAppResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): JavaScriptAppResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): JavaScriptAppResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): JavaScriptAppResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): JavaScriptAppResourcePromise; + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): JavaScriptAppResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): JavaScriptAppResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Publishes the JavaScript application as a standalone static website using YARP. */ + publishAsStaticWebsite(options?: PublishAsStaticWebsiteOptions): JavaScriptAppResourcePromise; + /** Publishes the JavaScript application as a standalone Node.js server that runs a built artifact directly. */ + publishAsNodeServer(entryPoint: string, options?: PublishAsNodeServerOptions): JavaScriptAppResourcePromise; + /** Publishes the JavaScript application as a Node.js server that uses a package manager script at runtime. */ + publishAsNpmScript(options?: PublishAsNpmScriptOptions): JavaScriptAppResourcePromise; + /** Configures npm as the package manager */ + withNpm(options?: WithNpmOptions): JavaScriptAppResourcePromise; + /** Configures Bun as the package manager */ + withBun(options?: WithBunOptions): JavaScriptAppResourcePromise; + /** Configures yarn as the package manager */ + withYarn(options?: WithYarnOptions): JavaScriptAppResourcePromise; + /** Configures pnpm as the package manager */ + withPnpm(options?: WithPnpmOptions): JavaScriptAppResourcePromise; + /** Specifies an npm script to run before starting the application */ + withBuildScript(scriptName: string, options?: WithBuildScriptOptions): JavaScriptAppResourcePromise; + /** Specifies an npm script to run during development */ + withRunScript(scriptName: string, options?: WithRunScriptOptions): JavaScriptAppResourcePromise; + /** Configures a browser debugger for the JavaScript application */ + withBrowserDebugger(options?: WithBrowserDebuggerOptions): JavaScriptAppResourcePromise; + /** Create a new reference, while also allowing customization of how a resource appears in the generated LikeC4 diagram. */ + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): JavaScriptAppResourcePromise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): JavaScriptAppResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): JavaScriptAppResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): JavaScriptAppResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): JavaScriptAppResourcePromise; + /** Associates an Azure user-assigned identity with a compute resource */ + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): JavaScriptAppResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): JavaScriptAppResourcePromise; +} + +// ============================================================================ +// JavaScriptAppResourceImpl +// ============================================================================ + +class JavaScriptAppResourceImpl extends ResourceBuilderBase implements JavaScriptAppResource { + constructor(handle: JavaScriptAppResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + async command(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/JavaScriptAppResource.command', + { context: this._handle } + ); + } + + async workingDirectory(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/JavaScriptAppResource.workingDirectory', + { context: this._handle } + ); + } + + async name(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/JavaScriptAppResource.name', + { context: this._handle } + ); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: Awaitable): Promise { + registry = isPromiseLike(registry) ? await registry : registry; + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withContainerRegistry(registry: Awaitable): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._withContainerRegistryInternal(registry), this._client); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): JavaScriptAppResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new JavaScriptAppResourcePromiseImpl(this._withDockerfileBaseImageInternal(buildImage, runtimeImage), this._client); + } + + /** @internal */ + private async _publishAsDockerFileInternal(configure: (obj: ContainerResource) => Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ContainerResourceHandle; + const obj = new ContainerResourceImpl(objHandle, this._client); + await configure(obj); + }); + const rpcArgs: Record = { builder: this._handle, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsDockerFile', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + publishAsDockerFile(configure: (obj: ContainerResource) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._publishAsDockerFileInternal(configure), this._client); + } + + /** @internal */ + private async _withExecutableCommandInternal(command: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExecutableCommand', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withExecutableCommand(command: string): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._withExecutableCommandInternal(command), this._client); + } + + /** @internal */ + private async _withWorkingDirectoryInternal(workingDirectory: string): Promise { + const rpcArgs: Record = { builder: this._handle, workingDirectory }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withWorkingDirectory', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withWorkingDirectory(workingDirectory: string): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._withWorkingDirectoryInternal(workingDirectory), this._client); + } + + /** @internal */ + private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withMcpServer', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withMcpServer(options?: WithMcpServerOptions): JavaScriptAppResourcePromise { + const path = options?.path; + const endpointName = options?.endpointName; + return new JavaScriptAppResourcePromiseImpl(this._withMcpServerInternal(path, endpointName), this._client); + } + + /** @internal */ + private async _withOtlpExporterInternal(protocol?: OtlpProtocol): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (protocol !== undefined) rpcArgs.protocol = protocol; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporter', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withOtlpExporter(options?: WithOtlpExporterOptions): JavaScriptAppResourcePromise { + const protocol = options?.protocol; + return new JavaScriptAppResourcePromiseImpl(this._withOtlpExporterInternal(protocol), this._client); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): JavaScriptAppResourcePromise { + const helpLink = options?.helpLink; + return new JavaScriptAppResourcePromiseImpl(this._withRequiredCommandInternal(command, helpLink), this._client); + } + + /** @internal */ + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): Promise { + value = isPromiseLike(value) ? await value : value; + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironment', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._withEnvironmentInternal(name, value), this._client); + } + + /** @internal */ + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentCallback', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._withEnvironmentCallbackInternal(callback), this._client); + } + + /** @internal */ + private async _withArgsInternal(args: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, args }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgs', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withArgs(args: string[]): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._withArgsInternal(args), this._client); + } + + /** @internal */ + private async _withArgsCallbackInternal(callback: (obj: CommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; + const obj = new CommandLineArgsCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallback', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._withArgsCallbackInternal(callback), this._client); + } + + /** @internal */ + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceEnvironment', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._withReferenceEnvironmentInternal(options), this._client); + } + + /** @internal */ + private async _withReferenceInternal(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, connectionName?: string, optional?: boolean, name?: string): Promise { + source = isPromiseLike(source) ? await source : source; + const rpcArgs: Record = { builder: this._handle, source }; + if (connectionName !== undefined) rpcArgs.connectionName = connectionName; + if (optional !== undefined) rpcArgs.optional = optional; + if (name !== undefined) rpcArgs.name = name; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReference', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): JavaScriptAppResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new JavaScriptAppResourcePromiseImpl(this._withReferenceInternal(source, connectionName, optional, name), this._client); + } + + /** @internal */ + private async _withEndpointCallbackInternal(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpointCallback', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): JavaScriptAppResourcePromise { + const createIfNotExists = options?.createIfNotExists; + return new JavaScriptAppResourcePromiseImpl(this._withEndpointCallbackInternal(endpointName, callback, createIfNotExists), this._client); + } + + /** @internal */ + private async _withHttpEndpointCallbackInternal(callback: (obj: EndpointUpdateContext) => Promise, name?: string, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + if (name !== undefined) rpcArgs.name = name; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpEndpointCallback', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): JavaScriptAppResourcePromise { + const name = options?.name; + const createIfNotExists = options?.createIfNotExists; + return new JavaScriptAppResourcePromiseImpl(this._withHttpEndpointCallbackInternal(callback, name, createIfNotExists), this._client); + } + + /** @internal */ + private async _withHttpsEndpointCallbackInternal(callback: (obj: EndpointUpdateContext) => Promise, name?: string, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + if (name !== undefined) rpcArgs.name = name; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsEndpointCallback', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): JavaScriptAppResourcePromise { + const name = options?.name; + const createIfNotExists = options?.createIfNotExists; + return new JavaScriptAppResourcePromiseImpl(this._withHttpsEndpointCallbackInternal(callback, name, createIfNotExists), this._client); + } + + /** @internal */ + private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (scheme !== undefined) rpcArgs.scheme = scheme; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + if (isExternal !== undefined) rpcArgs.isExternal = isExternal; + if (protocol !== undefined) rpcArgs.protocol = protocol; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpoint', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withEndpoint(options?: WithEndpointOptions): JavaScriptAppResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const scheme = options?.scheme; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + const isExternal = options?.isExternal; + const protocol = options?.protocol; + return new JavaScriptAppResourcePromiseImpl(this._withEndpointInternal(port, targetPort, scheme, name, env, isProxied, isExternal, protocol), this._client); + } + + /** @internal */ + private async _withHttpEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpEndpoint', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withHttpEndpoint(options?: WithHttpEndpointOptions): JavaScriptAppResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new JavaScriptAppResourcePromiseImpl(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied), this._client); + } + + /** @internal */ + private async _withHttpsEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsEndpoint', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withHttpsEndpoint(options?: WithHttpsEndpointOptions): JavaScriptAppResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new JavaScriptAppResourcePromiseImpl(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied), this._client); + } + + /** @internal */ + private async _withExternalHttpEndpointsInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExternalHttpEndpoints', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withExternalHttpEndpoints(): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._withExternalHttpEndpointsInternal(), this._client); + } + + async getEndpoint(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getEndpoint', + rpcArgs + ); + } + + /** @internal */ + private async _asHttp2ServiceInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/asHttp2Service', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + asHttp2Service(): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._asHttp2ServiceInternal(), this._client); + } + + /** @internal */ + private async _withUrlsInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrls', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._withUrlsInternal(callback), this._client); + } + + /** @internal */ + private async _withUrlInternal(url: string | ReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): JavaScriptAppResourcePromise { + const displayText = options?.displayText; + return new JavaScriptAppResourcePromiseImpl(this._withUrlInternal(url, displayText), this._client); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._withUrlForEndpointInternal(endpointName, callback), this._client); + } + + /** @internal */ + private async _withContainerFilesSourceInternal(sourcePath: string): Promise { + const rpcArgs: Record = { builder: this._handle, sourcePath }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerFilesSource', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withContainerFilesSource(sourcePath: string): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._withContainerFilesSourceInternal(sourcePath), this._client); + } + + /** @internal */ + private async _clearContainerFilesSourcesInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/clearContainerFilesSources', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + clearContainerFilesSources(): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._clearContainerFilesSourcesInternal(), this._client); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + excludeFromManifest(): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._excludeFromManifestInternal(), this._client); + } + + /** @internal */ + private async _waitForInternal(dependency: Awaitable, waitBehavior?: WaitBehavior): Promise { + dependency = isPromiseLike(dependency) ? await dependency : dependency; + const rpcArgs: Record = { builder: this._handle, dependency }; + if (waitBehavior !== undefined) rpcArgs.waitBehavior = waitBehavior; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitFor', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + waitFor(dependency: Awaitable, options?: WaitForOptions): JavaScriptAppResourcePromise { + const waitBehavior = options?.waitBehavior; + return new JavaScriptAppResourcePromiseImpl(this._waitForInternal(dependency, waitBehavior), this._client); + } + + /** @internal */ + private async _waitForStartInternal(dependency: Awaitable, waitBehavior?: WaitBehavior): Promise { + dependency = isPromiseLike(dependency) ? await dependency : dependency; + const rpcArgs: Record = { builder: this._handle, dependency }; + if (waitBehavior !== undefined) rpcArgs.waitBehavior = waitBehavior; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStart', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): JavaScriptAppResourcePromise { + const waitBehavior = options?.waitBehavior; + return new JavaScriptAppResourcePromiseImpl(this._waitForStartInternal(dependency, waitBehavior), this._client); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withExplicitStart(): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._withExplicitStartInternal(), this._client); + } + + /** @internal */ + private async _waitForCompletionInternal(dependency: Awaitable, exitCode?: number): Promise { + dependency = isPromiseLike(dependency) ? await dependency : dependency; + const rpcArgs: Record = { builder: this._handle, dependency }; + if (exitCode !== undefined) rpcArgs.exitCode = exitCode; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceCompletion', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): JavaScriptAppResourcePromise { + const exitCode = options?.exitCode; + return new JavaScriptAppResourcePromiseImpl(this._waitForCompletionInternal(dependency, exitCode), this._client); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withHealthCheck(key: string): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._withHealthCheckInternal(key), this._client); + } + + /** @internal */ + private async _withHttpHealthCheckInternal(path?: string, statusCode?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (statusCode !== undefined) rpcArgs.statusCode = statusCode; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpHealthCheck', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): JavaScriptAppResourcePromise { + const path = options?.path; + const statusCode = options?.statusCode; + const endpointName = options?.endpointName; + return new JavaScriptAppResourcePromiseImpl(this._withHttpHealthCheckInternal(path, statusCode, endpointName), this._client); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContextImpl(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): JavaScriptAppResourcePromise { + const commandOptions = options?.commandOptions; + return new JavaScriptAppResourcePromiseImpl(this._withCommandInternal(name, displayName, executeCommand, commandOptions), this._client); + } + + /** @internal */ + private async _withHttpCommandInternal(path: string, displayName: string, options?: HttpCommandExportOptions): Promise { + const rpcArgs: Record = { builder: this._handle, path, displayName }; + if (options !== undefined) rpcArgs.options = options; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpCommand', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._withHttpCommandInternal(path, displayName, options), this._client); + } + + /** @internal */ + private async _withDeveloperCertificateTrustInternal(trust: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, trust }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDeveloperCertificateTrust', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withDeveloperCertificateTrust(trust: boolean): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._withDeveloperCertificateTrustInternal(trust), this._client); + } + + /** @internal */ + private async _withCertificateTrustScopeInternal(scope: CertificateTrustScope): Promise { + const rpcArgs: Record = { builder: this._handle, scope }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCertificateTrustScope', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withCertificateTrustScope(scope: CertificateTrustScope): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._withCertificateTrustScopeInternal(scope), this._client); + } + + /** @internal */ + private async _withHttpsDeveloperCertificateInternal(password?: Awaitable): Promise { + password = isPromiseLike(password) ? await password : password; + const rpcArgs: Record = { builder: this._handle }; + if (password !== undefined) rpcArgs.password = password; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): JavaScriptAppResourcePromise { + let password = options?.password; + return new JavaScriptAppResourcePromiseImpl(this._withHttpsDeveloperCertificateInternal(password), this._client); + } + + /** @internal */ + private async _withoutHttpsCertificateInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withoutHttpsCertificate', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withoutHttpsCertificate(): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._withoutHttpsCertificateInternal(), this._client); + } + + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: Awaitable, type: string): Promise { + resourceBuilder = isPromiseLike(resourceBuilder) ? await resourceBuilder : resourceBuilder; + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._withRelationshipInternal(resourceBuilder, type), this._client); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: Awaitable): Promise { + parent = isPromiseLike(parent) ? await parent : parent; + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withParentRelationship(parent: Awaitable): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._withParentRelationshipInternal(parent), this._client); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: Awaitable): Promise { + child = isPromiseLike(child) ? await child : child; + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withChildRelationship(child: Awaitable): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._withChildRelationshipInternal(child), this._client); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): JavaScriptAppResourcePromise { + const iconVariant = options?.iconVariant; + return new JavaScriptAppResourcePromiseImpl(this._withIconNameInternal(iconName, iconVariant), this._client); + } + + /** @internal */ + private async _withHttpProbeInternal(probeType: ProbeType, path?: string, initialDelaySeconds?: number, periodSeconds?: number, timeoutSeconds?: number, failureThreshold?: number, successThreshold?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, probeType }; + if (path !== undefined) rpcArgs.path = path; + if (initialDelaySeconds !== undefined) rpcArgs.initialDelaySeconds = initialDelaySeconds; + if (periodSeconds !== undefined) rpcArgs.periodSeconds = periodSeconds; + if (timeoutSeconds !== undefined) rpcArgs.timeoutSeconds = timeoutSeconds; + if (failureThreshold !== undefined) rpcArgs.failureThreshold = failureThreshold; + if (successThreshold !== undefined) rpcArgs.successThreshold = successThreshold; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpProbe', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): JavaScriptAppResourcePromise { + const path = options?.path; + const initialDelaySeconds = options?.initialDelaySeconds; + const periodSeconds = options?.periodSeconds; + const timeoutSeconds = options?.timeoutSeconds; + const failureThreshold = options?.failureThreshold; + const successThreshold = options?.successThreshold; + const endpointName = options?.endpointName; + return new JavaScriptAppResourcePromiseImpl(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName), this._client); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + excludeFromMcp(): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._excludeFromMcpInternal(), this._client); + } + + /** @internal */ + private async _withImagePushOptionsInternal(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ContainerImagePushOptionsCallbackContextHandle; + const arg = new ContainerImagePushOptionsCallbackContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImagePushOptions', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._withImagePushOptionsInternal(callback), this._client); + } + + /** @internal */ + private async _withRemoteImageNameInternal(remoteImageName: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageName', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withRemoteImageName(remoteImageName: string): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._withRemoteImageNameInternal(remoteImageName), this._client); + } + + /** @internal */ + private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageTag', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withRemoteImageTag(remoteImageTag: string): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._withRemoteImageTagInternal(remoteImageTag), this._client); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): JavaScriptAppResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new JavaScriptAppResourcePromiseImpl(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description), this._client); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._withPipelineConfigurationInternal(callback), this._client); + } + + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); + } + + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._onBeforeResourceStartedInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._onResourceStoppedInternal(callback), this._client); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._onInitializeResourceInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceEndpointsAllocated', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._onResourceEndpointsAllocatedInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._onResourceReadyInternal(callback), this._client); + } + + async createExecutionConfiguration(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/createExecutionConfiguration', + rpcArgs + ); + } + + /** @internal */ + private async _publishAsStaticWebsiteInternal(apiPath?: string, apiTarget?: Awaitable, outputPath?: string, stripPrefix?: boolean, targetEndpointName?: string): Promise { + apiTarget = isPromiseLike(apiTarget) ? await apiTarget : apiTarget; + const rpcArgs: Record = { builder: this._handle }; + if (apiPath !== undefined) rpcArgs.apiPath = apiPath; + if (apiTarget !== undefined) rpcArgs.apiTarget = apiTarget; + if (outputPath !== undefined) rpcArgs.outputPath = outputPath; + if (stripPrefix !== undefined) rpcArgs.stripPrefix = stripPrefix; + if (targetEndpointName !== undefined) rpcArgs.targetEndpointName = targetEndpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/publishAsStaticWebsite', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + publishAsStaticWebsite(options?: PublishAsStaticWebsiteOptions): JavaScriptAppResourcePromise { + const apiPath = options?.apiPath; + let apiTarget = options?.apiTarget; + const outputPath = options?.outputPath; + const stripPrefix = options?.stripPrefix; + const targetEndpointName = options?.targetEndpointName; + return new JavaScriptAppResourcePromiseImpl(this._publishAsStaticWebsiteInternal(apiPath, apiTarget, outputPath, stripPrefix, targetEndpointName), this._client); + } + + /** @internal */ + private async _publishAsNodeServerInternal(entryPoint: string, outputPath?: string): Promise { + const rpcArgs: Record = { builder: this._handle, entryPoint }; + if (outputPath !== undefined) rpcArgs.outputPath = outputPath; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/publishAsNodeServer', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + publishAsNodeServer(entryPoint: string, options?: PublishAsNodeServerOptions): JavaScriptAppResourcePromise { + const outputPath = options?.outputPath; + return new JavaScriptAppResourcePromiseImpl(this._publishAsNodeServerInternal(entryPoint, outputPath), this._client); + } + + /** @internal */ + private async _publishAsNpmScriptInternal(startScriptName?: string, runScriptArguments?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (startScriptName !== undefined) rpcArgs.startScriptName = startScriptName; + if (runScriptArguments !== undefined) rpcArgs.runScriptArguments = runScriptArguments; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/publishAsNpmScript', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + publishAsNpmScript(options?: PublishAsNpmScriptOptions): JavaScriptAppResourcePromise { + const startScriptName = options?.startScriptName; + const runScriptArguments = options?.runScriptArguments; + return new JavaScriptAppResourcePromiseImpl(this._publishAsNpmScriptInternal(startScriptName, runScriptArguments), this._client); + } + + /** @internal */ + private async _withNpmInternal(install?: boolean, installCommand?: string, installArgs?: string[]): Promise { + const rpcArgs: Record = { resource: this._handle }; + if (install !== undefined) rpcArgs.install = install; + if (installCommand !== undefined) rpcArgs.installCommand = installCommand; + if (installArgs !== undefined) rpcArgs.installArgs = installArgs; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/withNpm', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withNpm(options?: WithNpmOptions): JavaScriptAppResourcePromise { + const install = options?.install; + const installCommand = options?.installCommand; + const installArgs = options?.installArgs; + return new JavaScriptAppResourcePromiseImpl(this._withNpmInternal(install, installCommand, installArgs), this._client); + } + + /** @internal */ + private async _withBunInternal(install?: boolean, installArgs?: string[]): Promise { + const rpcArgs: Record = { resource: this._handle }; + if (install !== undefined) rpcArgs.install = install; + if (installArgs !== undefined) rpcArgs.installArgs = installArgs; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/withBun', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withBun(options?: WithBunOptions): JavaScriptAppResourcePromise { + const install = options?.install; + const installArgs = options?.installArgs; + return new JavaScriptAppResourcePromiseImpl(this._withBunInternal(install, installArgs), this._client); + } + + /** @internal */ + private async _withYarnInternal(install?: boolean, installArgs?: string[]): Promise { + const rpcArgs: Record = { resource: this._handle }; + if (install !== undefined) rpcArgs.install = install; + if (installArgs !== undefined) rpcArgs.installArgs = installArgs; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/withYarn', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withYarn(options?: WithYarnOptions): JavaScriptAppResourcePromise { + const install = options?.install; + const installArgs = options?.installArgs; + return new JavaScriptAppResourcePromiseImpl(this._withYarnInternal(install, installArgs), this._client); + } + + /** @internal */ + private async _withPnpmInternal(install?: boolean, installArgs?: string[]): Promise { + const rpcArgs: Record = { resource: this._handle }; + if (install !== undefined) rpcArgs.install = install; + if (installArgs !== undefined) rpcArgs.installArgs = installArgs; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/withPnpm', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withPnpm(options?: WithPnpmOptions): JavaScriptAppResourcePromise { + const install = options?.install; + const installArgs = options?.installArgs; + return new JavaScriptAppResourcePromiseImpl(this._withPnpmInternal(install, installArgs), this._client); + } + + /** @internal */ + private async _withBuildScriptInternal(scriptName: string, args?: string[]): Promise { + const rpcArgs: Record = { resource: this._handle, scriptName }; + if (args !== undefined) rpcArgs.args = args; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/withBuildScript', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withBuildScript(scriptName: string, options?: WithBuildScriptOptions): JavaScriptAppResourcePromise { + const args = options?.args; + return new JavaScriptAppResourcePromiseImpl(this._withBuildScriptInternal(scriptName, args), this._client); + } + + /** @internal */ + private async _withRunScriptInternal(scriptName: string, args?: string[]): Promise { + const rpcArgs: Record = { resource: this._handle, scriptName }; + if (args !== undefined) rpcArgs.args = args; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/withRunScript', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withRunScript(scriptName: string, options?: WithRunScriptOptions): JavaScriptAppResourcePromise { + const args = options?.args; + return new JavaScriptAppResourcePromiseImpl(this._withRunScriptInternal(scriptName, args), this._client); + } + + /** @internal */ + private async _withBrowserDebuggerInternal(browser?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (browser !== undefined) rpcArgs.browser = browser; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/withBrowserDebugger', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withBrowserDebugger(options?: WithBrowserDebuggerOptions): JavaScriptAppResourcePromise { + const browser = options?.browser; + return new JavaScriptAppResourcePromiseImpl(this._withBrowserDebuggerInternal(browser), this._client); + } + + /** @internal */ + private async _withLikeC4ReferenceWithEnvironmentInternal(source: Awaitable, configure?: (obj: LikeC4RelationshipDetailsAnnotation) => Promise, connectionName?: string, optional?: boolean, skipAspireReference?: boolean): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4RelationshipDetailsAnnotationHandle; + const obj = new LikeC4RelationshipDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + source = isPromiseLike(source) ? await source : source; + const rpcArgs: Record = { builder: this._handle, source }; + if (configure !== undefined) rpcArgs.configure = configureId; + if (connectionName !== undefined) rpcArgs.connectionName = connectionName; + if (optional !== undefined) rpcArgs.optional = optional; + if (skipAspireReference !== undefined) rpcArgs.skipAspireReference = skipAspireReference; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4ReferenceWithEnvironment', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): JavaScriptAppResourcePromise { + const configure = options?.configure; + const connectionName = options?.connectionName; + const optional = options?.optional; + const skipAspireReference = options?.skipAspireReference; + return new JavaScriptAppResourcePromiseImpl(this._withLikeC4ReferenceWithEnvironmentInternal(source, configure, connectionName, optional, skipAspireReference), this._client); + } + + /** @internal */ + private async _withLikeC4DetailsInternal(label?: string, technology?: string, description?: string, summary?: string, icon?: string, configure?: (obj: LikeC4NodeDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4NodeDetailsAnnotationHandle; + const obj = new LikeC4NodeDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + const rpcArgs: Record = { builder: this._handle }; + if (label !== undefined) rpcArgs.label = label; + if (technology !== undefined) rpcArgs.technology = technology; + if (description !== undefined) rpcArgs.description = description; + if (summary !== undefined) rpcArgs.summary = summary; + if (icon !== undefined) rpcArgs.icon = icon; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4DetailsParameters', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): JavaScriptAppResourcePromise { + const label = options?.label; + const technology = options?.technology; + const description = options?.description; + const summary = options?.summary; + const icon = options?.icon; + const configure = options?.configure; + return new JavaScriptAppResourcePromiseImpl(this._withLikeC4DetailsInternal(label, technology, description, summary, icon, configure), this._client); + } + + /** @internal */ + private async _withLikeC4ReferenceInternal(target: Awaitable, configure?: (obj: LikeC4RelationshipDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4RelationshipDetailsAnnotationHandle; + const obj = new LikeC4RelationshipDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target }; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Reference', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): JavaScriptAppResourcePromise { + const configure = options?.configure; + return new JavaScriptAppResourcePromiseImpl(this._withLikeC4ReferenceInternal(target, configure), this._client); + } + + /** @internal */ + private async _withLikeC4GroupInternal(groupName: string): Promise { + const rpcArgs: Record = { builder: this._handle, groupName }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Group', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withLikeC4Group(groupName: string): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._withLikeC4GroupInternal(groupName), this._client); + } + + /** @internal */ + private async _excludeFromLikeC4Internal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/excludeFromLikeC4', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + excludeFromLikeC4(): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._excludeFromLikeC4Internal(), this._client); + } + + /** @internal */ + private async _withAzureUserAssignedIdentityInternal(identityResourceBuilder: Awaitable): Promise { + identityResourceBuilder = isPromiseLike(identityResourceBuilder) ? await identityResourceBuilder : identityResourceBuilder; + const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._withAzureUserAssignedIdentityInternal(identityResourceBuilder), this._client); + } + + /** @internal */ + private async _withRoleAssignmentsInternal(target: Awaitable, roles: AzureKeyVaultRole[]): Promise { + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target, roles }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.KeyVault/withKeyVaultRoleAssignments', + rpcArgs + ); + return new JavaScriptAppResourceImpl(result, this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._withRoleAssignmentsInternal(target, roles), this._client); + } + +} + +/** + * Thenable wrapper for JavaScriptAppResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +class JavaScriptAppResourcePromiseImpl implements JavaScriptAppResourcePromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: JavaScriptAppResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + command(): Promise { + return this._promise.then(obj => obj.command()); + } + + workingDirectory(): Promise { + return this._promise.then(obj => obj.workingDirectory()); + } + + name(): Promise { + return this._promise.then(obj => obj.name()); + } + + withContainerRegistry(registry: Awaitable): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withContainerRegistry(registry)), this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withDockerfileBaseImage(options)), this._client); + } + + publishAsDockerFile(configure: (obj: ContainerResource) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.publishAsDockerFile(configure)), this._client); + } + + withExecutableCommand(command: string): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withExecutableCommand(command)), this._client); + } + + withWorkingDirectory(workingDirectory: string): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withWorkingDirectory(workingDirectory)), this._client); + } + + withMcpServer(options?: WithMcpServerOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withMcpServer(options)), this._client); + } + + withOtlpExporter(options?: WithOtlpExporterOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withOtlpExporter(options)), this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withRequiredCommand(command, options)), this._client); + } + + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withEnvironment(name, value)), this._client); + } + + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentCallback(callback)), this._client); + } + + withArgs(args: string[]): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withArgs(args)), this._client); + } + + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withArgsCallback(callback)), this._client); + } + + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withReferenceEnvironment(options)), this._client); + } + + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withReference(source, options)), this._client); + } + + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withEndpointCallback(endpointName, callback, options)), this._client); + } + + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withHttpEndpointCallback(callback, options)), this._client); + } + + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withHttpsEndpointCallback(callback, options)), this._client); + } + + withEndpoint(options?: WithEndpointOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withEndpoint(options)), this._client); + } + + withHttpEndpoint(options?: WithHttpEndpointOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withHttpEndpoint(options)), this._client); + } + + withHttpsEndpoint(options?: WithHttpsEndpointOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withHttpsEndpoint(options)), this._client); + } + + withExternalHttpEndpoints(): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withExternalHttpEndpoints()), this._client); + } + + getEndpoint(name: string): Promise { + return this._promise.then(obj => obj.getEndpoint(name)); + } + + asHttp2Service(): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.asHttp2Service()), this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withUrls(callback)), this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withUrl(url, options)), this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback)), this._client); + } + + withContainerFilesSource(sourcePath: string): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withContainerFilesSource(sourcePath)), this._client); + } + + clearContainerFilesSources(): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.clearContainerFilesSources()), this._client); + } + + excludeFromManifest(): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.excludeFromManifest()), this._client); + } + + waitFor(dependency: Awaitable, options?: WaitForOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.waitFor(dependency, options)), this._client); + } + + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.waitForStart(dependency, options)), this._client); + } + + withExplicitStart(): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withExplicitStart()), this._client); + } + + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.waitForCompletion(dependency, options)), this._client); + } + + withHealthCheck(key: string): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withHealthCheck(key)), this._client); + } + + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withHttpHealthCheck(options)), this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options)), this._client); + } + + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withHttpCommand(path, displayName, options)), this._client); + } + + withDeveloperCertificateTrust(trust: boolean): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust)), this._client); + } + + withCertificateTrustScope(scope: CertificateTrustScope): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withCertificateTrustScope(scope)), this._client); + } + + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options)), this._client); + } + + withoutHttpsCertificate(): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withoutHttpsCertificate()), this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withRelationship(resourceBuilder, type)), this._client); + } + + withParentRelationship(parent: Awaitable): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withParentRelationship(parent)), this._client); + } + + withChildRelationship(child: Awaitable): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withChildRelationship(child)), this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withIconName(iconName, options)), this._client); + } + + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withHttpProbe(probeType, options)), this._client); + } + + excludeFromMcp(): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.excludeFromMcp()), this._client); + } + + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withImagePushOptions(callback)), this._client); + } + + withRemoteImageName(remoteImageName: string): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withRemoteImageName(remoteImageName)), this._client); + } + + withRemoteImageTag(remoteImageTag: string): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag)), this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options)), this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withPipelineConfiguration(callback)), this._client); + } + + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.onBeforeResourceStarted(callback)), this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.onResourceStopped(callback)), this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.onInitializeResource(callback)), this._client); + } + + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback)), this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.onResourceReady(callback)), this._client); + } + + createExecutionConfiguration(): Promise { + return this._promise.then(obj => obj.createExecutionConfiguration()); + } + + publishAsStaticWebsite(options?: PublishAsStaticWebsiteOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.publishAsStaticWebsite(options)), this._client); + } + + publishAsNodeServer(entryPoint: string, options?: PublishAsNodeServerOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.publishAsNodeServer(entryPoint, options)), this._client); + } + + publishAsNpmScript(options?: PublishAsNpmScriptOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.publishAsNpmScript(options)), this._client); + } + + withNpm(options?: WithNpmOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withNpm(options)), this._client); + } + + withBun(options?: WithBunOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withBun(options)), this._client); + } + + withYarn(options?: WithYarnOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withYarn(options)), this._client); + } + + withPnpm(options?: WithPnpmOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withPnpm(options)), this._client); + } + + withBuildScript(scriptName: string, options?: WithBuildScriptOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withBuildScript(scriptName, options)), this._client); + } + + withRunScript(scriptName: string, options?: WithRunScriptOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withRunScript(scriptName, options)), this._client); + } + + withBrowserDebugger(options?: WithBrowserDebuggerOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withBrowserDebugger(options)), this._client); + } + + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4ReferenceWithEnvironment(source, options)), this._client); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Details(options)), this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Reference(target, options)), this._client); + } + + withLikeC4Group(groupName: string): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Group(groupName)), this._client); + } + + excludeFromLikeC4(): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.excludeFromLikeC4()), this._client); + } + + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withAzureUserAssignedIdentity(identityResourceBuilder)), this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromiseImpl(this._promise.then(obj => obj.withRoleAssignments(target, roles)), this._client); + } + +} + +// ============================================================================ +// NextJsAppResource +// ============================================================================ + +export interface NextJsAppResource { + toJSON(): MarshalledHandle; + /** Gets the Command property */ + command(): Promise; + /** Gets the WorkingDirectory property */ + workingDirectory(): Promise; + /** Gets the Name property */ + name(): Promise; + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): NextJsAppResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): NextJsAppResourcePromise; + /** Publishes an executable as a Docker file */ + publishAsDockerFile(configure: (obj: ContainerResource) => Promise): NextJsAppResourcePromise; + /** Sets the executable command */ + withExecutableCommand(command: string): NextJsAppResourcePromise; + /** Sets the executable working directory */ + withWorkingDirectory(workingDirectory: string): NextJsAppResourcePromise; + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): NextJsAppResourcePromise; + /** Configures OTLP telemetry export */ + withOtlpExporter(options?: WithOtlpExporterOptions): NextJsAppResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): NextJsAppResourcePromise; + /** Sets an environment variable */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): NextJsAppResourcePromise; + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): NextJsAppResourcePromise; + /** Adds arguments */ + withArgs(args: string[]): NextJsAppResourcePromise; + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): NextJsAppResourcePromise; + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): NextJsAppResourcePromise; + /** Adds a reference to another resource */ + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): NextJsAppResourcePromise; + /** Updates a named endpoint via callback */ + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): NextJsAppResourcePromise; + /** Updates an HTTP endpoint via callback */ + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): NextJsAppResourcePromise; + /** Updates an HTTPS endpoint via callback */ + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): NextJsAppResourcePromise; + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): NextJsAppResourcePromise; + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): NextJsAppResourcePromise; + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): NextJsAppResourcePromise; + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): NextJsAppResourcePromise; + /** Gets an endpoint reference */ + getEndpoint(name: string): Promise; + /** Configures resource for HTTP/2 */ + asHttp2Service(): NextJsAppResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): NextJsAppResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): NextJsAppResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): NextJsAppResourcePromise; + /** Sets the source directory for container files */ + withContainerFilesSource(sourcePath: string): NextJsAppResourcePromise; + /** Clears all container file sources */ + clearContainerFilesSources(): NextJsAppResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): NextJsAppResourcePromise; + /** Waits for another resource to be ready */ + waitFor(dependency: Awaitable, options?: WaitForOptions): NextJsAppResourcePromise; + /** Waits for another resource to start */ + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): NextJsAppResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): NextJsAppResourcePromise; + /** Waits for resource completion */ + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): NextJsAppResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): NextJsAppResourcePromise; + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): NextJsAppResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): NextJsAppResourcePromise; + /** Adds an HTTP resource command */ + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): NextJsAppResourcePromise; + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): NextJsAppResourcePromise; + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): NextJsAppResourcePromise; + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): NextJsAppResourcePromise; + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): NextJsAppResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): NextJsAppResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): NextJsAppResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): NextJsAppResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): NextJsAppResourcePromise; + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): NextJsAppResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): NextJsAppResourcePromise; + /** Sets image push options via callback */ + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): NextJsAppResourcePromise; + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): NextJsAppResourcePromise; + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): NextJsAppResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): NextJsAppResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): NextJsAppResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): NextJsAppResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): NextJsAppResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): NextJsAppResourcePromise; + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): NextJsAppResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): NextJsAppResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Publishes the JavaScript application as a standalone static website using YARP. */ + publishAsStaticWebsite(options?: PublishAsStaticWebsiteOptions): NextJsAppResourcePromise; + /** Publishes the JavaScript application as a standalone Node.js server that runs a built artifact directly. */ + publishAsNodeServer(entryPoint: string, options?: PublishAsNodeServerOptions): NextJsAppResourcePromise; + /** Publishes the JavaScript application as a Node.js server that uses a package manager script at runtime. */ + publishAsNpmScript(options?: PublishAsNpmScriptOptions): NextJsAppResourcePromise; + /** Disables deploy-time build validation checks for the Next.js application. */ + disableBuildValidation(): NextJsAppResourcePromise; + /** Configures npm as the package manager */ + withNpm(options?: WithNpmOptions): NextJsAppResourcePromise; + /** Configures Bun as the package manager */ + withBun(options?: WithBunOptions): NextJsAppResourcePromise; + /** Configures yarn as the package manager */ + withYarn(options?: WithYarnOptions): NextJsAppResourcePromise; + /** Configures pnpm as the package manager */ + withPnpm(options?: WithPnpmOptions): NextJsAppResourcePromise; + /** Specifies an npm script to run before starting the application */ + withBuildScript(scriptName: string, options?: WithBuildScriptOptions): NextJsAppResourcePromise; + /** Specifies an npm script to run during development */ + withRunScript(scriptName: string, options?: WithRunScriptOptions): NextJsAppResourcePromise; + /** Configures a browser debugger for the JavaScript application */ + withBrowserDebugger(options?: WithBrowserDebuggerOptions): NextJsAppResourcePromise; + /** Create a new reference, while also allowing customization of how a resource appears in the generated LikeC4 diagram. */ + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): NextJsAppResourcePromise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): NextJsAppResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): NextJsAppResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): NextJsAppResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): NextJsAppResourcePromise; + /** Associates an Azure user-assigned identity with a compute resource */ + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): NextJsAppResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): NextJsAppResourcePromise; +} + +export interface NextJsAppResourcePromise extends PromiseLike { + /** Gets the Command property */ + command(): Promise; + /** Gets the WorkingDirectory property */ + workingDirectory(): Promise; + /** Gets the Name property */ + name(): Promise; + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): NextJsAppResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): NextJsAppResourcePromise; + /** Publishes an executable as a Docker file */ + publishAsDockerFile(configure: (obj: ContainerResource) => Promise): NextJsAppResourcePromise; + /** Sets the executable command */ + withExecutableCommand(command: string): NextJsAppResourcePromise; + /** Sets the executable working directory */ + withWorkingDirectory(workingDirectory: string): NextJsAppResourcePromise; + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): NextJsAppResourcePromise; + /** Configures OTLP telemetry export */ + withOtlpExporter(options?: WithOtlpExporterOptions): NextJsAppResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): NextJsAppResourcePromise; + /** Sets an environment variable */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): NextJsAppResourcePromise; + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): NextJsAppResourcePromise; + /** Adds arguments */ + withArgs(args: string[]): NextJsAppResourcePromise; + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): NextJsAppResourcePromise; + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): NextJsAppResourcePromise; + /** Adds a reference to another resource */ + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): NextJsAppResourcePromise; + /** Updates a named endpoint via callback */ + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): NextJsAppResourcePromise; + /** Updates an HTTP endpoint via callback */ + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): NextJsAppResourcePromise; + /** Updates an HTTPS endpoint via callback */ + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): NextJsAppResourcePromise; + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): NextJsAppResourcePromise; + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): NextJsAppResourcePromise; + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): NextJsAppResourcePromise; + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): NextJsAppResourcePromise; + /** Gets an endpoint reference */ + getEndpoint(name: string): Promise; + /** Configures resource for HTTP/2 */ + asHttp2Service(): NextJsAppResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): NextJsAppResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): NextJsAppResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): NextJsAppResourcePromise; + /** Sets the source directory for container files */ + withContainerFilesSource(sourcePath: string): NextJsAppResourcePromise; + /** Clears all container file sources */ + clearContainerFilesSources(): NextJsAppResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): NextJsAppResourcePromise; + /** Waits for another resource to be ready */ + waitFor(dependency: Awaitable, options?: WaitForOptions): NextJsAppResourcePromise; + /** Waits for another resource to start */ + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): NextJsAppResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): NextJsAppResourcePromise; + /** Waits for resource completion */ + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): NextJsAppResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): NextJsAppResourcePromise; + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): NextJsAppResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): NextJsAppResourcePromise; + /** Adds an HTTP resource command */ + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): NextJsAppResourcePromise; + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): NextJsAppResourcePromise; + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): NextJsAppResourcePromise; + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): NextJsAppResourcePromise; + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): NextJsAppResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): NextJsAppResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): NextJsAppResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): NextJsAppResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): NextJsAppResourcePromise; + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): NextJsAppResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): NextJsAppResourcePromise; + /** Sets image push options via callback */ + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): NextJsAppResourcePromise; + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): NextJsAppResourcePromise; + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): NextJsAppResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): NextJsAppResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): NextJsAppResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): NextJsAppResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): NextJsAppResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): NextJsAppResourcePromise; + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): NextJsAppResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): NextJsAppResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Publishes the JavaScript application as a standalone static website using YARP. */ + publishAsStaticWebsite(options?: PublishAsStaticWebsiteOptions): NextJsAppResourcePromise; + /** Publishes the JavaScript application as a standalone Node.js server that runs a built artifact directly. */ + publishAsNodeServer(entryPoint: string, options?: PublishAsNodeServerOptions): NextJsAppResourcePromise; + /** Publishes the JavaScript application as a Node.js server that uses a package manager script at runtime. */ + publishAsNpmScript(options?: PublishAsNpmScriptOptions): NextJsAppResourcePromise; + /** Disables deploy-time build validation checks for the Next.js application. */ + disableBuildValidation(): NextJsAppResourcePromise; + /** Configures npm as the package manager */ + withNpm(options?: WithNpmOptions): NextJsAppResourcePromise; + /** Configures Bun as the package manager */ + withBun(options?: WithBunOptions): NextJsAppResourcePromise; + /** Configures yarn as the package manager */ + withYarn(options?: WithYarnOptions): NextJsAppResourcePromise; + /** Configures pnpm as the package manager */ + withPnpm(options?: WithPnpmOptions): NextJsAppResourcePromise; + /** Specifies an npm script to run before starting the application */ + withBuildScript(scriptName: string, options?: WithBuildScriptOptions): NextJsAppResourcePromise; + /** Specifies an npm script to run during development */ + withRunScript(scriptName: string, options?: WithRunScriptOptions): NextJsAppResourcePromise; + /** Configures a browser debugger for the JavaScript application */ + withBrowserDebugger(options?: WithBrowserDebuggerOptions): NextJsAppResourcePromise; + /** Create a new reference, while also allowing customization of how a resource appears in the generated LikeC4 diagram. */ + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): NextJsAppResourcePromise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): NextJsAppResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): NextJsAppResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): NextJsAppResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): NextJsAppResourcePromise; + /** Associates an Azure user-assigned identity with a compute resource */ + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): NextJsAppResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): NextJsAppResourcePromise; +} + +// ============================================================================ +// NextJsAppResourceImpl +// ============================================================================ + +class NextJsAppResourceImpl extends ResourceBuilderBase implements NextJsAppResource { + constructor(handle: NextJsAppResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + async command(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/JavaScriptAppResource.command', + { context: this._handle } + ); + } + + async workingDirectory(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/JavaScriptAppResource.workingDirectory', + { context: this._handle } + ); + } + + async name(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/JavaScriptAppResource.name', + { context: this._handle } + ); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: Awaitable): Promise { + registry = isPromiseLike(registry) ? await registry : registry; + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withContainerRegistry(registry: Awaitable): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._withContainerRegistryInternal(registry), this._client); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): NextJsAppResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new NextJsAppResourcePromiseImpl(this._withDockerfileBaseImageInternal(buildImage, runtimeImage), this._client); + } + + /** @internal */ + private async _publishAsDockerFileInternal(configure: (obj: ContainerResource) => Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ContainerResourceHandle; + const obj = new ContainerResourceImpl(objHandle, this._client); + await configure(obj); + }); + const rpcArgs: Record = { builder: this._handle, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsDockerFile', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + publishAsDockerFile(configure: (obj: ContainerResource) => Promise): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._publishAsDockerFileInternal(configure), this._client); + } + + /** @internal */ + private async _withExecutableCommandInternal(command: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExecutableCommand', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withExecutableCommand(command: string): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._withExecutableCommandInternal(command), this._client); + } + + /** @internal */ + private async _withWorkingDirectoryInternal(workingDirectory: string): Promise { + const rpcArgs: Record = { builder: this._handle, workingDirectory }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withWorkingDirectory', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withWorkingDirectory(workingDirectory: string): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._withWorkingDirectoryInternal(workingDirectory), this._client); + } + + /** @internal */ + private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withMcpServer', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withMcpServer(options?: WithMcpServerOptions): NextJsAppResourcePromise { + const path = options?.path; + const endpointName = options?.endpointName; + return new NextJsAppResourcePromiseImpl(this._withMcpServerInternal(path, endpointName), this._client); + } + + /** @internal */ + private async _withOtlpExporterInternal(protocol?: OtlpProtocol): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (protocol !== undefined) rpcArgs.protocol = protocol; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporter', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withOtlpExporter(options?: WithOtlpExporterOptions): NextJsAppResourcePromise { + const protocol = options?.protocol; + return new NextJsAppResourcePromiseImpl(this._withOtlpExporterInternal(protocol), this._client); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): NextJsAppResourcePromise { + const helpLink = options?.helpLink; + return new NextJsAppResourcePromiseImpl(this._withRequiredCommandInternal(command, helpLink), this._client); + } + + /** @internal */ + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): Promise { + value = isPromiseLike(value) ? await value : value; + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironment', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._withEnvironmentInternal(name, value), this._client); + } + + /** @internal */ + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentCallback', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._withEnvironmentCallbackInternal(callback), this._client); + } + + /** @internal */ + private async _withArgsInternal(args: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, args }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgs', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withArgs(args: string[]): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._withArgsInternal(args), this._client); + } + + /** @internal */ + private async _withArgsCallbackInternal(callback: (obj: CommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; + const obj = new CommandLineArgsCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallback', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._withArgsCallbackInternal(callback), this._client); + } + + /** @internal */ + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceEnvironment', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._withReferenceEnvironmentInternal(options), this._client); + } + + /** @internal */ + private async _withReferenceInternal(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, connectionName?: string, optional?: boolean, name?: string): Promise { + source = isPromiseLike(source) ? await source : source; + const rpcArgs: Record = { builder: this._handle, source }; + if (connectionName !== undefined) rpcArgs.connectionName = connectionName; + if (optional !== undefined) rpcArgs.optional = optional; + if (name !== undefined) rpcArgs.name = name; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReference', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): NextJsAppResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new NextJsAppResourcePromiseImpl(this._withReferenceInternal(source, connectionName, optional, name), this._client); + } + + /** @internal */ + private async _withEndpointCallbackInternal(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpointCallback', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): NextJsAppResourcePromise { + const createIfNotExists = options?.createIfNotExists; + return new NextJsAppResourcePromiseImpl(this._withEndpointCallbackInternal(endpointName, callback, createIfNotExists), this._client); + } + + /** @internal */ + private async _withHttpEndpointCallbackInternal(callback: (obj: EndpointUpdateContext) => Promise, name?: string, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + if (name !== undefined) rpcArgs.name = name; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpEndpointCallback', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): NextJsAppResourcePromise { + const name = options?.name; + const createIfNotExists = options?.createIfNotExists; + return new NextJsAppResourcePromiseImpl(this._withHttpEndpointCallbackInternal(callback, name, createIfNotExists), this._client); + } + + /** @internal */ + private async _withHttpsEndpointCallbackInternal(callback: (obj: EndpointUpdateContext) => Promise, name?: string, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + if (name !== undefined) rpcArgs.name = name; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsEndpointCallback', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): NextJsAppResourcePromise { + const name = options?.name; + const createIfNotExists = options?.createIfNotExists; + return new NextJsAppResourcePromiseImpl(this._withHttpsEndpointCallbackInternal(callback, name, createIfNotExists), this._client); + } + + /** @internal */ + private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (scheme !== undefined) rpcArgs.scheme = scheme; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + if (isExternal !== undefined) rpcArgs.isExternal = isExternal; + if (protocol !== undefined) rpcArgs.protocol = protocol; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpoint', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withEndpoint(options?: WithEndpointOptions): NextJsAppResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const scheme = options?.scheme; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + const isExternal = options?.isExternal; + const protocol = options?.protocol; + return new NextJsAppResourcePromiseImpl(this._withEndpointInternal(port, targetPort, scheme, name, env, isProxied, isExternal, protocol), this._client); + } + + /** @internal */ + private async _withHttpEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpEndpoint', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withHttpEndpoint(options?: WithHttpEndpointOptions): NextJsAppResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new NextJsAppResourcePromiseImpl(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied), this._client); + } + + /** @internal */ + private async _withHttpsEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsEndpoint', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withHttpsEndpoint(options?: WithHttpsEndpointOptions): NextJsAppResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new NextJsAppResourcePromiseImpl(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied), this._client); + } + + /** @internal */ + private async _withExternalHttpEndpointsInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExternalHttpEndpoints', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withExternalHttpEndpoints(): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._withExternalHttpEndpointsInternal(), this._client); + } + + async getEndpoint(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getEndpoint', + rpcArgs + ); + } + + /** @internal */ + private async _asHttp2ServiceInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/asHttp2Service', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + asHttp2Service(): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._asHttp2ServiceInternal(), this._client); + } + + /** @internal */ + private async _withUrlsInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrls', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._withUrlsInternal(callback), this._client); + } + + /** @internal */ + private async _withUrlInternal(url: string | ReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): NextJsAppResourcePromise { + const displayText = options?.displayText; + return new NextJsAppResourcePromiseImpl(this._withUrlInternal(url, displayText), this._client); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._withUrlForEndpointInternal(endpointName, callback), this._client); + } + + /** @internal */ + private async _withContainerFilesSourceInternal(sourcePath: string): Promise { + const rpcArgs: Record = { builder: this._handle, sourcePath }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerFilesSource', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withContainerFilesSource(sourcePath: string): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._withContainerFilesSourceInternal(sourcePath), this._client); + } + + /** @internal */ + private async _clearContainerFilesSourcesInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/clearContainerFilesSources', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + clearContainerFilesSources(): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._clearContainerFilesSourcesInternal(), this._client); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + excludeFromManifest(): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._excludeFromManifestInternal(), this._client); + } + + /** @internal */ + private async _waitForInternal(dependency: Awaitable, waitBehavior?: WaitBehavior): Promise { + dependency = isPromiseLike(dependency) ? await dependency : dependency; + const rpcArgs: Record = { builder: this._handle, dependency }; + if (waitBehavior !== undefined) rpcArgs.waitBehavior = waitBehavior; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitFor', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + waitFor(dependency: Awaitable, options?: WaitForOptions): NextJsAppResourcePromise { + const waitBehavior = options?.waitBehavior; + return new NextJsAppResourcePromiseImpl(this._waitForInternal(dependency, waitBehavior), this._client); + } + + /** @internal */ + private async _waitForStartInternal(dependency: Awaitable, waitBehavior?: WaitBehavior): Promise { + dependency = isPromiseLike(dependency) ? await dependency : dependency; + const rpcArgs: Record = { builder: this._handle, dependency }; + if (waitBehavior !== undefined) rpcArgs.waitBehavior = waitBehavior; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStart', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): NextJsAppResourcePromise { + const waitBehavior = options?.waitBehavior; + return new NextJsAppResourcePromiseImpl(this._waitForStartInternal(dependency, waitBehavior), this._client); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withExplicitStart(): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._withExplicitStartInternal(), this._client); + } + + /** @internal */ + private async _waitForCompletionInternal(dependency: Awaitable, exitCode?: number): Promise { + dependency = isPromiseLike(dependency) ? await dependency : dependency; + const rpcArgs: Record = { builder: this._handle, dependency }; + if (exitCode !== undefined) rpcArgs.exitCode = exitCode; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceCompletion', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): NextJsAppResourcePromise { + const exitCode = options?.exitCode; + return new NextJsAppResourcePromiseImpl(this._waitForCompletionInternal(dependency, exitCode), this._client); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withHealthCheck(key: string): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._withHealthCheckInternal(key), this._client); + } + + /** @internal */ + private async _withHttpHealthCheckInternal(path?: string, statusCode?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (statusCode !== undefined) rpcArgs.statusCode = statusCode; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpHealthCheck', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): NextJsAppResourcePromise { + const path = options?.path; + const statusCode = options?.statusCode; + const endpointName = options?.endpointName; + return new NextJsAppResourcePromiseImpl(this._withHttpHealthCheckInternal(path, statusCode, endpointName), this._client); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContextImpl(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): NextJsAppResourcePromise { + const commandOptions = options?.commandOptions; + return new NextJsAppResourcePromiseImpl(this._withCommandInternal(name, displayName, executeCommand, commandOptions), this._client); + } + + /** @internal */ + private async _withHttpCommandInternal(path: string, displayName: string, options?: HttpCommandExportOptions): Promise { + const rpcArgs: Record = { builder: this._handle, path, displayName }; + if (options !== undefined) rpcArgs.options = options; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpCommand', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._withHttpCommandInternal(path, displayName, options), this._client); + } + + /** @internal */ + private async _withDeveloperCertificateTrustInternal(trust: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, trust }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDeveloperCertificateTrust', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withDeveloperCertificateTrust(trust: boolean): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._withDeveloperCertificateTrustInternal(trust), this._client); + } + + /** @internal */ + private async _withCertificateTrustScopeInternal(scope: CertificateTrustScope): Promise { + const rpcArgs: Record = { builder: this._handle, scope }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCertificateTrustScope', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withCertificateTrustScope(scope: CertificateTrustScope): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._withCertificateTrustScopeInternal(scope), this._client); + } + + /** @internal */ + private async _withHttpsDeveloperCertificateInternal(password?: Awaitable): Promise { + password = isPromiseLike(password) ? await password : password; + const rpcArgs: Record = { builder: this._handle }; + if (password !== undefined) rpcArgs.password = password; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): NextJsAppResourcePromise { + let password = options?.password; + return new NextJsAppResourcePromiseImpl(this._withHttpsDeveloperCertificateInternal(password), this._client); + } + + /** @internal */ + private async _withoutHttpsCertificateInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withoutHttpsCertificate', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withoutHttpsCertificate(): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._withoutHttpsCertificateInternal(), this._client); + } + + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: Awaitable, type: string): Promise { + resourceBuilder = isPromiseLike(resourceBuilder) ? await resourceBuilder : resourceBuilder; + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._withRelationshipInternal(resourceBuilder, type), this._client); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: Awaitable): Promise { + parent = isPromiseLike(parent) ? await parent : parent; + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withParentRelationship(parent: Awaitable): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._withParentRelationshipInternal(parent), this._client); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: Awaitable): Promise { + child = isPromiseLike(child) ? await child : child; + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withChildRelationship(child: Awaitable): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._withChildRelationshipInternal(child), this._client); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): NextJsAppResourcePromise { + const iconVariant = options?.iconVariant; + return new NextJsAppResourcePromiseImpl(this._withIconNameInternal(iconName, iconVariant), this._client); + } + + /** @internal */ + private async _withHttpProbeInternal(probeType: ProbeType, path?: string, initialDelaySeconds?: number, periodSeconds?: number, timeoutSeconds?: number, failureThreshold?: number, successThreshold?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, probeType }; + if (path !== undefined) rpcArgs.path = path; + if (initialDelaySeconds !== undefined) rpcArgs.initialDelaySeconds = initialDelaySeconds; + if (periodSeconds !== undefined) rpcArgs.periodSeconds = periodSeconds; + if (timeoutSeconds !== undefined) rpcArgs.timeoutSeconds = timeoutSeconds; + if (failureThreshold !== undefined) rpcArgs.failureThreshold = failureThreshold; + if (successThreshold !== undefined) rpcArgs.successThreshold = successThreshold; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpProbe', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): NextJsAppResourcePromise { + const path = options?.path; + const initialDelaySeconds = options?.initialDelaySeconds; + const periodSeconds = options?.periodSeconds; + const timeoutSeconds = options?.timeoutSeconds; + const failureThreshold = options?.failureThreshold; + const successThreshold = options?.successThreshold; + const endpointName = options?.endpointName; + return new NextJsAppResourcePromiseImpl(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName), this._client); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + excludeFromMcp(): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._excludeFromMcpInternal(), this._client); + } + + /** @internal */ + private async _withImagePushOptionsInternal(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ContainerImagePushOptionsCallbackContextHandle; + const arg = new ContainerImagePushOptionsCallbackContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImagePushOptions', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._withImagePushOptionsInternal(callback), this._client); + } + + /** @internal */ + private async _withRemoteImageNameInternal(remoteImageName: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageName', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withRemoteImageName(remoteImageName: string): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._withRemoteImageNameInternal(remoteImageName), this._client); + } + + /** @internal */ + private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageTag', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withRemoteImageTag(remoteImageTag: string): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._withRemoteImageTagInternal(remoteImageTag), this._client); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): NextJsAppResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new NextJsAppResourcePromiseImpl(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description), this._client); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._withPipelineConfigurationInternal(callback), this._client); + } + + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); + } + + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._onBeforeResourceStartedInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._onResourceStoppedInternal(callback), this._client); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._onInitializeResourceInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceEndpointsAllocated', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._onResourceEndpointsAllocatedInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._onResourceReadyInternal(callback), this._client); + } + + async createExecutionConfiguration(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/createExecutionConfiguration', + rpcArgs + ); + } + + /** @internal */ + private async _publishAsStaticWebsiteInternal(apiPath?: string, apiTarget?: Awaitable, outputPath?: string, stripPrefix?: boolean, targetEndpointName?: string): Promise { + apiTarget = isPromiseLike(apiTarget) ? await apiTarget : apiTarget; + const rpcArgs: Record = { builder: this._handle }; + if (apiPath !== undefined) rpcArgs.apiPath = apiPath; + if (apiTarget !== undefined) rpcArgs.apiTarget = apiTarget; + if (outputPath !== undefined) rpcArgs.outputPath = outputPath; + if (stripPrefix !== undefined) rpcArgs.stripPrefix = stripPrefix; + if (targetEndpointName !== undefined) rpcArgs.targetEndpointName = targetEndpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/publishAsStaticWebsite', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + publishAsStaticWebsite(options?: PublishAsStaticWebsiteOptions): NextJsAppResourcePromise { + const apiPath = options?.apiPath; + let apiTarget = options?.apiTarget; + const outputPath = options?.outputPath; + const stripPrefix = options?.stripPrefix; + const targetEndpointName = options?.targetEndpointName; + return new NextJsAppResourcePromiseImpl(this._publishAsStaticWebsiteInternal(apiPath, apiTarget, outputPath, stripPrefix, targetEndpointName), this._client); + } + + /** @internal */ + private async _publishAsNodeServerInternal(entryPoint: string, outputPath?: string): Promise { + const rpcArgs: Record = { builder: this._handle, entryPoint }; + if (outputPath !== undefined) rpcArgs.outputPath = outputPath; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/publishAsNodeServer', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + publishAsNodeServer(entryPoint: string, options?: PublishAsNodeServerOptions): NextJsAppResourcePromise { + const outputPath = options?.outputPath; + return new NextJsAppResourcePromiseImpl(this._publishAsNodeServerInternal(entryPoint, outputPath), this._client); + } + + /** @internal */ + private async _publishAsNpmScriptInternal(startScriptName?: string, runScriptArguments?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (startScriptName !== undefined) rpcArgs.startScriptName = startScriptName; + if (runScriptArguments !== undefined) rpcArgs.runScriptArguments = runScriptArguments; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/publishAsNpmScript', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + publishAsNpmScript(options?: PublishAsNpmScriptOptions): NextJsAppResourcePromise { + const startScriptName = options?.startScriptName; + const runScriptArguments = options?.runScriptArguments; + return new NextJsAppResourcePromiseImpl(this._publishAsNpmScriptInternal(startScriptName, runScriptArguments), this._client); + } + + /** @internal */ + private async _disableBuildValidationInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/disableBuildValidation', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + disableBuildValidation(): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._disableBuildValidationInternal(), this._client); + } + + /** @internal */ + private async _withNpmInternal(install?: boolean, installCommand?: string, installArgs?: string[]): Promise { + const rpcArgs: Record = { resource: this._handle }; + if (install !== undefined) rpcArgs.install = install; + if (installCommand !== undefined) rpcArgs.installCommand = installCommand; + if (installArgs !== undefined) rpcArgs.installArgs = installArgs; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/withNpm', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withNpm(options?: WithNpmOptions): NextJsAppResourcePromise { + const install = options?.install; + const installCommand = options?.installCommand; + const installArgs = options?.installArgs; + return new NextJsAppResourcePromiseImpl(this._withNpmInternal(install, installCommand, installArgs), this._client); + } + + /** @internal */ + private async _withBunInternal(install?: boolean, installArgs?: string[]): Promise { + const rpcArgs: Record = { resource: this._handle }; + if (install !== undefined) rpcArgs.install = install; + if (installArgs !== undefined) rpcArgs.installArgs = installArgs; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/withBun', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withBun(options?: WithBunOptions): NextJsAppResourcePromise { + const install = options?.install; + const installArgs = options?.installArgs; + return new NextJsAppResourcePromiseImpl(this._withBunInternal(install, installArgs), this._client); + } + + /** @internal */ + private async _withYarnInternal(install?: boolean, installArgs?: string[]): Promise { + const rpcArgs: Record = { resource: this._handle }; + if (install !== undefined) rpcArgs.install = install; + if (installArgs !== undefined) rpcArgs.installArgs = installArgs; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/withYarn', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withYarn(options?: WithYarnOptions): NextJsAppResourcePromise { + const install = options?.install; + const installArgs = options?.installArgs; + return new NextJsAppResourcePromiseImpl(this._withYarnInternal(install, installArgs), this._client); + } + + /** @internal */ + private async _withPnpmInternal(install?: boolean, installArgs?: string[]): Promise { + const rpcArgs: Record = { resource: this._handle }; + if (install !== undefined) rpcArgs.install = install; + if (installArgs !== undefined) rpcArgs.installArgs = installArgs; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/withPnpm', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withPnpm(options?: WithPnpmOptions): NextJsAppResourcePromise { + const install = options?.install; + const installArgs = options?.installArgs; + return new NextJsAppResourcePromiseImpl(this._withPnpmInternal(install, installArgs), this._client); + } + + /** @internal */ + private async _withBuildScriptInternal(scriptName: string, args?: string[]): Promise { + const rpcArgs: Record = { resource: this._handle, scriptName }; + if (args !== undefined) rpcArgs.args = args; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/withBuildScript', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withBuildScript(scriptName: string, options?: WithBuildScriptOptions): NextJsAppResourcePromise { + const args = options?.args; + return new NextJsAppResourcePromiseImpl(this._withBuildScriptInternal(scriptName, args), this._client); + } + + /** @internal */ + private async _withRunScriptInternal(scriptName: string, args?: string[]): Promise { + const rpcArgs: Record = { resource: this._handle, scriptName }; + if (args !== undefined) rpcArgs.args = args; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/withRunScript', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withRunScript(scriptName: string, options?: WithRunScriptOptions): NextJsAppResourcePromise { + const args = options?.args; + return new NextJsAppResourcePromiseImpl(this._withRunScriptInternal(scriptName, args), this._client); + } + + /** @internal */ + private async _withBrowserDebuggerInternal(browser?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (browser !== undefined) rpcArgs.browser = browser; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/withBrowserDebugger', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withBrowserDebugger(options?: WithBrowserDebuggerOptions): NextJsAppResourcePromise { + const browser = options?.browser; + return new NextJsAppResourcePromiseImpl(this._withBrowserDebuggerInternal(browser), this._client); + } + + /** @internal */ + private async _withLikeC4ReferenceWithEnvironmentInternal(source: Awaitable, configure?: (obj: LikeC4RelationshipDetailsAnnotation) => Promise, connectionName?: string, optional?: boolean, skipAspireReference?: boolean): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4RelationshipDetailsAnnotationHandle; + const obj = new LikeC4RelationshipDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + source = isPromiseLike(source) ? await source : source; + const rpcArgs: Record = { builder: this._handle, source }; + if (configure !== undefined) rpcArgs.configure = configureId; + if (connectionName !== undefined) rpcArgs.connectionName = connectionName; + if (optional !== undefined) rpcArgs.optional = optional; + if (skipAspireReference !== undefined) rpcArgs.skipAspireReference = skipAspireReference; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4ReferenceWithEnvironment', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): NextJsAppResourcePromise { + const configure = options?.configure; + const connectionName = options?.connectionName; + const optional = options?.optional; + const skipAspireReference = options?.skipAspireReference; + return new NextJsAppResourcePromiseImpl(this._withLikeC4ReferenceWithEnvironmentInternal(source, configure, connectionName, optional, skipAspireReference), this._client); + } + + /** @internal */ + private async _withLikeC4DetailsInternal(label?: string, technology?: string, description?: string, summary?: string, icon?: string, configure?: (obj: LikeC4NodeDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4NodeDetailsAnnotationHandle; + const obj = new LikeC4NodeDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + const rpcArgs: Record = { builder: this._handle }; + if (label !== undefined) rpcArgs.label = label; + if (technology !== undefined) rpcArgs.technology = technology; + if (description !== undefined) rpcArgs.description = description; + if (summary !== undefined) rpcArgs.summary = summary; + if (icon !== undefined) rpcArgs.icon = icon; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4DetailsParameters', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): NextJsAppResourcePromise { + const label = options?.label; + const technology = options?.technology; + const description = options?.description; + const summary = options?.summary; + const icon = options?.icon; + const configure = options?.configure; + return new NextJsAppResourcePromiseImpl(this._withLikeC4DetailsInternal(label, technology, description, summary, icon, configure), this._client); + } + + /** @internal */ + private async _withLikeC4ReferenceInternal(target: Awaitable, configure?: (obj: LikeC4RelationshipDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4RelationshipDetailsAnnotationHandle; + const obj = new LikeC4RelationshipDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target }; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Reference', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): NextJsAppResourcePromise { + const configure = options?.configure; + return new NextJsAppResourcePromiseImpl(this._withLikeC4ReferenceInternal(target, configure), this._client); + } + + /** @internal */ + private async _withLikeC4GroupInternal(groupName: string): Promise { + const rpcArgs: Record = { builder: this._handle, groupName }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Group', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withLikeC4Group(groupName: string): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._withLikeC4GroupInternal(groupName), this._client); + } + + /** @internal */ + private async _excludeFromLikeC4Internal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/excludeFromLikeC4', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + excludeFromLikeC4(): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._excludeFromLikeC4Internal(), this._client); + } + + /** @internal */ + private async _withAzureUserAssignedIdentityInternal(identityResourceBuilder: Awaitable): Promise { + identityResourceBuilder = isPromiseLike(identityResourceBuilder) ? await identityResourceBuilder : identityResourceBuilder; + const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._withAzureUserAssignedIdentityInternal(identityResourceBuilder), this._client); + } + + /** @internal */ + private async _withRoleAssignmentsInternal(target: Awaitable, roles: AzureKeyVaultRole[]): Promise { + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target, roles }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.KeyVault/withKeyVaultRoleAssignments', + rpcArgs + ); + return new NextJsAppResourceImpl(result, this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._withRoleAssignmentsInternal(target, roles), this._client); + } + +} + +/** + * Thenable wrapper for NextJsAppResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +class NextJsAppResourcePromiseImpl implements NextJsAppResourcePromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: NextJsAppResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + command(): Promise { + return this._promise.then(obj => obj.command()); + } + + workingDirectory(): Promise { + return this._promise.then(obj => obj.workingDirectory()); + } + + name(): Promise { + return this._promise.then(obj => obj.name()); + } + + withContainerRegistry(registry: Awaitable): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withContainerRegistry(registry)), this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withDockerfileBaseImage(options)), this._client); + } + + publishAsDockerFile(configure: (obj: ContainerResource) => Promise): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.publishAsDockerFile(configure)), this._client); + } + + withExecutableCommand(command: string): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withExecutableCommand(command)), this._client); + } + + withWorkingDirectory(workingDirectory: string): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withWorkingDirectory(workingDirectory)), this._client); + } + + withMcpServer(options?: WithMcpServerOptions): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withMcpServer(options)), this._client); + } + + withOtlpExporter(options?: WithOtlpExporterOptions): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withOtlpExporter(options)), this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withRequiredCommand(command, options)), this._client); + } + + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withEnvironment(name, value)), this._client); + } + + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentCallback(callback)), this._client); + } + + withArgs(args: string[]): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withArgs(args)), this._client); + } + + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withArgsCallback(callback)), this._client); + } + + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withReferenceEnvironment(options)), this._client); + } + + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withReference(source, options)), this._client); + } + + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withEndpointCallback(endpointName, callback, options)), this._client); + } + + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withHttpEndpointCallback(callback, options)), this._client); + } + + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withHttpsEndpointCallback(callback, options)), this._client); + } + + withEndpoint(options?: WithEndpointOptions): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withEndpoint(options)), this._client); + } + + withHttpEndpoint(options?: WithHttpEndpointOptions): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withHttpEndpoint(options)), this._client); + } + + withHttpsEndpoint(options?: WithHttpsEndpointOptions): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withHttpsEndpoint(options)), this._client); + } + + withExternalHttpEndpoints(): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withExternalHttpEndpoints()), this._client); + } + + getEndpoint(name: string): Promise { + return this._promise.then(obj => obj.getEndpoint(name)); + } + + asHttp2Service(): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.asHttp2Service()), this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withUrls(callback)), this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withUrl(url, options)), this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback)), this._client); + } + + withContainerFilesSource(sourcePath: string): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withContainerFilesSource(sourcePath)), this._client); + } + + clearContainerFilesSources(): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.clearContainerFilesSources()), this._client); + } + + excludeFromManifest(): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.excludeFromManifest()), this._client); + } + + waitFor(dependency: Awaitable, options?: WaitForOptions): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.waitFor(dependency, options)), this._client); + } + + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.waitForStart(dependency, options)), this._client); + } + + withExplicitStart(): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withExplicitStart()), this._client); + } + + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.waitForCompletion(dependency, options)), this._client); + } + + withHealthCheck(key: string): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withHealthCheck(key)), this._client); + } + + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withHttpHealthCheck(options)), this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options)), this._client); + } + + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withHttpCommand(path, displayName, options)), this._client); + } + + withDeveloperCertificateTrust(trust: boolean): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust)), this._client); + } + + withCertificateTrustScope(scope: CertificateTrustScope): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withCertificateTrustScope(scope)), this._client); + } + + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options)), this._client); + } + + withoutHttpsCertificate(): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withoutHttpsCertificate()), this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withRelationship(resourceBuilder, type)), this._client); + } + + withParentRelationship(parent: Awaitable): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withParentRelationship(parent)), this._client); + } + + withChildRelationship(child: Awaitable): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withChildRelationship(child)), this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withIconName(iconName, options)), this._client); + } + + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withHttpProbe(probeType, options)), this._client); + } + + excludeFromMcp(): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.excludeFromMcp()), this._client); + } + + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withImagePushOptions(callback)), this._client); + } + + withRemoteImageName(remoteImageName: string): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withRemoteImageName(remoteImageName)), this._client); + } + + withRemoteImageTag(remoteImageTag: string): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag)), this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options)), this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withPipelineConfiguration(callback)), this._client); + } + + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.onBeforeResourceStarted(callback)), this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.onResourceStopped(callback)), this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.onInitializeResource(callback)), this._client); + } + + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback)), this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.onResourceReady(callback)), this._client); + } + + createExecutionConfiguration(): Promise { + return this._promise.then(obj => obj.createExecutionConfiguration()); + } + + publishAsStaticWebsite(options?: PublishAsStaticWebsiteOptions): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.publishAsStaticWebsite(options)), this._client); + } + + publishAsNodeServer(entryPoint: string, options?: PublishAsNodeServerOptions): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.publishAsNodeServer(entryPoint, options)), this._client); + } + + publishAsNpmScript(options?: PublishAsNpmScriptOptions): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.publishAsNpmScript(options)), this._client); + } + + disableBuildValidation(): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.disableBuildValidation()), this._client); + } + + withNpm(options?: WithNpmOptions): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withNpm(options)), this._client); + } + + withBun(options?: WithBunOptions): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withBun(options)), this._client); + } + + withYarn(options?: WithYarnOptions): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withYarn(options)), this._client); + } + + withPnpm(options?: WithPnpmOptions): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withPnpm(options)), this._client); + } + + withBuildScript(scriptName: string, options?: WithBuildScriptOptions): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withBuildScript(scriptName, options)), this._client); + } + + withRunScript(scriptName: string, options?: WithRunScriptOptions): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withRunScript(scriptName, options)), this._client); + } + + withBrowserDebugger(options?: WithBrowserDebuggerOptions): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withBrowserDebugger(options)), this._client); + } + + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4ReferenceWithEnvironment(source, options)), this._client); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Details(options)), this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Reference(target, options)), this._client); + } + + withLikeC4Group(groupName: string): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Group(groupName)), this._client); + } + + excludeFromLikeC4(): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.excludeFromLikeC4()), this._client); + } + + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withAzureUserAssignedIdentity(identityResourceBuilder)), this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): NextJsAppResourcePromise { + return new NextJsAppResourcePromiseImpl(this._promise.then(obj => obj.withRoleAssignments(target, roles)), this._client); + } + +} + +// ============================================================================ +// NodeAppResource +// ============================================================================ + +export interface NodeAppResource { + toJSON(): MarshalledHandle; + /** Gets the Command property */ + command(): Promise; + /** Gets the WorkingDirectory property */ + workingDirectory(): Promise; + /** Gets the Name property */ + name(): Promise; + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): NodeAppResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): NodeAppResourcePromise; + /** Publishes an executable as a Docker file */ + publishAsDockerFile(configure: (obj: ContainerResource) => Promise): NodeAppResourcePromise; + /** Sets the executable command */ + withExecutableCommand(command: string): NodeAppResourcePromise; + /** Sets the executable working directory */ + withWorkingDirectory(workingDirectory: string): NodeAppResourcePromise; + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): NodeAppResourcePromise; + /** Configures OTLP telemetry export */ + withOtlpExporter(options?: WithOtlpExporterOptions): NodeAppResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): NodeAppResourcePromise; + /** Sets an environment variable */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): NodeAppResourcePromise; + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): NodeAppResourcePromise; + /** Adds arguments */ + withArgs(args: string[]): NodeAppResourcePromise; + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): NodeAppResourcePromise; + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): NodeAppResourcePromise; + /** Adds a reference to another resource */ + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): NodeAppResourcePromise; + /** Updates a named endpoint via callback */ + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): NodeAppResourcePromise; + /** Updates an HTTP endpoint via callback */ + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): NodeAppResourcePromise; + /** Updates an HTTPS endpoint via callback */ + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): NodeAppResourcePromise; + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): NodeAppResourcePromise; + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): NodeAppResourcePromise; + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): NodeAppResourcePromise; + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): NodeAppResourcePromise; + /** Gets an endpoint reference */ + getEndpoint(name: string): Promise; + /** Configures resource for HTTP/2 */ + asHttp2Service(): NodeAppResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): NodeAppResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): NodeAppResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): NodeAppResourcePromise; + /** Configures the resource to copy container files from the specified source during publishing */ + publishWithContainerFiles(source: Awaitable, destinationPath: string): NodeAppResourcePromise; + /** Sets the source directory for container files */ + withContainerFilesSource(sourcePath: string): NodeAppResourcePromise; + /** Clears all container file sources */ + clearContainerFilesSources(): NodeAppResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): NodeAppResourcePromise; + /** Waits for another resource to be ready */ + waitFor(dependency: Awaitable, options?: WaitForOptions): NodeAppResourcePromise; + /** Waits for another resource to start */ + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): NodeAppResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): NodeAppResourcePromise; + /** Waits for resource completion */ + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): NodeAppResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): NodeAppResourcePromise; + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): NodeAppResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): NodeAppResourcePromise; + /** Adds an HTTP resource command */ + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): NodeAppResourcePromise; + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): NodeAppResourcePromise; + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): NodeAppResourcePromise; + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): NodeAppResourcePromise; + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): NodeAppResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): NodeAppResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): NodeAppResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): NodeAppResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): NodeAppResourcePromise; + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): NodeAppResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): NodeAppResourcePromise; + /** Sets image push options via callback */ + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): NodeAppResourcePromise; + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): NodeAppResourcePromise; + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): NodeAppResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): NodeAppResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): NodeAppResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): NodeAppResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): NodeAppResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): NodeAppResourcePromise; + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): NodeAppResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): NodeAppResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Publishes the JavaScript application as a standalone static website using YARP. */ + publishAsStaticWebsite(options?: PublishAsStaticWebsiteOptions): NodeAppResourcePromise; + /** Publishes the JavaScript application as a standalone Node.js server that runs a built artifact directly. */ + publishAsNodeServer(entryPoint: string, options?: PublishAsNodeServerOptions): NodeAppResourcePromise; + /** Publishes the JavaScript application as a Node.js server that uses a package manager script at runtime. */ + publishAsNpmScript(options?: PublishAsNpmScriptOptions): NodeAppResourcePromise; + /** Configures npm as the package manager */ + withNpm(options?: WithNpmOptions): NodeAppResourcePromise; + /** Configures Bun as the package manager */ + withBun(options?: WithBunOptions): NodeAppResourcePromise; + /** Configures yarn as the package manager */ + withYarn(options?: WithYarnOptions): NodeAppResourcePromise; + /** Configures pnpm as the package manager */ + withPnpm(options?: WithPnpmOptions): NodeAppResourcePromise; + /** Specifies an npm script to run before starting the application */ + withBuildScript(scriptName: string, options?: WithBuildScriptOptions): NodeAppResourcePromise; + /** Specifies an npm script to run during development */ + withRunScript(scriptName: string, options?: WithRunScriptOptions): NodeAppResourcePromise; + /** Configures a browser debugger for the JavaScript application */ + withBrowserDebugger(options?: WithBrowserDebuggerOptions): NodeAppResourcePromise; + /** Create a new reference, while also allowing customization of how a resource appears in the generated LikeC4 diagram. */ + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): NodeAppResourcePromise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): NodeAppResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): NodeAppResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): NodeAppResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): NodeAppResourcePromise; + /** Associates an Azure user-assigned identity with a compute resource */ + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): NodeAppResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): NodeAppResourcePromise; +} + +export interface NodeAppResourcePromise extends PromiseLike { + /** Gets the Command property */ + command(): Promise; + /** Gets the WorkingDirectory property */ + workingDirectory(): Promise; + /** Gets the Name property */ + name(): Promise; + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): NodeAppResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): NodeAppResourcePromise; + /** Publishes an executable as a Docker file */ + publishAsDockerFile(configure: (obj: ContainerResource) => Promise): NodeAppResourcePromise; + /** Sets the executable command */ + withExecutableCommand(command: string): NodeAppResourcePromise; + /** Sets the executable working directory */ + withWorkingDirectory(workingDirectory: string): NodeAppResourcePromise; + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): NodeAppResourcePromise; + /** Configures OTLP telemetry export */ + withOtlpExporter(options?: WithOtlpExporterOptions): NodeAppResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): NodeAppResourcePromise; + /** Sets an environment variable */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): NodeAppResourcePromise; + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): NodeAppResourcePromise; + /** Adds arguments */ + withArgs(args: string[]): NodeAppResourcePromise; + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): NodeAppResourcePromise; + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): NodeAppResourcePromise; + /** Adds a reference to another resource */ + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): NodeAppResourcePromise; + /** Updates a named endpoint via callback */ + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): NodeAppResourcePromise; + /** Updates an HTTP endpoint via callback */ + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): NodeAppResourcePromise; + /** Updates an HTTPS endpoint via callback */ + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): NodeAppResourcePromise; + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): NodeAppResourcePromise; + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): NodeAppResourcePromise; + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): NodeAppResourcePromise; + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): NodeAppResourcePromise; + /** Gets an endpoint reference */ + getEndpoint(name: string): Promise; + /** Configures resource for HTTP/2 */ + asHttp2Service(): NodeAppResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): NodeAppResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): NodeAppResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): NodeAppResourcePromise; + /** Configures the resource to copy container files from the specified source during publishing */ + publishWithContainerFiles(source: Awaitable, destinationPath: string): NodeAppResourcePromise; + /** Sets the source directory for container files */ + withContainerFilesSource(sourcePath: string): NodeAppResourcePromise; + /** Clears all container file sources */ + clearContainerFilesSources(): NodeAppResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): NodeAppResourcePromise; + /** Waits for another resource to be ready */ + waitFor(dependency: Awaitable, options?: WaitForOptions): NodeAppResourcePromise; + /** Waits for another resource to start */ + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): NodeAppResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): NodeAppResourcePromise; + /** Waits for resource completion */ + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): NodeAppResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): NodeAppResourcePromise; + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): NodeAppResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): NodeAppResourcePromise; + /** Adds an HTTP resource command */ + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): NodeAppResourcePromise; + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): NodeAppResourcePromise; + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): NodeAppResourcePromise; + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): NodeAppResourcePromise; + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): NodeAppResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): NodeAppResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): NodeAppResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): NodeAppResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): NodeAppResourcePromise; + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): NodeAppResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): NodeAppResourcePromise; + /** Sets image push options via callback */ + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): NodeAppResourcePromise; + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): NodeAppResourcePromise; + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): NodeAppResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): NodeAppResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): NodeAppResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): NodeAppResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): NodeAppResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): NodeAppResourcePromise; + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): NodeAppResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): NodeAppResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Publishes the JavaScript application as a standalone static website using YARP. */ + publishAsStaticWebsite(options?: PublishAsStaticWebsiteOptions): NodeAppResourcePromise; + /** Publishes the JavaScript application as a standalone Node.js server that runs a built artifact directly. */ + publishAsNodeServer(entryPoint: string, options?: PublishAsNodeServerOptions): NodeAppResourcePromise; + /** Publishes the JavaScript application as a Node.js server that uses a package manager script at runtime. */ + publishAsNpmScript(options?: PublishAsNpmScriptOptions): NodeAppResourcePromise; + /** Configures npm as the package manager */ + withNpm(options?: WithNpmOptions): NodeAppResourcePromise; + /** Configures Bun as the package manager */ + withBun(options?: WithBunOptions): NodeAppResourcePromise; + /** Configures yarn as the package manager */ + withYarn(options?: WithYarnOptions): NodeAppResourcePromise; + /** Configures pnpm as the package manager */ + withPnpm(options?: WithPnpmOptions): NodeAppResourcePromise; + /** Specifies an npm script to run before starting the application */ + withBuildScript(scriptName: string, options?: WithBuildScriptOptions): NodeAppResourcePromise; + /** Specifies an npm script to run during development */ + withRunScript(scriptName: string, options?: WithRunScriptOptions): NodeAppResourcePromise; + /** Configures a browser debugger for the JavaScript application */ + withBrowserDebugger(options?: WithBrowserDebuggerOptions): NodeAppResourcePromise; + /** Create a new reference, while also allowing customization of how a resource appears in the generated LikeC4 diagram. */ + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): NodeAppResourcePromise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): NodeAppResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): NodeAppResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): NodeAppResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): NodeAppResourcePromise; + /** Associates an Azure user-assigned identity with a compute resource */ + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): NodeAppResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): NodeAppResourcePromise; +} + +// ============================================================================ +// NodeAppResourceImpl +// ============================================================================ + +class NodeAppResourceImpl extends ResourceBuilderBase implements NodeAppResource { + constructor(handle: NodeAppResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + async command(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/JavaScriptAppResource.command', + { context: this._handle } + ); + } + + async workingDirectory(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/JavaScriptAppResource.workingDirectory', + { context: this._handle } + ); + } + + async name(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/JavaScriptAppResource.name', + { context: this._handle } + ); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: Awaitable): Promise { + registry = isPromiseLike(registry) ? await registry : registry; + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withContainerRegistry(registry: Awaitable): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._withContainerRegistryInternal(registry), this._client); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): NodeAppResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new NodeAppResourcePromiseImpl(this._withDockerfileBaseImageInternal(buildImage, runtimeImage), this._client); + } + + /** @internal */ + private async _publishAsDockerFileInternal(configure: (obj: ContainerResource) => Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ContainerResourceHandle; + const obj = new ContainerResourceImpl(objHandle, this._client); + await configure(obj); + }); + const rpcArgs: Record = { builder: this._handle, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsDockerFile', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + publishAsDockerFile(configure: (obj: ContainerResource) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._publishAsDockerFileInternal(configure), this._client); + } + + /** @internal */ + private async _withExecutableCommandInternal(command: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExecutableCommand', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withExecutableCommand(command: string): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._withExecutableCommandInternal(command), this._client); + } + + /** @internal */ + private async _withWorkingDirectoryInternal(workingDirectory: string): Promise { + const rpcArgs: Record = { builder: this._handle, workingDirectory }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withWorkingDirectory', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withWorkingDirectory(workingDirectory: string): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._withWorkingDirectoryInternal(workingDirectory), this._client); + } + + /** @internal */ + private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withMcpServer', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withMcpServer(options?: WithMcpServerOptions): NodeAppResourcePromise { + const path = options?.path; + const endpointName = options?.endpointName; + return new NodeAppResourcePromiseImpl(this._withMcpServerInternal(path, endpointName), this._client); + } + + /** @internal */ + private async _withOtlpExporterInternal(protocol?: OtlpProtocol): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (protocol !== undefined) rpcArgs.protocol = protocol; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporter', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withOtlpExporter(options?: WithOtlpExporterOptions): NodeAppResourcePromise { + const protocol = options?.protocol; + return new NodeAppResourcePromiseImpl(this._withOtlpExporterInternal(protocol), this._client); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): NodeAppResourcePromise { + const helpLink = options?.helpLink; + return new NodeAppResourcePromiseImpl(this._withRequiredCommandInternal(command, helpLink), this._client); + } + + /** @internal */ + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): Promise { + value = isPromiseLike(value) ? await value : value; + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironment', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._withEnvironmentInternal(name, value), this._client); + } + + /** @internal */ + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentCallback', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._withEnvironmentCallbackInternal(callback), this._client); + } + + /** @internal */ + private async _withArgsInternal(args: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, args }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgs', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withArgs(args: string[]): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._withArgsInternal(args), this._client); + } + + /** @internal */ + private async _withArgsCallbackInternal(callback: (obj: CommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; + const obj = new CommandLineArgsCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallback', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._withArgsCallbackInternal(callback), this._client); + } + + /** @internal */ + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceEnvironment', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._withReferenceEnvironmentInternal(options), this._client); + } + + /** @internal */ + private async _withReferenceInternal(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, connectionName?: string, optional?: boolean, name?: string): Promise { + source = isPromiseLike(source) ? await source : source; + const rpcArgs: Record = { builder: this._handle, source }; + if (connectionName !== undefined) rpcArgs.connectionName = connectionName; + if (optional !== undefined) rpcArgs.optional = optional; + if (name !== undefined) rpcArgs.name = name; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReference', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): NodeAppResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new NodeAppResourcePromiseImpl(this._withReferenceInternal(source, connectionName, optional, name), this._client); + } + + /** @internal */ + private async _withEndpointCallbackInternal(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpointCallback', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): NodeAppResourcePromise { + const createIfNotExists = options?.createIfNotExists; + return new NodeAppResourcePromiseImpl(this._withEndpointCallbackInternal(endpointName, callback, createIfNotExists), this._client); + } + + /** @internal */ + private async _withHttpEndpointCallbackInternal(callback: (obj: EndpointUpdateContext) => Promise, name?: string, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + if (name !== undefined) rpcArgs.name = name; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpEndpointCallback', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): NodeAppResourcePromise { + const name = options?.name; + const createIfNotExists = options?.createIfNotExists; + return new NodeAppResourcePromiseImpl(this._withHttpEndpointCallbackInternal(callback, name, createIfNotExists), this._client); + } + + /** @internal */ + private async _withHttpsEndpointCallbackInternal(callback: (obj: EndpointUpdateContext) => Promise, name?: string, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + if (name !== undefined) rpcArgs.name = name; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsEndpointCallback', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): NodeAppResourcePromise { + const name = options?.name; + const createIfNotExists = options?.createIfNotExists; + return new NodeAppResourcePromiseImpl(this._withHttpsEndpointCallbackInternal(callback, name, createIfNotExists), this._client); + } + + /** @internal */ + private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (scheme !== undefined) rpcArgs.scheme = scheme; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + if (isExternal !== undefined) rpcArgs.isExternal = isExternal; + if (protocol !== undefined) rpcArgs.protocol = protocol; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpoint', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withEndpoint(options?: WithEndpointOptions): NodeAppResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const scheme = options?.scheme; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + const isExternal = options?.isExternal; + const protocol = options?.protocol; + return new NodeAppResourcePromiseImpl(this._withEndpointInternal(port, targetPort, scheme, name, env, isProxied, isExternal, protocol), this._client); + } + + /** @internal */ + private async _withHttpEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpEndpoint', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withHttpEndpoint(options?: WithHttpEndpointOptions): NodeAppResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new NodeAppResourcePromiseImpl(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied), this._client); + } + + /** @internal */ + private async _withHttpsEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsEndpoint', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withHttpsEndpoint(options?: WithHttpsEndpointOptions): NodeAppResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new NodeAppResourcePromiseImpl(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied), this._client); + } + + /** @internal */ + private async _withExternalHttpEndpointsInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExternalHttpEndpoints', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withExternalHttpEndpoints(): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._withExternalHttpEndpointsInternal(), this._client); + } + + async getEndpoint(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getEndpoint', + rpcArgs + ); + } + + /** @internal */ + private async _asHttp2ServiceInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/asHttp2Service', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + asHttp2Service(): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._asHttp2ServiceInternal(), this._client); + } + + /** @internal */ + private async _withUrlsInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrls', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._withUrlsInternal(callback), this._client); + } + + /** @internal */ + private async _withUrlInternal(url: string | ReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): NodeAppResourcePromise { + const displayText = options?.displayText; + return new NodeAppResourcePromiseImpl(this._withUrlInternal(url, displayText), this._client); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._withUrlForEndpointInternal(endpointName, callback), this._client); + } + + /** @internal */ + private async _publishWithContainerFilesInternal(source: Awaitable, destinationPath: string): Promise { + source = isPromiseLike(source) ? await source : source; + const rpcArgs: Record = { builder: this._handle, source, destinationPath }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishWithContainerFilesFromResource', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + publishWithContainerFiles(source: Awaitable, destinationPath: string): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._publishWithContainerFilesInternal(source, destinationPath), this._client); + } + + /** @internal */ + private async _withContainerFilesSourceInternal(sourcePath: string): Promise { + const rpcArgs: Record = { builder: this._handle, sourcePath }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerFilesSource', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withContainerFilesSource(sourcePath: string): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._withContainerFilesSourceInternal(sourcePath), this._client); + } + + /** @internal */ + private async _clearContainerFilesSourcesInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/clearContainerFilesSources', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + clearContainerFilesSources(): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._clearContainerFilesSourcesInternal(), this._client); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + excludeFromManifest(): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._excludeFromManifestInternal(), this._client); + } + + /** @internal */ + private async _waitForInternal(dependency: Awaitable, waitBehavior?: WaitBehavior): Promise { + dependency = isPromiseLike(dependency) ? await dependency : dependency; + const rpcArgs: Record = { builder: this._handle, dependency }; + if (waitBehavior !== undefined) rpcArgs.waitBehavior = waitBehavior; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitFor', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + waitFor(dependency: Awaitable, options?: WaitForOptions): NodeAppResourcePromise { + const waitBehavior = options?.waitBehavior; + return new NodeAppResourcePromiseImpl(this._waitForInternal(dependency, waitBehavior), this._client); + } + + /** @internal */ + private async _waitForStartInternal(dependency: Awaitable, waitBehavior?: WaitBehavior): Promise { + dependency = isPromiseLike(dependency) ? await dependency : dependency; + const rpcArgs: Record = { builder: this._handle, dependency }; + if (waitBehavior !== undefined) rpcArgs.waitBehavior = waitBehavior; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStart', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): NodeAppResourcePromise { + const waitBehavior = options?.waitBehavior; + return new NodeAppResourcePromiseImpl(this._waitForStartInternal(dependency, waitBehavior), this._client); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withExplicitStart(): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._withExplicitStartInternal(), this._client); + } + + /** @internal */ + private async _waitForCompletionInternal(dependency: Awaitable, exitCode?: number): Promise { + dependency = isPromiseLike(dependency) ? await dependency : dependency; + const rpcArgs: Record = { builder: this._handle, dependency }; + if (exitCode !== undefined) rpcArgs.exitCode = exitCode; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceCompletion', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): NodeAppResourcePromise { + const exitCode = options?.exitCode; + return new NodeAppResourcePromiseImpl(this._waitForCompletionInternal(dependency, exitCode), this._client); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withHealthCheck(key: string): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._withHealthCheckInternal(key), this._client); + } + + /** @internal */ + private async _withHttpHealthCheckInternal(path?: string, statusCode?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (statusCode !== undefined) rpcArgs.statusCode = statusCode; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpHealthCheck', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): NodeAppResourcePromise { + const path = options?.path; + const statusCode = options?.statusCode; + const endpointName = options?.endpointName; + return new NodeAppResourcePromiseImpl(this._withHttpHealthCheckInternal(path, statusCode, endpointName), this._client); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContextImpl(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): NodeAppResourcePromise { + const commandOptions = options?.commandOptions; + return new NodeAppResourcePromiseImpl(this._withCommandInternal(name, displayName, executeCommand, commandOptions), this._client); + } + + /** @internal */ + private async _withHttpCommandInternal(path: string, displayName: string, options?: HttpCommandExportOptions): Promise { + const rpcArgs: Record = { builder: this._handle, path, displayName }; + if (options !== undefined) rpcArgs.options = options; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpCommand', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._withHttpCommandInternal(path, displayName, options), this._client); + } + + /** @internal */ + private async _withDeveloperCertificateTrustInternal(trust: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, trust }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDeveloperCertificateTrust', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withDeveloperCertificateTrust(trust: boolean): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._withDeveloperCertificateTrustInternal(trust), this._client); + } + + /** @internal */ + private async _withCertificateTrustScopeInternal(scope: CertificateTrustScope): Promise { + const rpcArgs: Record = { builder: this._handle, scope }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCertificateTrustScope', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withCertificateTrustScope(scope: CertificateTrustScope): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._withCertificateTrustScopeInternal(scope), this._client); + } + + /** @internal */ + private async _withHttpsDeveloperCertificateInternal(password?: Awaitable): Promise { + password = isPromiseLike(password) ? await password : password; + const rpcArgs: Record = { builder: this._handle }; + if (password !== undefined) rpcArgs.password = password; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): NodeAppResourcePromise { + let password = options?.password; + return new NodeAppResourcePromiseImpl(this._withHttpsDeveloperCertificateInternal(password), this._client); + } + + /** @internal */ + private async _withoutHttpsCertificateInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withoutHttpsCertificate', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withoutHttpsCertificate(): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._withoutHttpsCertificateInternal(), this._client); + } + + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: Awaitable, type: string): Promise { + resourceBuilder = isPromiseLike(resourceBuilder) ? await resourceBuilder : resourceBuilder; + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._withRelationshipInternal(resourceBuilder, type), this._client); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: Awaitable): Promise { + parent = isPromiseLike(parent) ? await parent : parent; + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withParentRelationship(parent: Awaitable): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._withParentRelationshipInternal(parent), this._client); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: Awaitable): Promise { + child = isPromiseLike(child) ? await child : child; + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withChildRelationship(child: Awaitable): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._withChildRelationshipInternal(child), this._client); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): NodeAppResourcePromise { + const iconVariant = options?.iconVariant; + return new NodeAppResourcePromiseImpl(this._withIconNameInternal(iconName, iconVariant), this._client); + } + + /** @internal */ + private async _withHttpProbeInternal(probeType: ProbeType, path?: string, initialDelaySeconds?: number, periodSeconds?: number, timeoutSeconds?: number, failureThreshold?: number, successThreshold?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, probeType }; + if (path !== undefined) rpcArgs.path = path; + if (initialDelaySeconds !== undefined) rpcArgs.initialDelaySeconds = initialDelaySeconds; + if (periodSeconds !== undefined) rpcArgs.periodSeconds = periodSeconds; + if (timeoutSeconds !== undefined) rpcArgs.timeoutSeconds = timeoutSeconds; + if (failureThreshold !== undefined) rpcArgs.failureThreshold = failureThreshold; + if (successThreshold !== undefined) rpcArgs.successThreshold = successThreshold; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpProbe', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): NodeAppResourcePromise { + const path = options?.path; + const initialDelaySeconds = options?.initialDelaySeconds; + const periodSeconds = options?.periodSeconds; + const timeoutSeconds = options?.timeoutSeconds; + const failureThreshold = options?.failureThreshold; + const successThreshold = options?.successThreshold; + const endpointName = options?.endpointName; + return new NodeAppResourcePromiseImpl(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName), this._client); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + excludeFromMcp(): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._excludeFromMcpInternal(), this._client); + } + + /** @internal */ + private async _withImagePushOptionsInternal(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ContainerImagePushOptionsCallbackContextHandle; + const arg = new ContainerImagePushOptionsCallbackContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImagePushOptions', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._withImagePushOptionsInternal(callback), this._client); + } + + /** @internal */ + private async _withRemoteImageNameInternal(remoteImageName: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageName', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withRemoteImageName(remoteImageName: string): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._withRemoteImageNameInternal(remoteImageName), this._client); + } + + /** @internal */ + private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageTag', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withRemoteImageTag(remoteImageTag: string): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._withRemoteImageTagInternal(remoteImageTag), this._client); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): NodeAppResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new NodeAppResourcePromiseImpl(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description), this._client); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._withPipelineConfigurationInternal(callback), this._client); + } + + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); + } + + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._onBeforeResourceStartedInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._onResourceStoppedInternal(callback), this._client); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._onInitializeResourceInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceEndpointsAllocated', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._onResourceEndpointsAllocatedInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._onResourceReadyInternal(callback), this._client); + } + + async createExecutionConfiguration(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/createExecutionConfiguration', + rpcArgs + ); + } + + /** @internal */ + private async _publishAsStaticWebsiteInternal(apiPath?: string, apiTarget?: Awaitable, outputPath?: string, stripPrefix?: boolean, targetEndpointName?: string): Promise { + apiTarget = isPromiseLike(apiTarget) ? await apiTarget : apiTarget; + const rpcArgs: Record = { builder: this._handle }; + if (apiPath !== undefined) rpcArgs.apiPath = apiPath; + if (apiTarget !== undefined) rpcArgs.apiTarget = apiTarget; + if (outputPath !== undefined) rpcArgs.outputPath = outputPath; + if (stripPrefix !== undefined) rpcArgs.stripPrefix = stripPrefix; + if (targetEndpointName !== undefined) rpcArgs.targetEndpointName = targetEndpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/publishAsStaticWebsite', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + publishAsStaticWebsite(options?: PublishAsStaticWebsiteOptions): NodeAppResourcePromise { + const apiPath = options?.apiPath; + let apiTarget = options?.apiTarget; + const outputPath = options?.outputPath; + const stripPrefix = options?.stripPrefix; + const targetEndpointName = options?.targetEndpointName; + return new NodeAppResourcePromiseImpl(this._publishAsStaticWebsiteInternal(apiPath, apiTarget, outputPath, stripPrefix, targetEndpointName), this._client); + } + + /** @internal */ + private async _publishAsNodeServerInternal(entryPoint: string, outputPath?: string): Promise { + const rpcArgs: Record = { builder: this._handle, entryPoint }; + if (outputPath !== undefined) rpcArgs.outputPath = outputPath; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/publishAsNodeServer', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + publishAsNodeServer(entryPoint: string, options?: PublishAsNodeServerOptions): NodeAppResourcePromise { + const outputPath = options?.outputPath; + return new NodeAppResourcePromiseImpl(this._publishAsNodeServerInternal(entryPoint, outputPath), this._client); + } + + /** @internal */ + private async _publishAsNpmScriptInternal(startScriptName?: string, runScriptArguments?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (startScriptName !== undefined) rpcArgs.startScriptName = startScriptName; + if (runScriptArguments !== undefined) rpcArgs.runScriptArguments = runScriptArguments; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/publishAsNpmScript', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + publishAsNpmScript(options?: PublishAsNpmScriptOptions): NodeAppResourcePromise { + const startScriptName = options?.startScriptName; + const runScriptArguments = options?.runScriptArguments; + return new NodeAppResourcePromiseImpl(this._publishAsNpmScriptInternal(startScriptName, runScriptArguments), this._client); + } + + /** @internal */ + private async _withNpmInternal(install?: boolean, installCommand?: string, installArgs?: string[]): Promise { + const rpcArgs: Record = { resource: this._handle }; + if (install !== undefined) rpcArgs.install = install; + if (installCommand !== undefined) rpcArgs.installCommand = installCommand; + if (installArgs !== undefined) rpcArgs.installArgs = installArgs; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/withNpm', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withNpm(options?: WithNpmOptions): NodeAppResourcePromise { + const install = options?.install; + const installCommand = options?.installCommand; + const installArgs = options?.installArgs; + return new NodeAppResourcePromiseImpl(this._withNpmInternal(install, installCommand, installArgs), this._client); + } + + /** @internal */ + private async _withBunInternal(install?: boolean, installArgs?: string[]): Promise { + const rpcArgs: Record = { resource: this._handle }; + if (install !== undefined) rpcArgs.install = install; + if (installArgs !== undefined) rpcArgs.installArgs = installArgs; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/withBun', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withBun(options?: WithBunOptions): NodeAppResourcePromise { + const install = options?.install; + const installArgs = options?.installArgs; + return new NodeAppResourcePromiseImpl(this._withBunInternal(install, installArgs), this._client); + } + + /** @internal */ + private async _withYarnInternal(install?: boolean, installArgs?: string[]): Promise { + const rpcArgs: Record = { resource: this._handle }; + if (install !== undefined) rpcArgs.install = install; + if (installArgs !== undefined) rpcArgs.installArgs = installArgs; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/withYarn', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withYarn(options?: WithYarnOptions): NodeAppResourcePromise { + const install = options?.install; + const installArgs = options?.installArgs; + return new NodeAppResourcePromiseImpl(this._withYarnInternal(install, installArgs), this._client); + } + + /** @internal */ + private async _withPnpmInternal(install?: boolean, installArgs?: string[]): Promise { + const rpcArgs: Record = { resource: this._handle }; + if (install !== undefined) rpcArgs.install = install; + if (installArgs !== undefined) rpcArgs.installArgs = installArgs; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/withPnpm', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withPnpm(options?: WithPnpmOptions): NodeAppResourcePromise { + const install = options?.install; + const installArgs = options?.installArgs; + return new NodeAppResourcePromiseImpl(this._withPnpmInternal(install, installArgs), this._client); + } + + /** @internal */ + private async _withBuildScriptInternal(scriptName: string, args?: string[]): Promise { + const rpcArgs: Record = { resource: this._handle, scriptName }; + if (args !== undefined) rpcArgs.args = args; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/withBuildScript', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withBuildScript(scriptName: string, options?: WithBuildScriptOptions): NodeAppResourcePromise { + const args = options?.args; + return new NodeAppResourcePromiseImpl(this._withBuildScriptInternal(scriptName, args), this._client); + } + + /** @internal */ + private async _withRunScriptInternal(scriptName: string, args?: string[]): Promise { + const rpcArgs: Record = { resource: this._handle, scriptName }; + if (args !== undefined) rpcArgs.args = args; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/withRunScript', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withRunScript(scriptName: string, options?: WithRunScriptOptions): NodeAppResourcePromise { + const args = options?.args; + return new NodeAppResourcePromiseImpl(this._withRunScriptInternal(scriptName, args), this._client); + } + + /** @internal */ + private async _withBrowserDebuggerInternal(browser?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (browser !== undefined) rpcArgs.browser = browser; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/withBrowserDebugger', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withBrowserDebugger(options?: WithBrowserDebuggerOptions): NodeAppResourcePromise { + const browser = options?.browser; + return new NodeAppResourcePromiseImpl(this._withBrowserDebuggerInternal(browser), this._client); + } + + /** @internal */ + private async _withLikeC4ReferenceWithEnvironmentInternal(source: Awaitable, configure?: (obj: LikeC4RelationshipDetailsAnnotation) => Promise, connectionName?: string, optional?: boolean, skipAspireReference?: boolean): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4RelationshipDetailsAnnotationHandle; + const obj = new LikeC4RelationshipDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + source = isPromiseLike(source) ? await source : source; + const rpcArgs: Record = { builder: this._handle, source }; + if (configure !== undefined) rpcArgs.configure = configureId; + if (connectionName !== undefined) rpcArgs.connectionName = connectionName; + if (optional !== undefined) rpcArgs.optional = optional; + if (skipAspireReference !== undefined) rpcArgs.skipAspireReference = skipAspireReference; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4ReferenceWithEnvironment', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): NodeAppResourcePromise { + const configure = options?.configure; + const connectionName = options?.connectionName; + const optional = options?.optional; + const skipAspireReference = options?.skipAspireReference; + return new NodeAppResourcePromiseImpl(this._withLikeC4ReferenceWithEnvironmentInternal(source, configure, connectionName, optional, skipAspireReference), this._client); + } + + /** @internal */ + private async _withLikeC4DetailsInternal(label?: string, technology?: string, description?: string, summary?: string, icon?: string, configure?: (obj: LikeC4NodeDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4NodeDetailsAnnotationHandle; + const obj = new LikeC4NodeDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + const rpcArgs: Record = { builder: this._handle }; + if (label !== undefined) rpcArgs.label = label; + if (technology !== undefined) rpcArgs.technology = technology; + if (description !== undefined) rpcArgs.description = description; + if (summary !== undefined) rpcArgs.summary = summary; + if (icon !== undefined) rpcArgs.icon = icon; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4DetailsParameters', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): NodeAppResourcePromise { + const label = options?.label; + const technology = options?.technology; + const description = options?.description; + const summary = options?.summary; + const icon = options?.icon; + const configure = options?.configure; + return new NodeAppResourcePromiseImpl(this._withLikeC4DetailsInternal(label, technology, description, summary, icon, configure), this._client); + } + + /** @internal */ + private async _withLikeC4ReferenceInternal(target: Awaitable, configure?: (obj: LikeC4RelationshipDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4RelationshipDetailsAnnotationHandle; + const obj = new LikeC4RelationshipDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target }; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Reference', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): NodeAppResourcePromise { + const configure = options?.configure; + return new NodeAppResourcePromiseImpl(this._withLikeC4ReferenceInternal(target, configure), this._client); + } + + /** @internal */ + private async _withLikeC4GroupInternal(groupName: string): Promise { + const rpcArgs: Record = { builder: this._handle, groupName }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Group', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withLikeC4Group(groupName: string): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._withLikeC4GroupInternal(groupName), this._client); + } + + /** @internal */ + private async _excludeFromLikeC4Internal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/excludeFromLikeC4', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + excludeFromLikeC4(): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._excludeFromLikeC4Internal(), this._client); + } + + /** @internal */ + private async _withAzureUserAssignedIdentityInternal(identityResourceBuilder: Awaitable): Promise { + identityResourceBuilder = isPromiseLike(identityResourceBuilder) ? await identityResourceBuilder : identityResourceBuilder; + const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._withAzureUserAssignedIdentityInternal(identityResourceBuilder), this._client); + } + + /** @internal */ + private async _withRoleAssignmentsInternal(target: Awaitable, roles: AzureKeyVaultRole[]): Promise { + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target, roles }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.KeyVault/withKeyVaultRoleAssignments', + rpcArgs + ); + return new NodeAppResourceImpl(result, this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._withRoleAssignmentsInternal(target, roles), this._client); + } + +} + +/** + * Thenable wrapper for NodeAppResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +class NodeAppResourcePromiseImpl implements NodeAppResourcePromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: NodeAppResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + command(): Promise { + return this._promise.then(obj => obj.command()); + } + + workingDirectory(): Promise { + return this._promise.then(obj => obj.workingDirectory()); + } + + name(): Promise { + return this._promise.then(obj => obj.name()); + } + + withContainerRegistry(registry: Awaitable): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withContainerRegistry(registry)), this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withDockerfileBaseImage(options)), this._client); + } + + publishAsDockerFile(configure: (obj: ContainerResource) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.publishAsDockerFile(configure)), this._client); + } + + withExecutableCommand(command: string): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withExecutableCommand(command)), this._client); + } + + withWorkingDirectory(workingDirectory: string): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withWorkingDirectory(workingDirectory)), this._client); + } + + withMcpServer(options?: WithMcpServerOptions): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withMcpServer(options)), this._client); + } + + withOtlpExporter(options?: WithOtlpExporterOptions): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withOtlpExporter(options)), this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withRequiredCommand(command, options)), this._client); + } + + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withEnvironment(name, value)), this._client); + } + + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentCallback(callback)), this._client); + } + + withArgs(args: string[]): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withArgs(args)), this._client); + } + + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withArgsCallback(callback)), this._client); + } + + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withReferenceEnvironment(options)), this._client); + } + + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withReference(source, options)), this._client); + } + + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withEndpointCallback(endpointName, callback, options)), this._client); + } + + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withHttpEndpointCallback(callback, options)), this._client); + } + + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withHttpsEndpointCallback(callback, options)), this._client); + } + + withEndpoint(options?: WithEndpointOptions): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withEndpoint(options)), this._client); + } + + withHttpEndpoint(options?: WithHttpEndpointOptions): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withHttpEndpoint(options)), this._client); + } + + withHttpsEndpoint(options?: WithHttpsEndpointOptions): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withHttpsEndpoint(options)), this._client); + } + + withExternalHttpEndpoints(): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withExternalHttpEndpoints()), this._client); + } + + getEndpoint(name: string): Promise { + return this._promise.then(obj => obj.getEndpoint(name)); + } + + asHttp2Service(): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.asHttp2Service()), this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withUrls(callback)), this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withUrl(url, options)), this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback)), this._client); + } + + publishWithContainerFiles(source: Awaitable, destinationPath: string): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.publishWithContainerFiles(source, destinationPath)), this._client); + } + + withContainerFilesSource(sourcePath: string): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withContainerFilesSource(sourcePath)), this._client); + } + + clearContainerFilesSources(): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.clearContainerFilesSources()), this._client); + } + + excludeFromManifest(): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.excludeFromManifest()), this._client); + } + + waitFor(dependency: Awaitable, options?: WaitForOptions): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.waitFor(dependency, options)), this._client); + } + + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.waitForStart(dependency, options)), this._client); + } + + withExplicitStart(): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withExplicitStart()), this._client); + } + + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.waitForCompletion(dependency, options)), this._client); + } + + withHealthCheck(key: string): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withHealthCheck(key)), this._client); + } + + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withHttpHealthCheck(options)), this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options)), this._client); + } + + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withHttpCommand(path, displayName, options)), this._client); + } + + withDeveloperCertificateTrust(trust: boolean): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust)), this._client); + } + + withCertificateTrustScope(scope: CertificateTrustScope): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withCertificateTrustScope(scope)), this._client); + } + + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options)), this._client); + } + + withoutHttpsCertificate(): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withoutHttpsCertificate()), this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withRelationship(resourceBuilder, type)), this._client); + } + + withParentRelationship(parent: Awaitable): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withParentRelationship(parent)), this._client); + } + + withChildRelationship(child: Awaitable): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withChildRelationship(child)), this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withIconName(iconName, options)), this._client); + } + + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withHttpProbe(probeType, options)), this._client); + } + + excludeFromMcp(): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.excludeFromMcp()), this._client); + } + + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withImagePushOptions(callback)), this._client); + } + + withRemoteImageName(remoteImageName: string): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withRemoteImageName(remoteImageName)), this._client); + } + + withRemoteImageTag(remoteImageTag: string): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag)), this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options)), this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withPipelineConfiguration(callback)), this._client); + } + + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.onBeforeResourceStarted(callback)), this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.onResourceStopped(callback)), this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.onInitializeResource(callback)), this._client); + } + + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback)), this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.onResourceReady(callback)), this._client); + } + + createExecutionConfiguration(): Promise { + return this._promise.then(obj => obj.createExecutionConfiguration()); + } + + publishAsStaticWebsite(options?: PublishAsStaticWebsiteOptions): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.publishAsStaticWebsite(options)), this._client); + } + + publishAsNodeServer(entryPoint: string, options?: PublishAsNodeServerOptions): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.publishAsNodeServer(entryPoint, options)), this._client); + } + + publishAsNpmScript(options?: PublishAsNpmScriptOptions): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.publishAsNpmScript(options)), this._client); + } + + withNpm(options?: WithNpmOptions): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withNpm(options)), this._client); + } + + withBun(options?: WithBunOptions): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withBun(options)), this._client); + } + + withYarn(options?: WithYarnOptions): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withYarn(options)), this._client); + } + + withPnpm(options?: WithPnpmOptions): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withPnpm(options)), this._client); + } + + withBuildScript(scriptName: string, options?: WithBuildScriptOptions): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withBuildScript(scriptName, options)), this._client); + } + + withRunScript(scriptName: string, options?: WithRunScriptOptions): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withRunScript(scriptName, options)), this._client); + } + + withBrowserDebugger(options?: WithBrowserDebuggerOptions): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withBrowserDebugger(options)), this._client); + } + + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4ReferenceWithEnvironment(source, options)), this._client); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Details(options)), this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Reference(target, options)), this._client); + } + + withLikeC4Group(groupName: string): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Group(groupName)), this._client); + } + + excludeFromLikeC4(): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.excludeFromLikeC4()), this._client); + } + + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withAzureUserAssignedIdentity(identityResourceBuilder)), this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): NodeAppResourcePromise { + return new NodeAppResourcePromiseImpl(this._promise.then(obj => obj.withRoleAssignments(target, roles)), this._client); + } + +} + +// ============================================================================ +// ParameterResource +// ============================================================================ + +export interface ParameterResource { + toJSON(): MarshalledHandle; + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): ParameterResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ParameterResourcePromise; + /** Sets a parameter description */ + withDescription(description: string, options?: WithDescriptionOptions): ParameterResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ParameterResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): ParameterResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): ParameterResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ParameterResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): ParameterResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): ParameterResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): ParameterResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ParameterResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): ParameterResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): ParameterResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): ParameterResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ParameterResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ParameterResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ParameterResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ParameterResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ParameterResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ParameterResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ParameterResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ParameterResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): ParameterResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): ParameterResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): ParameterResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): ParameterResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): ParameterResourcePromise; +} + +export interface ParameterResourcePromise extends PromiseLike { + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): ParameterResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ParameterResourcePromise; + /** Sets a parameter description */ + withDescription(description: string, options?: WithDescriptionOptions): ParameterResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ParameterResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): ParameterResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): ParameterResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ParameterResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): ParameterResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): ParameterResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): ParameterResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ParameterResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): ParameterResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): ParameterResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): ParameterResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ParameterResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ParameterResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ParameterResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ParameterResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ParameterResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ParameterResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ParameterResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ParameterResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): ParameterResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): ParameterResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): ParameterResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): ParameterResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): ParameterResourcePromise; +} + +// ============================================================================ +// ParameterResourceImpl +// ============================================================================ + +class ParameterResourceImpl extends ResourceBuilderBase implements ParameterResource { + constructor(handle: ParameterResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: Awaitable): Promise { + registry = isPromiseLike(registry) ? await registry : registry; + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new ParameterResourceImpl(result, this._client); + } + + withContainerRegistry(registry: Awaitable): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._withContainerRegistryInternal(registry), this._client); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new ParameterResourceImpl(result, this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ParameterResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new ParameterResourcePromiseImpl(this._withDockerfileBaseImageInternal(buildImage, runtimeImage), this._client); + } + + /** @internal */ + private async _withDescriptionInternal(description: string, enableMarkdown?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, description }; + if (enableMarkdown !== undefined) rpcArgs.enableMarkdown = enableMarkdown; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDescription', + rpcArgs + ); + return new ParameterResourceImpl(result, this._client); + } + + withDescription(description: string, options?: WithDescriptionOptions): ParameterResourcePromise { + const enableMarkdown = options?.enableMarkdown; + return new ParameterResourcePromiseImpl(this._withDescriptionInternal(description, enableMarkdown), this._client); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new ParameterResourceImpl(result, this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ParameterResourcePromise { + const helpLink = options?.helpLink; + return new ParameterResourcePromiseImpl(this._withRequiredCommandInternal(command, helpLink), this._client); + } + + /** @internal */ + private async _withUrlsInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrls', + rpcArgs + ); + return new ParameterResourceImpl(result, this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._withUrlsInternal(callback), this._client); + } + + /** @internal */ + private async _withUrlInternal(url: string | ReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new ParameterResourceImpl(result, this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): ParameterResourcePromise { + const displayText = options?.displayText; + return new ParameterResourcePromiseImpl(this._withUrlInternal(url, displayText), this._client); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new ParameterResourceImpl(result, this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._withUrlForEndpointInternal(endpointName, callback), this._client); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new ParameterResourceImpl(result, this._client); + } + + excludeFromManifest(): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._excludeFromManifestInternal(), this._client); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new ParameterResourceImpl(result, this._client); + } + + withExplicitStart(): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._withExplicitStartInternal(), this._client); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new ParameterResourceImpl(result, this._client); + } + + withHealthCheck(key: string): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._withHealthCheckInternal(key), this._client); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContextImpl(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new ParameterResourceImpl(result, this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ParameterResourcePromise { + const commandOptions = options?.commandOptions; + return new ParameterResourcePromiseImpl(this._withCommandInternal(name, displayName, executeCommand, commandOptions), this._client); + } + + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: Awaitable, type: string): Promise { + resourceBuilder = isPromiseLike(resourceBuilder) ? await resourceBuilder : resourceBuilder; + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ParameterResourceImpl(result, this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._withRelationshipInternal(resourceBuilder, type), this._client); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: Awaitable): Promise { + parent = isPromiseLike(parent) ? await parent : parent; + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new ParameterResourceImpl(result, this._client); + } + + withParentRelationship(parent: Awaitable): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._withParentRelationshipInternal(parent), this._client); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: Awaitable): Promise { + child = isPromiseLike(child) ? await child : child; + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', + rpcArgs + ); + return new ParameterResourceImpl(result, this._client); + } + + withChildRelationship(child: Awaitable): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._withChildRelationshipInternal(child), this._client); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new ParameterResourceImpl(result, this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): ParameterResourcePromise { + const iconVariant = options?.iconVariant; + return new ParameterResourcePromiseImpl(this._withIconNameInternal(iconName, iconVariant), this._client); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new ParameterResourceImpl(result, this._client); + } + + excludeFromMcp(): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._excludeFromMcpInternal(), this._client); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new ParameterResourceImpl(result, this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ParameterResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new ParameterResourcePromiseImpl(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description), this._client); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new ParameterResourceImpl(result, this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._withPipelineConfigurationInternal(callback), this._client); + } + + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); + } + + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new ParameterResourceImpl(result, this._client); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._onBeforeResourceStartedInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new ParameterResourceImpl(result, this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._onResourceStoppedInternal(callback), this._client); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new ParameterResourceImpl(result, this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._onInitializeResourceInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new ParameterResourceImpl(result, this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._onResourceReadyInternal(callback), this._client); + } + + async createExecutionConfiguration(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/createExecutionConfiguration', + rpcArgs + ); + } + + /** @internal */ + private async _withLikeC4DetailsInternal(label?: string, technology?: string, description?: string, summary?: string, icon?: string, configure?: (obj: LikeC4NodeDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4NodeDetailsAnnotationHandle; + const obj = new LikeC4NodeDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + const rpcArgs: Record = { builder: this._handle }; + if (label !== undefined) rpcArgs.label = label; + if (technology !== undefined) rpcArgs.technology = technology; + if (description !== undefined) rpcArgs.description = description; + if (summary !== undefined) rpcArgs.summary = summary; + if (icon !== undefined) rpcArgs.icon = icon; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4DetailsParameters', + rpcArgs + ); + return new ParameterResourceImpl(result, this._client); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): ParameterResourcePromise { + const label = options?.label; + const technology = options?.technology; + const description = options?.description; + const summary = options?.summary; + const icon = options?.icon; + const configure = options?.configure; + return new ParameterResourcePromiseImpl(this._withLikeC4DetailsInternal(label, technology, description, summary, icon, configure), this._client); + } + + /** @internal */ + private async _withLikeC4ReferenceInternal(target: Awaitable, configure?: (obj: LikeC4RelationshipDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4RelationshipDetailsAnnotationHandle; + const obj = new LikeC4RelationshipDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target }; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Reference', + rpcArgs + ); + return new ParameterResourceImpl(result, this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): ParameterResourcePromise { + const configure = options?.configure; + return new ParameterResourcePromiseImpl(this._withLikeC4ReferenceInternal(target, configure), this._client); + } + + /** @internal */ + private async _withLikeC4GroupInternal(groupName: string): Promise { + const rpcArgs: Record = { builder: this._handle, groupName }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Group', + rpcArgs + ); + return new ParameterResourceImpl(result, this._client); + } + + withLikeC4Group(groupName: string): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._withLikeC4GroupInternal(groupName), this._client); + } + + /** @internal */ + private async _excludeFromLikeC4Internal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/excludeFromLikeC4', + rpcArgs + ); + return new ParameterResourceImpl(result, this._client); + } + + excludeFromLikeC4(): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._excludeFromLikeC4Internal(), this._client); + } + + /** @internal */ + private async _withRoleAssignmentsInternal(target: Awaitable, roles: AzureKeyVaultRole[]): Promise { + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target, roles }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.KeyVault/withKeyVaultRoleAssignments', + rpcArgs + ); + return new ParameterResourceImpl(result, this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._withRoleAssignmentsInternal(target, roles), this._client); + } + +} + +/** + * Thenable wrapper for ParameterResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +class ParameterResourcePromiseImpl implements ParameterResourcePromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: ParameterResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + withContainerRegistry(registry: Awaitable): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withContainerRegistry(registry)), this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withDockerfileBaseImage(options)), this._client); + } + + withDescription(description: string, options?: WithDescriptionOptions): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withDescription(description, options)), this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withRequiredCommand(command, options)), this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withUrls(callback)), this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withUrl(url, options)), this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback)), this._client); + } + + excludeFromManifest(): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.excludeFromManifest()), this._client); + } + + withExplicitStart(): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withExplicitStart()), this._client); + } + + withHealthCheck(key: string): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withHealthCheck(key)), this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options)), this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withRelationship(resourceBuilder, type)), this._client); + } + + withParentRelationship(parent: Awaitable): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withParentRelationship(parent)), this._client); + } + + withChildRelationship(child: Awaitable): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withChildRelationship(child)), this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withIconName(iconName, options)), this._client); + } + + excludeFromMcp(): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.excludeFromMcp()), this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options)), this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withPipelineConfiguration(callback)), this._client); + } + + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.onBeforeResourceStarted(callback)), this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.onResourceStopped(callback)), this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.onInitializeResource(callback)), this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.onResourceReady(callback)), this._client); + } + + createExecutionConfiguration(): Promise { + return this._promise.then(obj => obj.createExecutionConfiguration()); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Details(options)), this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Reference(target, options)), this._client); + } + + withLikeC4Group(groupName: string): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Group(groupName)), this._client); + } + + excludeFromLikeC4(): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.excludeFromLikeC4()), this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withRoleAssignments(target, roles)), this._client); + } + +} + +// ============================================================================ +// PgAdminContainerResource +// ============================================================================ + +export interface PgAdminContainerResource { + toJSON(): MarshalledHandle; + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): PgAdminContainerResourcePromise; + /** Adds a bind mount */ + withBindMount(source: string, target: string, options?: WithBindMountOptions): PgAdminContainerResourcePromise; + /** Sets the container entrypoint */ + withEntrypoint(entrypoint: string): PgAdminContainerResourcePromise; + /** Sets the container image tag */ + withImageTag(tag: string): PgAdminContainerResourcePromise; + /** Sets the container image registry */ + withImageRegistry(registry: string): PgAdminContainerResourcePromise; + /** Sets the container image */ + withImage(image: string, options?: WithImageOptions): PgAdminContainerResourcePromise; + /** Sets the image SHA256 digest */ + withImageSHA256(sha256: string): PgAdminContainerResourcePromise; + /** Adds runtime arguments for the container */ + withContainerRuntimeArgs(args: string[]): PgAdminContainerResourcePromise; + /** Sets the lifetime behavior of the container resource */ + withLifetime(lifetime: ContainerLifetime): PgAdminContainerResourcePromise; + /** Sets the container image pull policy */ + withImagePullPolicy(pullPolicy: ImagePullPolicy): PgAdminContainerResourcePromise; + /** Configures the resource to be published as a container */ + publishAsContainer(): PgAdminContainerResourcePromise; + /** Configures the resource to use a Dockerfile */ + withDockerfile(contextPath: string, options?: WithDockerfileOptions): PgAdminContainerResourcePromise; + /** Sets the container name */ + withContainerName(name: string): PgAdminContainerResourcePromise; + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource | Awaitable): PgAdminContainerResourcePromise; + /** Adds a build secret from a parameter resource */ + withBuildSecret(name: string, value: Awaitable): PgAdminContainerResourcePromise; + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): PgAdminContainerResourcePromise; + /** Configures endpoint proxy support */ + withEndpointProxySupport(proxyEnabled: boolean): PgAdminContainerResourcePromise; + /** Configures the resource to use a programmatically generated Dockerfile */ + withDockerfileBuilder(contextPath: string, callback: (arg: DockerfileBuilderCallbackContext) => Promise, options?: WithDockerfileBuilderOptions): PgAdminContainerResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): PgAdminContainerResourcePromise; + /** Adds a network alias for the container */ + withContainerNetworkAlias(alias: string): PgAdminContainerResourcePromise; + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): PgAdminContainerResourcePromise; + /** Configures OTLP telemetry export */ + withOtlpExporter(options?: WithOtlpExporterOptions): PgAdminContainerResourcePromise; + /** Publishes the resource as a connection string */ + publishAsConnectionString(): PgAdminContainerResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): PgAdminContainerResourcePromise; + /** Sets an environment variable */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): PgAdminContainerResourcePromise; + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): PgAdminContainerResourcePromise; + /** Adds arguments */ + withArgs(args: string[]): PgAdminContainerResourcePromise; + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): PgAdminContainerResourcePromise; + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): PgAdminContainerResourcePromise; + /** Adds a reference to another resource */ + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): PgAdminContainerResourcePromise; + /** Updates a named endpoint via callback */ + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): PgAdminContainerResourcePromise; + /** Updates an HTTP endpoint via callback */ + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): PgAdminContainerResourcePromise; + /** Updates an HTTPS endpoint via callback */ + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): PgAdminContainerResourcePromise; + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): PgAdminContainerResourcePromise; + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): PgAdminContainerResourcePromise; + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): PgAdminContainerResourcePromise; + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): PgAdminContainerResourcePromise; + /** Gets an endpoint reference */ + getEndpoint(name: string): Promise; + /** Configures resource for HTTP/2 */ + asHttp2Service(): PgAdminContainerResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): PgAdminContainerResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): PgAdminContainerResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): PgAdminContainerResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): PgAdminContainerResourcePromise; + /** Waits for another resource to be ready */ + waitFor(dependency: Awaitable, options?: WaitForOptions): PgAdminContainerResourcePromise; + /** Waits for another resource to start */ + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): PgAdminContainerResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): PgAdminContainerResourcePromise; + /** Waits for resource completion */ + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): PgAdminContainerResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): PgAdminContainerResourcePromise; + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): PgAdminContainerResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): PgAdminContainerResourcePromise; + /** Adds an HTTP resource command */ + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): PgAdminContainerResourcePromise; + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): PgAdminContainerResourcePromise; + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): PgAdminContainerResourcePromise; + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): PgAdminContainerResourcePromise; + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): PgAdminContainerResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): PgAdminContainerResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): PgAdminContainerResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): PgAdminContainerResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): PgAdminContainerResourcePromise; + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): PgAdminContainerResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): PgAdminContainerResourcePromise; + /** Sets image push options via callback */ + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): PgAdminContainerResourcePromise; + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): PgAdminContainerResourcePromise; + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): PgAdminContainerResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): PgAdminContainerResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): PgAdminContainerResourcePromise; + /** Adds a volume */ + withVolume(target: string, options?: WithVolumeOptions): PgAdminContainerResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): PgAdminContainerResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): PgAdminContainerResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): PgAdminContainerResourcePromise; + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): PgAdminContainerResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): PgAdminContainerResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Create a new reference, while also allowing customization of how a resource appears in the generated LikeC4 diagram. */ + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): PgAdminContainerResourcePromise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): PgAdminContainerResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): PgAdminContainerResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): PgAdminContainerResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): PgAdminContainerResourcePromise; + /** Associates an Azure user-assigned identity with a compute resource */ + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): PgAdminContainerResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): PgAdminContainerResourcePromise; + /** Sets the host port for pgAdmin */ + withHostPort(options?: WithHostPortOptions): PgAdminContainerResourcePromise; +} + +export interface PgAdminContainerResourcePromise extends PromiseLike { + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): PgAdminContainerResourcePromise; + /** Adds a bind mount */ + withBindMount(source: string, target: string, options?: WithBindMountOptions): PgAdminContainerResourcePromise; + /** Sets the container entrypoint */ + withEntrypoint(entrypoint: string): PgAdminContainerResourcePromise; + /** Sets the container image tag */ + withImageTag(tag: string): PgAdminContainerResourcePromise; + /** Sets the container image registry */ + withImageRegistry(registry: string): PgAdminContainerResourcePromise; + /** Sets the container image */ + withImage(image: string, options?: WithImageOptions): PgAdminContainerResourcePromise; + /** Sets the image SHA256 digest */ + withImageSHA256(sha256: string): PgAdminContainerResourcePromise; + /** Adds runtime arguments for the container */ + withContainerRuntimeArgs(args: string[]): PgAdminContainerResourcePromise; + /** Sets the lifetime behavior of the container resource */ + withLifetime(lifetime: ContainerLifetime): PgAdminContainerResourcePromise; + /** Sets the container image pull policy */ + withImagePullPolicy(pullPolicy: ImagePullPolicy): PgAdminContainerResourcePromise; + /** Configures the resource to be published as a container */ + publishAsContainer(): PgAdminContainerResourcePromise; + /** Configures the resource to use a Dockerfile */ + withDockerfile(contextPath: string, options?: WithDockerfileOptions): PgAdminContainerResourcePromise; + /** Sets the container name */ + withContainerName(name: string): PgAdminContainerResourcePromise; + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource | Awaitable): PgAdminContainerResourcePromise; + /** Adds a build secret from a parameter resource */ + withBuildSecret(name: string, value: Awaitable): PgAdminContainerResourcePromise; + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): PgAdminContainerResourcePromise; + /** Configures endpoint proxy support */ + withEndpointProxySupport(proxyEnabled: boolean): PgAdminContainerResourcePromise; + /** Configures the resource to use a programmatically generated Dockerfile */ + withDockerfileBuilder(contextPath: string, callback: (arg: DockerfileBuilderCallbackContext) => Promise, options?: WithDockerfileBuilderOptions): PgAdminContainerResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): PgAdminContainerResourcePromise; + /** Adds a network alias for the container */ + withContainerNetworkAlias(alias: string): PgAdminContainerResourcePromise; + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): PgAdminContainerResourcePromise; + /** Configures OTLP telemetry export */ + withOtlpExporter(options?: WithOtlpExporterOptions): PgAdminContainerResourcePromise; + /** Publishes the resource as a connection string */ + publishAsConnectionString(): PgAdminContainerResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): PgAdminContainerResourcePromise; + /** Sets an environment variable */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): PgAdminContainerResourcePromise; + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): PgAdminContainerResourcePromise; + /** Adds arguments */ + withArgs(args: string[]): PgAdminContainerResourcePromise; + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): PgAdminContainerResourcePromise; + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): PgAdminContainerResourcePromise; + /** Adds a reference to another resource */ + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): PgAdminContainerResourcePromise; + /** Updates a named endpoint via callback */ + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): PgAdminContainerResourcePromise; + /** Updates an HTTP endpoint via callback */ + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): PgAdminContainerResourcePromise; + /** Updates an HTTPS endpoint via callback */ + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): PgAdminContainerResourcePromise; + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): PgAdminContainerResourcePromise; + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): PgAdminContainerResourcePromise; + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): PgAdminContainerResourcePromise; + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): PgAdminContainerResourcePromise; + /** Gets an endpoint reference */ + getEndpoint(name: string): Promise; + /** Configures resource for HTTP/2 */ + asHttp2Service(): PgAdminContainerResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): PgAdminContainerResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): PgAdminContainerResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): PgAdminContainerResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): PgAdminContainerResourcePromise; + /** Waits for another resource to be ready */ + waitFor(dependency: Awaitable, options?: WaitForOptions): PgAdminContainerResourcePromise; + /** Waits for another resource to start */ + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): PgAdminContainerResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): PgAdminContainerResourcePromise; + /** Waits for resource completion */ + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): PgAdminContainerResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): PgAdminContainerResourcePromise; + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): PgAdminContainerResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): PgAdminContainerResourcePromise; + /** Adds an HTTP resource command */ + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): PgAdminContainerResourcePromise; + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): PgAdminContainerResourcePromise; + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): PgAdminContainerResourcePromise; + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): PgAdminContainerResourcePromise; + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): PgAdminContainerResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): PgAdminContainerResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): PgAdminContainerResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): PgAdminContainerResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): PgAdminContainerResourcePromise; + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): PgAdminContainerResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): PgAdminContainerResourcePromise; + /** Sets image push options via callback */ + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): PgAdminContainerResourcePromise; + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): PgAdminContainerResourcePromise; + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): PgAdminContainerResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): PgAdminContainerResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): PgAdminContainerResourcePromise; + /** Adds a volume */ + withVolume(target: string, options?: WithVolumeOptions): PgAdminContainerResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): PgAdminContainerResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): PgAdminContainerResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): PgAdminContainerResourcePromise; + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): PgAdminContainerResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): PgAdminContainerResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Create a new reference, while also allowing customization of how a resource appears in the generated LikeC4 diagram. */ + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): PgAdminContainerResourcePromise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): PgAdminContainerResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): PgAdminContainerResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): PgAdminContainerResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): PgAdminContainerResourcePromise; + /** Associates an Azure user-assigned identity with a compute resource */ + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): PgAdminContainerResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): PgAdminContainerResourcePromise; + /** Sets the host port for pgAdmin */ + withHostPort(options?: WithHostPortOptions): PgAdminContainerResourcePromise; +} + +// ============================================================================ +// PgAdminContainerResourceImpl +// ============================================================================ + +class PgAdminContainerResourceImpl extends ResourceBuilderBase implements PgAdminContainerResource { + constructor(handle: PgAdminContainerResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: Awaitable): Promise { + registry = isPromiseLike(registry) ? await registry : registry; + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withContainerRegistry(registry: Awaitable): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._withContainerRegistryInternal(registry), this._client); + } + + /** @internal */ + private async _withBindMountInternal(source: string, target: string, isReadOnly?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, source, target }; + if (isReadOnly !== undefined) rpcArgs.isReadOnly = isReadOnly; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBindMount', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withBindMount(source: string, target: string, options?: WithBindMountOptions): PgAdminContainerResourcePromise { + const isReadOnly = options?.isReadOnly; + return new PgAdminContainerResourcePromiseImpl(this._withBindMountInternal(source, target, isReadOnly), this._client); + } + + /** @internal */ + private async _withEntrypointInternal(entrypoint: string): Promise { + const rpcArgs: Record = { builder: this._handle, entrypoint }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEntrypoint', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withEntrypoint(entrypoint: string): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._withEntrypointInternal(entrypoint), this._client); + } + + /** @internal */ + private async _withImageTagInternal(tag: string): Promise { + const rpcArgs: Record = { builder: this._handle, tag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImageTag', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withImageTag(tag: string): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._withImageTagInternal(tag), this._client); + } + + /** @internal */ + private async _withImageRegistryInternal(registry: string): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImageRegistry', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withImageRegistry(registry: string): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._withImageRegistryInternal(registry), this._client); + } + + /** @internal */ + private async _withImageInternal(image: string, tag?: string): Promise { + const rpcArgs: Record = { builder: this._handle, image }; + if (tag !== undefined) rpcArgs.tag = tag; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImage', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withImage(image: string, options?: WithImageOptions): PgAdminContainerResourcePromise { + const tag = options?.tag; + return new PgAdminContainerResourcePromiseImpl(this._withImageInternal(image, tag), this._client); + } + + /** @internal */ + private async _withImageSHA256Internal(sha256: string): Promise { + const rpcArgs: Record = { builder: this._handle, sha256 }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImageSHA256', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withImageSHA256(sha256: string): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._withImageSHA256Internal(sha256), this._client); + } + + /** @internal */ + private async _withContainerRuntimeArgsInternal(args: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, args }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRuntimeArgs', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withContainerRuntimeArgs(args: string[]): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._withContainerRuntimeArgsInternal(args), this._client); + } + + /** @internal */ + private async _withLifetimeInternal(lifetime: ContainerLifetime): Promise { + const rpcArgs: Record = { builder: this._handle, lifetime }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withLifetime', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withLifetime(lifetime: ContainerLifetime): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._withLifetimeInternal(lifetime), this._client); + } + + /** @internal */ + private async _withImagePullPolicyInternal(pullPolicy: ImagePullPolicy): Promise { + const rpcArgs: Record = { builder: this._handle, pullPolicy }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImagePullPolicy', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withImagePullPolicy(pullPolicy: ImagePullPolicy): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._withImagePullPolicyInternal(pullPolicy), this._client); + } + + /** @internal */ + private async _publishAsContainerInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsContainer', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + publishAsContainer(): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._publishAsContainerInternal(), this._client); + } + + /** @internal */ + private async _withDockerfileInternal(contextPath: string, dockerfilePath?: string, stage?: string): Promise { + const rpcArgs: Record = { builder: this._handle, contextPath }; + if (dockerfilePath !== undefined) rpcArgs.dockerfilePath = dockerfilePath; + if (stage !== undefined) rpcArgs.stage = stage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfile', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withDockerfile(contextPath: string, options?: WithDockerfileOptions): PgAdminContainerResourcePromise { + const dockerfilePath = options?.dockerfilePath; + const stage = options?.stage; + return new PgAdminContainerResourcePromiseImpl(this._withDockerfileInternal(contextPath, dockerfilePath, stage), this._client); + } + + /** @internal */ + private async _withContainerNameInternal(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerName', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withContainerName(name: string): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._withContainerNameInternal(name), this._client); + } + + /** @internal */ + private async _withBuildArgInternal(name: string, value: string | ParameterResource | Awaitable): Promise { + value = isPromiseLike(value) ? await value : value; + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuildArg', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withBuildArg(name: string, value: string | ParameterResource | Awaitable): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._withBuildArgInternal(name, value), this._client); + } + + /** @internal */ + private async _withBuildSecretInternal(name: string, value: Awaitable): Promise { + value = isPromiseLike(value) ? await value : value; + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParameterBuildSecret', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withBuildSecret(name: string, value: Awaitable): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._withBuildSecretInternal(name, value), this._client); + } + + /** @internal */ + private async _withContainerCertificatePathsInternal(customCertificatesDestination?: string, defaultCertificateBundlePaths?: string[], defaultCertificateDirectoryPaths?: string[]): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (customCertificatesDestination !== undefined) rpcArgs.customCertificatesDestination = customCertificatesDestination; + if (defaultCertificateBundlePaths !== undefined) rpcArgs.defaultCertificateBundlePaths = defaultCertificateBundlePaths; + if (defaultCertificateDirectoryPaths !== undefined) rpcArgs.defaultCertificateDirectoryPaths = defaultCertificateDirectoryPaths; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerCertificatePaths', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): PgAdminContainerResourcePromise { + const customCertificatesDestination = options?.customCertificatesDestination; + const defaultCertificateBundlePaths = options?.defaultCertificateBundlePaths; + const defaultCertificateDirectoryPaths = options?.defaultCertificateDirectoryPaths; + return new PgAdminContainerResourcePromiseImpl(this._withContainerCertificatePathsInternal(customCertificatesDestination, defaultCertificateBundlePaths, defaultCertificateDirectoryPaths), this._client); + } + + /** @internal */ + private async _withEndpointProxySupportInternal(proxyEnabled: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, proxyEnabled }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpointProxySupport', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withEndpointProxySupport(proxyEnabled: boolean): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._withEndpointProxySupportInternal(proxyEnabled), this._client); + } + + /** @internal */ + private async _withDockerfileBuilderInternal(contextPath: string, callback: (arg: DockerfileBuilderCallbackContext) => Promise, stage?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as DockerfileBuilderCallbackContextHandle; + const arg = new DockerfileBuilderCallbackContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, contextPath, callback: callbackId }; + if (stage !== undefined) rpcArgs.stage = stage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBuilder', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withDockerfileBuilder(contextPath: string, callback: (arg: DockerfileBuilderCallbackContext) => Promise, options?: WithDockerfileBuilderOptions): PgAdminContainerResourcePromise { + const stage = options?.stage; + return new PgAdminContainerResourcePromiseImpl(this._withDockerfileBuilderInternal(contextPath, callback, stage), this._client); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): PgAdminContainerResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new PgAdminContainerResourcePromiseImpl(this._withDockerfileBaseImageInternal(buildImage, runtimeImage), this._client); + } + + /** @internal */ + private async _withContainerNetworkAliasInternal(alias: string): Promise { + const rpcArgs: Record = { builder: this._handle, alias }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerNetworkAlias', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withContainerNetworkAlias(alias: string): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._withContainerNetworkAliasInternal(alias), this._client); + } + + /** @internal */ + private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withMcpServer', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withMcpServer(options?: WithMcpServerOptions): PgAdminContainerResourcePromise { + const path = options?.path; + const endpointName = options?.endpointName; + return new PgAdminContainerResourcePromiseImpl(this._withMcpServerInternal(path, endpointName), this._client); + } + + /** @internal */ + private async _withOtlpExporterInternal(protocol?: OtlpProtocol): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (protocol !== undefined) rpcArgs.protocol = protocol; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporter', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withOtlpExporter(options?: WithOtlpExporterOptions): PgAdminContainerResourcePromise { + const protocol = options?.protocol; + return new PgAdminContainerResourcePromiseImpl(this._withOtlpExporterInternal(protocol), this._client); + } + + /** @internal */ + private async _publishAsConnectionStringInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsConnectionString', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + publishAsConnectionString(): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._publishAsConnectionStringInternal(), this._client); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): PgAdminContainerResourcePromise { + const helpLink = options?.helpLink; + return new PgAdminContainerResourcePromiseImpl(this._withRequiredCommandInternal(command, helpLink), this._client); + } + + /** @internal */ + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): Promise { + value = isPromiseLike(value) ? await value : value; + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironment', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._withEnvironmentInternal(name, value), this._client); + } + + /** @internal */ + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentCallback', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._withEnvironmentCallbackInternal(callback), this._client); + } + + /** @internal */ + private async _withArgsInternal(args: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, args }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgs', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withArgs(args: string[]): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._withArgsInternal(args), this._client); + } + + /** @internal */ + private async _withArgsCallbackInternal(callback: (obj: CommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; + const obj = new CommandLineArgsCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallback', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._withArgsCallbackInternal(callback), this._client); + } + + /** @internal */ + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceEnvironment', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._withReferenceEnvironmentInternal(options), this._client); + } + + /** @internal */ + private async _withReferenceInternal(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, connectionName?: string, optional?: boolean, name?: string): Promise { + source = isPromiseLike(source) ? await source : source; + const rpcArgs: Record = { builder: this._handle, source }; + if (connectionName !== undefined) rpcArgs.connectionName = connectionName; + if (optional !== undefined) rpcArgs.optional = optional; + if (name !== undefined) rpcArgs.name = name; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReference', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): PgAdminContainerResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new PgAdminContainerResourcePromiseImpl(this._withReferenceInternal(source, connectionName, optional, name), this._client); + } + + /** @internal */ + private async _withEndpointCallbackInternal(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpointCallback', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): PgAdminContainerResourcePromise { + const createIfNotExists = options?.createIfNotExists; + return new PgAdminContainerResourcePromiseImpl(this._withEndpointCallbackInternal(endpointName, callback, createIfNotExists), this._client); + } + + /** @internal */ + private async _withHttpEndpointCallbackInternal(callback: (obj: EndpointUpdateContext) => Promise, name?: string, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + if (name !== undefined) rpcArgs.name = name; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpEndpointCallback', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): PgAdminContainerResourcePromise { + const name = options?.name; + const createIfNotExists = options?.createIfNotExists; + return new PgAdminContainerResourcePromiseImpl(this._withHttpEndpointCallbackInternal(callback, name, createIfNotExists), this._client); + } + + /** @internal */ + private async _withHttpsEndpointCallbackInternal(callback: (obj: EndpointUpdateContext) => Promise, name?: string, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + if (name !== undefined) rpcArgs.name = name; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsEndpointCallback', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): PgAdminContainerResourcePromise { + const name = options?.name; + const createIfNotExists = options?.createIfNotExists; + return new PgAdminContainerResourcePromiseImpl(this._withHttpsEndpointCallbackInternal(callback, name, createIfNotExists), this._client); + } + + /** @internal */ + private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (scheme !== undefined) rpcArgs.scheme = scheme; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + if (isExternal !== undefined) rpcArgs.isExternal = isExternal; + if (protocol !== undefined) rpcArgs.protocol = protocol; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpoint', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withEndpoint(options?: WithEndpointOptions): PgAdminContainerResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const scheme = options?.scheme; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + const isExternal = options?.isExternal; + const protocol = options?.protocol; + return new PgAdminContainerResourcePromiseImpl(this._withEndpointInternal(port, targetPort, scheme, name, env, isProxied, isExternal, protocol), this._client); + } + + /** @internal */ + private async _withHttpEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpEndpoint', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withHttpEndpoint(options?: WithHttpEndpointOptions): PgAdminContainerResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new PgAdminContainerResourcePromiseImpl(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied), this._client); + } + + /** @internal */ + private async _withHttpsEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsEndpoint', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withHttpsEndpoint(options?: WithHttpsEndpointOptions): PgAdminContainerResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new PgAdminContainerResourcePromiseImpl(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied), this._client); + } + + /** @internal */ + private async _withExternalHttpEndpointsInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExternalHttpEndpoints', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withExternalHttpEndpoints(): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._withExternalHttpEndpointsInternal(), this._client); + } + + async getEndpoint(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getEndpoint', + rpcArgs + ); + } + + /** @internal */ + private async _asHttp2ServiceInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/asHttp2Service', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + asHttp2Service(): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._asHttp2ServiceInternal(), this._client); + } + + /** @internal */ + private async _withUrlsInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrls', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._withUrlsInternal(callback), this._client); + } + + /** @internal */ + private async _withUrlInternal(url: string | ReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): PgAdminContainerResourcePromise { + const displayText = options?.displayText; + return new PgAdminContainerResourcePromiseImpl(this._withUrlInternal(url, displayText), this._client); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._withUrlForEndpointInternal(endpointName, callback), this._client); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + excludeFromManifest(): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._excludeFromManifestInternal(), this._client); + } + + /** @internal */ + private async _waitForInternal(dependency: Awaitable, waitBehavior?: WaitBehavior): Promise { + dependency = isPromiseLike(dependency) ? await dependency : dependency; + const rpcArgs: Record = { builder: this._handle, dependency }; + if (waitBehavior !== undefined) rpcArgs.waitBehavior = waitBehavior; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitFor', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + waitFor(dependency: Awaitable, options?: WaitForOptions): PgAdminContainerResourcePromise { + const waitBehavior = options?.waitBehavior; + return new PgAdminContainerResourcePromiseImpl(this._waitForInternal(dependency, waitBehavior), this._client); + } + + /** @internal */ + private async _waitForStartInternal(dependency: Awaitable, waitBehavior?: WaitBehavior): Promise { + dependency = isPromiseLike(dependency) ? await dependency : dependency; + const rpcArgs: Record = { builder: this._handle, dependency }; + if (waitBehavior !== undefined) rpcArgs.waitBehavior = waitBehavior; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStart', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): PgAdminContainerResourcePromise { + const waitBehavior = options?.waitBehavior; + return new PgAdminContainerResourcePromiseImpl(this._waitForStartInternal(dependency, waitBehavior), this._client); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withExplicitStart(): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._withExplicitStartInternal(), this._client); + } + + /** @internal */ + private async _waitForCompletionInternal(dependency: Awaitable, exitCode?: number): Promise { + dependency = isPromiseLike(dependency) ? await dependency : dependency; + const rpcArgs: Record = { builder: this._handle, dependency }; + if (exitCode !== undefined) rpcArgs.exitCode = exitCode; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceCompletion', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): PgAdminContainerResourcePromise { + const exitCode = options?.exitCode; + return new PgAdminContainerResourcePromiseImpl(this._waitForCompletionInternal(dependency, exitCode), this._client); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withHealthCheck(key: string): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._withHealthCheckInternal(key), this._client); + } + + /** @internal */ + private async _withHttpHealthCheckInternal(path?: string, statusCode?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (statusCode !== undefined) rpcArgs.statusCode = statusCode; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpHealthCheck', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): PgAdminContainerResourcePromise { + const path = options?.path; + const statusCode = options?.statusCode; + const endpointName = options?.endpointName; + return new PgAdminContainerResourcePromiseImpl(this._withHttpHealthCheckInternal(path, statusCode, endpointName), this._client); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContextImpl(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): PgAdminContainerResourcePromise { + const commandOptions = options?.commandOptions; + return new PgAdminContainerResourcePromiseImpl(this._withCommandInternal(name, displayName, executeCommand, commandOptions), this._client); + } + + /** @internal */ + private async _withHttpCommandInternal(path: string, displayName: string, options?: HttpCommandExportOptions): Promise { + const rpcArgs: Record = { builder: this._handle, path, displayName }; + if (options !== undefined) rpcArgs.options = options; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpCommand', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._withHttpCommandInternal(path, displayName, options), this._client); + } + + /** @internal */ + private async _withDeveloperCertificateTrustInternal(trust: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, trust }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDeveloperCertificateTrust', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withDeveloperCertificateTrust(trust: boolean): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._withDeveloperCertificateTrustInternal(trust), this._client); + } + + /** @internal */ + private async _withCertificateTrustScopeInternal(scope: CertificateTrustScope): Promise { + const rpcArgs: Record = { builder: this._handle, scope }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCertificateTrustScope', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withCertificateTrustScope(scope: CertificateTrustScope): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._withCertificateTrustScopeInternal(scope), this._client); + } + + /** @internal */ + private async _withHttpsDeveloperCertificateInternal(password?: Awaitable): Promise { + password = isPromiseLike(password) ? await password : password; + const rpcArgs: Record = { builder: this._handle }; + if (password !== undefined) rpcArgs.password = password; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): PgAdminContainerResourcePromise { + let password = options?.password; + return new PgAdminContainerResourcePromiseImpl(this._withHttpsDeveloperCertificateInternal(password), this._client); + } + + /** @internal */ + private async _withoutHttpsCertificateInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withoutHttpsCertificate', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withoutHttpsCertificate(): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._withoutHttpsCertificateInternal(), this._client); + } + + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: Awaitable, type: string): Promise { + resourceBuilder = isPromiseLike(resourceBuilder) ? await resourceBuilder : resourceBuilder; + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._withRelationshipInternal(resourceBuilder, type), this._client); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: Awaitable): Promise { + parent = isPromiseLike(parent) ? await parent : parent; + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withParentRelationship(parent: Awaitable): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._withParentRelationshipInternal(parent), this._client); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: Awaitable): Promise { + child = isPromiseLike(child) ? await child : child; + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withChildRelationship(child: Awaitable): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._withChildRelationshipInternal(child), this._client); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): PgAdminContainerResourcePromise { + const iconVariant = options?.iconVariant; + return new PgAdminContainerResourcePromiseImpl(this._withIconNameInternal(iconName, iconVariant), this._client); + } + + /** @internal */ + private async _withHttpProbeInternal(probeType: ProbeType, path?: string, initialDelaySeconds?: number, periodSeconds?: number, timeoutSeconds?: number, failureThreshold?: number, successThreshold?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, probeType }; + if (path !== undefined) rpcArgs.path = path; + if (initialDelaySeconds !== undefined) rpcArgs.initialDelaySeconds = initialDelaySeconds; + if (periodSeconds !== undefined) rpcArgs.periodSeconds = periodSeconds; + if (timeoutSeconds !== undefined) rpcArgs.timeoutSeconds = timeoutSeconds; + if (failureThreshold !== undefined) rpcArgs.failureThreshold = failureThreshold; + if (successThreshold !== undefined) rpcArgs.successThreshold = successThreshold; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpProbe', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): PgAdminContainerResourcePromise { + const path = options?.path; + const initialDelaySeconds = options?.initialDelaySeconds; + const periodSeconds = options?.periodSeconds; + const timeoutSeconds = options?.timeoutSeconds; + const failureThreshold = options?.failureThreshold; + const successThreshold = options?.successThreshold; + const endpointName = options?.endpointName; + return new PgAdminContainerResourcePromiseImpl(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName), this._client); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + excludeFromMcp(): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._excludeFromMcpInternal(), this._client); + } + + /** @internal */ + private async _withImagePushOptionsInternal(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ContainerImagePushOptionsCallbackContextHandle; + const arg = new ContainerImagePushOptionsCallbackContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImagePushOptions', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._withImagePushOptionsInternal(callback), this._client); + } + + /** @internal */ + private async _withRemoteImageNameInternal(remoteImageName: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageName', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withRemoteImageName(remoteImageName: string): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._withRemoteImageNameInternal(remoteImageName), this._client); + } + + /** @internal */ + private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageTag', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withRemoteImageTag(remoteImageTag: string): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._withRemoteImageTagInternal(remoteImageTag), this._client); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): PgAdminContainerResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new PgAdminContainerResourcePromiseImpl(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description), this._client); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._withPipelineConfigurationInternal(callback), this._client); + } + + /** @internal */ + private async _withVolumeInternal(target: string, name?: string, isReadOnly?: boolean): Promise { + const rpcArgs: Record = { resource: this._handle, target }; + if (name !== undefined) rpcArgs.name = name; + if (isReadOnly !== undefined) rpcArgs.isReadOnly = isReadOnly; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withVolume', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withVolume(target: string, options?: WithVolumeOptions): PgAdminContainerResourcePromise { + const name = options?.name; + const isReadOnly = options?.isReadOnly; + return new PgAdminContainerResourcePromiseImpl(this._withVolumeInternal(target, name, isReadOnly), this._client); + } + + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); + } + + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._onBeforeResourceStartedInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._onResourceStoppedInternal(callback), this._client); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._onInitializeResourceInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceEndpointsAllocated', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._onResourceEndpointsAllocatedInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._onResourceReadyInternal(callback), this._client); + } + + async createExecutionConfiguration(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/createExecutionConfiguration', + rpcArgs + ); + } + + /** @internal */ + private async _withLikeC4ReferenceWithEnvironmentInternal(source: Awaitable, configure?: (obj: LikeC4RelationshipDetailsAnnotation) => Promise, connectionName?: string, optional?: boolean, skipAspireReference?: boolean): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4RelationshipDetailsAnnotationHandle; + const obj = new LikeC4RelationshipDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + source = isPromiseLike(source) ? await source : source; + const rpcArgs: Record = { builder: this._handle, source }; + if (configure !== undefined) rpcArgs.configure = configureId; + if (connectionName !== undefined) rpcArgs.connectionName = connectionName; + if (optional !== undefined) rpcArgs.optional = optional; + if (skipAspireReference !== undefined) rpcArgs.skipAspireReference = skipAspireReference; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4ReferenceWithEnvironment', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): PgAdminContainerResourcePromise { + const configure = options?.configure; + const connectionName = options?.connectionName; + const optional = options?.optional; + const skipAspireReference = options?.skipAspireReference; + return new PgAdminContainerResourcePromiseImpl(this._withLikeC4ReferenceWithEnvironmentInternal(source, configure, connectionName, optional, skipAspireReference), this._client); + } + + /** @internal */ + private async _withLikeC4DetailsInternal(label?: string, technology?: string, description?: string, summary?: string, icon?: string, configure?: (obj: LikeC4NodeDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4NodeDetailsAnnotationHandle; + const obj = new LikeC4NodeDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + const rpcArgs: Record = { builder: this._handle }; + if (label !== undefined) rpcArgs.label = label; + if (technology !== undefined) rpcArgs.technology = technology; + if (description !== undefined) rpcArgs.description = description; + if (summary !== undefined) rpcArgs.summary = summary; + if (icon !== undefined) rpcArgs.icon = icon; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4DetailsParameters', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): PgAdminContainerResourcePromise { + const label = options?.label; + const technology = options?.technology; + const description = options?.description; + const summary = options?.summary; + const icon = options?.icon; + const configure = options?.configure; + return new PgAdminContainerResourcePromiseImpl(this._withLikeC4DetailsInternal(label, technology, description, summary, icon, configure), this._client); + } + + /** @internal */ + private async _withLikeC4ReferenceInternal(target: Awaitable, configure?: (obj: LikeC4RelationshipDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4RelationshipDetailsAnnotationHandle; + const obj = new LikeC4RelationshipDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target }; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Reference', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): PgAdminContainerResourcePromise { + const configure = options?.configure; + return new PgAdminContainerResourcePromiseImpl(this._withLikeC4ReferenceInternal(target, configure), this._client); + } + + /** @internal */ + private async _withLikeC4GroupInternal(groupName: string): Promise { + const rpcArgs: Record = { builder: this._handle, groupName }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Group', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withLikeC4Group(groupName: string): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._withLikeC4GroupInternal(groupName), this._client); + } + + /** @internal */ + private async _excludeFromLikeC4Internal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/excludeFromLikeC4', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + excludeFromLikeC4(): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._excludeFromLikeC4Internal(), this._client); + } + + /** @internal */ + private async _withAzureUserAssignedIdentityInternal(identityResourceBuilder: Awaitable): Promise { + identityResourceBuilder = isPromiseLike(identityResourceBuilder) ? await identityResourceBuilder : identityResourceBuilder; + const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._withAzureUserAssignedIdentityInternal(identityResourceBuilder), this._client); + } + + /** @internal */ + private async _withRoleAssignmentsInternal(target: Awaitable, roles: AzureKeyVaultRole[]): Promise { + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target, roles }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.KeyVault/withKeyVaultRoleAssignments', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._withRoleAssignmentsInternal(target, roles), this._client); + } + + /** @internal */ + private async _withHostPortInternal(port?: number): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.PostgreSQL/withPgAdminHostPort', + rpcArgs + ); + return new PgAdminContainerResourceImpl(result, this._client); + } + + withHostPort(options?: WithHostPortOptions): PgAdminContainerResourcePromise { + const port = options?.port; + return new PgAdminContainerResourcePromiseImpl(this._withHostPortInternal(port), this._client); + } + +} + +/** + * Thenable wrapper for PgAdminContainerResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +class PgAdminContainerResourcePromiseImpl implements PgAdminContainerResourcePromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: PgAdminContainerResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + withContainerRegistry(registry: Awaitable): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withContainerRegistry(registry)), this._client); + } + + withBindMount(source: string, target: string, options?: WithBindMountOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withBindMount(source, target, options)), this._client); + } + + withEntrypoint(entrypoint: string): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withEntrypoint(entrypoint)), this._client); + } + + withImageTag(tag: string): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withImageTag(tag)), this._client); + } + + withImageRegistry(registry: string): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withImageRegistry(registry)), this._client); + } + + withImage(image: string, options?: WithImageOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withImage(image, options)), this._client); + } + + withImageSHA256(sha256: string): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withImageSHA256(sha256)), this._client); + } + + withContainerRuntimeArgs(args: string[]): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withContainerRuntimeArgs(args)), this._client); + } + + withLifetime(lifetime: ContainerLifetime): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withLifetime(lifetime)), this._client); + } + + withImagePullPolicy(pullPolicy: ImagePullPolicy): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withImagePullPolicy(pullPolicy)), this._client); + } + + publishAsContainer(): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.publishAsContainer()), this._client); + } + + withDockerfile(contextPath: string, options?: WithDockerfileOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withDockerfile(contextPath, options)), this._client); + } + + withContainerName(name: string): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withContainerName(name)), this._client); + } + + withBuildArg(name: string, value: string | ParameterResource | Awaitable): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withBuildArg(name, value)), this._client); + } + + withBuildSecret(name: string, value: Awaitable): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withBuildSecret(name, value)), this._client); + } + + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withContainerCertificatePaths(options)), this._client); + } + + withEndpointProxySupport(proxyEnabled: boolean): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withEndpointProxySupport(proxyEnabled)), this._client); + } + + withDockerfileBuilder(contextPath: string, callback: (arg: DockerfileBuilderCallbackContext) => Promise, options?: WithDockerfileBuilderOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withDockerfileBuilder(contextPath, callback, options)), this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withDockerfileBaseImage(options)), this._client); + } + + withContainerNetworkAlias(alias: string): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withContainerNetworkAlias(alias)), this._client); + } + + withMcpServer(options?: WithMcpServerOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withMcpServer(options)), this._client); + } + + withOtlpExporter(options?: WithOtlpExporterOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withOtlpExporter(options)), this._client); + } + + publishAsConnectionString(): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.publishAsConnectionString()), this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withRequiredCommand(command, options)), this._client); + } + + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withEnvironment(name, value)), this._client); + } + + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentCallback(callback)), this._client); + } + + withArgs(args: string[]): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withArgs(args)), this._client); + } + + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withArgsCallback(callback)), this._client); + } + + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withReferenceEnvironment(options)), this._client); + } + + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withReference(source, options)), this._client); + } + + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withEndpointCallback(endpointName, callback, options)), this._client); + } + + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withHttpEndpointCallback(callback, options)), this._client); + } + + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withHttpsEndpointCallback(callback, options)), this._client); + } + + withEndpoint(options?: WithEndpointOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withEndpoint(options)), this._client); + } + + withHttpEndpoint(options?: WithHttpEndpointOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withHttpEndpoint(options)), this._client); + } + + withHttpsEndpoint(options?: WithHttpsEndpointOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withHttpsEndpoint(options)), this._client); + } + + withExternalHttpEndpoints(): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withExternalHttpEndpoints()), this._client); + } + + getEndpoint(name: string): Promise { + return this._promise.then(obj => obj.getEndpoint(name)); + } + + asHttp2Service(): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.asHttp2Service()), this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withUrls(callback)), this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withUrl(url, options)), this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback)), this._client); + } + + excludeFromManifest(): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.excludeFromManifest()), this._client); + } + + waitFor(dependency: Awaitable, options?: WaitForOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.waitFor(dependency, options)), this._client); + } + + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.waitForStart(dependency, options)), this._client); + } + + withExplicitStart(): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withExplicitStart()), this._client); + } + + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.waitForCompletion(dependency, options)), this._client); + } + + withHealthCheck(key: string): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withHealthCheck(key)), this._client); + } + + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withHttpHealthCheck(options)), this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options)), this._client); + } + + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withHttpCommand(path, displayName, options)), this._client); + } + + withDeveloperCertificateTrust(trust: boolean): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust)), this._client); + } + + withCertificateTrustScope(scope: CertificateTrustScope): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withCertificateTrustScope(scope)), this._client); + } + + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options)), this._client); + } + + withoutHttpsCertificate(): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withoutHttpsCertificate()), this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withRelationship(resourceBuilder, type)), this._client); + } + + withParentRelationship(parent: Awaitable): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withParentRelationship(parent)), this._client); + } + + withChildRelationship(child: Awaitable): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withChildRelationship(child)), this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withIconName(iconName, options)), this._client); + } + + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withHttpProbe(probeType, options)), this._client); + } + + excludeFromMcp(): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.excludeFromMcp()), this._client); + } + + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withImagePushOptions(callback)), this._client); + } + + withRemoteImageName(remoteImageName: string): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withRemoteImageName(remoteImageName)), this._client); + } + + withRemoteImageTag(remoteImageTag: string): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag)), this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options)), this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withPipelineConfiguration(callback)), this._client); + } + + withVolume(target: string, options?: WithVolumeOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withVolume(target, options)), this._client); + } + + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.onBeforeResourceStarted(callback)), this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.onResourceStopped(callback)), this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.onInitializeResource(callback)), this._client); + } + + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback)), this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.onResourceReady(callback)), this._client); + } + + createExecutionConfiguration(): Promise { + return this._promise.then(obj => obj.createExecutionConfiguration()); + } + + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4ReferenceWithEnvironment(source, options)), this._client); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Details(options)), this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Reference(target, options)), this._client); + } + + withLikeC4Group(groupName: string): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Group(groupName)), this._client); + } + + excludeFromLikeC4(): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.excludeFromLikeC4()), this._client); + } + + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withAzureUserAssignedIdentity(identityResourceBuilder)), this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withRoleAssignments(target, roles)), this._client); + } + + withHostPort(options?: WithHostPortOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromiseImpl(this._promise.then(obj => obj.withHostPort(options)), this._client); + } + +} + +// ============================================================================ +// PgWebContainerResource +// ============================================================================ + +export interface PgWebContainerResource { + toJSON(): MarshalledHandle; + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): PgWebContainerResourcePromise; + /** Adds a bind mount */ + withBindMount(source: string, target: string, options?: WithBindMountOptions): PgWebContainerResourcePromise; + /** Sets the container entrypoint */ + withEntrypoint(entrypoint: string): PgWebContainerResourcePromise; + /** Sets the container image tag */ + withImageTag(tag: string): PgWebContainerResourcePromise; + /** Sets the container image registry */ + withImageRegistry(registry: string): PgWebContainerResourcePromise; + /** Sets the container image */ + withImage(image: string, options?: WithImageOptions): PgWebContainerResourcePromise; + /** Sets the image SHA256 digest */ + withImageSHA256(sha256: string): PgWebContainerResourcePromise; + /** Adds runtime arguments for the container */ + withContainerRuntimeArgs(args: string[]): PgWebContainerResourcePromise; + /** Sets the lifetime behavior of the container resource */ + withLifetime(lifetime: ContainerLifetime): PgWebContainerResourcePromise; + /** Sets the container image pull policy */ + withImagePullPolicy(pullPolicy: ImagePullPolicy): PgWebContainerResourcePromise; + /** Configures the resource to be published as a container */ + publishAsContainer(): PgWebContainerResourcePromise; + /** Configures the resource to use a Dockerfile */ + withDockerfile(contextPath: string, options?: WithDockerfileOptions): PgWebContainerResourcePromise; + /** Sets the container name */ + withContainerName(name: string): PgWebContainerResourcePromise; + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource | Awaitable): PgWebContainerResourcePromise; + /** Adds a build secret from a parameter resource */ + withBuildSecret(name: string, value: Awaitable): PgWebContainerResourcePromise; + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): PgWebContainerResourcePromise; + /** Configures endpoint proxy support */ + withEndpointProxySupport(proxyEnabled: boolean): PgWebContainerResourcePromise; + /** Configures the resource to use a programmatically generated Dockerfile */ + withDockerfileBuilder(contextPath: string, callback: (arg: DockerfileBuilderCallbackContext) => Promise, options?: WithDockerfileBuilderOptions): PgWebContainerResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): PgWebContainerResourcePromise; + /** Adds a network alias for the container */ + withContainerNetworkAlias(alias: string): PgWebContainerResourcePromise; + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): PgWebContainerResourcePromise; + /** Configures OTLP telemetry export */ + withOtlpExporter(options?: WithOtlpExporterOptions): PgWebContainerResourcePromise; + /** Publishes the resource as a connection string */ + publishAsConnectionString(): PgWebContainerResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): PgWebContainerResourcePromise; + /** Sets an environment variable */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): PgWebContainerResourcePromise; + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): PgWebContainerResourcePromise; + /** Adds arguments */ + withArgs(args: string[]): PgWebContainerResourcePromise; + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): PgWebContainerResourcePromise; + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): PgWebContainerResourcePromise; + /** Adds a reference to another resource */ + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): PgWebContainerResourcePromise; + /** Updates a named endpoint via callback */ + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): PgWebContainerResourcePromise; + /** Updates an HTTP endpoint via callback */ + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): PgWebContainerResourcePromise; + /** Updates an HTTPS endpoint via callback */ + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): PgWebContainerResourcePromise; + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): PgWebContainerResourcePromise; + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): PgWebContainerResourcePromise; + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): PgWebContainerResourcePromise; + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): PgWebContainerResourcePromise; + /** Gets an endpoint reference */ + getEndpoint(name: string): Promise; + /** Configures resource for HTTP/2 */ + asHttp2Service(): PgWebContainerResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): PgWebContainerResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): PgWebContainerResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): PgWebContainerResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): PgWebContainerResourcePromise; + /** Waits for another resource to be ready */ + waitFor(dependency: Awaitable, options?: WaitForOptions): PgWebContainerResourcePromise; + /** Waits for another resource to start */ + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): PgWebContainerResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): PgWebContainerResourcePromise; + /** Waits for resource completion */ + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): PgWebContainerResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): PgWebContainerResourcePromise; + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): PgWebContainerResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): PgWebContainerResourcePromise; + /** Adds an HTTP resource command */ + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): PgWebContainerResourcePromise; + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): PgWebContainerResourcePromise; + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): PgWebContainerResourcePromise; + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): PgWebContainerResourcePromise; + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): PgWebContainerResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): PgWebContainerResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): PgWebContainerResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): PgWebContainerResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): PgWebContainerResourcePromise; + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): PgWebContainerResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): PgWebContainerResourcePromise; + /** Sets image push options via callback */ + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): PgWebContainerResourcePromise; + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): PgWebContainerResourcePromise; + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): PgWebContainerResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): PgWebContainerResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): PgWebContainerResourcePromise; + /** Adds a volume */ + withVolume(target: string, options?: WithVolumeOptions): PgWebContainerResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): PgWebContainerResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): PgWebContainerResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): PgWebContainerResourcePromise; + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): PgWebContainerResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): PgWebContainerResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Create a new reference, while also allowing customization of how a resource appears in the generated LikeC4 diagram. */ + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): PgWebContainerResourcePromise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): PgWebContainerResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): PgWebContainerResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): PgWebContainerResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): PgWebContainerResourcePromise; + /** Associates an Azure user-assigned identity with a compute resource */ + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): PgWebContainerResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): PgWebContainerResourcePromise; + /** Sets the host port for pgweb */ + withHostPort(options?: WithHostPortOptions): PgWebContainerResourcePromise; +} + +export interface PgWebContainerResourcePromise extends PromiseLike { + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): PgWebContainerResourcePromise; + /** Adds a bind mount */ + withBindMount(source: string, target: string, options?: WithBindMountOptions): PgWebContainerResourcePromise; + /** Sets the container entrypoint */ + withEntrypoint(entrypoint: string): PgWebContainerResourcePromise; + /** Sets the container image tag */ + withImageTag(tag: string): PgWebContainerResourcePromise; + /** Sets the container image registry */ + withImageRegistry(registry: string): PgWebContainerResourcePromise; + /** Sets the container image */ + withImage(image: string, options?: WithImageOptions): PgWebContainerResourcePromise; + /** Sets the image SHA256 digest */ + withImageSHA256(sha256: string): PgWebContainerResourcePromise; + /** Adds runtime arguments for the container */ + withContainerRuntimeArgs(args: string[]): PgWebContainerResourcePromise; + /** Sets the lifetime behavior of the container resource */ + withLifetime(lifetime: ContainerLifetime): PgWebContainerResourcePromise; + /** Sets the container image pull policy */ + withImagePullPolicy(pullPolicy: ImagePullPolicy): PgWebContainerResourcePromise; + /** Configures the resource to be published as a container */ + publishAsContainer(): PgWebContainerResourcePromise; + /** Configures the resource to use a Dockerfile */ + withDockerfile(contextPath: string, options?: WithDockerfileOptions): PgWebContainerResourcePromise; + /** Sets the container name */ + withContainerName(name: string): PgWebContainerResourcePromise; + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource | Awaitable): PgWebContainerResourcePromise; + /** Adds a build secret from a parameter resource */ + withBuildSecret(name: string, value: Awaitable): PgWebContainerResourcePromise; + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): PgWebContainerResourcePromise; + /** Configures endpoint proxy support */ + withEndpointProxySupport(proxyEnabled: boolean): PgWebContainerResourcePromise; + /** Configures the resource to use a programmatically generated Dockerfile */ + withDockerfileBuilder(contextPath: string, callback: (arg: DockerfileBuilderCallbackContext) => Promise, options?: WithDockerfileBuilderOptions): PgWebContainerResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): PgWebContainerResourcePromise; + /** Adds a network alias for the container */ + withContainerNetworkAlias(alias: string): PgWebContainerResourcePromise; + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): PgWebContainerResourcePromise; + /** Configures OTLP telemetry export */ + withOtlpExporter(options?: WithOtlpExporterOptions): PgWebContainerResourcePromise; + /** Publishes the resource as a connection string */ + publishAsConnectionString(): PgWebContainerResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): PgWebContainerResourcePromise; + /** Sets an environment variable */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): PgWebContainerResourcePromise; + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): PgWebContainerResourcePromise; + /** Adds arguments */ + withArgs(args: string[]): PgWebContainerResourcePromise; + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): PgWebContainerResourcePromise; + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): PgWebContainerResourcePromise; + /** Adds a reference to another resource */ + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): PgWebContainerResourcePromise; + /** Updates a named endpoint via callback */ + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): PgWebContainerResourcePromise; + /** Updates an HTTP endpoint via callback */ + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): PgWebContainerResourcePromise; + /** Updates an HTTPS endpoint via callback */ + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): PgWebContainerResourcePromise; + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): PgWebContainerResourcePromise; + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): PgWebContainerResourcePromise; + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): PgWebContainerResourcePromise; + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): PgWebContainerResourcePromise; + /** Gets an endpoint reference */ + getEndpoint(name: string): Promise; + /** Configures resource for HTTP/2 */ + asHttp2Service(): PgWebContainerResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): PgWebContainerResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): PgWebContainerResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): PgWebContainerResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): PgWebContainerResourcePromise; + /** Waits for another resource to be ready */ + waitFor(dependency: Awaitable, options?: WaitForOptions): PgWebContainerResourcePromise; + /** Waits for another resource to start */ + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): PgWebContainerResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): PgWebContainerResourcePromise; + /** Waits for resource completion */ + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): PgWebContainerResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): PgWebContainerResourcePromise; + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): PgWebContainerResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): PgWebContainerResourcePromise; + /** Adds an HTTP resource command */ + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): PgWebContainerResourcePromise; + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): PgWebContainerResourcePromise; + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): PgWebContainerResourcePromise; + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): PgWebContainerResourcePromise; + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): PgWebContainerResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): PgWebContainerResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): PgWebContainerResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): PgWebContainerResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): PgWebContainerResourcePromise; + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): PgWebContainerResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): PgWebContainerResourcePromise; + /** Sets image push options via callback */ + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): PgWebContainerResourcePromise; + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): PgWebContainerResourcePromise; + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): PgWebContainerResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): PgWebContainerResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): PgWebContainerResourcePromise; + /** Adds a volume */ + withVolume(target: string, options?: WithVolumeOptions): PgWebContainerResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): PgWebContainerResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): PgWebContainerResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): PgWebContainerResourcePromise; + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): PgWebContainerResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): PgWebContainerResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Create a new reference, while also allowing customization of how a resource appears in the generated LikeC4 diagram. */ + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): PgWebContainerResourcePromise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): PgWebContainerResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): PgWebContainerResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): PgWebContainerResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): PgWebContainerResourcePromise; + /** Associates an Azure user-assigned identity with a compute resource */ + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): PgWebContainerResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): PgWebContainerResourcePromise; + /** Sets the host port for pgweb */ + withHostPort(options?: WithHostPortOptions): PgWebContainerResourcePromise; +} + +// ============================================================================ +// PgWebContainerResourceImpl +// ============================================================================ + +class PgWebContainerResourceImpl extends ResourceBuilderBase implements PgWebContainerResource { + constructor(handle: PgWebContainerResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: Awaitable): Promise { + registry = isPromiseLike(registry) ? await registry : registry; + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withContainerRegistry(registry: Awaitable): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._withContainerRegistryInternal(registry), this._client); + } + + /** @internal */ + private async _withBindMountInternal(source: string, target: string, isReadOnly?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, source, target }; + if (isReadOnly !== undefined) rpcArgs.isReadOnly = isReadOnly; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBindMount', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withBindMount(source: string, target: string, options?: WithBindMountOptions): PgWebContainerResourcePromise { + const isReadOnly = options?.isReadOnly; + return new PgWebContainerResourcePromiseImpl(this._withBindMountInternal(source, target, isReadOnly), this._client); + } + + /** @internal */ + private async _withEntrypointInternal(entrypoint: string): Promise { + const rpcArgs: Record = { builder: this._handle, entrypoint }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEntrypoint', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withEntrypoint(entrypoint: string): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._withEntrypointInternal(entrypoint), this._client); + } + + /** @internal */ + private async _withImageTagInternal(tag: string): Promise { + const rpcArgs: Record = { builder: this._handle, tag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImageTag', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withImageTag(tag: string): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._withImageTagInternal(tag), this._client); + } + + /** @internal */ + private async _withImageRegistryInternal(registry: string): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImageRegistry', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withImageRegistry(registry: string): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._withImageRegistryInternal(registry), this._client); + } + + /** @internal */ + private async _withImageInternal(image: string, tag?: string): Promise { + const rpcArgs: Record = { builder: this._handle, image }; + if (tag !== undefined) rpcArgs.tag = tag; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImage', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withImage(image: string, options?: WithImageOptions): PgWebContainerResourcePromise { + const tag = options?.tag; + return new PgWebContainerResourcePromiseImpl(this._withImageInternal(image, tag), this._client); + } + + /** @internal */ + private async _withImageSHA256Internal(sha256: string): Promise { + const rpcArgs: Record = { builder: this._handle, sha256 }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImageSHA256', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withImageSHA256(sha256: string): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._withImageSHA256Internal(sha256), this._client); + } + + /** @internal */ + private async _withContainerRuntimeArgsInternal(args: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, args }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRuntimeArgs', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withContainerRuntimeArgs(args: string[]): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._withContainerRuntimeArgsInternal(args), this._client); + } + + /** @internal */ + private async _withLifetimeInternal(lifetime: ContainerLifetime): Promise { + const rpcArgs: Record = { builder: this._handle, lifetime }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withLifetime', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withLifetime(lifetime: ContainerLifetime): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._withLifetimeInternal(lifetime), this._client); + } + + /** @internal */ + private async _withImagePullPolicyInternal(pullPolicy: ImagePullPolicy): Promise { + const rpcArgs: Record = { builder: this._handle, pullPolicy }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImagePullPolicy', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withImagePullPolicy(pullPolicy: ImagePullPolicy): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._withImagePullPolicyInternal(pullPolicy), this._client); + } + + /** @internal */ + private async _publishAsContainerInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsContainer', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + publishAsContainer(): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._publishAsContainerInternal(), this._client); + } + + /** @internal */ + private async _withDockerfileInternal(contextPath: string, dockerfilePath?: string, stage?: string): Promise { + const rpcArgs: Record = { builder: this._handle, contextPath }; + if (dockerfilePath !== undefined) rpcArgs.dockerfilePath = dockerfilePath; + if (stage !== undefined) rpcArgs.stage = stage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfile', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withDockerfile(contextPath: string, options?: WithDockerfileOptions): PgWebContainerResourcePromise { + const dockerfilePath = options?.dockerfilePath; + const stage = options?.stage; + return new PgWebContainerResourcePromiseImpl(this._withDockerfileInternal(contextPath, dockerfilePath, stage), this._client); + } + + /** @internal */ + private async _withContainerNameInternal(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerName', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withContainerName(name: string): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._withContainerNameInternal(name), this._client); + } + + /** @internal */ + private async _withBuildArgInternal(name: string, value: string | ParameterResource | Awaitable): Promise { + value = isPromiseLike(value) ? await value : value; + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuildArg', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withBuildArg(name: string, value: string | ParameterResource | Awaitable): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._withBuildArgInternal(name, value), this._client); + } + + /** @internal */ + private async _withBuildSecretInternal(name: string, value: Awaitable): Promise { + value = isPromiseLike(value) ? await value : value; + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParameterBuildSecret', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withBuildSecret(name: string, value: Awaitable): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._withBuildSecretInternal(name, value), this._client); + } + + /** @internal */ + private async _withContainerCertificatePathsInternal(customCertificatesDestination?: string, defaultCertificateBundlePaths?: string[], defaultCertificateDirectoryPaths?: string[]): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (customCertificatesDestination !== undefined) rpcArgs.customCertificatesDestination = customCertificatesDestination; + if (defaultCertificateBundlePaths !== undefined) rpcArgs.defaultCertificateBundlePaths = defaultCertificateBundlePaths; + if (defaultCertificateDirectoryPaths !== undefined) rpcArgs.defaultCertificateDirectoryPaths = defaultCertificateDirectoryPaths; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerCertificatePaths', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): PgWebContainerResourcePromise { + const customCertificatesDestination = options?.customCertificatesDestination; + const defaultCertificateBundlePaths = options?.defaultCertificateBundlePaths; + const defaultCertificateDirectoryPaths = options?.defaultCertificateDirectoryPaths; + return new PgWebContainerResourcePromiseImpl(this._withContainerCertificatePathsInternal(customCertificatesDestination, defaultCertificateBundlePaths, defaultCertificateDirectoryPaths), this._client); + } + + /** @internal */ + private async _withEndpointProxySupportInternal(proxyEnabled: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, proxyEnabled }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpointProxySupport', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withEndpointProxySupport(proxyEnabled: boolean): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._withEndpointProxySupportInternal(proxyEnabled), this._client); + } + + /** @internal */ + private async _withDockerfileBuilderInternal(contextPath: string, callback: (arg: DockerfileBuilderCallbackContext) => Promise, stage?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as DockerfileBuilderCallbackContextHandle; + const arg = new DockerfileBuilderCallbackContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, contextPath, callback: callbackId }; + if (stage !== undefined) rpcArgs.stage = stage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBuilder', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withDockerfileBuilder(contextPath: string, callback: (arg: DockerfileBuilderCallbackContext) => Promise, options?: WithDockerfileBuilderOptions): PgWebContainerResourcePromise { + const stage = options?.stage; + return new PgWebContainerResourcePromiseImpl(this._withDockerfileBuilderInternal(contextPath, callback, stage), this._client); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): PgWebContainerResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new PgWebContainerResourcePromiseImpl(this._withDockerfileBaseImageInternal(buildImage, runtimeImage), this._client); + } + + /** @internal */ + private async _withContainerNetworkAliasInternal(alias: string): Promise { + const rpcArgs: Record = { builder: this._handle, alias }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerNetworkAlias', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withContainerNetworkAlias(alias: string): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._withContainerNetworkAliasInternal(alias), this._client); + } + + /** @internal */ + private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withMcpServer', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withMcpServer(options?: WithMcpServerOptions): PgWebContainerResourcePromise { + const path = options?.path; + const endpointName = options?.endpointName; + return new PgWebContainerResourcePromiseImpl(this._withMcpServerInternal(path, endpointName), this._client); + } + + /** @internal */ + private async _withOtlpExporterInternal(protocol?: OtlpProtocol): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (protocol !== undefined) rpcArgs.protocol = protocol; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporter', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withOtlpExporter(options?: WithOtlpExporterOptions): PgWebContainerResourcePromise { + const protocol = options?.protocol; + return new PgWebContainerResourcePromiseImpl(this._withOtlpExporterInternal(protocol), this._client); + } + + /** @internal */ + private async _publishAsConnectionStringInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsConnectionString', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + publishAsConnectionString(): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._publishAsConnectionStringInternal(), this._client); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): PgWebContainerResourcePromise { + const helpLink = options?.helpLink; + return new PgWebContainerResourcePromiseImpl(this._withRequiredCommandInternal(command, helpLink), this._client); + } + + /** @internal */ + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): Promise { + value = isPromiseLike(value) ? await value : value; + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironment', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._withEnvironmentInternal(name, value), this._client); + } + + /** @internal */ + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentCallback', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._withEnvironmentCallbackInternal(callback), this._client); + } + + /** @internal */ + private async _withArgsInternal(args: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, args }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgs', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withArgs(args: string[]): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._withArgsInternal(args), this._client); + } + + /** @internal */ + private async _withArgsCallbackInternal(callback: (obj: CommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; + const obj = new CommandLineArgsCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallback', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._withArgsCallbackInternal(callback), this._client); + } + + /** @internal */ + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceEnvironment', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._withReferenceEnvironmentInternal(options), this._client); + } + + /** @internal */ + private async _withReferenceInternal(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, connectionName?: string, optional?: boolean, name?: string): Promise { + source = isPromiseLike(source) ? await source : source; + const rpcArgs: Record = { builder: this._handle, source }; + if (connectionName !== undefined) rpcArgs.connectionName = connectionName; + if (optional !== undefined) rpcArgs.optional = optional; + if (name !== undefined) rpcArgs.name = name; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReference', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): PgWebContainerResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new PgWebContainerResourcePromiseImpl(this._withReferenceInternal(source, connectionName, optional, name), this._client); + } + + /** @internal */ + private async _withEndpointCallbackInternal(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpointCallback', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): PgWebContainerResourcePromise { + const createIfNotExists = options?.createIfNotExists; + return new PgWebContainerResourcePromiseImpl(this._withEndpointCallbackInternal(endpointName, callback, createIfNotExists), this._client); + } + + /** @internal */ + private async _withHttpEndpointCallbackInternal(callback: (obj: EndpointUpdateContext) => Promise, name?: string, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + if (name !== undefined) rpcArgs.name = name; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpEndpointCallback', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): PgWebContainerResourcePromise { + const name = options?.name; + const createIfNotExists = options?.createIfNotExists; + return new PgWebContainerResourcePromiseImpl(this._withHttpEndpointCallbackInternal(callback, name, createIfNotExists), this._client); + } + + /** @internal */ + private async _withHttpsEndpointCallbackInternal(callback: (obj: EndpointUpdateContext) => Promise, name?: string, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + if (name !== undefined) rpcArgs.name = name; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsEndpointCallback', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): PgWebContainerResourcePromise { + const name = options?.name; + const createIfNotExists = options?.createIfNotExists; + return new PgWebContainerResourcePromiseImpl(this._withHttpsEndpointCallbackInternal(callback, name, createIfNotExists), this._client); + } + + /** @internal */ + private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (scheme !== undefined) rpcArgs.scheme = scheme; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + if (isExternal !== undefined) rpcArgs.isExternal = isExternal; + if (protocol !== undefined) rpcArgs.protocol = protocol; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpoint', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withEndpoint(options?: WithEndpointOptions): PgWebContainerResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const scheme = options?.scheme; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + const isExternal = options?.isExternal; + const protocol = options?.protocol; + return new PgWebContainerResourcePromiseImpl(this._withEndpointInternal(port, targetPort, scheme, name, env, isProxied, isExternal, protocol), this._client); + } + + /** @internal */ + private async _withHttpEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpEndpoint', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withHttpEndpoint(options?: WithHttpEndpointOptions): PgWebContainerResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new PgWebContainerResourcePromiseImpl(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied), this._client); + } + + /** @internal */ + private async _withHttpsEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsEndpoint', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withHttpsEndpoint(options?: WithHttpsEndpointOptions): PgWebContainerResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new PgWebContainerResourcePromiseImpl(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied), this._client); + } + + /** @internal */ + private async _withExternalHttpEndpointsInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExternalHttpEndpoints', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withExternalHttpEndpoints(): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._withExternalHttpEndpointsInternal(), this._client); + } + + async getEndpoint(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getEndpoint', + rpcArgs + ); + } + + /** @internal */ + private async _asHttp2ServiceInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/asHttp2Service', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + asHttp2Service(): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._asHttp2ServiceInternal(), this._client); + } + + /** @internal */ + private async _withUrlsInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrls', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._withUrlsInternal(callback), this._client); + } + + /** @internal */ + private async _withUrlInternal(url: string | ReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): PgWebContainerResourcePromise { + const displayText = options?.displayText; + return new PgWebContainerResourcePromiseImpl(this._withUrlInternal(url, displayText), this._client); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._withUrlForEndpointInternal(endpointName, callback), this._client); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + excludeFromManifest(): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._excludeFromManifestInternal(), this._client); + } + + /** @internal */ + private async _waitForInternal(dependency: Awaitable, waitBehavior?: WaitBehavior): Promise { + dependency = isPromiseLike(dependency) ? await dependency : dependency; + const rpcArgs: Record = { builder: this._handle, dependency }; + if (waitBehavior !== undefined) rpcArgs.waitBehavior = waitBehavior; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitFor', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + waitFor(dependency: Awaitable, options?: WaitForOptions): PgWebContainerResourcePromise { + const waitBehavior = options?.waitBehavior; + return new PgWebContainerResourcePromiseImpl(this._waitForInternal(dependency, waitBehavior), this._client); + } + + /** @internal */ + private async _waitForStartInternal(dependency: Awaitable, waitBehavior?: WaitBehavior): Promise { + dependency = isPromiseLike(dependency) ? await dependency : dependency; + const rpcArgs: Record = { builder: this._handle, dependency }; + if (waitBehavior !== undefined) rpcArgs.waitBehavior = waitBehavior; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStart', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): PgWebContainerResourcePromise { + const waitBehavior = options?.waitBehavior; + return new PgWebContainerResourcePromiseImpl(this._waitForStartInternal(dependency, waitBehavior), this._client); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withExplicitStart(): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._withExplicitStartInternal(), this._client); + } + + /** @internal */ + private async _waitForCompletionInternal(dependency: Awaitable, exitCode?: number): Promise { + dependency = isPromiseLike(dependency) ? await dependency : dependency; + const rpcArgs: Record = { builder: this._handle, dependency }; + if (exitCode !== undefined) rpcArgs.exitCode = exitCode; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceCompletion', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): PgWebContainerResourcePromise { + const exitCode = options?.exitCode; + return new PgWebContainerResourcePromiseImpl(this._waitForCompletionInternal(dependency, exitCode), this._client); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withHealthCheck(key: string): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._withHealthCheckInternal(key), this._client); + } + + /** @internal */ + private async _withHttpHealthCheckInternal(path?: string, statusCode?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (statusCode !== undefined) rpcArgs.statusCode = statusCode; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpHealthCheck', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): PgWebContainerResourcePromise { + const path = options?.path; + const statusCode = options?.statusCode; + const endpointName = options?.endpointName; + return new PgWebContainerResourcePromiseImpl(this._withHttpHealthCheckInternal(path, statusCode, endpointName), this._client); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContextImpl(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): PgWebContainerResourcePromise { + const commandOptions = options?.commandOptions; + return new PgWebContainerResourcePromiseImpl(this._withCommandInternal(name, displayName, executeCommand, commandOptions), this._client); + } + + /** @internal */ + private async _withHttpCommandInternal(path: string, displayName: string, options?: HttpCommandExportOptions): Promise { + const rpcArgs: Record = { builder: this._handle, path, displayName }; + if (options !== undefined) rpcArgs.options = options; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpCommand', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._withHttpCommandInternal(path, displayName, options), this._client); + } + + /** @internal */ + private async _withDeveloperCertificateTrustInternal(trust: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, trust }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDeveloperCertificateTrust', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withDeveloperCertificateTrust(trust: boolean): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._withDeveloperCertificateTrustInternal(trust), this._client); + } + + /** @internal */ + private async _withCertificateTrustScopeInternal(scope: CertificateTrustScope): Promise { + const rpcArgs: Record = { builder: this._handle, scope }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCertificateTrustScope', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withCertificateTrustScope(scope: CertificateTrustScope): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._withCertificateTrustScopeInternal(scope), this._client); + } + + /** @internal */ + private async _withHttpsDeveloperCertificateInternal(password?: Awaitable): Promise { + password = isPromiseLike(password) ? await password : password; + const rpcArgs: Record = { builder: this._handle }; + if (password !== undefined) rpcArgs.password = password; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): PgWebContainerResourcePromise { + let password = options?.password; + return new PgWebContainerResourcePromiseImpl(this._withHttpsDeveloperCertificateInternal(password), this._client); + } + + /** @internal */ + private async _withoutHttpsCertificateInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withoutHttpsCertificate', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withoutHttpsCertificate(): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._withoutHttpsCertificateInternal(), this._client); + } + + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: Awaitable, type: string): Promise { + resourceBuilder = isPromiseLike(resourceBuilder) ? await resourceBuilder : resourceBuilder; + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._withRelationshipInternal(resourceBuilder, type), this._client); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: Awaitable): Promise { + parent = isPromiseLike(parent) ? await parent : parent; + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withParentRelationship(parent: Awaitable): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._withParentRelationshipInternal(parent), this._client); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: Awaitable): Promise { + child = isPromiseLike(child) ? await child : child; + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withChildRelationship(child: Awaitable): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._withChildRelationshipInternal(child), this._client); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): PgWebContainerResourcePromise { + const iconVariant = options?.iconVariant; + return new PgWebContainerResourcePromiseImpl(this._withIconNameInternal(iconName, iconVariant), this._client); + } + + /** @internal */ + private async _withHttpProbeInternal(probeType: ProbeType, path?: string, initialDelaySeconds?: number, periodSeconds?: number, timeoutSeconds?: number, failureThreshold?: number, successThreshold?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, probeType }; + if (path !== undefined) rpcArgs.path = path; + if (initialDelaySeconds !== undefined) rpcArgs.initialDelaySeconds = initialDelaySeconds; + if (periodSeconds !== undefined) rpcArgs.periodSeconds = periodSeconds; + if (timeoutSeconds !== undefined) rpcArgs.timeoutSeconds = timeoutSeconds; + if (failureThreshold !== undefined) rpcArgs.failureThreshold = failureThreshold; + if (successThreshold !== undefined) rpcArgs.successThreshold = successThreshold; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpProbe', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): PgWebContainerResourcePromise { + const path = options?.path; + const initialDelaySeconds = options?.initialDelaySeconds; + const periodSeconds = options?.periodSeconds; + const timeoutSeconds = options?.timeoutSeconds; + const failureThreshold = options?.failureThreshold; + const successThreshold = options?.successThreshold; + const endpointName = options?.endpointName; + return new PgWebContainerResourcePromiseImpl(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName), this._client); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + excludeFromMcp(): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._excludeFromMcpInternal(), this._client); + } + + /** @internal */ + private async _withImagePushOptionsInternal(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ContainerImagePushOptionsCallbackContextHandle; + const arg = new ContainerImagePushOptionsCallbackContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImagePushOptions', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._withImagePushOptionsInternal(callback), this._client); + } + + /** @internal */ + private async _withRemoteImageNameInternal(remoteImageName: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageName', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withRemoteImageName(remoteImageName: string): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._withRemoteImageNameInternal(remoteImageName), this._client); + } + + /** @internal */ + private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageTag', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withRemoteImageTag(remoteImageTag: string): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._withRemoteImageTagInternal(remoteImageTag), this._client); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): PgWebContainerResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new PgWebContainerResourcePromiseImpl(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description), this._client); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._withPipelineConfigurationInternal(callback), this._client); + } + + /** @internal */ + private async _withVolumeInternal(target: string, name?: string, isReadOnly?: boolean): Promise { + const rpcArgs: Record = { resource: this._handle, target }; + if (name !== undefined) rpcArgs.name = name; + if (isReadOnly !== undefined) rpcArgs.isReadOnly = isReadOnly; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withVolume', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withVolume(target: string, options?: WithVolumeOptions): PgWebContainerResourcePromise { + const name = options?.name; + const isReadOnly = options?.isReadOnly; + return new PgWebContainerResourcePromiseImpl(this._withVolumeInternal(target, name, isReadOnly), this._client); + } + + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); + } + + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._onBeforeResourceStartedInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._onResourceStoppedInternal(callback), this._client); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._onInitializeResourceInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceEndpointsAllocated', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._onResourceEndpointsAllocatedInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._onResourceReadyInternal(callback), this._client); + } + + async createExecutionConfiguration(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/createExecutionConfiguration', + rpcArgs + ); + } + + /** @internal */ + private async _withLikeC4ReferenceWithEnvironmentInternal(source: Awaitable, configure?: (obj: LikeC4RelationshipDetailsAnnotation) => Promise, connectionName?: string, optional?: boolean, skipAspireReference?: boolean): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4RelationshipDetailsAnnotationHandle; + const obj = new LikeC4RelationshipDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + source = isPromiseLike(source) ? await source : source; + const rpcArgs: Record = { builder: this._handle, source }; + if (configure !== undefined) rpcArgs.configure = configureId; + if (connectionName !== undefined) rpcArgs.connectionName = connectionName; + if (optional !== undefined) rpcArgs.optional = optional; + if (skipAspireReference !== undefined) rpcArgs.skipAspireReference = skipAspireReference; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4ReferenceWithEnvironment', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): PgWebContainerResourcePromise { + const configure = options?.configure; + const connectionName = options?.connectionName; + const optional = options?.optional; + const skipAspireReference = options?.skipAspireReference; + return new PgWebContainerResourcePromiseImpl(this._withLikeC4ReferenceWithEnvironmentInternal(source, configure, connectionName, optional, skipAspireReference), this._client); + } + + /** @internal */ + private async _withLikeC4DetailsInternal(label?: string, technology?: string, description?: string, summary?: string, icon?: string, configure?: (obj: LikeC4NodeDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4NodeDetailsAnnotationHandle; + const obj = new LikeC4NodeDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + const rpcArgs: Record = { builder: this._handle }; + if (label !== undefined) rpcArgs.label = label; + if (technology !== undefined) rpcArgs.technology = technology; + if (description !== undefined) rpcArgs.description = description; + if (summary !== undefined) rpcArgs.summary = summary; + if (icon !== undefined) rpcArgs.icon = icon; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4DetailsParameters', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): PgWebContainerResourcePromise { + const label = options?.label; + const technology = options?.technology; + const description = options?.description; + const summary = options?.summary; + const icon = options?.icon; + const configure = options?.configure; + return new PgWebContainerResourcePromiseImpl(this._withLikeC4DetailsInternal(label, technology, description, summary, icon, configure), this._client); + } + + /** @internal */ + private async _withLikeC4ReferenceInternal(target: Awaitable, configure?: (obj: LikeC4RelationshipDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4RelationshipDetailsAnnotationHandle; + const obj = new LikeC4RelationshipDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target }; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Reference', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): PgWebContainerResourcePromise { + const configure = options?.configure; + return new PgWebContainerResourcePromiseImpl(this._withLikeC4ReferenceInternal(target, configure), this._client); + } + + /** @internal */ + private async _withLikeC4GroupInternal(groupName: string): Promise { + const rpcArgs: Record = { builder: this._handle, groupName }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Group', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withLikeC4Group(groupName: string): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._withLikeC4GroupInternal(groupName), this._client); + } + + /** @internal */ + private async _excludeFromLikeC4Internal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/excludeFromLikeC4', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + excludeFromLikeC4(): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._excludeFromLikeC4Internal(), this._client); + } + + /** @internal */ + private async _withAzureUserAssignedIdentityInternal(identityResourceBuilder: Awaitable): Promise { + identityResourceBuilder = isPromiseLike(identityResourceBuilder) ? await identityResourceBuilder : identityResourceBuilder; + const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._withAzureUserAssignedIdentityInternal(identityResourceBuilder), this._client); + } + + /** @internal */ + private async _withRoleAssignmentsInternal(target: Awaitable, roles: AzureKeyVaultRole[]): Promise { + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target, roles }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.KeyVault/withKeyVaultRoleAssignments', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._withRoleAssignmentsInternal(target, roles), this._client); + } + + /** @internal */ + private async _withHostPortInternal(port?: number): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.PostgreSQL/withPgWebHostPort', + rpcArgs + ); + return new PgWebContainerResourceImpl(result, this._client); + } + + withHostPort(options?: WithHostPortOptions): PgWebContainerResourcePromise { + const port = options?.port; + return new PgWebContainerResourcePromiseImpl(this._withHostPortInternal(port), this._client); + } + +} + +/** + * Thenable wrapper for PgWebContainerResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +class PgWebContainerResourcePromiseImpl implements PgWebContainerResourcePromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: PgWebContainerResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + withContainerRegistry(registry: Awaitable): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withContainerRegistry(registry)), this._client); + } + + withBindMount(source: string, target: string, options?: WithBindMountOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withBindMount(source, target, options)), this._client); + } + + withEntrypoint(entrypoint: string): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withEntrypoint(entrypoint)), this._client); + } + + withImageTag(tag: string): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withImageTag(tag)), this._client); + } + + withImageRegistry(registry: string): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withImageRegistry(registry)), this._client); + } + + withImage(image: string, options?: WithImageOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withImage(image, options)), this._client); + } + + withImageSHA256(sha256: string): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withImageSHA256(sha256)), this._client); + } + + withContainerRuntimeArgs(args: string[]): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withContainerRuntimeArgs(args)), this._client); + } + + withLifetime(lifetime: ContainerLifetime): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withLifetime(lifetime)), this._client); + } + + withImagePullPolicy(pullPolicy: ImagePullPolicy): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withImagePullPolicy(pullPolicy)), this._client); + } + + publishAsContainer(): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.publishAsContainer()), this._client); + } + + withDockerfile(contextPath: string, options?: WithDockerfileOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withDockerfile(contextPath, options)), this._client); + } + + withContainerName(name: string): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withContainerName(name)), this._client); + } + + withBuildArg(name: string, value: string | ParameterResource | Awaitable): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withBuildArg(name, value)), this._client); + } + + withBuildSecret(name: string, value: Awaitable): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withBuildSecret(name, value)), this._client); + } + + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withContainerCertificatePaths(options)), this._client); + } + + withEndpointProxySupport(proxyEnabled: boolean): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withEndpointProxySupport(proxyEnabled)), this._client); + } + + withDockerfileBuilder(contextPath: string, callback: (arg: DockerfileBuilderCallbackContext) => Promise, options?: WithDockerfileBuilderOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withDockerfileBuilder(contextPath, callback, options)), this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withDockerfileBaseImage(options)), this._client); + } + + withContainerNetworkAlias(alias: string): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withContainerNetworkAlias(alias)), this._client); + } + + withMcpServer(options?: WithMcpServerOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withMcpServer(options)), this._client); + } + + withOtlpExporter(options?: WithOtlpExporterOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withOtlpExporter(options)), this._client); + } + + publishAsConnectionString(): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.publishAsConnectionString()), this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withRequiredCommand(command, options)), this._client); + } + + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withEnvironment(name, value)), this._client); + } + + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentCallback(callback)), this._client); + } + + withArgs(args: string[]): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withArgs(args)), this._client); + } + + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withArgsCallback(callback)), this._client); + } + + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withReferenceEnvironment(options)), this._client); + } + + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withReference(source, options)), this._client); + } + + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withEndpointCallback(endpointName, callback, options)), this._client); + } + + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withHttpEndpointCallback(callback, options)), this._client); + } + + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withHttpsEndpointCallback(callback, options)), this._client); + } + + withEndpoint(options?: WithEndpointOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withEndpoint(options)), this._client); + } + + withHttpEndpoint(options?: WithHttpEndpointOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withHttpEndpoint(options)), this._client); + } + + withHttpsEndpoint(options?: WithHttpsEndpointOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withHttpsEndpoint(options)), this._client); + } + + withExternalHttpEndpoints(): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withExternalHttpEndpoints()), this._client); + } + + getEndpoint(name: string): Promise { + return this._promise.then(obj => obj.getEndpoint(name)); + } + + asHttp2Service(): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.asHttp2Service()), this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withUrls(callback)), this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withUrl(url, options)), this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback)), this._client); + } + + excludeFromManifest(): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.excludeFromManifest()), this._client); + } + + waitFor(dependency: Awaitable, options?: WaitForOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.waitFor(dependency, options)), this._client); + } + + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.waitForStart(dependency, options)), this._client); + } + + withExplicitStart(): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withExplicitStart()), this._client); + } + + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.waitForCompletion(dependency, options)), this._client); + } + + withHealthCheck(key: string): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withHealthCheck(key)), this._client); + } + + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withHttpHealthCheck(options)), this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options)), this._client); + } + + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withHttpCommand(path, displayName, options)), this._client); + } + + withDeveloperCertificateTrust(trust: boolean): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust)), this._client); + } + + withCertificateTrustScope(scope: CertificateTrustScope): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withCertificateTrustScope(scope)), this._client); + } + + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options)), this._client); + } + + withoutHttpsCertificate(): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withoutHttpsCertificate()), this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withRelationship(resourceBuilder, type)), this._client); + } + + withParentRelationship(parent: Awaitable): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withParentRelationship(parent)), this._client); + } + + withChildRelationship(child: Awaitable): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withChildRelationship(child)), this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withIconName(iconName, options)), this._client); + } + + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withHttpProbe(probeType, options)), this._client); + } + + excludeFromMcp(): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.excludeFromMcp()), this._client); + } + + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withImagePushOptions(callback)), this._client); + } + + withRemoteImageName(remoteImageName: string): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withRemoteImageName(remoteImageName)), this._client); + } + + withRemoteImageTag(remoteImageTag: string): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag)), this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options)), this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withPipelineConfiguration(callback)), this._client); + } + + withVolume(target: string, options?: WithVolumeOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withVolume(target, options)), this._client); + } + + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.onBeforeResourceStarted(callback)), this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.onResourceStopped(callback)), this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.onInitializeResource(callback)), this._client); + } + + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback)), this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.onResourceReady(callback)), this._client); + } + + createExecutionConfiguration(): Promise { + return this._promise.then(obj => obj.createExecutionConfiguration()); + } + + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4ReferenceWithEnvironment(source, options)), this._client); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Details(options)), this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Reference(target, options)), this._client); + } + + withLikeC4Group(groupName: string): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Group(groupName)), this._client); + } + + excludeFromLikeC4(): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.excludeFromLikeC4()), this._client); + } + + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withAzureUserAssignedIdentity(identityResourceBuilder)), this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withRoleAssignments(target, roles)), this._client); + } + + withHostPort(options?: WithHostPortOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromiseImpl(this._promise.then(obj => obj.withHostPort(options)), this._client); + } + +} + +// ============================================================================ +// PostgresDatabaseResource +// ============================================================================ + +export interface PostgresDatabaseResource { + toJSON(): MarshalledHandle; + /** Gets the Parent property */ + parent(): Promise; + /** Gets the ConnectionStringExpression property */ + connectionStringExpression(): Promise; + /** Gets the DatabaseName property */ + databaseName(): Promise; + /** Gets the UriExpression property */ + uriExpression(): Promise; + /** Gets the JdbcConnectionString property */ + jdbcConnectionString(): Promise; + /** Gets the Name property */ + name(): Promise; + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): PostgresDatabaseResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): PostgresDatabaseResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): PostgresDatabaseResourcePromise; + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): PostgresDatabaseResourcePromise; + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): PostgresDatabaseResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): PostgresDatabaseResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): PostgresDatabaseResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): PostgresDatabaseResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): PostgresDatabaseResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): PostgresDatabaseResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): PostgresDatabaseResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): PostgresDatabaseResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): PostgresDatabaseResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): PostgresDatabaseResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): PostgresDatabaseResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): PostgresDatabaseResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): PostgresDatabaseResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): PostgresDatabaseResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): PostgresDatabaseResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): PostgresDatabaseResourcePromise; + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): PostgresDatabaseResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): PostgresDatabaseResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): PostgresDatabaseResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): PostgresDatabaseResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): PostgresDatabaseResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): PostgresDatabaseResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): PostgresDatabaseResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): PostgresDatabaseResourcePromise; + /** Adds Postgres MCP server */ + withPostgresMcp(options?: WithPostgresMcpOptions): PostgresDatabaseResourcePromise; + /** Defines the SQL script for database creation */ + withCreationScript(script: string): PostgresDatabaseResourcePromise; +} + +export interface PostgresDatabaseResourcePromise extends PromiseLike { + /** Gets the Parent property */ + parent(): Promise; + /** Gets the ConnectionStringExpression property */ + connectionStringExpression(): Promise; + /** Gets the DatabaseName property */ + databaseName(): Promise; + /** Gets the UriExpression property */ + uriExpression(): Promise; + /** Gets the JdbcConnectionString property */ + jdbcConnectionString(): Promise; + /** Gets the Name property */ + name(): Promise; + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): PostgresDatabaseResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): PostgresDatabaseResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): PostgresDatabaseResourcePromise; + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): PostgresDatabaseResourcePromise; + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): PostgresDatabaseResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): PostgresDatabaseResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): PostgresDatabaseResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): PostgresDatabaseResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): PostgresDatabaseResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): PostgresDatabaseResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): PostgresDatabaseResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): PostgresDatabaseResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): PostgresDatabaseResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): PostgresDatabaseResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): PostgresDatabaseResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): PostgresDatabaseResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): PostgresDatabaseResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): PostgresDatabaseResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): PostgresDatabaseResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): PostgresDatabaseResourcePromise; + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): PostgresDatabaseResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): PostgresDatabaseResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): PostgresDatabaseResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): PostgresDatabaseResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): PostgresDatabaseResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): PostgresDatabaseResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): PostgresDatabaseResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): PostgresDatabaseResourcePromise; + /** Adds Postgres MCP server */ + withPostgresMcp(options?: WithPostgresMcpOptions): PostgresDatabaseResourcePromise; + /** Defines the SQL script for database creation */ + withCreationScript(script: string): PostgresDatabaseResourcePromise; +} + +// ============================================================================ +// PostgresDatabaseResourceImpl +// ============================================================================ + +class PostgresDatabaseResourceImpl extends ResourceBuilderBase implements PostgresDatabaseResource { + constructor(handle: PostgresDatabaseResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + async parent(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/PostgresDatabaseResource.parent', + { context: this._handle } + ); + return new PostgresServerResourceImpl(handle, this._client); + } + + async connectionStringExpression(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/PostgresDatabaseResource.connectionStringExpression', + { context: this._handle } + ); + } + + async databaseName(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/PostgresDatabaseResource.databaseName', + { context: this._handle } + ); + } + + async uriExpression(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/PostgresDatabaseResource.uriExpression', + { context: this._handle } + ); + } + + async jdbcConnectionString(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/PostgresDatabaseResource.jdbcConnectionString', + { context: this._handle } + ); + } + + async name(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/PostgresDatabaseResource.name', + { context: this._handle } + ); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: Awaitable): Promise { + registry = isPromiseLike(registry) ? await registry : registry; + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new PostgresDatabaseResourceImpl(result, this._client); + } + + withContainerRegistry(registry: Awaitable): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromiseImpl(this._withContainerRegistryInternal(registry), this._client); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new PostgresDatabaseResourceImpl(result, this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): PostgresDatabaseResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new PostgresDatabaseResourcePromiseImpl(this._withDockerfileBaseImageInternal(buildImage, runtimeImage), this._client); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new PostgresDatabaseResourceImpl(result, this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): PostgresDatabaseResourcePromise { + const helpLink = options?.helpLink; + return new PostgresDatabaseResourcePromiseImpl(this._withRequiredCommandInternal(command, helpLink), this._client); + } + + /** @internal */ + private async _withConnectionPropertyInternal(name: string, value: string | ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withConnectionProperty', + rpcArgs + ); + return new PostgresDatabaseResourceImpl(result, this._client); + } + + withConnectionProperty(name: string, value: string | ReferenceExpression): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromiseImpl(this._withConnectionPropertyInternal(name, value), this._client); + } + + async getConnectionProperty(key: string): Promise { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + + /** @internal */ + private async _withUrlsInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrls', + rpcArgs + ); + return new PostgresDatabaseResourceImpl(result, this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromiseImpl(this._withUrlsInternal(callback), this._client); + } + + /** @internal */ + private async _withUrlInternal(url: string | ReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new PostgresDatabaseResourceImpl(result, this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): PostgresDatabaseResourcePromise { + const displayText = options?.displayText; + return new PostgresDatabaseResourcePromiseImpl(this._withUrlInternal(url, displayText), this._client); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new PostgresDatabaseResourceImpl(result, this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromiseImpl(this._withUrlForEndpointInternal(endpointName, callback), this._client); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new PostgresDatabaseResourceImpl(result, this._client); + } + + excludeFromManifest(): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromiseImpl(this._excludeFromManifestInternal(), this._client); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new PostgresDatabaseResourceImpl(result, this._client); + } + + withExplicitStart(): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromiseImpl(this._withExplicitStartInternal(), this._client); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new PostgresDatabaseResourceImpl(result, this._client); + } + + withHealthCheck(key: string): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromiseImpl(this._withHealthCheckInternal(key), this._client); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContextImpl(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new PostgresDatabaseResourceImpl(result, this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): PostgresDatabaseResourcePromise { + const commandOptions = options?.commandOptions; + return new PostgresDatabaseResourcePromiseImpl(this._withCommandInternal(name, displayName, executeCommand, commandOptions), this._client); + } + + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: Awaitable, type: string): Promise { + resourceBuilder = isPromiseLike(resourceBuilder) ? await resourceBuilder : resourceBuilder; + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new PostgresDatabaseResourceImpl(result, this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromiseImpl(this._withRelationshipInternal(resourceBuilder, type), this._client); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: Awaitable): Promise { + parent = isPromiseLike(parent) ? await parent : parent; + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new PostgresDatabaseResourceImpl(result, this._client); + } + + withParentRelationship(parent: Awaitable): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromiseImpl(this._withParentRelationshipInternal(parent), this._client); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: Awaitable): Promise { + child = isPromiseLike(child) ? await child : child; + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', + rpcArgs + ); + return new PostgresDatabaseResourceImpl(result, this._client); + } + + withChildRelationship(child: Awaitable): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromiseImpl(this._withChildRelationshipInternal(child), this._client); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new PostgresDatabaseResourceImpl(result, this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): PostgresDatabaseResourcePromise { + const iconVariant = options?.iconVariant; + return new PostgresDatabaseResourcePromiseImpl(this._withIconNameInternal(iconName, iconVariant), this._client); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new PostgresDatabaseResourceImpl(result, this._client); + } + + excludeFromMcp(): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromiseImpl(this._excludeFromMcpInternal(), this._client); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new PostgresDatabaseResourceImpl(result, this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): PostgresDatabaseResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new PostgresDatabaseResourcePromiseImpl(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description), this._client); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new PostgresDatabaseResourceImpl(result, this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromiseImpl(this._withPipelineConfigurationInternal(callback), this._client); + } + + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); + } + + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new PostgresDatabaseResourceImpl(result, this._client); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromiseImpl(this._onBeforeResourceStartedInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new PostgresDatabaseResourceImpl(result, this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromiseImpl(this._onResourceStoppedInternal(callback), this._client); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onConnectionStringAvailable', + rpcArgs + ); + return new PostgresDatabaseResourceImpl(result, this._client); + } + + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromiseImpl(this._onConnectionStringAvailableInternal(callback), this._client); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new PostgresDatabaseResourceImpl(result, this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromiseImpl(this._onInitializeResourceInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new PostgresDatabaseResourceImpl(result, this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromiseImpl(this._onResourceReadyInternal(callback), this._client); + } + + async createExecutionConfiguration(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/createExecutionConfiguration', + rpcArgs + ); + } + + /** @internal */ + private async _withLikeC4DetailsInternal(label?: string, technology?: string, description?: string, summary?: string, icon?: string, configure?: (obj: LikeC4NodeDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4NodeDetailsAnnotationHandle; + const obj = new LikeC4NodeDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + const rpcArgs: Record = { builder: this._handle }; + if (label !== undefined) rpcArgs.label = label; + if (technology !== undefined) rpcArgs.technology = technology; + if (description !== undefined) rpcArgs.description = description; + if (summary !== undefined) rpcArgs.summary = summary; + if (icon !== undefined) rpcArgs.icon = icon; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4DetailsParameters', + rpcArgs + ); + return new PostgresDatabaseResourceImpl(result, this._client); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): PostgresDatabaseResourcePromise { + const label = options?.label; + const technology = options?.technology; + const description = options?.description; + const summary = options?.summary; + const icon = options?.icon; + const configure = options?.configure; + return new PostgresDatabaseResourcePromiseImpl(this._withLikeC4DetailsInternal(label, technology, description, summary, icon, configure), this._client); + } + + /** @internal */ + private async _withLikeC4ReferenceInternal(target: Awaitable, configure?: (obj: LikeC4RelationshipDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4RelationshipDetailsAnnotationHandle; + const obj = new LikeC4RelationshipDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target }; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Reference', + rpcArgs + ); + return new PostgresDatabaseResourceImpl(result, this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): PostgresDatabaseResourcePromise { + const configure = options?.configure; + return new PostgresDatabaseResourcePromiseImpl(this._withLikeC4ReferenceInternal(target, configure), this._client); + } + + /** @internal */ + private async _withLikeC4GroupInternal(groupName: string): Promise { + const rpcArgs: Record = { builder: this._handle, groupName }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Group', + rpcArgs + ); + return new PostgresDatabaseResourceImpl(result, this._client); + } + + withLikeC4Group(groupName: string): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromiseImpl(this._withLikeC4GroupInternal(groupName), this._client); + } + + /** @internal */ + private async _excludeFromLikeC4Internal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/excludeFromLikeC4', + rpcArgs + ); + return new PostgresDatabaseResourceImpl(result, this._client); + } + + excludeFromLikeC4(): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromiseImpl(this._excludeFromLikeC4Internal(), this._client); + } + + /** @internal */ + private async _withRoleAssignmentsInternal(target: Awaitable, roles: AzureKeyVaultRole[]): Promise { + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target, roles }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.KeyVault/withKeyVaultRoleAssignments', + rpcArgs + ); + return new PostgresDatabaseResourceImpl(result, this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromiseImpl(this._withRoleAssignmentsInternal(target, roles), this._client); + } + + /** @internal */ + private async _withPostgresMcpInternal(configureContainer?: (obj: PostgresMcpContainerResource) => Promise, containerName?: string): Promise { + const configureContainerId = configureContainer ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PostgresMcpContainerResourceHandle; + const obj = new PostgresMcpContainerResourceImpl(objHandle, this._client); + await configureContainer(obj); + }) : undefined; + const rpcArgs: Record = { builder: this._handle }; + if (configureContainer !== undefined) rpcArgs.configureContainer = configureContainerId; + if (containerName !== undefined) rpcArgs.containerName = containerName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.PostgreSQL/withPostgresMcp', + rpcArgs + ); + return new PostgresDatabaseResourceImpl(result, this._client); + } + + withPostgresMcp(options?: WithPostgresMcpOptions): PostgresDatabaseResourcePromise { + const configureContainer = options?.configureContainer; + const containerName = options?.containerName; + return new PostgresDatabaseResourcePromiseImpl(this._withPostgresMcpInternal(configureContainer, containerName), this._client); + } + + /** @internal */ + private async _withCreationScriptInternal(script: string): Promise { + const rpcArgs: Record = { builder: this._handle, script }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.PostgreSQL/withCreationScript', + rpcArgs + ); + return new PostgresDatabaseResourceImpl(result, this._client); + } + + withCreationScript(script: string): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromiseImpl(this._withCreationScriptInternal(script), this._client); + } + +} + +/** + * Thenable wrapper for PostgresDatabaseResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +class PostgresDatabaseResourcePromiseImpl implements PostgresDatabaseResourcePromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: PostgresDatabaseResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + parent(): Promise { + return this._promise.then(obj => obj.parent()); + } + + connectionStringExpression(): Promise { + return this._promise.then(obj => obj.connectionStringExpression()); + } + + databaseName(): Promise { + return this._promise.then(obj => obj.databaseName()); + } + + uriExpression(): Promise { + return this._promise.then(obj => obj.uriExpression()); + } + + jdbcConnectionString(): Promise { + return this._promise.then(obj => obj.jdbcConnectionString()); + } + + name(): Promise { + return this._promise.then(obj => obj.name()); + } + + withContainerRegistry(registry: Awaitable): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withContainerRegistry(registry)), this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withDockerfileBaseImage(options)), this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withRequiredCommand(command, options)), this._client); + } + + withConnectionProperty(name: string, value: string | ReferenceExpression): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withConnectionProperty(name, value)), this._client); + } + + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withUrls(callback)), this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withUrl(url, options)), this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback)), this._client); + } + + excludeFromManifest(): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromiseImpl(this._promise.then(obj => obj.excludeFromManifest()), this._client); + } + + withExplicitStart(): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withExplicitStart()), this._client); + } + + withHealthCheck(key: string): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withHealthCheck(key)), this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options)), this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withRelationship(resourceBuilder, type)), this._client); + } + + withParentRelationship(parent: Awaitable): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withParentRelationship(parent)), this._client); + } + + withChildRelationship(child: Awaitable): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withChildRelationship(child)), this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withIconName(iconName, options)), this._client); + } + + excludeFromMcp(): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromiseImpl(this._promise.then(obj => obj.excludeFromMcp()), this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options)), this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withPipelineConfiguration(callback)), this._client); + } + + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromiseImpl(this._promise.then(obj => obj.onBeforeResourceStarted(callback)), this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromiseImpl(this._promise.then(obj => obj.onResourceStopped(callback)), this._client); + } + + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromiseImpl(this._promise.then(obj => obj.onConnectionStringAvailable(callback)), this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromiseImpl(this._promise.then(obj => obj.onInitializeResource(callback)), this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromiseImpl(this._promise.then(obj => obj.onResourceReady(callback)), this._client); + } + + createExecutionConfiguration(): Promise { + return this._promise.then(obj => obj.createExecutionConfiguration()); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Details(options)), this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Reference(target, options)), this._client); + } + + withLikeC4Group(groupName: string): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Group(groupName)), this._client); + } + + excludeFromLikeC4(): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromiseImpl(this._promise.then(obj => obj.excludeFromLikeC4()), this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withRoleAssignments(target, roles)), this._client); + } + + withPostgresMcp(options?: WithPostgresMcpOptions): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withPostgresMcp(options)), this._client); + } + + withCreationScript(script: string): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withCreationScript(script)), this._client); + } + +} + +// ============================================================================ +// PostgresMcpContainerResource +// ============================================================================ + +export interface PostgresMcpContainerResource { + toJSON(): MarshalledHandle; + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): PostgresMcpContainerResourcePromise; + /** Adds a bind mount */ + withBindMount(source: string, target: string, options?: WithBindMountOptions): PostgresMcpContainerResourcePromise; + /** Sets the container entrypoint */ + withEntrypoint(entrypoint: string): PostgresMcpContainerResourcePromise; + /** Sets the container image tag */ + withImageTag(tag: string): PostgresMcpContainerResourcePromise; + /** Sets the container image registry */ + withImageRegistry(registry: string): PostgresMcpContainerResourcePromise; + /** Sets the container image */ + withImage(image: string, options?: WithImageOptions): PostgresMcpContainerResourcePromise; + /** Sets the image SHA256 digest */ + withImageSHA256(sha256: string): PostgresMcpContainerResourcePromise; + /** Adds runtime arguments for the container */ + withContainerRuntimeArgs(args: string[]): PostgresMcpContainerResourcePromise; + /** Sets the lifetime behavior of the container resource */ + withLifetime(lifetime: ContainerLifetime): PostgresMcpContainerResourcePromise; + /** Sets the container image pull policy */ + withImagePullPolicy(pullPolicy: ImagePullPolicy): PostgresMcpContainerResourcePromise; + /** Configures the resource to be published as a container */ + publishAsContainer(): PostgresMcpContainerResourcePromise; + /** Configures the resource to use a Dockerfile */ + withDockerfile(contextPath: string, options?: WithDockerfileOptions): PostgresMcpContainerResourcePromise; + /** Sets the container name */ + withContainerName(name: string): PostgresMcpContainerResourcePromise; + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource | Awaitable): PostgresMcpContainerResourcePromise; + /** Adds a build secret from a parameter resource */ + withBuildSecret(name: string, value: Awaitable): PostgresMcpContainerResourcePromise; + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): PostgresMcpContainerResourcePromise; + /** Configures endpoint proxy support */ + withEndpointProxySupport(proxyEnabled: boolean): PostgresMcpContainerResourcePromise; + /** Configures the resource to use a programmatically generated Dockerfile */ + withDockerfileBuilder(contextPath: string, callback: (arg: DockerfileBuilderCallbackContext) => Promise, options?: WithDockerfileBuilderOptions): PostgresMcpContainerResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): PostgresMcpContainerResourcePromise; + /** Adds a network alias for the container */ + withContainerNetworkAlias(alias: string): PostgresMcpContainerResourcePromise; + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): PostgresMcpContainerResourcePromise; + /** Configures OTLP telemetry export */ + withOtlpExporter(options?: WithOtlpExporterOptions): PostgresMcpContainerResourcePromise; + /** Publishes the resource as a connection string */ + publishAsConnectionString(): PostgresMcpContainerResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): PostgresMcpContainerResourcePromise; + /** Sets an environment variable */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): PostgresMcpContainerResourcePromise; + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): PostgresMcpContainerResourcePromise; + /** Adds arguments */ + withArgs(args: string[]): PostgresMcpContainerResourcePromise; + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): PostgresMcpContainerResourcePromise; + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): PostgresMcpContainerResourcePromise; + /** Adds a reference to another resource */ + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): PostgresMcpContainerResourcePromise; + /** Updates a named endpoint via callback */ + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): PostgresMcpContainerResourcePromise; + /** Updates an HTTP endpoint via callback */ + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): PostgresMcpContainerResourcePromise; + /** Updates an HTTPS endpoint via callback */ + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): PostgresMcpContainerResourcePromise; + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): PostgresMcpContainerResourcePromise; + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): PostgresMcpContainerResourcePromise; + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): PostgresMcpContainerResourcePromise; + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): PostgresMcpContainerResourcePromise; + /** Gets an endpoint reference */ + getEndpoint(name: string): Promise; + /** Configures resource for HTTP/2 */ + asHttp2Service(): PostgresMcpContainerResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): PostgresMcpContainerResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): PostgresMcpContainerResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): PostgresMcpContainerResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): PostgresMcpContainerResourcePromise; + /** Waits for another resource to be ready */ + waitFor(dependency: Awaitable, options?: WaitForOptions): PostgresMcpContainerResourcePromise; + /** Waits for another resource to start */ + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): PostgresMcpContainerResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): PostgresMcpContainerResourcePromise; + /** Waits for resource completion */ + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): PostgresMcpContainerResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): PostgresMcpContainerResourcePromise; + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): PostgresMcpContainerResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): PostgresMcpContainerResourcePromise; + /** Adds an HTTP resource command */ + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): PostgresMcpContainerResourcePromise; + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): PostgresMcpContainerResourcePromise; + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): PostgresMcpContainerResourcePromise; + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): PostgresMcpContainerResourcePromise; + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): PostgresMcpContainerResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): PostgresMcpContainerResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): PostgresMcpContainerResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): PostgresMcpContainerResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): PostgresMcpContainerResourcePromise; + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): PostgresMcpContainerResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): PostgresMcpContainerResourcePromise; + /** Sets image push options via callback */ + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): PostgresMcpContainerResourcePromise; + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): PostgresMcpContainerResourcePromise; + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): PostgresMcpContainerResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): PostgresMcpContainerResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): PostgresMcpContainerResourcePromise; + /** Adds a volume */ + withVolume(target: string, options?: WithVolumeOptions): PostgresMcpContainerResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): PostgresMcpContainerResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): PostgresMcpContainerResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): PostgresMcpContainerResourcePromise; + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): PostgresMcpContainerResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): PostgresMcpContainerResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Create a new reference, while also allowing customization of how a resource appears in the generated LikeC4 diagram. */ + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): PostgresMcpContainerResourcePromise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): PostgresMcpContainerResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): PostgresMcpContainerResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): PostgresMcpContainerResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): PostgresMcpContainerResourcePromise; + /** Associates an Azure user-assigned identity with a compute resource */ + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): PostgresMcpContainerResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): PostgresMcpContainerResourcePromise; +} + +export interface PostgresMcpContainerResourcePromise extends PromiseLike { + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): PostgresMcpContainerResourcePromise; + /** Adds a bind mount */ + withBindMount(source: string, target: string, options?: WithBindMountOptions): PostgresMcpContainerResourcePromise; + /** Sets the container entrypoint */ + withEntrypoint(entrypoint: string): PostgresMcpContainerResourcePromise; + /** Sets the container image tag */ + withImageTag(tag: string): PostgresMcpContainerResourcePromise; + /** Sets the container image registry */ + withImageRegistry(registry: string): PostgresMcpContainerResourcePromise; + /** Sets the container image */ + withImage(image: string, options?: WithImageOptions): PostgresMcpContainerResourcePromise; + /** Sets the image SHA256 digest */ + withImageSHA256(sha256: string): PostgresMcpContainerResourcePromise; + /** Adds runtime arguments for the container */ + withContainerRuntimeArgs(args: string[]): PostgresMcpContainerResourcePromise; + /** Sets the lifetime behavior of the container resource */ + withLifetime(lifetime: ContainerLifetime): PostgresMcpContainerResourcePromise; + /** Sets the container image pull policy */ + withImagePullPolicy(pullPolicy: ImagePullPolicy): PostgresMcpContainerResourcePromise; + /** Configures the resource to be published as a container */ + publishAsContainer(): PostgresMcpContainerResourcePromise; + /** Configures the resource to use a Dockerfile */ + withDockerfile(contextPath: string, options?: WithDockerfileOptions): PostgresMcpContainerResourcePromise; + /** Sets the container name */ + withContainerName(name: string): PostgresMcpContainerResourcePromise; + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource | Awaitable): PostgresMcpContainerResourcePromise; + /** Adds a build secret from a parameter resource */ + withBuildSecret(name: string, value: Awaitable): PostgresMcpContainerResourcePromise; + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): PostgresMcpContainerResourcePromise; + /** Configures endpoint proxy support */ + withEndpointProxySupport(proxyEnabled: boolean): PostgresMcpContainerResourcePromise; + /** Configures the resource to use a programmatically generated Dockerfile */ + withDockerfileBuilder(contextPath: string, callback: (arg: DockerfileBuilderCallbackContext) => Promise, options?: WithDockerfileBuilderOptions): PostgresMcpContainerResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): PostgresMcpContainerResourcePromise; + /** Adds a network alias for the container */ + withContainerNetworkAlias(alias: string): PostgresMcpContainerResourcePromise; + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): PostgresMcpContainerResourcePromise; + /** Configures OTLP telemetry export */ + withOtlpExporter(options?: WithOtlpExporterOptions): PostgresMcpContainerResourcePromise; + /** Publishes the resource as a connection string */ + publishAsConnectionString(): PostgresMcpContainerResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): PostgresMcpContainerResourcePromise; + /** Sets an environment variable */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): PostgresMcpContainerResourcePromise; + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): PostgresMcpContainerResourcePromise; + /** Adds arguments */ + withArgs(args: string[]): PostgresMcpContainerResourcePromise; + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): PostgresMcpContainerResourcePromise; + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): PostgresMcpContainerResourcePromise; + /** Adds a reference to another resource */ + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): PostgresMcpContainerResourcePromise; + /** Updates a named endpoint via callback */ + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): PostgresMcpContainerResourcePromise; + /** Updates an HTTP endpoint via callback */ + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): PostgresMcpContainerResourcePromise; + /** Updates an HTTPS endpoint via callback */ + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): PostgresMcpContainerResourcePromise; + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): PostgresMcpContainerResourcePromise; + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): PostgresMcpContainerResourcePromise; + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): PostgresMcpContainerResourcePromise; + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): PostgresMcpContainerResourcePromise; + /** Gets an endpoint reference */ + getEndpoint(name: string): Promise; + /** Configures resource for HTTP/2 */ + asHttp2Service(): PostgresMcpContainerResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): PostgresMcpContainerResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): PostgresMcpContainerResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): PostgresMcpContainerResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): PostgresMcpContainerResourcePromise; + /** Waits for another resource to be ready */ + waitFor(dependency: Awaitable, options?: WaitForOptions): PostgresMcpContainerResourcePromise; + /** Waits for another resource to start */ + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): PostgresMcpContainerResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): PostgresMcpContainerResourcePromise; + /** Waits for resource completion */ + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): PostgresMcpContainerResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): PostgresMcpContainerResourcePromise; + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): PostgresMcpContainerResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): PostgresMcpContainerResourcePromise; + /** Adds an HTTP resource command */ + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): PostgresMcpContainerResourcePromise; + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): PostgresMcpContainerResourcePromise; + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): PostgresMcpContainerResourcePromise; + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): PostgresMcpContainerResourcePromise; + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): PostgresMcpContainerResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): PostgresMcpContainerResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): PostgresMcpContainerResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): PostgresMcpContainerResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): PostgresMcpContainerResourcePromise; + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): PostgresMcpContainerResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): PostgresMcpContainerResourcePromise; + /** Sets image push options via callback */ + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): PostgresMcpContainerResourcePromise; + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): PostgresMcpContainerResourcePromise; + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): PostgresMcpContainerResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): PostgresMcpContainerResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): PostgresMcpContainerResourcePromise; + /** Adds a volume */ + withVolume(target: string, options?: WithVolumeOptions): PostgresMcpContainerResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): PostgresMcpContainerResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): PostgresMcpContainerResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): PostgresMcpContainerResourcePromise; + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): PostgresMcpContainerResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): PostgresMcpContainerResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Create a new reference, while also allowing customization of how a resource appears in the generated LikeC4 diagram. */ + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): PostgresMcpContainerResourcePromise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): PostgresMcpContainerResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): PostgresMcpContainerResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): PostgresMcpContainerResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): PostgresMcpContainerResourcePromise; + /** Associates an Azure user-assigned identity with a compute resource */ + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): PostgresMcpContainerResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): PostgresMcpContainerResourcePromise; +} + +// ============================================================================ +// PostgresMcpContainerResourceImpl +// ============================================================================ + +class PostgresMcpContainerResourceImpl extends ResourceBuilderBase implements PostgresMcpContainerResource { + constructor(handle: PostgresMcpContainerResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: Awaitable): Promise { + registry = isPromiseLike(registry) ? await registry : registry; + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withContainerRegistry(registry: Awaitable): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._withContainerRegistryInternal(registry), this._client); + } + + /** @internal */ + private async _withBindMountInternal(source: string, target: string, isReadOnly?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, source, target }; + if (isReadOnly !== undefined) rpcArgs.isReadOnly = isReadOnly; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBindMount', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withBindMount(source: string, target: string, options?: WithBindMountOptions): PostgresMcpContainerResourcePromise { + const isReadOnly = options?.isReadOnly; + return new PostgresMcpContainerResourcePromiseImpl(this._withBindMountInternal(source, target, isReadOnly), this._client); + } + + /** @internal */ + private async _withEntrypointInternal(entrypoint: string): Promise { + const rpcArgs: Record = { builder: this._handle, entrypoint }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEntrypoint', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withEntrypoint(entrypoint: string): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._withEntrypointInternal(entrypoint), this._client); + } + + /** @internal */ + private async _withImageTagInternal(tag: string): Promise { + const rpcArgs: Record = { builder: this._handle, tag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImageTag', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withImageTag(tag: string): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._withImageTagInternal(tag), this._client); + } + + /** @internal */ + private async _withImageRegistryInternal(registry: string): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImageRegistry', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withImageRegistry(registry: string): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._withImageRegistryInternal(registry), this._client); + } + + /** @internal */ + private async _withImageInternal(image: string, tag?: string): Promise { + const rpcArgs: Record = { builder: this._handle, image }; + if (tag !== undefined) rpcArgs.tag = tag; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImage', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withImage(image: string, options?: WithImageOptions): PostgresMcpContainerResourcePromise { + const tag = options?.tag; + return new PostgresMcpContainerResourcePromiseImpl(this._withImageInternal(image, tag), this._client); + } + + /** @internal */ + private async _withImageSHA256Internal(sha256: string): Promise { + const rpcArgs: Record = { builder: this._handle, sha256 }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImageSHA256', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withImageSHA256(sha256: string): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._withImageSHA256Internal(sha256), this._client); + } + + /** @internal */ + private async _withContainerRuntimeArgsInternal(args: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, args }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRuntimeArgs', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withContainerRuntimeArgs(args: string[]): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._withContainerRuntimeArgsInternal(args), this._client); + } + + /** @internal */ + private async _withLifetimeInternal(lifetime: ContainerLifetime): Promise { + const rpcArgs: Record = { builder: this._handle, lifetime }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withLifetime', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withLifetime(lifetime: ContainerLifetime): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._withLifetimeInternal(lifetime), this._client); + } + + /** @internal */ + private async _withImagePullPolicyInternal(pullPolicy: ImagePullPolicy): Promise { + const rpcArgs: Record = { builder: this._handle, pullPolicy }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImagePullPolicy', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withImagePullPolicy(pullPolicy: ImagePullPolicy): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._withImagePullPolicyInternal(pullPolicy), this._client); + } + + /** @internal */ + private async _publishAsContainerInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsContainer', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + publishAsContainer(): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._publishAsContainerInternal(), this._client); + } + + /** @internal */ + private async _withDockerfileInternal(contextPath: string, dockerfilePath?: string, stage?: string): Promise { + const rpcArgs: Record = { builder: this._handle, contextPath }; + if (dockerfilePath !== undefined) rpcArgs.dockerfilePath = dockerfilePath; + if (stage !== undefined) rpcArgs.stage = stage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfile', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withDockerfile(contextPath: string, options?: WithDockerfileOptions): PostgresMcpContainerResourcePromise { + const dockerfilePath = options?.dockerfilePath; + const stage = options?.stage; + return new PostgresMcpContainerResourcePromiseImpl(this._withDockerfileInternal(contextPath, dockerfilePath, stage), this._client); + } + + /** @internal */ + private async _withContainerNameInternal(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerName', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withContainerName(name: string): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._withContainerNameInternal(name), this._client); + } + + /** @internal */ + private async _withBuildArgInternal(name: string, value: string | ParameterResource | Awaitable): Promise { + value = isPromiseLike(value) ? await value : value; + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuildArg', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withBuildArg(name: string, value: string | ParameterResource | Awaitable): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._withBuildArgInternal(name, value), this._client); + } + + /** @internal */ + private async _withBuildSecretInternal(name: string, value: Awaitable): Promise { + value = isPromiseLike(value) ? await value : value; + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParameterBuildSecret', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withBuildSecret(name: string, value: Awaitable): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._withBuildSecretInternal(name, value), this._client); + } + + /** @internal */ + private async _withContainerCertificatePathsInternal(customCertificatesDestination?: string, defaultCertificateBundlePaths?: string[], defaultCertificateDirectoryPaths?: string[]): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (customCertificatesDestination !== undefined) rpcArgs.customCertificatesDestination = customCertificatesDestination; + if (defaultCertificateBundlePaths !== undefined) rpcArgs.defaultCertificateBundlePaths = defaultCertificateBundlePaths; + if (defaultCertificateDirectoryPaths !== undefined) rpcArgs.defaultCertificateDirectoryPaths = defaultCertificateDirectoryPaths; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerCertificatePaths', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): PostgresMcpContainerResourcePromise { + const customCertificatesDestination = options?.customCertificatesDestination; + const defaultCertificateBundlePaths = options?.defaultCertificateBundlePaths; + const defaultCertificateDirectoryPaths = options?.defaultCertificateDirectoryPaths; + return new PostgresMcpContainerResourcePromiseImpl(this._withContainerCertificatePathsInternal(customCertificatesDestination, defaultCertificateBundlePaths, defaultCertificateDirectoryPaths), this._client); + } + + /** @internal */ + private async _withEndpointProxySupportInternal(proxyEnabled: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, proxyEnabled }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpointProxySupport', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withEndpointProxySupport(proxyEnabled: boolean): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._withEndpointProxySupportInternal(proxyEnabled), this._client); + } + + /** @internal */ + private async _withDockerfileBuilderInternal(contextPath: string, callback: (arg: DockerfileBuilderCallbackContext) => Promise, stage?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as DockerfileBuilderCallbackContextHandle; + const arg = new DockerfileBuilderCallbackContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, contextPath, callback: callbackId }; + if (stage !== undefined) rpcArgs.stage = stage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBuilder', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withDockerfileBuilder(contextPath: string, callback: (arg: DockerfileBuilderCallbackContext) => Promise, options?: WithDockerfileBuilderOptions): PostgresMcpContainerResourcePromise { + const stage = options?.stage; + return new PostgresMcpContainerResourcePromiseImpl(this._withDockerfileBuilderInternal(contextPath, callback, stage), this._client); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): PostgresMcpContainerResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new PostgresMcpContainerResourcePromiseImpl(this._withDockerfileBaseImageInternal(buildImage, runtimeImage), this._client); + } + + /** @internal */ + private async _withContainerNetworkAliasInternal(alias: string): Promise { + const rpcArgs: Record = { builder: this._handle, alias }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerNetworkAlias', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withContainerNetworkAlias(alias: string): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._withContainerNetworkAliasInternal(alias), this._client); + } + + /** @internal */ + private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withMcpServer', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withMcpServer(options?: WithMcpServerOptions): PostgresMcpContainerResourcePromise { + const path = options?.path; + const endpointName = options?.endpointName; + return new PostgresMcpContainerResourcePromiseImpl(this._withMcpServerInternal(path, endpointName), this._client); + } + + /** @internal */ + private async _withOtlpExporterInternal(protocol?: OtlpProtocol): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (protocol !== undefined) rpcArgs.protocol = protocol; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporter', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withOtlpExporter(options?: WithOtlpExporterOptions): PostgresMcpContainerResourcePromise { + const protocol = options?.protocol; + return new PostgresMcpContainerResourcePromiseImpl(this._withOtlpExporterInternal(protocol), this._client); + } + + /** @internal */ + private async _publishAsConnectionStringInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsConnectionString', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + publishAsConnectionString(): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._publishAsConnectionStringInternal(), this._client); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): PostgresMcpContainerResourcePromise { + const helpLink = options?.helpLink; + return new PostgresMcpContainerResourcePromiseImpl(this._withRequiredCommandInternal(command, helpLink), this._client); + } + + /** @internal */ + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): Promise { + value = isPromiseLike(value) ? await value : value; + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironment', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._withEnvironmentInternal(name, value), this._client); + } + + /** @internal */ + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentCallback', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._withEnvironmentCallbackInternal(callback), this._client); + } + + /** @internal */ + private async _withArgsInternal(args: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, args }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgs', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withArgs(args: string[]): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._withArgsInternal(args), this._client); + } + + /** @internal */ + private async _withArgsCallbackInternal(callback: (obj: CommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; + const obj = new CommandLineArgsCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallback', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._withArgsCallbackInternal(callback), this._client); + } + + /** @internal */ + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceEnvironment', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._withReferenceEnvironmentInternal(options), this._client); + } + + /** @internal */ + private async _withReferenceInternal(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, connectionName?: string, optional?: boolean, name?: string): Promise { + source = isPromiseLike(source) ? await source : source; + const rpcArgs: Record = { builder: this._handle, source }; + if (connectionName !== undefined) rpcArgs.connectionName = connectionName; + if (optional !== undefined) rpcArgs.optional = optional; + if (name !== undefined) rpcArgs.name = name; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReference', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): PostgresMcpContainerResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new PostgresMcpContainerResourcePromiseImpl(this._withReferenceInternal(source, connectionName, optional, name), this._client); + } + + /** @internal */ + private async _withEndpointCallbackInternal(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpointCallback', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): PostgresMcpContainerResourcePromise { + const createIfNotExists = options?.createIfNotExists; + return new PostgresMcpContainerResourcePromiseImpl(this._withEndpointCallbackInternal(endpointName, callback, createIfNotExists), this._client); + } + + /** @internal */ + private async _withHttpEndpointCallbackInternal(callback: (obj: EndpointUpdateContext) => Promise, name?: string, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + if (name !== undefined) rpcArgs.name = name; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpEndpointCallback', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): PostgresMcpContainerResourcePromise { + const name = options?.name; + const createIfNotExists = options?.createIfNotExists; + return new PostgresMcpContainerResourcePromiseImpl(this._withHttpEndpointCallbackInternal(callback, name, createIfNotExists), this._client); + } + + /** @internal */ + private async _withHttpsEndpointCallbackInternal(callback: (obj: EndpointUpdateContext) => Promise, name?: string, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + if (name !== undefined) rpcArgs.name = name; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsEndpointCallback', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): PostgresMcpContainerResourcePromise { + const name = options?.name; + const createIfNotExists = options?.createIfNotExists; + return new PostgresMcpContainerResourcePromiseImpl(this._withHttpsEndpointCallbackInternal(callback, name, createIfNotExists), this._client); + } + + /** @internal */ + private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (scheme !== undefined) rpcArgs.scheme = scheme; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + if (isExternal !== undefined) rpcArgs.isExternal = isExternal; + if (protocol !== undefined) rpcArgs.protocol = protocol; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpoint', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withEndpoint(options?: WithEndpointOptions): PostgresMcpContainerResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const scheme = options?.scheme; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + const isExternal = options?.isExternal; + const protocol = options?.protocol; + return new PostgresMcpContainerResourcePromiseImpl(this._withEndpointInternal(port, targetPort, scheme, name, env, isProxied, isExternal, protocol), this._client); + } + + /** @internal */ + private async _withHttpEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpEndpoint', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withHttpEndpoint(options?: WithHttpEndpointOptions): PostgresMcpContainerResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new PostgresMcpContainerResourcePromiseImpl(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied), this._client); + } + + /** @internal */ + private async _withHttpsEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsEndpoint', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withHttpsEndpoint(options?: WithHttpsEndpointOptions): PostgresMcpContainerResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new PostgresMcpContainerResourcePromiseImpl(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied), this._client); + } + + /** @internal */ + private async _withExternalHttpEndpointsInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExternalHttpEndpoints', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withExternalHttpEndpoints(): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._withExternalHttpEndpointsInternal(), this._client); + } + + async getEndpoint(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getEndpoint', + rpcArgs + ); + } + + /** @internal */ + private async _asHttp2ServiceInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/asHttp2Service', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + asHttp2Service(): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._asHttp2ServiceInternal(), this._client); + } + + /** @internal */ + private async _withUrlsInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrls', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._withUrlsInternal(callback), this._client); + } + + /** @internal */ + private async _withUrlInternal(url: string | ReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): PostgresMcpContainerResourcePromise { + const displayText = options?.displayText; + return new PostgresMcpContainerResourcePromiseImpl(this._withUrlInternal(url, displayText), this._client); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._withUrlForEndpointInternal(endpointName, callback), this._client); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + excludeFromManifest(): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._excludeFromManifestInternal(), this._client); + } + + /** @internal */ + private async _waitForInternal(dependency: Awaitable, waitBehavior?: WaitBehavior): Promise { + dependency = isPromiseLike(dependency) ? await dependency : dependency; + const rpcArgs: Record = { builder: this._handle, dependency }; + if (waitBehavior !== undefined) rpcArgs.waitBehavior = waitBehavior; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitFor', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + waitFor(dependency: Awaitable, options?: WaitForOptions): PostgresMcpContainerResourcePromise { + const waitBehavior = options?.waitBehavior; + return new PostgresMcpContainerResourcePromiseImpl(this._waitForInternal(dependency, waitBehavior), this._client); + } + + /** @internal */ + private async _waitForStartInternal(dependency: Awaitable, waitBehavior?: WaitBehavior): Promise { + dependency = isPromiseLike(dependency) ? await dependency : dependency; + const rpcArgs: Record = { builder: this._handle, dependency }; + if (waitBehavior !== undefined) rpcArgs.waitBehavior = waitBehavior; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStart', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): PostgresMcpContainerResourcePromise { + const waitBehavior = options?.waitBehavior; + return new PostgresMcpContainerResourcePromiseImpl(this._waitForStartInternal(dependency, waitBehavior), this._client); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withExplicitStart(): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._withExplicitStartInternal(), this._client); + } + + /** @internal */ + private async _waitForCompletionInternal(dependency: Awaitable, exitCode?: number): Promise { + dependency = isPromiseLike(dependency) ? await dependency : dependency; + const rpcArgs: Record = { builder: this._handle, dependency }; + if (exitCode !== undefined) rpcArgs.exitCode = exitCode; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceCompletion', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): PostgresMcpContainerResourcePromise { + const exitCode = options?.exitCode; + return new PostgresMcpContainerResourcePromiseImpl(this._waitForCompletionInternal(dependency, exitCode), this._client); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withHealthCheck(key: string): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._withHealthCheckInternal(key), this._client); + } + + /** @internal */ + private async _withHttpHealthCheckInternal(path?: string, statusCode?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (statusCode !== undefined) rpcArgs.statusCode = statusCode; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpHealthCheck', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): PostgresMcpContainerResourcePromise { + const path = options?.path; + const statusCode = options?.statusCode; + const endpointName = options?.endpointName; + return new PostgresMcpContainerResourcePromiseImpl(this._withHttpHealthCheckInternal(path, statusCode, endpointName), this._client); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContextImpl(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): PostgresMcpContainerResourcePromise { + const commandOptions = options?.commandOptions; + return new PostgresMcpContainerResourcePromiseImpl(this._withCommandInternal(name, displayName, executeCommand, commandOptions), this._client); + } + + /** @internal */ + private async _withHttpCommandInternal(path: string, displayName: string, options?: HttpCommandExportOptions): Promise { + const rpcArgs: Record = { builder: this._handle, path, displayName }; + if (options !== undefined) rpcArgs.options = options; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpCommand', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._withHttpCommandInternal(path, displayName, options), this._client); + } + + /** @internal */ + private async _withDeveloperCertificateTrustInternal(trust: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, trust }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDeveloperCertificateTrust', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withDeveloperCertificateTrust(trust: boolean): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._withDeveloperCertificateTrustInternal(trust), this._client); + } + + /** @internal */ + private async _withCertificateTrustScopeInternal(scope: CertificateTrustScope): Promise { + const rpcArgs: Record = { builder: this._handle, scope }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCertificateTrustScope', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withCertificateTrustScope(scope: CertificateTrustScope): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._withCertificateTrustScopeInternal(scope), this._client); + } + + /** @internal */ + private async _withHttpsDeveloperCertificateInternal(password?: Awaitable): Promise { + password = isPromiseLike(password) ? await password : password; + const rpcArgs: Record = { builder: this._handle }; + if (password !== undefined) rpcArgs.password = password; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): PostgresMcpContainerResourcePromise { + let password = options?.password; + return new PostgresMcpContainerResourcePromiseImpl(this._withHttpsDeveloperCertificateInternal(password), this._client); + } + + /** @internal */ + private async _withoutHttpsCertificateInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withoutHttpsCertificate', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withoutHttpsCertificate(): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._withoutHttpsCertificateInternal(), this._client); + } + + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: Awaitable, type: string): Promise { + resourceBuilder = isPromiseLike(resourceBuilder) ? await resourceBuilder : resourceBuilder; + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._withRelationshipInternal(resourceBuilder, type), this._client); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: Awaitable): Promise { + parent = isPromiseLike(parent) ? await parent : parent; + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withParentRelationship(parent: Awaitable): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._withParentRelationshipInternal(parent), this._client); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: Awaitable): Promise { + child = isPromiseLike(child) ? await child : child; + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withChildRelationship(child: Awaitable): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._withChildRelationshipInternal(child), this._client); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): PostgresMcpContainerResourcePromise { + const iconVariant = options?.iconVariant; + return new PostgresMcpContainerResourcePromiseImpl(this._withIconNameInternal(iconName, iconVariant), this._client); + } + + /** @internal */ + private async _withHttpProbeInternal(probeType: ProbeType, path?: string, initialDelaySeconds?: number, periodSeconds?: number, timeoutSeconds?: number, failureThreshold?: number, successThreshold?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, probeType }; + if (path !== undefined) rpcArgs.path = path; + if (initialDelaySeconds !== undefined) rpcArgs.initialDelaySeconds = initialDelaySeconds; + if (periodSeconds !== undefined) rpcArgs.periodSeconds = periodSeconds; + if (timeoutSeconds !== undefined) rpcArgs.timeoutSeconds = timeoutSeconds; + if (failureThreshold !== undefined) rpcArgs.failureThreshold = failureThreshold; + if (successThreshold !== undefined) rpcArgs.successThreshold = successThreshold; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpProbe', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): PostgresMcpContainerResourcePromise { + const path = options?.path; + const initialDelaySeconds = options?.initialDelaySeconds; + const periodSeconds = options?.periodSeconds; + const timeoutSeconds = options?.timeoutSeconds; + const failureThreshold = options?.failureThreshold; + const successThreshold = options?.successThreshold; + const endpointName = options?.endpointName; + return new PostgresMcpContainerResourcePromiseImpl(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName), this._client); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + excludeFromMcp(): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._excludeFromMcpInternal(), this._client); + } + + /** @internal */ + private async _withImagePushOptionsInternal(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ContainerImagePushOptionsCallbackContextHandle; + const arg = new ContainerImagePushOptionsCallbackContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImagePushOptions', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._withImagePushOptionsInternal(callback), this._client); + } + + /** @internal */ + private async _withRemoteImageNameInternal(remoteImageName: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageName', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withRemoteImageName(remoteImageName: string): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._withRemoteImageNameInternal(remoteImageName), this._client); + } + + /** @internal */ + private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageTag', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withRemoteImageTag(remoteImageTag: string): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._withRemoteImageTagInternal(remoteImageTag), this._client); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): PostgresMcpContainerResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new PostgresMcpContainerResourcePromiseImpl(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description), this._client); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._withPipelineConfigurationInternal(callback), this._client); + } + + /** @internal */ + private async _withVolumeInternal(target: string, name?: string, isReadOnly?: boolean): Promise { + const rpcArgs: Record = { resource: this._handle, target }; + if (name !== undefined) rpcArgs.name = name; + if (isReadOnly !== undefined) rpcArgs.isReadOnly = isReadOnly; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withVolume', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withVolume(target: string, options?: WithVolumeOptions): PostgresMcpContainerResourcePromise { + const name = options?.name; + const isReadOnly = options?.isReadOnly; + return new PostgresMcpContainerResourcePromiseImpl(this._withVolumeInternal(target, name, isReadOnly), this._client); + } + + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); + } + + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._onBeforeResourceStartedInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._onResourceStoppedInternal(callback), this._client); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._onInitializeResourceInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceEndpointsAllocated', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._onResourceEndpointsAllocatedInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._onResourceReadyInternal(callback), this._client); + } + + async createExecutionConfiguration(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/createExecutionConfiguration', + rpcArgs + ); + } + + /** @internal */ + private async _withLikeC4ReferenceWithEnvironmentInternal(source: Awaitable, configure?: (obj: LikeC4RelationshipDetailsAnnotation) => Promise, connectionName?: string, optional?: boolean, skipAspireReference?: boolean): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4RelationshipDetailsAnnotationHandle; + const obj = new LikeC4RelationshipDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + source = isPromiseLike(source) ? await source : source; + const rpcArgs: Record = { builder: this._handle, source }; + if (configure !== undefined) rpcArgs.configure = configureId; + if (connectionName !== undefined) rpcArgs.connectionName = connectionName; + if (optional !== undefined) rpcArgs.optional = optional; + if (skipAspireReference !== undefined) rpcArgs.skipAspireReference = skipAspireReference; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4ReferenceWithEnvironment', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): PostgresMcpContainerResourcePromise { + const configure = options?.configure; + const connectionName = options?.connectionName; + const optional = options?.optional; + const skipAspireReference = options?.skipAspireReference; + return new PostgresMcpContainerResourcePromiseImpl(this._withLikeC4ReferenceWithEnvironmentInternal(source, configure, connectionName, optional, skipAspireReference), this._client); + } + + /** @internal */ + private async _withLikeC4DetailsInternal(label?: string, technology?: string, description?: string, summary?: string, icon?: string, configure?: (obj: LikeC4NodeDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4NodeDetailsAnnotationHandle; + const obj = new LikeC4NodeDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + const rpcArgs: Record = { builder: this._handle }; + if (label !== undefined) rpcArgs.label = label; + if (technology !== undefined) rpcArgs.technology = technology; + if (description !== undefined) rpcArgs.description = description; + if (summary !== undefined) rpcArgs.summary = summary; + if (icon !== undefined) rpcArgs.icon = icon; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4DetailsParameters', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): PostgresMcpContainerResourcePromise { + const label = options?.label; + const technology = options?.technology; + const description = options?.description; + const summary = options?.summary; + const icon = options?.icon; + const configure = options?.configure; + return new PostgresMcpContainerResourcePromiseImpl(this._withLikeC4DetailsInternal(label, technology, description, summary, icon, configure), this._client); + } + + /** @internal */ + private async _withLikeC4ReferenceInternal(target: Awaitable, configure?: (obj: LikeC4RelationshipDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4RelationshipDetailsAnnotationHandle; + const obj = new LikeC4RelationshipDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target }; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Reference', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): PostgresMcpContainerResourcePromise { + const configure = options?.configure; + return new PostgresMcpContainerResourcePromiseImpl(this._withLikeC4ReferenceInternal(target, configure), this._client); + } + + /** @internal */ + private async _withLikeC4GroupInternal(groupName: string): Promise { + const rpcArgs: Record = { builder: this._handle, groupName }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Group', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withLikeC4Group(groupName: string): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._withLikeC4GroupInternal(groupName), this._client); + } + + /** @internal */ + private async _excludeFromLikeC4Internal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/excludeFromLikeC4', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + excludeFromLikeC4(): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._excludeFromLikeC4Internal(), this._client); + } + + /** @internal */ + private async _withAzureUserAssignedIdentityInternal(identityResourceBuilder: Awaitable): Promise { + identityResourceBuilder = isPromiseLike(identityResourceBuilder) ? await identityResourceBuilder : identityResourceBuilder; + const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._withAzureUserAssignedIdentityInternal(identityResourceBuilder), this._client); + } + + /** @internal */ + private async _withRoleAssignmentsInternal(target: Awaitable, roles: AzureKeyVaultRole[]): Promise { + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target, roles }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.KeyVault/withKeyVaultRoleAssignments', + rpcArgs + ); + return new PostgresMcpContainerResourceImpl(result, this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._withRoleAssignmentsInternal(target, roles), this._client); + } + +} + +/** + * Thenable wrapper for PostgresMcpContainerResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +class PostgresMcpContainerResourcePromiseImpl implements PostgresMcpContainerResourcePromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: PostgresMcpContainerResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + withContainerRegistry(registry: Awaitable): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withContainerRegistry(registry)), this._client); + } + + withBindMount(source: string, target: string, options?: WithBindMountOptions): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withBindMount(source, target, options)), this._client); + } + + withEntrypoint(entrypoint: string): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withEntrypoint(entrypoint)), this._client); + } + + withImageTag(tag: string): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withImageTag(tag)), this._client); + } + + withImageRegistry(registry: string): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withImageRegistry(registry)), this._client); + } + + withImage(image: string, options?: WithImageOptions): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withImage(image, options)), this._client); + } + + withImageSHA256(sha256: string): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withImageSHA256(sha256)), this._client); + } + + withContainerRuntimeArgs(args: string[]): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withContainerRuntimeArgs(args)), this._client); + } + + withLifetime(lifetime: ContainerLifetime): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withLifetime(lifetime)), this._client); + } + + withImagePullPolicy(pullPolicy: ImagePullPolicy): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withImagePullPolicy(pullPolicy)), this._client); + } + + publishAsContainer(): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.publishAsContainer()), this._client); + } + + withDockerfile(contextPath: string, options?: WithDockerfileOptions): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withDockerfile(contextPath, options)), this._client); + } + + withContainerName(name: string): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withContainerName(name)), this._client); + } + + withBuildArg(name: string, value: string | ParameterResource | Awaitable): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withBuildArg(name, value)), this._client); + } + + withBuildSecret(name: string, value: Awaitable): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withBuildSecret(name, value)), this._client); + } + + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withContainerCertificatePaths(options)), this._client); + } + + withEndpointProxySupport(proxyEnabled: boolean): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withEndpointProxySupport(proxyEnabled)), this._client); + } + + withDockerfileBuilder(contextPath: string, callback: (arg: DockerfileBuilderCallbackContext) => Promise, options?: WithDockerfileBuilderOptions): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withDockerfileBuilder(contextPath, callback, options)), this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withDockerfileBaseImage(options)), this._client); + } + + withContainerNetworkAlias(alias: string): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withContainerNetworkAlias(alias)), this._client); + } + + withMcpServer(options?: WithMcpServerOptions): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withMcpServer(options)), this._client); + } + + withOtlpExporter(options?: WithOtlpExporterOptions): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withOtlpExporter(options)), this._client); + } + + publishAsConnectionString(): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.publishAsConnectionString()), this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withRequiredCommand(command, options)), this._client); + } + + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withEnvironment(name, value)), this._client); + } + + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentCallback(callback)), this._client); + } + + withArgs(args: string[]): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withArgs(args)), this._client); + } + + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withArgsCallback(callback)), this._client); + } + + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withReferenceEnvironment(options)), this._client); + } + + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withReference(source, options)), this._client); + } + + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withEndpointCallback(endpointName, callback, options)), this._client); + } + + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withHttpEndpointCallback(callback, options)), this._client); + } + + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withHttpsEndpointCallback(callback, options)), this._client); + } + + withEndpoint(options?: WithEndpointOptions): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withEndpoint(options)), this._client); + } + + withHttpEndpoint(options?: WithHttpEndpointOptions): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withHttpEndpoint(options)), this._client); + } + + withHttpsEndpoint(options?: WithHttpsEndpointOptions): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withHttpsEndpoint(options)), this._client); + } + + withExternalHttpEndpoints(): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withExternalHttpEndpoints()), this._client); + } + + getEndpoint(name: string): Promise { + return this._promise.then(obj => obj.getEndpoint(name)); + } + + asHttp2Service(): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.asHttp2Service()), this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withUrls(callback)), this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withUrl(url, options)), this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback)), this._client); + } + + excludeFromManifest(): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.excludeFromManifest()), this._client); + } + + waitFor(dependency: Awaitable, options?: WaitForOptions): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.waitFor(dependency, options)), this._client); + } + + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.waitForStart(dependency, options)), this._client); + } + + withExplicitStart(): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withExplicitStart()), this._client); + } + + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.waitForCompletion(dependency, options)), this._client); + } + + withHealthCheck(key: string): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withHealthCheck(key)), this._client); + } + + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withHttpHealthCheck(options)), this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options)), this._client); + } + + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withHttpCommand(path, displayName, options)), this._client); + } + + withDeveloperCertificateTrust(trust: boolean): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust)), this._client); + } + + withCertificateTrustScope(scope: CertificateTrustScope): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withCertificateTrustScope(scope)), this._client); + } + + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options)), this._client); + } + + withoutHttpsCertificate(): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withoutHttpsCertificate()), this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withRelationship(resourceBuilder, type)), this._client); + } + + withParentRelationship(parent: Awaitable): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withParentRelationship(parent)), this._client); + } + + withChildRelationship(child: Awaitable): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withChildRelationship(child)), this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withIconName(iconName, options)), this._client); + } + + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withHttpProbe(probeType, options)), this._client); + } + + excludeFromMcp(): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.excludeFromMcp()), this._client); + } + + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withImagePushOptions(callback)), this._client); + } + + withRemoteImageName(remoteImageName: string): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withRemoteImageName(remoteImageName)), this._client); + } + + withRemoteImageTag(remoteImageTag: string): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag)), this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options)), this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withPipelineConfiguration(callback)), this._client); + } + + withVolume(target: string, options?: WithVolumeOptions): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withVolume(target, options)), this._client); + } + + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.onBeforeResourceStarted(callback)), this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.onResourceStopped(callback)), this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.onInitializeResource(callback)), this._client); + } + + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback)), this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.onResourceReady(callback)), this._client); + } + + createExecutionConfiguration(): Promise { + return this._promise.then(obj => obj.createExecutionConfiguration()); + } + + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4ReferenceWithEnvironment(source, options)), this._client); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Details(options)), this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Reference(target, options)), this._client); + } + + withLikeC4Group(groupName: string): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Group(groupName)), this._client); + } + + excludeFromLikeC4(): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.excludeFromLikeC4()), this._client); + } + + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withAzureUserAssignedIdentity(identityResourceBuilder)), this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromiseImpl(this._promise.then(obj => obj.withRoleAssignments(target, roles)), this._client); + } + +} + +// ============================================================================ +// PostgresServerResource +// ============================================================================ + +export interface PostgresServerResource { + toJSON(): MarshalledHandle; + /** Gets the PrimaryEndpoint property */ + primaryEndpoint(): Promise; + /** Gets the UserNameParameter property */ + userNameParameter: { + get: () => Promise; + set: (value: Awaitable) => Promise; + }; + /** Gets the UserNameReference property */ + userNameReference(): Promise; + /** Gets the PasswordParameter property */ + passwordParameter: { + get: () => Promise; + set: (value: Awaitable) => Promise; + }; + /** Gets the ConnectionStringExpression property */ + connectionStringExpression(): Promise; + /** Gets the Databases property */ + databases(): Promise>; + /** Gets the Host property */ + host(): Promise; + /** Gets the Port property */ + port(): Promise; + /** Gets the UriExpression property */ + uriExpression(): Promise; + /** Gets the JdbcConnectionString property */ + jdbcConnectionString(): Promise; + /** Gets the Entrypoint property */ + entrypoint: { + get: () => Promise; + set: (value: string) => Promise; + }; + /** Gets the ShellExecution property */ + shellExecution: { + get: () => Promise; + set: (value: boolean) => Promise; + }; + /** Gets the Name property */ + name(): Promise; + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): PostgresServerResourcePromise; + /** Adds a bind mount */ + withBindMount(source: string, target: string, options?: WithBindMountOptions): PostgresServerResourcePromise; + /** Sets the container entrypoint */ + withEntrypoint(entrypoint: string): PostgresServerResourcePromise; + /** Sets the container image tag */ + withImageTag(tag: string): PostgresServerResourcePromise; + /** Sets the container image registry */ + withImageRegistry(registry: string): PostgresServerResourcePromise; + /** Sets the container image */ + withImage(image: string, options?: WithImageOptions): PostgresServerResourcePromise; + /** Sets the image SHA256 digest */ + withImageSHA256(sha256: string): PostgresServerResourcePromise; + /** Adds runtime arguments for the container */ + withContainerRuntimeArgs(args: string[]): PostgresServerResourcePromise; + /** Sets the lifetime behavior of the container resource */ + withLifetime(lifetime: ContainerLifetime): PostgresServerResourcePromise; + /** Sets the container image pull policy */ + withImagePullPolicy(pullPolicy: ImagePullPolicy): PostgresServerResourcePromise; + /** Configures the resource to be published as a container */ + publishAsContainer(): PostgresServerResourcePromise; + /** Configures the resource to use a Dockerfile */ + withDockerfile(contextPath: string, options?: WithDockerfileOptions): PostgresServerResourcePromise; + /** Sets the container name */ + withContainerName(name: string): PostgresServerResourcePromise; + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource | Awaitable): PostgresServerResourcePromise; + /** Adds a build secret from a parameter resource */ + withBuildSecret(name: string, value: Awaitable): PostgresServerResourcePromise; + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): PostgresServerResourcePromise; + /** Configures endpoint proxy support */ + withEndpointProxySupport(proxyEnabled: boolean): PostgresServerResourcePromise; + /** Configures the resource to use a programmatically generated Dockerfile */ + withDockerfileBuilder(contextPath: string, callback: (arg: DockerfileBuilderCallbackContext) => Promise, options?: WithDockerfileBuilderOptions): PostgresServerResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): PostgresServerResourcePromise; + /** Adds a network alias for the container */ + withContainerNetworkAlias(alias: string): PostgresServerResourcePromise; + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): PostgresServerResourcePromise; + /** Configures OTLP telemetry export */ + withOtlpExporter(options?: WithOtlpExporterOptions): PostgresServerResourcePromise; + /** Publishes the resource as a connection string */ + publishAsConnectionString(): PostgresServerResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): PostgresServerResourcePromise; + /** Sets an environment variable */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): PostgresServerResourcePromise; + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): PostgresServerResourcePromise; + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): PostgresServerResourcePromise; + /** Adds arguments */ + withArgs(args: string[]): PostgresServerResourcePromise; + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): PostgresServerResourcePromise; + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): PostgresServerResourcePromise; + /** Adds a reference to another resource */ + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): PostgresServerResourcePromise; + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise; + /** Updates a named endpoint via callback */ + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): PostgresServerResourcePromise; + /** Updates an HTTP endpoint via callback */ + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): PostgresServerResourcePromise; + /** Updates an HTTPS endpoint via callback */ + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): PostgresServerResourcePromise; + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): PostgresServerResourcePromise; + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): PostgresServerResourcePromise; + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): PostgresServerResourcePromise; + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): PostgresServerResourcePromise; + /** Gets an endpoint reference */ + getEndpoint(name: string): Promise; + /** Configures resource for HTTP/2 */ + asHttp2Service(): PostgresServerResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): PostgresServerResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): PostgresServerResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): PostgresServerResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): PostgresServerResourcePromise; + /** Waits for another resource to be ready */ + waitFor(dependency: Awaitable, options?: WaitForOptions): PostgresServerResourcePromise; + /** Waits for another resource to start */ + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): PostgresServerResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): PostgresServerResourcePromise; + /** Waits for resource completion */ + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): PostgresServerResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): PostgresServerResourcePromise; + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): PostgresServerResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): PostgresServerResourcePromise; + /** Adds an HTTP resource command */ + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): PostgresServerResourcePromise; + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): PostgresServerResourcePromise; + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): PostgresServerResourcePromise; + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): PostgresServerResourcePromise; + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): PostgresServerResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): PostgresServerResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): PostgresServerResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): PostgresServerResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): PostgresServerResourcePromise; + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): PostgresServerResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): PostgresServerResourcePromise; + /** Sets image push options via callback */ + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): PostgresServerResourcePromise; + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): PostgresServerResourcePromise; + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): PostgresServerResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): PostgresServerResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): PostgresServerResourcePromise; + /** Adds a volume */ + withVolume(target: string, options?: WithVolumeOptions): PostgresServerResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): PostgresServerResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): PostgresServerResourcePromise; + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): PostgresServerResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): PostgresServerResourcePromise; + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): PostgresServerResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): PostgresServerResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Create a new reference, while also allowing customization of how a resource appears in the generated LikeC4 diagram. */ + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): PostgresServerResourcePromise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): PostgresServerResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): PostgresServerResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): PostgresServerResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): PostgresServerResourcePromise; + /** Associates an Azure user-assigned identity with a compute resource */ + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): PostgresServerResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): PostgresServerResourcePromise; + /** Adds a PostgreSQL database */ + addDatabase(name: string, options?: AddDatabaseOptions): PostgresDatabaseResourcePromise; + /** Adds pgAdmin 4 management UI */ + withPgAdmin(options?: WithPgAdminOptions): PostgresServerResourcePromise; + /** Adds pgweb management UI */ + withPgWeb(options?: WithPgWebOptions): PostgresServerResourcePromise; + /** Adds a data volume for PostgreSQL */ + withDataVolume(options?: WithDataVolumeOptions): PostgresServerResourcePromise; + /** Adds a data bind mount for PostgreSQL */ + withDataBindMount(source: string, options?: WithDataBindMountOptions): PostgresServerResourcePromise; + /** Copies init files to PostgreSQL */ + withInitFiles(source: string): PostgresServerResourcePromise; + /** Configures the PostgreSQL password */ + withPassword(password: Awaitable): PostgresServerResourcePromise; + /** Configures the PostgreSQL user name */ + withUserName(userName: Awaitable): PostgresServerResourcePromise; + /** Sets the host port for PostgreSQL */ + withHostPort(options?: WithHostPortOptions): PostgresServerResourcePromise; +} + +export interface PostgresServerResourcePromise extends PromiseLike { + /** Gets the PrimaryEndpoint property */ + primaryEndpoint(): Promise; + /** Gets the UserNameReference property */ + userNameReference(): Promise; + /** Gets the ConnectionStringExpression property */ + connectionStringExpression(): Promise; + /** Gets the Databases property */ + databases(): Promise>; + /** Gets the Host property */ + host(): Promise; + /** Gets the Port property */ + port(): Promise; + /** Gets the UriExpression property */ + uriExpression(): Promise; + /** Gets the JdbcConnectionString property */ + jdbcConnectionString(): Promise; + /** Gets the Name property */ + name(): Promise; + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): PostgresServerResourcePromise; + /** Adds a bind mount */ + withBindMount(source: string, target: string, options?: WithBindMountOptions): PostgresServerResourcePromise; + /** Sets the container entrypoint */ + withEntrypoint(entrypoint: string): PostgresServerResourcePromise; + /** Sets the container image tag */ + withImageTag(tag: string): PostgresServerResourcePromise; + /** Sets the container image registry */ + withImageRegistry(registry: string): PostgresServerResourcePromise; + /** Sets the container image */ + withImage(image: string, options?: WithImageOptions): PostgresServerResourcePromise; + /** Sets the image SHA256 digest */ + withImageSHA256(sha256: string): PostgresServerResourcePromise; + /** Adds runtime arguments for the container */ + withContainerRuntimeArgs(args: string[]): PostgresServerResourcePromise; + /** Sets the lifetime behavior of the container resource */ + withLifetime(lifetime: ContainerLifetime): PostgresServerResourcePromise; + /** Sets the container image pull policy */ + withImagePullPolicy(pullPolicy: ImagePullPolicy): PostgresServerResourcePromise; + /** Configures the resource to be published as a container */ + publishAsContainer(): PostgresServerResourcePromise; + /** Configures the resource to use a Dockerfile */ + withDockerfile(contextPath: string, options?: WithDockerfileOptions): PostgresServerResourcePromise; + /** Sets the container name */ + withContainerName(name: string): PostgresServerResourcePromise; + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource | Awaitable): PostgresServerResourcePromise; + /** Adds a build secret from a parameter resource */ + withBuildSecret(name: string, value: Awaitable): PostgresServerResourcePromise; + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): PostgresServerResourcePromise; + /** Configures endpoint proxy support */ + withEndpointProxySupport(proxyEnabled: boolean): PostgresServerResourcePromise; + /** Configures the resource to use a programmatically generated Dockerfile */ + withDockerfileBuilder(contextPath: string, callback: (arg: DockerfileBuilderCallbackContext) => Promise, options?: WithDockerfileBuilderOptions): PostgresServerResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): PostgresServerResourcePromise; + /** Adds a network alias for the container */ + withContainerNetworkAlias(alias: string): PostgresServerResourcePromise; + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): PostgresServerResourcePromise; + /** Configures OTLP telemetry export */ + withOtlpExporter(options?: WithOtlpExporterOptions): PostgresServerResourcePromise; + /** Publishes the resource as a connection string */ + publishAsConnectionString(): PostgresServerResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): PostgresServerResourcePromise; + /** Sets an environment variable */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): PostgresServerResourcePromise; + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): PostgresServerResourcePromise; + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): PostgresServerResourcePromise; + /** Adds arguments */ + withArgs(args: string[]): PostgresServerResourcePromise; + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): PostgresServerResourcePromise; + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): PostgresServerResourcePromise; + /** Adds a reference to another resource */ + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): PostgresServerResourcePromise; + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise; + /** Updates a named endpoint via callback */ + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): PostgresServerResourcePromise; + /** Updates an HTTP endpoint via callback */ + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): PostgresServerResourcePromise; + /** Updates an HTTPS endpoint via callback */ + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): PostgresServerResourcePromise; + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): PostgresServerResourcePromise; + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): PostgresServerResourcePromise; + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): PostgresServerResourcePromise; + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): PostgresServerResourcePromise; + /** Gets an endpoint reference */ + getEndpoint(name: string): Promise; + /** Configures resource for HTTP/2 */ + asHttp2Service(): PostgresServerResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): PostgresServerResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): PostgresServerResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): PostgresServerResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): PostgresServerResourcePromise; + /** Waits for another resource to be ready */ + waitFor(dependency: Awaitable, options?: WaitForOptions): PostgresServerResourcePromise; + /** Waits for another resource to start */ + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): PostgresServerResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): PostgresServerResourcePromise; + /** Waits for resource completion */ + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): PostgresServerResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): PostgresServerResourcePromise; + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): PostgresServerResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): PostgresServerResourcePromise; + /** Adds an HTTP resource command */ + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): PostgresServerResourcePromise; + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): PostgresServerResourcePromise; + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): PostgresServerResourcePromise; + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): PostgresServerResourcePromise; + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): PostgresServerResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): PostgresServerResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): PostgresServerResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): PostgresServerResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): PostgresServerResourcePromise; + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): PostgresServerResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): PostgresServerResourcePromise; + /** Sets image push options via callback */ + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): PostgresServerResourcePromise; + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): PostgresServerResourcePromise; + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): PostgresServerResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): PostgresServerResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): PostgresServerResourcePromise; + /** Adds a volume */ + withVolume(target: string, options?: WithVolumeOptions): PostgresServerResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): PostgresServerResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): PostgresServerResourcePromise; + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): PostgresServerResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): PostgresServerResourcePromise; + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): PostgresServerResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): PostgresServerResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Create a new reference, while also allowing customization of how a resource appears in the generated LikeC4 diagram. */ + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): PostgresServerResourcePromise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): PostgresServerResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): PostgresServerResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): PostgresServerResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): PostgresServerResourcePromise; + /** Associates an Azure user-assigned identity with a compute resource */ + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): PostgresServerResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): PostgresServerResourcePromise; + /** Adds a PostgreSQL database */ + addDatabase(name: string, options?: AddDatabaseOptions): PostgresDatabaseResourcePromise; + /** Adds pgAdmin 4 management UI */ + withPgAdmin(options?: WithPgAdminOptions): PostgresServerResourcePromise; + /** Adds pgweb management UI */ + withPgWeb(options?: WithPgWebOptions): PostgresServerResourcePromise; + /** Adds a data volume for PostgreSQL */ + withDataVolume(options?: WithDataVolumeOptions): PostgresServerResourcePromise; + /** Adds a data bind mount for PostgreSQL */ + withDataBindMount(source: string, options?: WithDataBindMountOptions): PostgresServerResourcePromise; + /** Copies init files to PostgreSQL */ + withInitFiles(source: string): PostgresServerResourcePromise; + /** Configures the PostgreSQL password */ + withPassword(password: Awaitable): PostgresServerResourcePromise; + /** Configures the PostgreSQL user name */ + withUserName(userName: Awaitable): PostgresServerResourcePromise; + /** Sets the host port for PostgreSQL */ + withHostPort(options?: WithHostPortOptions): PostgresServerResourcePromise; +} + +// ============================================================================ +// PostgresServerResourceImpl +// ============================================================================ + +class PostgresServerResourceImpl extends ResourceBuilderBase implements PostgresServerResource { + constructor(handle: PostgresServerResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + async primaryEndpoint(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/PostgresServerResource.primaryEndpoint', + { context: this._handle } + ); + return new EndpointReferenceImpl(handle, this._client); + } + + userNameParameter = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/PostgresServerResource.userNameParameter', + { context: this._handle } + ); + return new ParameterResourceImpl(handle, this._client); + }, + set: async (value: Awaitable): Promise => { + value = isPromiseLike(value) ? await value : value; + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/PostgresServerResource.setUserNameParameter', + { context: this._handle, value } + ); + } + }; + + async userNameReference(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/PostgresServerResource.userNameReference', + { context: this._handle } + ); + } + + passwordParameter = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/PostgresServerResource.passwordParameter', + { context: this._handle } + ); + return new ParameterResourceImpl(handle, this._client); + }, + set: async (value: Awaitable): Promise => { + value = isPromiseLike(value) ? await value : value; + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/PostgresServerResource.setPasswordParameter', + { context: this._handle, value } + ); + } + }; + + async connectionStringExpression(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/PostgresServerResource.connectionStringExpression', + { context: this._handle } + ); + } + + private _databases?: AspireDict; + async databases(): Promise> { + if (!this._databases) { + this._databases = new AspireDict( + this._handle, + this._client, + 'Aspire.Hosting.ApplicationModel/PostgresServerResource.databases', + 'Aspire.Hosting.ApplicationModel/PostgresServerResource.databases' + ); + } + return this._databases; + } + + async host(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/PostgresServerResource.host', + { context: this._handle } + ); + return new EndpointReferenceExpressionImpl(handle, this._client); + } + + async port(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/PostgresServerResource.port', + { context: this._handle } + ); + return new EndpointReferenceExpressionImpl(handle, this._client); + } + + async uriExpression(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/PostgresServerResource.uriExpression', + { context: this._handle } + ); + } + + async jdbcConnectionString(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/PostgresServerResource.jdbcConnectionString', + { context: this._handle } + ); + } + + entrypoint = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/PostgresServerResource.entrypoint', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/PostgresServerResource.setEntrypoint', + { context: this._handle, value } + ); + } + }; + + shellExecution = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/PostgresServerResource.shellExecution', + { context: this._handle } + ); + }, + set: async (value: boolean): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/PostgresServerResource.setShellExecution', + { context: this._handle, value } + ); + } + }; + + async name(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/PostgresServerResource.name', + { context: this._handle } + ); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: Awaitable): Promise { + registry = isPromiseLike(registry) ? await registry : registry; + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withContainerRegistry(registry: Awaitable): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._withContainerRegistryInternal(registry), this._client); + } + + /** @internal */ + private async _withBindMountInternal(source: string, target: string, isReadOnly?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, source, target }; + if (isReadOnly !== undefined) rpcArgs.isReadOnly = isReadOnly; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBindMount', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withBindMount(source: string, target: string, options?: WithBindMountOptions): PostgresServerResourcePromise { + const isReadOnly = options?.isReadOnly; + return new PostgresServerResourcePromiseImpl(this._withBindMountInternal(source, target, isReadOnly), this._client); + } + + /** @internal */ + private async _withEntrypointInternal(entrypoint: string): Promise { + const rpcArgs: Record = { builder: this._handle, entrypoint }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEntrypoint', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withEntrypoint(entrypoint: string): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._withEntrypointInternal(entrypoint), this._client); + } + + /** @internal */ + private async _withImageTagInternal(tag: string): Promise { + const rpcArgs: Record = { builder: this._handle, tag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImageTag', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withImageTag(tag: string): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._withImageTagInternal(tag), this._client); + } + + /** @internal */ + private async _withImageRegistryInternal(registry: string): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImageRegistry', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withImageRegistry(registry: string): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._withImageRegistryInternal(registry), this._client); + } + + /** @internal */ + private async _withImageInternal(image: string, tag?: string): Promise { + const rpcArgs: Record = { builder: this._handle, image }; + if (tag !== undefined) rpcArgs.tag = tag; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImage', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withImage(image: string, options?: WithImageOptions): PostgresServerResourcePromise { + const tag = options?.tag; + return new PostgresServerResourcePromiseImpl(this._withImageInternal(image, tag), this._client); + } + + /** @internal */ + private async _withImageSHA256Internal(sha256: string): Promise { + const rpcArgs: Record = { builder: this._handle, sha256 }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImageSHA256', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withImageSHA256(sha256: string): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._withImageSHA256Internal(sha256), this._client); + } + + /** @internal */ + private async _withContainerRuntimeArgsInternal(args: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, args }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRuntimeArgs', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withContainerRuntimeArgs(args: string[]): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._withContainerRuntimeArgsInternal(args), this._client); + } + + /** @internal */ + private async _withLifetimeInternal(lifetime: ContainerLifetime): Promise { + const rpcArgs: Record = { builder: this._handle, lifetime }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withLifetime', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withLifetime(lifetime: ContainerLifetime): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._withLifetimeInternal(lifetime), this._client); + } + + /** @internal */ + private async _withImagePullPolicyInternal(pullPolicy: ImagePullPolicy): Promise { + const rpcArgs: Record = { builder: this._handle, pullPolicy }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImagePullPolicy', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withImagePullPolicy(pullPolicy: ImagePullPolicy): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._withImagePullPolicyInternal(pullPolicy), this._client); + } + + /** @internal */ + private async _publishAsContainerInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsContainer', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + publishAsContainer(): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._publishAsContainerInternal(), this._client); + } + + /** @internal */ + private async _withDockerfileInternal(contextPath: string, dockerfilePath?: string, stage?: string): Promise { + const rpcArgs: Record = { builder: this._handle, contextPath }; + if (dockerfilePath !== undefined) rpcArgs.dockerfilePath = dockerfilePath; + if (stage !== undefined) rpcArgs.stage = stage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfile', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withDockerfile(contextPath: string, options?: WithDockerfileOptions): PostgresServerResourcePromise { + const dockerfilePath = options?.dockerfilePath; + const stage = options?.stage; + return new PostgresServerResourcePromiseImpl(this._withDockerfileInternal(contextPath, dockerfilePath, stage), this._client); + } + + /** @internal */ + private async _withContainerNameInternal(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerName', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withContainerName(name: string): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._withContainerNameInternal(name), this._client); + } + + /** @internal */ + private async _withBuildArgInternal(name: string, value: string | ParameterResource | Awaitable): Promise { + value = isPromiseLike(value) ? await value : value; + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuildArg', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withBuildArg(name: string, value: string | ParameterResource | Awaitable): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._withBuildArgInternal(name, value), this._client); + } + + /** @internal */ + private async _withBuildSecretInternal(name: string, value: Awaitable): Promise { + value = isPromiseLike(value) ? await value : value; + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParameterBuildSecret', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withBuildSecret(name: string, value: Awaitable): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._withBuildSecretInternal(name, value), this._client); + } + + /** @internal */ + private async _withContainerCertificatePathsInternal(customCertificatesDestination?: string, defaultCertificateBundlePaths?: string[], defaultCertificateDirectoryPaths?: string[]): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (customCertificatesDestination !== undefined) rpcArgs.customCertificatesDestination = customCertificatesDestination; + if (defaultCertificateBundlePaths !== undefined) rpcArgs.defaultCertificateBundlePaths = defaultCertificateBundlePaths; + if (defaultCertificateDirectoryPaths !== undefined) rpcArgs.defaultCertificateDirectoryPaths = defaultCertificateDirectoryPaths; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerCertificatePaths', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): PostgresServerResourcePromise { + const customCertificatesDestination = options?.customCertificatesDestination; + const defaultCertificateBundlePaths = options?.defaultCertificateBundlePaths; + const defaultCertificateDirectoryPaths = options?.defaultCertificateDirectoryPaths; + return new PostgresServerResourcePromiseImpl(this._withContainerCertificatePathsInternal(customCertificatesDestination, defaultCertificateBundlePaths, defaultCertificateDirectoryPaths), this._client); + } + + /** @internal */ + private async _withEndpointProxySupportInternal(proxyEnabled: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, proxyEnabled }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpointProxySupport', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withEndpointProxySupport(proxyEnabled: boolean): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._withEndpointProxySupportInternal(proxyEnabled), this._client); + } + + /** @internal */ + private async _withDockerfileBuilderInternal(contextPath: string, callback: (arg: DockerfileBuilderCallbackContext) => Promise, stage?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as DockerfileBuilderCallbackContextHandle; + const arg = new DockerfileBuilderCallbackContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, contextPath, callback: callbackId }; + if (stage !== undefined) rpcArgs.stage = stage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBuilder', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withDockerfileBuilder(contextPath: string, callback: (arg: DockerfileBuilderCallbackContext) => Promise, options?: WithDockerfileBuilderOptions): PostgresServerResourcePromise { + const stage = options?.stage; + return new PostgresServerResourcePromiseImpl(this._withDockerfileBuilderInternal(contextPath, callback, stage), this._client); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): PostgresServerResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new PostgresServerResourcePromiseImpl(this._withDockerfileBaseImageInternal(buildImage, runtimeImage), this._client); + } + + /** @internal */ + private async _withContainerNetworkAliasInternal(alias: string): Promise { + const rpcArgs: Record = { builder: this._handle, alias }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerNetworkAlias', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withContainerNetworkAlias(alias: string): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._withContainerNetworkAliasInternal(alias), this._client); + } + + /** @internal */ + private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withMcpServer', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withMcpServer(options?: WithMcpServerOptions): PostgresServerResourcePromise { + const path = options?.path; + const endpointName = options?.endpointName; + return new PostgresServerResourcePromiseImpl(this._withMcpServerInternal(path, endpointName), this._client); + } + + /** @internal */ + private async _withOtlpExporterInternal(protocol?: OtlpProtocol): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (protocol !== undefined) rpcArgs.protocol = protocol; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporter', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withOtlpExporter(options?: WithOtlpExporterOptions): PostgresServerResourcePromise { + const protocol = options?.protocol; + return new PostgresServerResourcePromiseImpl(this._withOtlpExporterInternal(protocol), this._client); + } + + /** @internal */ + private async _publishAsConnectionStringInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsConnectionString', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + publishAsConnectionString(): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._publishAsConnectionStringInternal(), this._client); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): PostgresServerResourcePromise { + const helpLink = options?.helpLink; + return new PostgresServerResourcePromiseImpl(this._withRequiredCommandInternal(command, helpLink), this._client); + } + + /** @internal */ + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): Promise { + value = isPromiseLike(value) ? await value : value; + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironment', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._withEnvironmentInternal(name, value), this._client); + } + + /** @internal */ + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentCallback', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._withEnvironmentCallbackInternal(callback), this._client); + } + + /** @internal */ + private async _withConnectionPropertyInternal(name: string, value: string | ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withConnectionProperty', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withConnectionProperty(name: string, value: string | ReferenceExpression): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._withConnectionPropertyInternal(name, value), this._client); + } + + /** @internal */ + private async _withArgsInternal(args: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, args }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgs', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withArgs(args: string[]): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._withArgsInternal(args), this._client); + } + + /** @internal */ + private async _withArgsCallbackInternal(callback: (obj: CommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; + const obj = new CommandLineArgsCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallback', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._withArgsCallbackInternal(callback), this._client); + } + + /** @internal */ + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceEnvironment', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._withReferenceEnvironmentInternal(options), this._client); + } + + /** @internal */ + private async _withReferenceInternal(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, connectionName?: string, optional?: boolean, name?: string): Promise { + source = isPromiseLike(source) ? await source : source; + const rpcArgs: Record = { builder: this._handle, source }; + if (connectionName !== undefined) rpcArgs.connectionName = connectionName; + if (optional !== undefined) rpcArgs.optional = optional; + if (name !== undefined) rpcArgs.name = name; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReference', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): PostgresServerResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new PostgresServerResourcePromiseImpl(this._withReferenceInternal(source, connectionName, optional, name), this._client); + } + + async getConnectionProperty(key: string): Promise { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + + /** @internal */ + private async _withEndpointCallbackInternal(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpointCallback', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): PostgresServerResourcePromise { + const createIfNotExists = options?.createIfNotExists; + return new PostgresServerResourcePromiseImpl(this._withEndpointCallbackInternal(endpointName, callback, createIfNotExists), this._client); + } + + /** @internal */ + private async _withHttpEndpointCallbackInternal(callback: (obj: EndpointUpdateContext) => Promise, name?: string, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + if (name !== undefined) rpcArgs.name = name; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpEndpointCallback', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): PostgresServerResourcePromise { + const name = options?.name; + const createIfNotExists = options?.createIfNotExists; + return new PostgresServerResourcePromiseImpl(this._withHttpEndpointCallbackInternal(callback, name, createIfNotExists), this._client); + } + + /** @internal */ + private async _withHttpsEndpointCallbackInternal(callback: (obj: EndpointUpdateContext) => Promise, name?: string, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + if (name !== undefined) rpcArgs.name = name; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsEndpointCallback', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): PostgresServerResourcePromise { + const name = options?.name; + const createIfNotExists = options?.createIfNotExists; + return new PostgresServerResourcePromiseImpl(this._withHttpsEndpointCallbackInternal(callback, name, createIfNotExists), this._client); + } + + /** @internal */ + private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (scheme !== undefined) rpcArgs.scheme = scheme; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + if (isExternal !== undefined) rpcArgs.isExternal = isExternal; + if (protocol !== undefined) rpcArgs.protocol = protocol; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpoint', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withEndpoint(options?: WithEndpointOptions): PostgresServerResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const scheme = options?.scheme; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + const isExternal = options?.isExternal; + const protocol = options?.protocol; + return new PostgresServerResourcePromiseImpl(this._withEndpointInternal(port, targetPort, scheme, name, env, isProxied, isExternal, protocol), this._client); + } + + /** @internal */ + private async _withHttpEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpEndpoint', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withHttpEndpoint(options?: WithHttpEndpointOptions): PostgresServerResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new PostgresServerResourcePromiseImpl(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied), this._client); + } + + /** @internal */ + private async _withHttpsEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsEndpoint', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withHttpsEndpoint(options?: WithHttpsEndpointOptions): PostgresServerResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new PostgresServerResourcePromiseImpl(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied), this._client); + } + + /** @internal */ + private async _withExternalHttpEndpointsInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExternalHttpEndpoints', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withExternalHttpEndpoints(): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._withExternalHttpEndpointsInternal(), this._client); + } + + async getEndpoint(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getEndpoint', + rpcArgs + ); + } + + /** @internal */ + private async _asHttp2ServiceInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/asHttp2Service', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + asHttp2Service(): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._asHttp2ServiceInternal(), this._client); + } + + /** @internal */ + private async _withUrlsInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrls', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._withUrlsInternal(callback), this._client); + } + + /** @internal */ + private async _withUrlInternal(url: string | ReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): PostgresServerResourcePromise { + const displayText = options?.displayText; + return new PostgresServerResourcePromiseImpl(this._withUrlInternal(url, displayText), this._client); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._withUrlForEndpointInternal(endpointName, callback), this._client); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + excludeFromManifest(): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._excludeFromManifestInternal(), this._client); + } + + /** @internal */ + private async _waitForInternal(dependency: Awaitable, waitBehavior?: WaitBehavior): Promise { + dependency = isPromiseLike(dependency) ? await dependency : dependency; + const rpcArgs: Record = { builder: this._handle, dependency }; + if (waitBehavior !== undefined) rpcArgs.waitBehavior = waitBehavior; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitFor', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + waitFor(dependency: Awaitable, options?: WaitForOptions): PostgresServerResourcePromise { + const waitBehavior = options?.waitBehavior; + return new PostgresServerResourcePromiseImpl(this._waitForInternal(dependency, waitBehavior), this._client); + } + + /** @internal */ + private async _waitForStartInternal(dependency: Awaitable, waitBehavior?: WaitBehavior): Promise { + dependency = isPromiseLike(dependency) ? await dependency : dependency; + const rpcArgs: Record = { builder: this._handle, dependency }; + if (waitBehavior !== undefined) rpcArgs.waitBehavior = waitBehavior; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStart', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): PostgresServerResourcePromise { + const waitBehavior = options?.waitBehavior; + return new PostgresServerResourcePromiseImpl(this._waitForStartInternal(dependency, waitBehavior), this._client); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withExplicitStart(): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._withExplicitStartInternal(), this._client); + } + + /** @internal */ + private async _waitForCompletionInternal(dependency: Awaitable, exitCode?: number): Promise { + dependency = isPromiseLike(dependency) ? await dependency : dependency; + const rpcArgs: Record = { builder: this._handle, dependency }; + if (exitCode !== undefined) rpcArgs.exitCode = exitCode; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceCompletion', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): PostgresServerResourcePromise { + const exitCode = options?.exitCode; + return new PostgresServerResourcePromiseImpl(this._waitForCompletionInternal(dependency, exitCode), this._client); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withHealthCheck(key: string): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._withHealthCheckInternal(key), this._client); + } + + /** @internal */ + private async _withHttpHealthCheckInternal(path?: string, statusCode?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (statusCode !== undefined) rpcArgs.statusCode = statusCode; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpHealthCheck', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): PostgresServerResourcePromise { + const path = options?.path; + const statusCode = options?.statusCode; + const endpointName = options?.endpointName; + return new PostgresServerResourcePromiseImpl(this._withHttpHealthCheckInternal(path, statusCode, endpointName), this._client); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContextImpl(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): PostgresServerResourcePromise { + const commandOptions = options?.commandOptions; + return new PostgresServerResourcePromiseImpl(this._withCommandInternal(name, displayName, executeCommand, commandOptions), this._client); + } + + /** @internal */ + private async _withHttpCommandInternal(path: string, displayName: string, options?: HttpCommandExportOptions): Promise { + const rpcArgs: Record = { builder: this._handle, path, displayName }; + if (options !== undefined) rpcArgs.options = options; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpCommand', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._withHttpCommandInternal(path, displayName, options), this._client); + } + + /** @internal */ + private async _withDeveloperCertificateTrustInternal(trust: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, trust }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDeveloperCertificateTrust', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withDeveloperCertificateTrust(trust: boolean): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._withDeveloperCertificateTrustInternal(trust), this._client); + } + + /** @internal */ + private async _withCertificateTrustScopeInternal(scope: CertificateTrustScope): Promise { + const rpcArgs: Record = { builder: this._handle, scope }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCertificateTrustScope', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withCertificateTrustScope(scope: CertificateTrustScope): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._withCertificateTrustScopeInternal(scope), this._client); + } + + /** @internal */ + private async _withHttpsDeveloperCertificateInternal(password?: Awaitable): Promise { + password = isPromiseLike(password) ? await password : password; + const rpcArgs: Record = { builder: this._handle }; + if (password !== undefined) rpcArgs.password = password; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): PostgresServerResourcePromise { + let password = options?.password; + return new PostgresServerResourcePromiseImpl(this._withHttpsDeveloperCertificateInternal(password), this._client); + } + + /** @internal */ + private async _withoutHttpsCertificateInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withoutHttpsCertificate', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withoutHttpsCertificate(): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._withoutHttpsCertificateInternal(), this._client); + } + + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: Awaitable, type: string): Promise { + resourceBuilder = isPromiseLike(resourceBuilder) ? await resourceBuilder : resourceBuilder; + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._withRelationshipInternal(resourceBuilder, type), this._client); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: Awaitable): Promise { + parent = isPromiseLike(parent) ? await parent : parent; + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withParentRelationship(parent: Awaitable): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._withParentRelationshipInternal(parent), this._client); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: Awaitable): Promise { + child = isPromiseLike(child) ? await child : child; + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withChildRelationship(child: Awaitable): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._withChildRelationshipInternal(child), this._client); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): PostgresServerResourcePromise { + const iconVariant = options?.iconVariant; + return new PostgresServerResourcePromiseImpl(this._withIconNameInternal(iconName, iconVariant), this._client); + } + + /** @internal */ + private async _withHttpProbeInternal(probeType: ProbeType, path?: string, initialDelaySeconds?: number, periodSeconds?: number, timeoutSeconds?: number, failureThreshold?: number, successThreshold?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, probeType }; + if (path !== undefined) rpcArgs.path = path; + if (initialDelaySeconds !== undefined) rpcArgs.initialDelaySeconds = initialDelaySeconds; + if (periodSeconds !== undefined) rpcArgs.periodSeconds = periodSeconds; + if (timeoutSeconds !== undefined) rpcArgs.timeoutSeconds = timeoutSeconds; + if (failureThreshold !== undefined) rpcArgs.failureThreshold = failureThreshold; + if (successThreshold !== undefined) rpcArgs.successThreshold = successThreshold; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpProbe', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): PostgresServerResourcePromise { + const path = options?.path; + const initialDelaySeconds = options?.initialDelaySeconds; + const periodSeconds = options?.periodSeconds; + const timeoutSeconds = options?.timeoutSeconds; + const failureThreshold = options?.failureThreshold; + const successThreshold = options?.successThreshold; + const endpointName = options?.endpointName; + return new PostgresServerResourcePromiseImpl(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName), this._client); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + excludeFromMcp(): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._excludeFromMcpInternal(), this._client); + } + + /** @internal */ + private async _withImagePushOptionsInternal(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ContainerImagePushOptionsCallbackContextHandle; + const arg = new ContainerImagePushOptionsCallbackContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImagePushOptions', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._withImagePushOptionsInternal(callback), this._client); + } + + /** @internal */ + private async _withRemoteImageNameInternal(remoteImageName: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageName', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withRemoteImageName(remoteImageName: string): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._withRemoteImageNameInternal(remoteImageName), this._client); + } + + /** @internal */ + private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageTag', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withRemoteImageTag(remoteImageTag: string): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._withRemoteImageTagInternal(remoteImageTag), this._client); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): PostgresServerResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new PostgresServerResourcePromiseImpl(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description), this._client); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._withPipelineConfigurationInternal(callback), this._client); + } + + /** @internal */ + private async _withVolumeInternal(target: string, name?: string, isReadOnly?: boolean): Promise { + const rpcArgs: Record = { resource: this._handle, target }; + if (name !== undefined) rpcArgs.name = name; + if (isReadOnly !== undefined) rpcArgs.isReadOnly = isReadOnly; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withVolume', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withVolume(target: string, options?: WithVolumeOptions): PostgresServerResourcePromise { + const name = options?.name; + const isReadOnly = options?.isReadOnly; + return new PostgresServerResourcePromiseImpl(this._withVolumeInternal(target, name, isReadOnly), this._client); + } + + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); + } + + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._onBeforeResourceStartedInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._onResourceStoppedInternal(callback), this._client); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onConnectionStringAvailable', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._onConnectionStringAvailableInternal(callback), this._client); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._onInitializeResourceInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceEndpointsAllocated', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._onResourceEndpointsAllocatedInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._onResourceReadyInternal(callback), this._client); + } + + async createExecutionConfiguration(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/createExecutionConfiguration', + rpcArgs + ); + } + + /** @internal */ + private async _withLikeC4ReferenceWithEnvironmentInternal(source: Awaitable, configure?: (obj: LikeC4RelationshipDetailsAnnotation) => Promise, connectionName?: string, optional?: boolean, skipAspireReference?: boolean): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4RelationshipDetailsAnnotationHandle; + const obj = new LikeC4RelationshipDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + source = isPromiseLike(source) ? await source : source; + const rpcArgs: Record = { builder: this._handle, source }; + if (configure !== undefined) rpcArgs.configure = configureId; + if (connectionName !== undefined) rpcArgs.connectionName = connectionName; + if (optional !== undefined) rpcArgs.optional = optional; + if (skipAspireReference !== undefined) rpcArgs.skipAspireReference = skipAspireReference; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4ReferenceWithEnvironment', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): PostgresServerResourcePromise { + const configure = options?.configure; + const connectionName = options?.connectionName; + const optional = options?.optional; + const skipAspireReference = options?.skipAspireReference; + return new PostgresServerResourcePromiseImpl(this._withLikeC4ReferenceWithEnvironmentInternal(source, configure, connectionName, optional, skipAspireReference), this._client); + } + + /** @internal */ + private async _withLikeC4DetailsInternal(label?: string, technology?: string, description?: string, summary?: string, icon?: string, configure?: (obj: LikeC4NodeDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4NodeDetailsAnnotationHandle; + const obj = new LikeC4NodeDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + const rpcArgs: Record = { builder: this._handle }; + if (label !== undefined) rpcArgs.label = label; + if (technology !== undefined) rpcArgs.technology = technology; + if (description !== undefined) rpcArgs.description = description; + if (summary !== undefined) rpcArgs.summary = summary; + if (icon !== undefined) rpcArgs.icon = icon; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4DetailsParameters', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): PostgresServerResourcePromise { + const label = options?.label; + const technology = options?.technology; + const description = options?.description; + const summary = options?.summary; + const icon = options?.icon; + const configure = options?.configure; + return new PostgresServerResourcePromiseImpl(this._withLikeC4DetailsInternal(label, technology, description, summary, icon, configure), this._client); + } + + /** @internal */ + private async _withLikeC4ReferenceInternal(target: Awaitable, configure?: (obj: LikeC4RelationshipDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4RelationshipDetailsAnnotationHandle; + const obj = new LikeC4RelationshipDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target }; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Reference', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): PostgresServerResourcePromise { + const configure = options?.configure; + return new PostgresServerResourcePromiseImpl(this._withLikeC4ReferenceInternal(target, configure), this._client); + } + + /** @internal */ + private async _withLikeC4GroupInternal(groupName: string): Promise { + const rpcArgs: Record = { builder: this._handle, groupName }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Group', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withLikeC4Group(groupName: string): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._withLikeC4GroupInternal(groupName), this._client); + } + + /** @internal */ + private async _excludeFromLikeC4Internal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/excludeFromLikeC4', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + excludeFromLikeC4(): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._excludeFromLikeC4Internal(), this._client); + } + + /** @internal */ + private async _withAzureUserAssignedIdentityInternal(identityResourceBuilder: Awaitable): Promise { + identityResourceBuilder = isPromiseLike(identityResourceBuilder) ? await identityResourceBuilder : identityResourceBuilder; + const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._withAzureUserAssignedIdentityInternal(identityResourceBuilder), this._client); + } + + /** @internal */ + private async _withRoleAssignmentsInternal(target: Awaitable, roles: AzureKeyVaultRole[]): Promise { + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target, roles }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.KeyVault/withKeyVaultRoleAssignments', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._withRoleAssignmentsInternal(target, roles), this._client); + } + + /** @internal */ + private async _addDatabaseInternal(name: string, databaseName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (databaseName !== undefined) rpcArgs.databaseName = databaseName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.PostgreSQL/addDatabase', + rpcArgs + ); + return new PostgresDatabaseResourceImpl(result, this._client); + } + + addDatabase(name: string, options?: AddDatabaseOptions): PostgresDatabaseResourcePromise { + const databaseName = options?.databaseName; + return new PostgresDatabaseResourcePromiseImpl(this._addDatabaseInternal(name, databaseName), this._client); + } + + /** @internal */ + private async _withPgAdminInternal(configureContainer?: (obj: PgAdminContainerResource) => Promise, containerName?: string): Promise { + const configureContainerId = configureContainer ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PgAdminContainerResourceHandle; + const obj = new PgAdminContainerResourceImpl(objHandle, this._client); + await configureContainer(obj); + }) : undefined; + const rpcArgs: Record = { builder: this._handle }; + if (configureContainer !== undefined) rpcArgs.configureContainer = configureContainerId; + if (containerName !== undefined) rpcArgs.containerName = containerName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.PostgreSQL/withPgAdmin', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withPgAdmin(options?: WithPgAdminOptions): PostgresServerResourcePromise { + const configureContainer = options?.configureContainer; + const containerName = options?.containerName; + return new PostgresServerResourcePromiseImpl(this._withPgAdminInternal(configureContainer, containerName), this._client); + } + + /** @internal */ + private async _withPgWebInternal(configureContainer?: (obj: PgWebContainerResource) => Promise, containerName?: string): Promise { + const configureContainerId = configureContainer ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PgWebContainerResourceHandle; + const obj = new PgWebContainerResourceImpl(objHandle, this._client); + await configureContainer(obj); + }) : undefined; + const rpcArgs: Record = { builder: this._handle }; + if (configureContainer !== undefined) rpcArgs.configureContainer = configureContainerId; + if (containerName !== undefined) rpcArgs.containerName = containerName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.PostgreSQL/withPgWeb', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withPgWeb(options?: WithPgWebOptions): PostgresServerResourcePromise { + const configureContainer = options?.configureContainer; + const containerName = options?.containerName; + return new PostgresServerResourcePromiseImpl(this._withPgWebInternal(configureContainer, containerName), this._client); + } + + /** @internal */ + private async _withDataVolumeInternal(name?: string, isReadOnly?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (name !== undefined) rpcArgs.name = name; + if (isReadOnly !== undefined) rpcArgs.isReadOnly = isReadOnly; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.PostgreSQL/withDataVolume', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withDataVolume(options?: WithDataVolumeOptions): PostgresServerResourcePromise { + const name = options?.name; + const isReadOnly = options?.isReadOnly; + return new PostgresServerResourcePromiseImpl(this._withDataVolumeInternal(name, isReadOnly), this._client); + } + + /** @internal */ + private async _withDataBindMountInternal(source: string, isReadOnly?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, source }; + if (isReadOnly !== undefined) rpcArgs.isReadOnly = isReadOnly; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.PostgreSQL/withDataBindMount', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withDataBindMount(source: string, options?: WithDataBindMountOptions): PostgresServerResourcePromise { + const isReadOnly = options?.isReadOnly; + return new PostgresServerResourcePromiseImpl(this._withDataBindMountInternal(source, isReadOnly), this._client); + } + + /** @internal */ + private async _withInitFilesInternal(source: string): Promise { + const rpcArgs: Record = { builder: this._handle, source }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.PostgreSQL/withInitFiles', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withInitFiles(source: string): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._withInitFilesInternal(source), this._client); + } + + /** @internal */ + private async _withPasswordInternal(password: Awaitable): Promise { + password = isPromiseLike(password) ? await password : password; + const rpcArgs: Record = { builder: this._handle, password }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.PostgreSQL/withPassword', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withPassword(password: Awaitable): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._withPasswordInternal(password), this._client); + } + + /** @internal */ + private async _withUserNameInternal(userName: Awaitable): Promise { + userName = isPromiseLike(userName) ? await userName : userName; + const rpcArgs: Record = { builder: this._handle, userName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.PostgreSQL/withUserName', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withUserName(userName: Awaitable): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._withUserNameInternal(userName), this._client); + } + + /** @internal */ + private async _withHostPortInternal(port?: number): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.PostgreSQL/withPostgresHostPort', + rpcArgs + ); + return new PostgresServerResourceImpl(result, this._client); + } + + withHostPort(options?: WithHostPortOptions): PostgresServerResourcePromise { + const port = options?.port; + return new PostgresServerResourcePromiseImpl(this._withHostPortInternal(port), this._client); + } + +} + +/** + * Thenable wrapper for PostgresServerResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +class PostgresServerResourcePromiseImpl implements PostgresServerResourcePromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: PostgresServerResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + primaryEndpoint(): Promise { + return this._promise.then(obj => obj.primaryEndpoint()); + } + + userNameReference(): Promise { + return this._promise.then(obj => obj.userNameReference()); + } + + connectionStringExpression(): Promise { + return this._promise.then(obj => obj.connectionStringExpression()); + } + + databases(): Promise> { + return this._promise.then(obj => obj.databases()); + } + + host(): Promise { + return this._promise.then(obj => obj.host()); + } + + port(): Promise { + return this._promise.then(obj => obj.port()); + } + + uriExpression(): Promise { + return this._promise.then(obj => obj.uriExpression()); + } + + jdbcConnectionString(): Promise { + return this._promise.then(obj => obj.jdbcConnectionString()); + } + + name(): Promise { + return this._promise.then(obj => obj.name()); + } + + withContainerRegistry(registry: Awaitable): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withContainerRegistry(registry)), this._client); + } + + withBindMount(source: string, target: string, options?: WithBindMountOptions): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withBindMount(source, target, options)), this._client); + } + + withEntrypoint(entrypoint: string): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withEntrypoint(entrypoint)), this._client); + } + + withImageTag(tag: string): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withImageTag(tag)), this._client); + } + + withImageRegistry(registry: string): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withImageRegistry(registry)), this._client); + } + + withImage(image: string, options?: WithImageOptions): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withImage(image, options)), this._client); + } + + withImageSHA256(sha256: string): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withImageSHA256(sha256)), this._client); + } + + withContainerRuntimeArgs(args: string[]): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withContainerRuntimeArgs(args)), this._client); + } + + withLifetime(lifetime: ContainerLifetime): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withLifetime(lifetime)), this._client); + } + + withImagePullPolicy(pullPolicy: ImagePullPolicy): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withImagePullPolicy(pullPolicy)), this._client); + } + + publishAsContainer(): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.publishAsContainer()), this._client); + } + + withDockerfile(contextPath: string, options?: WithDockerfileOptions): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withDockerfile(contextPath, options)), this._client); + } + + withContainerName(name: string): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withContainerName(name)), this._client); + } + + withBuildArg(name: string, value: string | ParameterResource | Awaitable): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withBuildArg(name, value)), this._client); + } + + withBuildSecret(name: string, value: Awaitable): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withBuildSecret(name, value)), this._client); + } + + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withContainerCertificatePaths(options)), this._client); + } + + withEndpointProxySupport(proxyEnabled: boolean): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withEndpointProxySupport(proxyEnabled)), this._client); + } + + withDockerfileBuilder(contextPath: string, callback: (arg: DockerfileBuilderCallbackContext) => Promise, options?: WithDockerfileBuilderOptions): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withDockerfileBuilder(contextPath, callback, options)), this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withDockerfileBaseImage(options)), this._client); + } + + withContainerNetworkAlias(alias: string): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withContainerNetworkAlias(alias)), this._client); + } + + withMcpServer(options?: WithMcpServerOptions): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withMcpServer(options)), this._client); + } + + withOtlpExporter(options?: WithOtlpExporterOptions): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withOtlpExporter(options)), this._client); + } + + publishAsConnectionString(): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.publishAsConnectionString()), this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withRequiredCommand(command, options)), this._client); + } + + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withEnvironment(name, value)), this._client); + } + + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentCallback(callback)), this._client); + } + + withConnectionProperty(name: string, value: string | ReferenceExpression): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withConnectionProperty(name, value)), this._client); + } + + withArgs(args: string[]): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withArgs(args)), this._client); + } + + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withArgsCallback(callback)), this._client); + } + + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withReferenceEnvironment(options)), this._client); + } + + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withReference(source, options)), this._client); + } + + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withEndpointCallback(endpointName, callback, options)), this._client); + } + + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withHttpEndpointCallback(callback, options)), this._client); + } + + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withHttpsEndpointCallback(callback, options)), this._client); + } + + withEndpoint(options?: WithEndpointOptions): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withEndpoint(options)), this._client); + } + + withHttpEndpoint(options?: WithHttpEndpointOptions): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withHttpEndpoint(options)), this._client); + } + + withHttpsEndpoint(options?: WithHttpsEndpointOptions): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withHttpsEndpoint(options)), this._client); + } + + withExternalHttpEndpoints(): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withExternalHttpEndpoints()), this._client); + } + + getEndpoint(name: string): Promise { + return this._promise.then(obj => obj.getEndpoint(name)); + } + + asHttp2Service(): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.asHttp2Service()), this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withUrls(callback)), this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withUrl(url, options)), this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback)), this._client); + } + + excludeFromManifest(): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.excludeFromManifest()), this._client); + } + + waitFor(dependency: Awaitable, options?: WaitForOptions): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.waitFor(dependency, options)), this._client); + } + + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.waitForStart(dependency, options)), this._client); + } + + withExplicitStart(): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withExplicitStart()), this._client); + } + + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.waitForCompletion(dependency, options)), this._client); + } + + withHealthCheck(key: string): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withHealthCheck(key)), this._client); + } + + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withHttpHealthCheck(options)), this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options)), this._client); + } + + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withHttpCommand(path, displayName, options)), this._client); + } + + withDeveloperCertificateTrust(trust: boolean): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust)), this._client); + } + + withCertificateTrustScope(scope: CertificateTrustScope): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withCertificateTrustScope(scope)), this._client); + } + + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options)), this._client); + } + + withoutHttpsCertificate(): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withoutHttpsCertificate()), this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withRelationship(resourceBuilder, type)), this._client); + } + + withParentRelationship(parent: Awaitable): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withParentRelationship(parent)), this._client); + } + + withChildRelationship(child: Awaitable): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withChildRelationship(child)), this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withIconName(iconName, options)), this._client); + } + + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withHttpProbe(probeType, options)), this._client); + } + + excludeFromMcp(): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.excludeFromMcp()), this._client); + } + + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withImagePushOptions(callback)), this._client); + } + + withRemoteImageName(remoteImageName: string): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withRemoteImageName(remoteImageName)), this._client); + } + + withRemoteImageTag(remoteImageTag: string): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag)), this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options)), this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withPipelineConfiguration(callback)), this._client); + } + + withVolume(target: string, options?: WithVolumeOptions): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withVolume(target, options)), this._client); + } + + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.onBeforeResourceStarted(callback)), this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.onResourceStopped(callback)), this._client); + } + + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.onConnectionStringAvailable(callback)), this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.onInitializeResource(callback)), this._client); + } + + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback)), this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.onResourceReady(callback)), this._client); + } + + createExecutionConfiguration(): Promise { + return this._promise.then(obj => obj.createExecutionConfiguration()); + } + + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4ReferenceWithEnvironment(source, options)), this._client); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Details(options)), this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Reference(target, options)), this._client); + } + + withLikeC4Group(groupName: string): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Group(groupName)), this._client); + } + + excludeFromLikeC4(): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.excludeFromLikeC4()), this._client); + } + + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withAzureUserAssignedIdentity(identityResourceBuilder)), this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withRoleAssignments(target, roles)), this._client); + } + + addDatabase(name: string, options?: AddDatabaseOptions): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromiseImpl(this._promise.then(obj => obj.addDatabase(name, options)), this._client); + } + + withPgAdmin(options?: WithPgAdminOptions): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withPgAdmin(options)), this._client); + } + + withPgWeb(options?: WithPgWebOptions): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withPgWeb(options)), this._client); + } + + withDataVolume(options?: WithDataVolumeOptions): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withDataVolume(options)), this._client); + } + + withDataBindMount(source: string, options?: WithDataBindMountOptions): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withDataBindMount(source, options)), this._client); + } + + withInitFiles(source: string): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withInitFiles(source)), this._client); + } + + withPassword(password: Awaitable): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withPassword(password)), this._client); + } + + withUserName(userName: Awaitable): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withUserName(userName)), this._client); + } + + withHostPort(options?: WithHostPortOptions): PostgresServerResourcePromise { + return new PostgresServerResourcePromiseImpl(this._promise.then(obj => obj.withHostPort(options)), this._client); + } + +} + +// ============================================================================ +// ProjectResource +// ============================================================================ + +export interface ProjectResource { + toJSON(): MarshalledHandle; + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): ProjectResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ProjectResourcePromise; + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): ProjectResourcePromise; + /** Configures OTLP telemetry export */ + withOtlpExporter(options?: WithOtlpExporterOptions): ProjectResourcePromise; + /** Sets the number of replicas */ + withReplicas(replicas: number): ProjectResourcePromise; + /** Disables forwarded headers for the project */ + disableForwardedHeaders(): ProjectResourcePromise; + /** Publishes a project as a Docker file with optional container configuration */ + publishAsDockerFile(options?: PublishAsDockerFileOptions): ProjectResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ProjectResourcePromise; + /** Sets an environment variable */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): ProjectResourcePromise; + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ProjectResourcePromise; + /** Adds arguments */ + withArgs(args: string[]): ProjectResourcePromise; + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): ProjectResourcePromise; + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ProjectResourcePromise; + /** Adds a reference to another resource */ + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): ProjectResourcePromise; + /** Updates a named endpoint via callback */ + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): ProjectResourcePromise; + /** Updates an HTTP endpoint via callback */ + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): ProjectResourcePromise; + /** Updates an HTTPS endpoint via callback */ + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): ProjectResourcePromise; + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): ProjectResourcePromise; + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): ProjectResourcePromise; + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): ProjectResourcePromise; + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): ProjectResourcePromise; + /** Gets an endpoint reference */ + getEndpoint(name: string): Promise; + /** Configures resource for HTTP/2 */ + asHttp2Service(): ProjectResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): ProjectResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): ProjectResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ProjectResourcePromise; + /** Configures the resource to copy container files from the specified source during publishing */ + publishWithContainerFiles(source: Awaitable, destinationPath: string): ProjectResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): ProjectResourcePromise; + /** Waits for another resource to be ready */ + waitFor(dependency: Awaitable, options?: WaitForOptions): ProjectResourcePromise; + /** Waits for another resource to start */ + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): ProjectResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): ProjectResourcePromise; + /** Waits for resource completion */ + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): ProjectResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): ProjectResourcePromise; + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ProjectResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ProjectResourcePromise; + /** Adds an HTTP resource command */ + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): ProjectResourcePromise; + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): ProjectResourcePromise; + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): ProjectResourcePromise; + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ProjectResourcePromise; + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): ProjectResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): ProjectResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): ProjectResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): ProjectResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ProjectResourcePromise; + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ProjectResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ProjectResourcePromise; + /** Sets image push options via callback */ + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): ProjectResourcePromise; + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): ProjectResourcePromise; + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): ProjectResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ProjectResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ProjectResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ProjectResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ProjectResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ProjectResourcePromise; + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ProjectResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ProjectResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Create a new reference, while also allowing customization of how a resource appears in the generated LikeC4 diagram. */ + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): ProjectResourcePromise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): ProjectResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): ProjectResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): ProjectResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): ProjectResourcePromise; + /** Associates an Azure user-assigned identity with a compute resource */ + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): ProjectResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): ProjectResourcePromise; +} + +export interface ProjectResourcePromise extends PromiseLike { + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): ProjectResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ProjectResourcePromise; + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): ProjectResourcePromise; + /** Configures OTLP telemetry export */ + withOtlpExporter(options?: WithOtlpExporterOptions): ProjectResourcePromise; + /** Sets the number of replicas */ + withReplicas(replicas: number): ProjectResourcePromise; + /** Disables forwarded headers for the project */ + disableForwardedHeaders(): ProjectResourcePromise; + /** Publishes a project as a Docker file with optional container configuration */ + publishAsDockerFile(options?: PublishAsDockerFileOptions): ProjectResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ProjectResourcePromise; + /** Sets an environment variable */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): ProjectResourcePromise; + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ProjectResourcePromise; + /** Adds arguments */ + withArgs(args: string[]): ProjectResourcePromise; + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): ProjectResourcePromise; + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ProjectResourcePromise; + /** Adds a reference to another resource */ + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): ProjectResourcePromise; + /** Updates a named endpoint via callback */ + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): ProjectResourcePromise; + /** Updates an HTTP endpoint via callback */ + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): ProjectResourcePromise; + /** Updates an HTTPS endpoint via callback */ + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): ProjectResourcePromise; + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): ProjectResourcePromise; + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): ProjectResourcePromise; + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): ProjectResourcePromise; + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): ProjectResourcePromise; + /** Gets an endpoint reference */ + getEndpoint(name: string): Promise; + /** Configures resource for HTTP/2 */ + asHttp2Service(): ProjectResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): ProjectResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): ProjectResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ProjectResourcePromise; + /** Configures the resource to copy container files from the specified source during publishing */ + publishWithContainerFiles(source: Awaitable, destinationPath: string): ProjectResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): ProjectResourcePromise; + /** Waits for another resource to be ready */ + waitFor(dependency: Awaitable, options?: WaitForOptions): ProjectResourcePromise; + /** Waits for another resource to start */ + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): ProjectResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): ProjectResourcePromise; + /** Waits for resource completion */ + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): ProjectResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): ProjectResourcePromise; + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ProjectResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ProjectResourcePromise; + /** Adds an HTTP resource command */ + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): ProjectResourcePromise; + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): ProjectResourcePromise; + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): ProjectResourcePromise; + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ProjectResourcePromise; + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): ProjectResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): ProjectResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): ProjectResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): ProjectResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ProjectResourcePromise; + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ProjectResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ProjectResourcePromise; + /** Sets image push options via callback */ + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): ProjectResourcePromise; + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): ProjectResourcePromise; + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): ProjectResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ProjectResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ProjectResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ProjectResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ProjectResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ProjectResourcePromise; + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ProjectResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ProjectResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Create a new reference, while also allowing customization of how a resource appears in the generated LikeC4 diagram. */ + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): ProjectResourcePromise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): ProjectResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): ProjectResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): ProjectResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): ProjectResourcePromise; + /** Associates an Azure user-assigned identity with a compute resource */ + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): ProjectResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): ProjectResourcePromise; +} + +// ============================================================================ +// ProjectResourceImpl +// ============================================================================ + +class ProjectResourceImpl extends ResourceBuilderBase implements ProjectResource { + constructor(handle: ProjectResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: Awaitable): Promise { + registry = isPromiseLike(registry) ? await registry : registry; + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + withContainerRegistry(registry: Awaitable): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._withContainerRegistryInternal(registry), this._client); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ProjectResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new ProjectResourcePromiseImpl(this._withDockerfileBaseImageInternal(buildImage, runtimeImage), this._client); + } + + /** @internal */ + private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withMcpServer', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + withMcpServer(options?: WithMcpServerOptions): ProjectResourcePromise { + const path = options?.path; + const endpointName = options?.endpointName; + return new ProjectResourcePromiseImpl(this._withMcpServerInternal(path, endpointName), this._client); + } + + /** @internal */ + private async _withOtlpExporterInternal(protocol?: OtlpProtocol): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (protocol !== undefined) rpcArgs.protocol = protocol; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporter', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + withOtlpExporter(options?: WithOtlpExporterOptions): ProjectResourcePromise { + const protocol = options?.protocol; + return new ProjectResourcePromiseImpl(this._withOtlpExporterInternal(protocol), this._client); + } + + /** @internal */ + private async _withReplicasInternal(replicas: number): Promise { + const rpcArgs: Record = { builder: this._handle, replicas }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReplicas', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + withReplicas(replicas: number): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._withReplicasInternal(replicas), this._client); + } + + /** @internal */ + private async _disableForwardedHeadersInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/disableForwardedHeaders', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + disableForwardedHeaders(): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._disableForwardedHeadersInternal(), this._client); + } + + /** @internal */ + private async _publishAsDockerFileInternal(configure?: (obj: ContainerResource) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ContainerResourceHandle; + const obj = new ContainerResourceImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + const rpcArgs: Record = { builder: this._handle }; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishProjectAsDockerFileWithConfigure', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + publishAsDockerFile(options?: PublishAsDockerFileOptions): ProjectResourcePromise { + const configure = options?.configure; + return new ProjectResourcePromiseImpl(this._publishAsDockerFileInternal(configure), this._client); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ProjectResourcePromise { + const helpLink = options?.helpLink; + return new ProjectResourcePromiseImpl(this._withRequiredCommandInternal(command, helpLink), this._client); + } + + /** @internal */ + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): Promise { + value = isPromiseLike(value) ? await value : value; + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironment', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._withEnvironmentInternal(name, value), this._client); + } + + /** @internal */ + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentCallback', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._withEnvironmentCallbackInternal(callback), this._client); + } + + /** @internal */ + private async _withArgsInternal(args: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, args }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgs', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + withArgs(args: string[]): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._withArgsInternal(args), this._client); + } + + /** @internal */ + private async _withArgsCallbackInternal(callback: (obj: CommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; + const obj = new CommandLineArgsCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallback', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._withArgsCallbackInternal(callback), this._client); + } + + /** @internal */ + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceEnvironment', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._withReferenceEnvironmentInternal(options), this._client); + } + + /** @internal */ + private async _withReferenceInternal(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, connectionName?: string, optional?: boolean, name?: string): Promise { + source = isPromiseLike(source) ? await source : source; + const rpcArgs: Record = { builder: this._handle, source }; + if (connectionName !== undefined) rpcArgs.connectionName = connectionName; + if (optional !== undefined) rpcArgs.optional = optional; + if (name !== undefined) rpcArgs.name = name; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReference', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): ProjectResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new ProjectResourcePromiseImpl(this._withReferenceInternal(source, connectionName, optional, name), this._client); + } + + /** @internal */ + private async _withEndpointCallbackInternal(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpointCallback', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): ProjectResourcePromise { + const createIfNotExists = options?.createIfNotExists; + return new ProjectResourcePromiseImpl(this._withEndpointCallbackInternal(endpointName, callback, createIfNotExists), this._client); + } + + /** @internal */ + private async _withHttpEndpointCallbackInternal(callback: (obj: EndpointUpdateContext) => Promise, name?: string, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + if (name !== undefined) rpcArgs.name = name; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpEndpointCallback', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): ProjectResourcePromise { + const name = options?.name; + const createIfNotExists = options?.createIfNotExists; + return new ProjectResourcePromiseImpl(this._withHttpEndpointCallbackInternal(callback, name, createIfNotExists), this._client); + } + + /** @internal */ + private async _withHttpsEndpointCallbackInternal(callback: (obj: EndpointUpdateContext) => Promise, name?: string, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + if (name !== undefined) rpcArgs.name = name; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsEndpointCallback', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): ProjectResourcePromise { + const name = options?.name; + const createIfNotExists = options?.createIfNotExists; + return new ProjectResourcePromiseImpl(this._withHttpsEndpointCallbackInternal(callback, name, createIfNotExists), this._client); + } + + /** @internal */ + private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (scheme !== undefined) rpcArgs.scheme = scheme; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + if (isExternal !== undefined) rpcArgs.isExternal = isExternal; + if (protocol !== undefined) rpcArgs.protocol = protocol; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpoint', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + withEndpoint(options?: WithEndpointOptions): ProjectResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const scheme = options?.scheme; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + const isExternal = options?.isExternal; + const protocol = options?.protocol; + return new ProjectResourcePromiseImpl(this._withEndpointInternal(port, targetPort, scheme, name, env, isProxied, isExternal, protocol), this._client); + } + + /** @internal */ + private async _withHttpEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpEndpoint', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + withHttpEndpoint(options?: WithHttpEndpointOptions): ProjectResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new ProjectResourcePromiseImpl(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied), this._client); + } + + /** @internal */ + private async _withHttpsEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsEndpoint', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + withHttpsEndpoint(options?: WithHttpsEndpointOptions): ProjectResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new ProjectResourcePromiseImpl(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied), this._client); + } + + /** @internal */ + private async _withExternalHttpEndpointsInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExternalHttpEndpoints', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + withExternalHttpEndpoints(): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._withExternalHttpEndpointsInternal(), this._client); + } + + async getEndpoint(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getEndpoint', + rpcArgs + ); + } + + /** @internal */ + private async _asHttp2ServiceInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/asHttp2Service', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + asHttp2Service(): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._asHttp2ServiceInternal(), this._client); + } + + /** @internal */ + private async _withUrlsInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrls', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._withUrlsInternal(callback), this._client); + } + + /** @internal */ + private async _withUrlInternal(url: string | ReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): ProjectResourcePromise { + const displayText = options?.displayText; + return new ProjectResourcePromiseImpl(this._withUrlInternal(url, displayText), this._client); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._withUrlForEndpointInternal(endpointName, callback), this._client); + } + + /** @internal */ + private async _publishWithContainerFilesInternal(source: Awaitable, destinationPath: string): Promise { + source = isPromiseLike(source) ? await source : source; + const rpcArgs: Record = { builder: this._handle, source, destinationPath }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishWithContainerFilesFromResource', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + publishWithContainerFiles(source: Awaitable, destinationPath: string): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._publishWithContainerFilesInternal(source, destinationPath), this._client); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + excludeFromManifest(): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._excludeFromManifestInternal(), this._client); + } + + /** @internal */ + private async _waitForInternal(dependency: Awaitable, waitBehavior?: WaitBehavior): Promise { + dependency = isPromiseLike(dependency) ? await dependency : dependency; + const rpcArgs: Record = { builder: this._handle, dependency }; + if (waitBehavior !== undefined) rpcArgs.waitBehavior = waitBehavior; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitFor', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + waitFor(dependency: Awaitable, options?: WaitForOptions): ProjectResourcePromise { + const waitBehavior = options?.waitBehavior; + return new ProjectResourcePromiseImpl(this._waitForInternal(dependency, waitBehavior), this._client); + } + + /** @internal */ + private async _waitForStartInternal(dependency: Awaitable, waitBehavior?: WaitBehavior): Promise { + dependency = isPromiseLike(dependency) ? await dependency : dependency; + const rpcArgs: Record = { builder: this._handle, dependency }; + if (waitBehavior !== undefined) rpcArgs.waitBehavior = waitBehavior; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStart', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): ProjectResourcePromise { + const waitBehavior = options?.waitBehavior; + return new ProjectResourcePromiseImpl(this._waitForStartInternal(dependency, waitBehavior), this._client); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + withExplicitStart(): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._withExplicitStartInternal(), this._client); + } + + /** @internal */ + private async _waitForCompletionInternal(dependency: Awaitable, exitCode?: number): Promise { + dependency = isPromiseLike(dependency) ? await dependency : dependency; + const rpcArgs: Record = { builder: this._handle, dependency }; + if (exitCode !== undefined) rpcArgs.exitCode = exitCode; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceCompletion', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): ProjectResourcePromise { + const exitCode = options?.exitCode; + return new ProjectResourcePromiseImpl(this._waitForCompletionInternal(dependency, exitCode), this._client); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + withHealthCheck(key: string): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._withHealthCheckInternal(key), this._client); + } + + /** @internal */ + private async _withHttpHealthCheckInternal(path?: string, statusCode?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (statusCode !== undefined) rpcArgs.statusCode = statusCode; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpHealthCheck', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ProjectResourcePromise { + const path = options?.path; + const statusCode = options?.statusCode; + const endpointName = options?.endpointName; + return new ProjectResourcePromiseImpl(this._withHttpHealthCheckInternal(path, statusCode, endpointName), this._client); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContextImpl(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ProjectResourcePromise { + const commandOptions = options?.commandOptions; + return new ProjectResourcePromiseImpl(this._withCommandInternal(name, displayName, executeCommand, commandOptions), this._client); + } + + /** @internal */ + private async _withHttpCommandInternal(path: string, displayName: string, options?: HttpCommandExportOptions): Promise { + const rpcArgs: Record = { builder: this._handle, path, displayName }; + if (options !== undefined) rpcArgs.options = options; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpCommand', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._withHttpCommandInternal(path, displayName, options), this._client); + } + + /** @internal */ + private async _withDeveloperCertificateTrustInternal(trust: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, trust }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDeveloperCertificateTrust', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + withDeveloperCertificateTrust(trust: boolean): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._withDeveloperCertificateTrustInternal(trust), this._client); + } + + /** @internal */ + private async _withCertificateTrustScopeInternal(scope: CertificateTrustScope): Promise { + const rpcArgs: Record = { builder: this._handle, scope }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCertificateTrustScope', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + withCertificateTrustScope(scope: CertificateTrustScope): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._withCertificateTrustScopeInternal(scope), this._client); + } + + /** @internal */ + private async _withHttpsDeveloperCertificateInternal(password?: Awaitable): Promise { + password = isPromiseLike(password) ? await password : password; + const rpcArgs: Record = { builder: this._handle }; + if (password !== undefined) rpcArgs.password = password; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ProjectResourcePromise { + let password = options?.password; + return new ProjectResourcePromiseImpl(this._withHttpsDeveloperCertificateInternal(password), this._client); + } + + /** @internal */ + private async _withoutHttpsCertificateInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withoutHttpsCertificate', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + withoutHttpsCertificate(): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._withoutHttpsCertificateInternal(), this._client); + } + + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: Awaitable, type: string): Promise { + resourceBuilder = isPromiseLike(resourceBuilder) ? await resourceBuilder : resourceBuilder; + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._withRelationshipInternal(resourceBuilder, type), this._client); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: Awaitable): Promise { + parent = isPromiseLike(parent) ? await parent : parent; + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + withParentRelationship(parent: Awaitable): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._withParentRelationshipInternal(parent), this._client); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: Awaitable): Promise { + child = isPromiseLike(child) ? await child : child; + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + withChildRelationship(child: Awaitable): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._withChildRelationshipInternal(child), this._client); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): ProjectResourcePromise { + const iconVariant = options?.iconVariant; + return new ProjectResourcePromiseImpl(this._withIconNameInternal(iconName, iconVariant), this._client); + } + + /** @internal */ + private async _withHttpProbeInternal(probeType: ProbeType, path?: string, initialDelaySeconds?: number, periodSeconds?: number, timeoutSeconds?: number, failureThreshold?: number, successThreshold?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, probeType }; + if (path !== undefined) rpcArgs.path = path; + if (initialDelaySeconds !== undefined) rpcArgs.initialDelaySeconds = initialDelaySeconds; + if (periodSeconds !== undefined) rpcArgs.periodSeconds = periodSeconds; + if (timeoutSeconds !== undefined) rpcArgs.timeoutSeconds = timeoutSeconds; + if (failureThreshold !== undefined) rpcArgs.failureThreshold = failureThreshold; + if (successThreshold !== undefined) rpcArgs.successThreshold = successThreshold; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpProbe', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ProjectResourcePromise { + const path = options?.path; + const initialDelaySeconds = options?.initialDelaySeconds; + const periodSeconds = options?.periodSeconds; + const timeoutSeconds = options?.timeoutSeconds; + const failureThreshold = options?.failureThreshold; + const successThreshold = options?.successThreshold; + const endpointName = options?.endpointName; + return new ProjectResourcePromiseImpl(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName), this._client); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + excludeFromMcp(): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._excludeFromMcpInternal(), this._client); + } + + /** @internal */ + private async _withImagePushOptionsInternal(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ContainerImagePushOptionsCallbackContextHandle; + const arg = new ContainerImagePushOptionsCallbackContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImagePushOptions', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._withImagePushOptionsInternal(callback), this._client); + } + + /** @internal */ + private async _withRemoteImageNameInternal(remoteImageName: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageName', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + withRemoteImageName(remoteImageName: string): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._withRemoteImageNameInternal(remoteImageName), this._client); + } + + /** @internal */ + private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageTag', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + withRemoteImageTag(remoteImageTag: string): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._withRemoteImageTagInternal(remoteImageTag), this._client); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ProjectResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new ProjectResourcePromiseImpl(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description), this._client); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._withPipelineConfigurationInternal(callback), this._client); + } + + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); + } + + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._onBeforeResourceStartedInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._onResourceStoppedInternal(callback), this._client); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._onInitializeResourceInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceEndpointsAllocated', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._onResourceEndpointsAllocatedInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._onResourceReadyInternal(callback), this._client); + } + + async createExecutionConfiguration(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/createExecutionConfiguration', + rpcArgs + ); + } + + /** @internal */ + private async _withLikeC4ReferenceWithEnvironmentInternal(source: Awaitable, configure?: (obj: LikeC4RelationshipDetailsAnnotation) => Promise, connectionName?: string, optional?: boolean, skipAspireReference?: boolean): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4RelationshipDetailsAnnotationHandle; + const obj = new LikeC4RelationshipDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + source = isPromiseLike(source) ? await source : source; + const rpcArgs: Record = { builder: this._handle, source }; + if (configure !== undefined) rpcArgs.configure = configureId; + if (connectionName !== undefined) rpcArgs.connectionName = connectionName; + if (optional !== undefined) rpcArgs.optional = optional; + if (skipAspireReference !== undefined) rpcArgs.skipAspireReference = skipAspireReference; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4ReferenceWithEnvironment', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): ProjectResourcePromise { + const configure = options?.configure; + const connectionName = options?.connectionName; + const optional = options?.optional; + const skipAspireReference = options?.skipAspireReference; + return new ProjectResourcePromiseImpl(this._withLikeC4ReferenceWithEnvironmentInternal(source, configure, connectionName, optional, skipAspireReference), this._client); + } + + /** @internal */ + private async _withLikeC4DetailsInternal(label?: string, technology?: string, description?: string, summary?: string, icon?: string, configure?: (obj: LikeC4NodeDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4NodeDetailsAnnotationHandle; + const obj = new LikeC4NodeDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + const rpcArgs: Record = { builder: this._handle }; + if (label !== undefined) rpcArgs.label = label; + if (technology !== undefined) rpcArgs.technology = technology; + if (description !== undefined) rpcArgs.description = description; + if (summary !== undefined) rpcArgs.summary = summary; + if (icon !== undefined) rpcArgs.icon = icon; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4DetailsParameters', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): ProjectResourcePromise { + const label = options?.label; + const technology = options?.technology; + const description = options?.description; + const summary = options?.summary; + const icon = options?.icon; + const configure = options?.configure; + return new ProjectResourcePromiseImpl(this._withLikeC4DetailsInternal(label, technology, description, summary, icon, configure), this._client); + } + + /** @internal */ + private async _withLikeC4ReferenceInternal(target: Awaitable, configure?: (obj: LikeC4RelationshipDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4RelationshipDetailsAnnotationHandle; + const obj = new LikeC4RelationshipDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target }; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Reference', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): ProjectResourcePromise { + const configure = options?.configure; + return new ProjectResourcePromiseImpl(this._withLikeC4ReferenceInternal(target, configure), this._client); + } + + /** @internal */ + private async _withLikeC4GroupInternal(groupName: string): Promise { + const rpcArgs: Record = { builder: this._handle, groupName }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Group', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + withLikeC4Group(groupName: string): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._withLikeC4GroupInternal(groupName), this._client); + } + + /** @internal */ + private async _excludeFromLikeC4Internal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/excludeFromLikeC4', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + excludeFromLikeC4(): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._excludeFromLikeC4Internal(), this._client); + } + + /** @internal */ + private async _withAzureUserAssignedIdentityInternal(identityResourceBuilder: Awaitable): Promise { + identityResourceBuilder = isPromiseLike(identityResourceBuilder) ? await identityResourceBuilder : identityResourceBuilder; + const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._withAzureUserAssignedIdentityInternal(identityResourceBuilder), this._client); + } + + /** @internal */ + private async _withRoleAssignmentsInternal(target: Awaitable, roles: AzureKeyVaultRole[]): Promise { + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target, roles }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.KeyVault/withKeyVaultRoleAssignments', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._withRoleAssignmentsInternal(target, roles), this._client); + } + +} + +/** + * Thenable wrapper for ProjectResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +class ProjectResourcePromiseImpl implements ProjectResourcePromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: ProjectResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + withContainerRegistry(registry: Awaitable): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withContainerRegistry(registry)), this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withDockerfileBaseImage(options)), this._client); + } + + withMcpServer(options?: WithMcpServerOptions): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withMcpServer(options)), this._client); + } + + withOtlpExporter(options?: WithOtlpExporterOptions): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withOtlpExporter(options)), this._client); + } + + withReplicas(replicas: number): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withReplicas(replicas)), this._client); + } + + disableForwardedHeaders(): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.disableForwardedHeaders()), this._client); + } + + publishAsDockerFile(options?: PublishAsDockerFileOptions): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.publishAsDockerFile(options)), this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withRequiredCommand(command, options)), this._client); + } + + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withEnvironment(name, value)), this._client); + } + + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentCallback(callback)), this._client); + } + + withArgs(args: string[]): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withArgs(args)), this._client); + } + + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withArgsCallback(callback)), this._client); + } + + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withReferenceEnvironment(options)), this._client); + } + + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withReference(source, options)), this._client); + } + + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withEndpointCallback(endpointName, callback, options)), this._client); + } + + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withHttpEndpointCallback(callback, options)), this._client); + } + + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withHttpsEndpointCallback(callback, options)), this._client); + } + + withEndpoint(options?: WithEndpointOptions): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withEndpoint(options)), this._client); + } + + withHttpEndpoint(options?: WithHttpEndpointOptions): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withHttpEndpoint(options)), this._client); + } + + withHttpsEndpoint(options?: WithHttpsEndpointOptions): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withHttpsEndpoint(options)), this._client); + } + + withExternalHttpEndpoints(): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withExternalHttpEndpoints()), this._client); + } + + getEndpoint(name: string): Promise { + return this._promise.then(obj => obj.getEndpoint(name)); + } + + asHttp2Service(): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.asHttp2Service()), this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withUrls(callback)), this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withUrl(url, options)), this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback)), this._client); + } + + publishWithContainerFiles(source: Awaitable, destinationPath: string): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.publishWithContainerFiles(source, destinationPath)), this._client); + } + + excludeFromManifest(): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.excludeFromManifest()), this._client); + } + + waitFor(dependency: Awaitable, options?: WaitForOptions): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.waitFor(dependency, options)), this._client); + } + + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.waitForStart(dependency, options)), this._client); + } + + withExplicitStart(): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withExplicitStart()), this._client); + } + + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.waitForCompletion(dependency, options)), this._client); + } + + withHealthCheck(key: string): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withHealthCheck(key)), this._client); + } + + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withHttpHealthCheck(options)), this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options)), this._client); + } + + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withHttpCommand(path, displayName, options)), this._client); + } + + withDeveloperCertificateTrust(trust: boolean): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust)), this._client); + } + + withCertificateTrustScope(scope: CertificateTrustScope): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withCertificateTrustScope(scope)), this._client); + } + + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options)), this._client); + } + + withoutHttpsCertificate(): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withoutHttpsCertificate()), this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withRelationship(resourceBuilder, type)), this._client); + } + + withParentRelationship(parent: Awaitable): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withParentRelationship(parent)), this._client); + } + + withChildRelationship(child: Awaitable): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withChildRelationship(child)), this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withIconName(iconName, options)), this._client); + } + + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withHttpProbe(probeType, options)), this._client); + } + + excludeFromMcp(): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.excludeFromMcp()), this._client); + } + + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withImagePushOptions(callback)), this._client); + } + + withRemoteImageName(remoteImageName: string): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withRemoteImageName(remoteImageName)), this._client); + } + + withRemoteImageTag(remoteImageTag: string): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag)), this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options)), this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withPipelineConfiguration(callback)), this._client); + } + + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.onBeforeResourceStarted(callback)), this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.onResourceStopped(callback)), this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.onInitializeResource(callback)), this._client); + } + + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback)), this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.onResourceReady(callback)), this._client); + } + + createExecutionConfiguration(): Promise { + return this._promise.then(obj => obj.createExecutionConfiguration()); + } + + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4ReferenceWithEnvironment(source, options)), this._client); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Details(options)), this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Reference(target, options)), this._client); + } + + withLikeC4Group(groupName: string): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Group(groupName)), this._client); + } + + excludeFromLikeC4(): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.excludeFromLikeC4()), this._client); + } + + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withAzureUserAssignedIdentity(identityResourceBuilder)), this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withRoleAssignments(target, roles)), this._client); + } + +} + +// ============================================================================ +// RedisCommanderResource +// ============================================================================ + +export interface RedisCommanderResource { + toJSON(): MarshalledHandle; + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): RedisCommanderResourcePromise; + /** Adds a bind mount */ + withBindMount(source: string, target: string, options?: WithBindMountOptions): RedisCommanderResourcePromise; + /** Sets the container entrypoint */ + withEntrypoint(entrypoint: string): RedisCommanderResourcePromise; + /** Sets the container image tag */ + withImageTag(tag: string): RedisCommanderResourcePromise; + /** Sets the container image registry */ + withImageRegistry(registry: string): RedisCommanderResourcePromise; + /** Sets the container image */ + withImage(image: string, options?: WithImageOptions): RedisCommanderResourcePromise; + /** Sets the image SHA256 digest */ + withImageSHA256(sha256: string): RedisCommanderResourcePromise; + /** Adds runtime arguments for the container */ + withContainerRuntimeArgs(args: string[]): RedisCommanderResourcePromise; + /** Sets the lifetime behavior of the container resource */ + withLifetime(lifetime: ContainerLifetime): RedisCommanderResourcePromise; + /** Sets the container image pull policy */ + withImagePullPolicy(pullPolicy: ImagePullPolicy): RedisCommanderResourcePromise; + /** Configures the resource to be published as a container */ + publishAsContainer(): RedisCommanderResourcePromise; + /** Configures the resource to use a Dockerfile */ + withDockerfile(contextPath: string, options?: WithDockerfileOptions): RedisCommanderResourcePromise; + /** Sets the container name */ + withContainerName(name: string): RedisCommanderResourcePromise; + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource | Awaitable): RedisCommanderResourcePromise; + /** Adds a build secret from a parameter resource */ + withBuildSecret(name: string, value: Awaitable): RedisCommanderResourcePromise; + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): RedisCommanderResourcePromise; + /** Configures endpoint proxy support */ + withEndpointProxySupport(proxyEnabled: boolean): RedisCommanderResourcePromise; + /** Configures the resource to use a programmatically generated Dockerfile */ + withDockerfileBuilder(contextPath: string, callback: (arg: DockerfileBuilderCallbackContext) => Promise, options?: WithDockerfileBuilderOptions): RedisCommanderResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): RedisCommanderResourcePromise; + /** Adds a network alias for the container */ + withContainerNetworkAlias(alias: string): RedisCommanderResourcePromise; + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): RedisCommanderResourcePromise; + /** Configures OTLP telemetry export */ + withOtlpExporter(options?: WithOtlpExporterOptions): RedisCommanderResourcePromise; + /** Publishes the resource as a connection string */ + publishAsConnectionString(): RedisCommanderResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): RedisCommanderResourcePromise; + /** Sets an environment variable */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): RedisCommanderResourcePromise; + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): RedisCommanderResourcePromise; + /** Adds arguments */ + withArgs(args: string[]): RedisCommanderResourcePromise; + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): RedisCommanderResourcePromise; + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): RedisCommanderResourcePromise; + /** Adds a reference to another resource */ + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): RedisCommanderResourcePromise; + /** Updates a named endpoint via callback */ + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): RedisCommanderResourcePromise; + /** Updates an HTTP endpoint via callback */ + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): RedisCommanderResourcePromise; + /** Updates an HTTPS endpoint via callback */ + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): RedisCommanderResourcePromise; + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): RedisCommanderResourcePromise; + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): RedisCommanderResourcePromise; + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): RedisCommanderResourcePromise; + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): RedisCommanderResourcePromise; + /** Gets an endpoint reference */ + getEndpoint(name: string): Promise; + /** Configures resource for HTTP/2 */ + asHttp2Service(): RedisCommanderResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): RedisCommanderResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): RedisCommanderResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): RedisCommanderResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): RedisCommanderResourcePromise; + /** Waits for another resource to be ready */ + waitFor(dependency: Awaitable, options?: WaitForOptions): RedisCommanderResourcePromise; + /** Waits for another resource to start */ + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): RedisCommanderResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): RedisCommanderResourcePromise; + /** Waits for resource completion */ + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): RedisCommanderResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): RedisCommanderResourcePromise; + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): RedisCommanderResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): RedisCommanderResourcePromise; + /** Adds an HTTP resource command */ + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): RedisCommanderResourcePromise; + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): RedisCommanderResourcePromise; + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): RedisCommanderResourcePromise; + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): RedisCommanderResourcePromise; + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): RedisCommanderResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): RedisCommanderResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): RedisCommanderResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): RedisCommanderResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): RedisCommanderResourcePromise; + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): RedisCommanderResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): RedisCommanderResourcePromise; + /** Sets image push options via callback */ + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): RedisCommanderResourcePromise; + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): RedisCommanderResourcePromise; + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): RedisCommanderResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): RedisCommanderResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): RedisCommanderResourcePromise; + /** Adds a volume */ + withVolume(target: string, options?: WithVolumeOptions): RedisCommanderResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): RedisCommanderResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): RedisCommanderResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): RedisCommanderResourcePromise; + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): RedisCommanderResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): RedisCommanderResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Create a new reference, while also allowing customization of how a resource appears in the generated LikeC4 diagram. */ + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): RedisCommanderResourcePromise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): RedisCommanderResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): RedisCommanderResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): RedisCommanderResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): RedisCommanderResourcePromise; + /** Associates an Azure user-assigned identity with a compute resource */ + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): RedisCommanderResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): RedisCommanderResourcePromise; + /** Sets the host port for Redis Commander */ + withHostPort(options?: WithHostPortOptions): RedisCommanderResourcePromise; +} + +export interface RedisCommanderResourcePromise extends PromiseLike { + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): RedisCommanderResourcePromise; + /** Adds a bind mount */ + withBindMount(source: string, target: string, options?: WithBindMountOptions): RedisCommanderResourcePromise; + /** Sets the container entrypoint */ + withEntrypoint(entrypoint: string): RedisCommanderResourcePromise; + /** Sets the container image tag */ + withImageTag(tag: string): RedisCommanderResourcePromise; + /** Sets the container image registry */ + withImageRegistry(registry: string): RedisCommanderResourcePromise; + /** Sets the container image */ + withImage(image: string, options?: WithImageOptions): RedisCommanderResourcePromise; + /** Sets the image SHA256 digest */ + withImageSHA256(sha256: string): RedisCommanderResourcePromise; + /** Adds runtime arguments for the container */ + withContainerRuntimeArgs(args: string[]): RedisCommanderResourcePromise; + /** Sets the lifetime behavior of the container resource */ + withLifetime(lifetime: ContainerLifetime): RedisCommanderResourcePromise; + /** Sets the container image pull policy */ + withImagePullPolicy(pullPolicy: ImagePullPolicy): RedisCommanderResourcePromise; + /** Configures the resource to be published as a container */ + publishAsContainer(): RedisCommanderResourcePromise; + /** Configures the resource to use a Dockerfile */ + withDockerfile(contextPath: string, options?: WithDockerfileOptions): RedisCommanderResourcePromise; + /** Sets the container name */ + withContainerName(name: string): RedisCommanderResourcePromise; + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource | Awaitable): RedisCommanderResourcePromise; + /** Adds a build secret from a parameter resource */ + withBuildSecret(name: string, value: Awaitable): RedisCommanderResourcePromise; + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): RedisCommanderResourcePromise; + /** Configures endpoint proxy support */ + withEndpointProxySupport(proxyEnabled: boolean): RedisCommanderResourcePromise; + /** Configures the resource to use a programmatically generated Dockerfile */ + withDockerfileBuilder(contextPath: string, callback: (arg: DockerfileBuilderCallbackContext) => Promise, options?: WithDockerfileBuilderOptions): RedisCommanderResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): RedisCommanderResourcePromise; + /** Adds a network alias for the container */ + withContainerNetworkAlias(alias: string): RedisCommanderResourcePromise; + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): RedisCommanderResourcePromise; + /** Configures OTLP telemetry export */ + withOtlpExporter(options?: WithOtlpExporterOptions): RedisCommanderResourcePromise; + /** Publishes the resource as a connection string */ + publishAsConnectionString(): RedisCommanderResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): RedisCommanderResourcePromise; + /** Sets an environment variable */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): RedisCommanderResourcePromise; + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): RedisCommanderResourcePromise; + /** Adds arguments */ + withArgs(args: string[]): RedisCommanderResourcePromise; + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): RedisCommanderResourcePromise; + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): RedisCommanderResourcePromise; + /** Adds a reference to another resource */ + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): RedisCommanderResourcePromise; + /** Updates a named endpoint via callback */ + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): RedisCommanderResourcePromise; + /** Updates an HTTP endpoint via callback */ + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): RedisCommanderResourcePromise; + /** Updates an HTTPS endpoint via callback */ + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): RedisCommanderResourcePromise; + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): RedisCommanderResourcePromise; + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): RedisCommanderResourcePromise; + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): RedisCommanderResourcePromise; + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): RedisCommanderResourcePromise; + /** Gets an endpoint reference */ + getEndpoint(name: string): Promise; + /** Configures resource for HTTP/2 */ + asHttp2Service(): RedisCommanderResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): RedisCommanderResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): RedisCommanderResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): RedisCommanderResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): RedisCommanderResourcePromise; + /** Waits for another resource to be ready */ + waitFor(dependency: Awaitable, options?: WaitForOptions): RedisCommanderResourcePromise; + /** Waits for another resource to start */ + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): RedisCommanderResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): RedisCommanderResourcePromise; + /** Waits for resource completion */ + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): RedisCommanderResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): RedisCommanderResourcePromise; + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): RedisCommanderResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): RedisCommanderResourcePromise; + /** Adds an HTTP resource command */ + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): RedisCommanderResourcePromise; + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): RedisCommanderResourcePromise; + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): RedisCommanderResourcePromise; + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): RedisCommanderResourcePromise; + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): RedisCommanderResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): RedisCommanderResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): RedisCommanderResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): RedisCommanderResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): RedisCommanderResourcePromise; + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): RedisCommanderResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): RedisCommanderResourcePromise; + /** Sets image push options via callback */ + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): RedisCommanderResourcePromise; + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): RedisCommanderResourcePromise; + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): RedisCommanderResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): RedisCommanderResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): RedisCommanderResourcePromise; + /** Adds a volume */ + withVolume(target: string, options?: WithVolumeOptions): RedisCommanderResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): RedisCommanderResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): RedisCommanderResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): RedisCommanderResourcePromise; + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): RedisCommanderResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): RedisCommanderResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Create a new reference, while also allowing customization of how a resource appears in the generated LikeC4 diagram. */ + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): RedisCommanderResourcePromise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): RedisCommanderResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): RedisCommanderResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): RedisCommanderResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): RedisCommanderResourcePromise; + /** Associates an Azure user-assigned identity with a compute resource */ + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): RedisCommanderResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): RedisCommanderResourcePromise; + /** Sets the host port for Redis Commander */ + withHostPort(options?: WithHostPortOptions): RedisCommanderResourcePromise; +} + +// ============================================================================ +// RedisCommanderResourceImpl +// ============================================================================ + +class RedisCommanderResourceImpl extends ResourceBuilderBase implements RedisCommanderResource { + constructor(handle: RedisCommanderResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: Awaitable): Promise { + registry = isPromiseLike(registry) ? await registry : registry; + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withContainerRegistry(registry: Awaitable): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._withContainerRegistryInternal(registry), this._client); + } + + /** @internal */ + private async _withBindMountInternal(source: string, target: string, isReadOnly?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, source, target }; + if (isReadOnly !== undefined) rpcArgs.isReadOnly = isReadOnly; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBindMount', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withBindMount(source: string, target: string, options?: WithBindMountOptions): RedisCommanderResourcePromise { + const isReadOnly = options?.isReadOnly; + return new RedisCommanderResourcePromiseImpl(this._withBindMountInternal(source, target, isReadOnly), this._client); + } + + /** @internal */ + private async _withEntrypointInternal(entrypoint: string): Promise { + const rpcArgs: Record = { builder: this._handle, entrypoint }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEntrypoint', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withEntrypoint(entrypoint: string): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._withEntrypointInternal(entrypoint), this._client); + } + + /** @internal */ + private async _withImageTagInternal(tag: string): Promise { + const rpcArgs: Record = { builder: this._handle, tag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImageTag', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withImageTag(tag: string): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._withImageTagInternal(tag), this._client); + } + + /** @internal */ + private async _withImageRegistryInternal(registry: string): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImageRegistry', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withImageRegistry(registry: string): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._withImageRegistryInternal(registry), this._client); + } + + /** @internal */ + private async _withImageInternal(image: string, tag?: string): Promise { + const rpcArgs: Record = { builder: this._handle, image }; + if (tag !== undefined) rpcArgs.tag = tag; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImage', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withImage(image: string, options?: WithImageOptions): RedisCommanderResourcePromise { + const tag = options?.tag; + return new RedisCommanderResourcePromiseImpl(this._withImageInternal(image, tag), this._client); + } + + /** @internal */ + private async _withImageSHA256Internal(sha256: string): Promise { + const rpcArgs: Record = { builder: this._handle, sha256 }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImageSHA256', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withImageSHA256(sha256: string): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._withImageSHA256Internal(sha256), this._client); + } + + /** @internal */ + private async _withContainerRuntimeArgsInternal(args: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, args }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRuntimeArgs', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withContainerRuntimeArgs(args: string[]): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._withContainerRuntimeArgsInternal(args), this._client); + } + + /** @internal */ + private async _withLifetimeInternal(lifetime: ContainerLifetime): Promise { + const rpcArgs: Record = { builder: this._handle, lifetime }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withLifetime', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withLifetime(lifetime: ContainerLifetime): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._withLifetimeInternal(lifetime), this._client); + } + + /** @internal */ + private async _withImagePullPolicyInternal(pullPolicy: ImagePullPolicy): Promise { + const rpcArgs: Record = { builder: this._handle, pullPolicy }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImagePullPolicy', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withImagePullPolicy(pullPolicy: ImagePullPolicy): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._withImagePullPolicyInternal(pullPolicy), this._client); + } + + /** @internal */ + private async _publishAsContainerInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsContainer', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + publishAsContainer(): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._publishAsContainerInternal(), this._client); + } + + /** @internal */ + private async _withDockerfileInternal(contextPath: string, dockerfilePath?: string, stage?: string): Promise { + const rpcArgs: Record = { builder: this._handle, contextPath }; + if (dockerfilePath !== undefined) rpcArgs.dockerfilePath = dockerfilePath; + if (stage !== undefined) rpcArgs.stage = stage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfile', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withDockerfile(contextPath: string, options?: WithDockerfileOptions): RedisCommanderResourcePromise { + const dockerfilePath = options?.dockerfilePath; + const stage = options?.stage; + return new RedisCommanderResourcePromiseImpl(this._withDockerfileInternal(contextPath, dockerfilePath, stage), this._client); + } + + /** @internal */ + private async _withContainerNameInternal(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerName', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withContainerName(name: string): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._withContainerNameInternal(name), this._client); + } + + /** @internal */ + private async _withBuildArgInternal(name: string, value: string | ParameterResource | Awaitable): Promise { + value = isPromiseLike(value) ? await value : value; + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuildArg', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withBuildArg(name: string, value: string | ParameterResource | Awaitable): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._withBuildArgInternal(name, value), this._client); + } + + /** @internal */ + private async _withBuildSecretInternal(name: string, value: Awaitable): Promise { + value = isPromiseLike(value) ? await value : value; + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParameterBuildSecret', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withBuildSecret(name: string, value: Awaitable): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._withBuildSecretInternal(name, value), this._client); + } + + /** @internal */ + private async _withContainerCertificatePathsInternal(customCertificatesDestination?: string, defaultCertificateBundlePaths?: string[], defaultCertificateDirectoryPaths?: string[]): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (customCertificatesDestination !== undefined) rpcArgs.customCertificatesDestination = customCertificatesDestination; + if (defaultCertificateBundlePaths !== undefined) rpcArgs.defaultCertificateBundlePaths = defaultCertificateBundlePaths; + if (defaultCertificateDirectoryPaths !== undefined) rpcArgs.defaultCertificateDirectoryPaths = defaultCertificateDirectoryPaths; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerCertificatePaths', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): RedisCommanderResourcePromise { + const customCertificatesDestination = options?.customCertificatesDestination; + const defaultCertificateBundlePaths = options?.defaultCertificateBundlePaths; + const defaultCertificateDirectoryPaths = options?.defaultCertificateDirectoryPaths; + return new RedisCommanderResourcePromiseImpl(this._withContainerCertificatePathsInternal(customCertificatesDestination, defaultCertificateBundlePaths, defaultCertificateDirectoryPaths), this._client); + } + + /** @internal */ + private async _withEndpointProxySupportInternal(proxyEnabled: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, proxyEnabled }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpointProxySupport', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withEndpointProxySupport(proxyEnabled: boolean): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._withEndpointProxySupportInternal(proxyEnabled), this._client); + } + + /** @internal */ + private async _withDockerfileBuilderInternal(contextPath: string, callback: (arg: DockerfileBuilderCallbackContext) => Promise, stage?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as DockerfileBuilderCallbackContextHandle; + const arg = new DockerfileBuilderCallbackContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, contextPath, callback: callbackId }; + if (stage !== undefined) rpcArgs.stage = stage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBuilder', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withDockerfileBuilder(contextPath: string, callback: (arg: DockerfileBuilderCallbackContext) => Promise, options?: WithDockerfileBuilderOptions): RedisCommanderResourcePromise { + const stage = options?.stage; + return new RedisCommanderResourcePromiseImpl(this._withDockerfileBuilderInternal(contextPath, callback, stage), this._client); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): RedisCommanderResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new RedisCommanderResourcePromiseImpl(this._withDockerfileBaseImageInternal(buildImage, runtimeImage), this._client); + } + + /** @internal */ + private async _withContainerNetworkAliasInternal(alias: string): Promise { + const rpcArgs: Record = { builder: this._handle, alias }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerNetworkAlias', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withContainerNetworkAlias(alias: string): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._withContainerNetworkAliasInternal(alias), this._client); + } + + /** @internal */ + private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withMcpServer', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withMcpServer(options?: WithMcpServerOptions): RedisCommanderResourcePromise { + const path = options?.path; + const endpointName = options?.endpointName; + return new RedisCommanderResourcePromiseImpl(this._withMcpServerInternal(path, endpointName), this._client); + } + + /** @internal */ + private async _withOtlpExporterInternal(protocol?: OtlpProtocol): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (protocol !== undefined) rpcArgs.protocol = protocol; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporter', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withOtlpExporter(options?: WithOtlpExporterOptions): RedisCommanderResourcePromise { + const protocol = options?.protocol; + return new RedisCommanderResourcePromiseImpl(this._withOtlpExporterInternal(protocol), this._client); + } + + /** @internal */ + private async _publishAsConnectionStringInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsConnectionString', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + publishAsConnectionString(): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._publishAsConnectionStringInternal(), this._client); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): RedisCommanderResourcePromise { + const helpLink = options?.helpLink; + return new RedisCommanderResourcePromiseImpl(this._withRequiredCommandInternal(command, helpLink), this._client); + } + + /** @internal */ + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): Promise { + value = isPromiseLike(value) ? await value : value; + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironment', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._withEnvironmentInternal(name, value), this._client); + } + + /** @internal */ + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentCallback', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._withEnvironmentCallbackInternal(callback), this._client); + } + + /** @internal */ + private async _withArgsInternal(args: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, args }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgs', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withArgs(args: string[]): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._withArgsInternal(args), this._client); + } + + /** @internal */ + private async _withArgsCallbackInternal(callback: (obj: CommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; + const obj = new CommandLineArgsCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallback', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._withArgsCallbackInternal(callback), this._client); + } + + /** @internal */ + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceEnvironment', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._withReferenceEnvironmentInternal(options), this._client); + } + + /** @internal */ + private async _withReferenceInternal(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, connectionName?: string, optional?: boolean, name?: string): Promise { + source = isPromiseLike(source) ? await source : source; + const rpcArgs: Record = { builder: this._handle, source }; + if (connectionName !== undefined) rpcArgs.connectionName = connectionName; + if (optional !== undefined) rpcArgs.optional = optional; + if (name !== undefined) rpcArgs.name = name; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReference', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): RedisCommanderResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new RedisCommanderResourcePromiseImpl(this._withReferenceInternal(source, connectionName, optional, name), this._client); + } + + /** @internal */ + private async _withEndpointCallbackInternal(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpointCallback', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): RedisCommanderResourcePromise { + const createIfNotExists = options?.createIfNotExists; + return new RedisCommanderResourcePromiseImpl(this._withEndpointCallbackInternal(endpointName, callback, createIfNotExists), this._client); + } + + /** @internal */ + private async _withHttpEndpointCallbackInternal(callback: (obj: EndpointUpdateContext) => Promise, name?: string, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + if (name !== undefined) rpcArgs.name = name; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpEndpointCallback', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): RedisCommanderResourcePromise { + const name = options?.name; + const createIfNotExists = options?.createIfNotExists; + return new RedisCommanderResourcePromiseImpl(this._withHttpEndpointCallbackInternal(callback, name, createIfNotExists), this._client); + } + + /** @internal */ + private async _withHttpsEndpointCallbackInternal(callback: (obj: EndpointUpdateContext) => Promise, name?: string, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + if (name !== undefined) rpcArgs.name = name; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsEndpointCallback', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): RedisCommanderResourcePromise { + const name = options?.name; + const createIfNotExists = options?.createIfNotExists; + return new RedisCommanderResourcePromiseImpl(this._withHttpsEndpointCallbackInternal(callback, name, createIfNotExists), this._client); + } + + /** @internal */ + private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (scheme !== undefined) rpcArgs.scheme = scheme; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + if (isExternal !== undefined) rpcArgs.isExternal = isExternal; + if (protocol !== undefined) rpcArgs.protocol = protocol; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpoint', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withEndpoint(options?: WithEndpointOptions): RedisCommanderResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const scheme = options?.scheme; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + const isExternal = options?.isExternal; + const protocol = options?.protocol; + return new RedisCommanderResourcePromiseImpl(this._withEndpointInternal(port, targetPort, scheme, name, env, isProxied, isExternal, protocol), this._client); + } + + /** @internal */ + private async _withHttpEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpEndpoint', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withHttpEndpoint(options?: WithHttpEndpointOptions): RedisCommanderResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new RedisCommanderResourcePromiseImpl(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied), this._client); + } + + /** @internal */ + private async _withHttpsEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsEndpoint', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withHttpsEndpoint(options?: WithHttpsEndpointOptions): RedisCommanderResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new RedisCommanderResourcePromiseImpl(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied), this._client); + } + + /** @internal */ + private async _withExternalHttpEndpointsInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExternalHttpEndpoints', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withExternalHttpEndpoints(): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._withExternalHttpEndpointsInternal(), this._client); + } + + async getEndpoint(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getEndpoint', + rpcArgs + ); + } + + /** @internal */ + private async _asHttp2ServiceInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/asHttp2Service', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + asHttp2Service(): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._asHttp2ServiceInternal(), this._client); + } + + /** @internal */ + private async _withUrlsInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrls', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._withUrlsInternal(callback), this._client); + } + + /** @internal */ + private async _withUrlInternal(url: string | ReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): RedisCommanderResourcePromise { + const displayText = options?.displayText; + return new RedisCommanderResourcePromiseImpl(this._withUrlInternal(url, displayText), this._client); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._withUrlForEndpointInternal(endpointName, callback), this._client); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + excludeFromManifest(): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._excludeFromManifestInternal(), this._client); + } + + /** @internal */ + private async _waitForInternal(dependency: Awaitable, waitBehavior?: WaitBehavior): Promise { + dependency = isPromiseLike(dependency) ? await dependency : dependency; + const rpcArgs: Record = { builder: this._handle, dependency }; + if (waitBehavior !== undefined) rpcArgs.waitBehavior = waitBehavior; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitFor', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + waitFor(dependency: Awaitable, options?: WaitForOptions): RedisCommanderResourcePromise { + const waitBehavior = options?.waitBehavior; + return new RedisCommanderResourcePromiseImpl(this._waitForInternal(dependency, waitBehavior), this._client); + } + + /** @internal */ + private async _waitForStartInternal(dependency: Awaitable, waitBehavior?: WaitBehavior): Promise { + dependency = isPromiseLike(dependency) ? await dependency : dependency; + const rpcArgs: Record = { builder: this._handle, dependency }; + if (waitBehavior !== undefined) rpcArgs.waitBehavior = waitBehavior; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStart', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): RedisCommanderResourcePromise { + const waitBehavior = options?.waitBehavior; + return new RedisCommanderResourcePromiseImpl(this._waitForStartInternal(dependency, waitBehavior), this._client); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withExplicitStart(): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._withExplicitStartInternal(), this._client); + } + + /** @internal */ + private async _waitForCompletionInternal(dependency: Awaitable, exitCode?: number): Promise { + dependency = isPromiseLike(dependency) ? await dependency : dependency; + const rpcArgs: Record = { builder: this._handle, dependency }; + if (exitCode !== undefined) rpcArgs.exitCode = exitCode; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceCompletion', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): RedisCommanderResourcePromise { + const exitCode = options?.exitCode; + return new RedisCommanderResourcePromiseImpl(this._waitForCompletionInternal(dependency, exitCode), this._client); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withHealthCheck(key: string): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._withHealthCheckInternal(key), this._client); + } + + /** @internal */ + private async _withHttpHealthCheckInternal(path?: string, statusCode?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (statusCode !== undefined) rpcArgs.statusCode = statusCode; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpHealthCheck', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): RedisCommanderResourcePromise { + const path = options?.path; + const statusCode = options?.statusCode; + const endpointName = options?.endpointName; + return new RedisCommanderResourcePromiseImpl(this._withHttpHealthCheckInternal(path, statusCode, endpointName), this._client); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContextImpl(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): RedisCommanderResourcePromise { + const commandOptions = options?.commandOptions; + return new RedisCommanderResourcePromiseImpl(this._withCommandInternal(name, displayName, executeCommand, commandOptions), this._client); + } + + /** @internal */ + private async _withHttpCommandInternal(path: string, displayName: string, options?: HttpCommandExportOptions): Promise { + const rpcArgs: Record = { builder: this._handle, path, displayName }; + if (options !== undefined) rpcArgs.options = options; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpCommand', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._withHttpCommandInternal(path, displayName, options), this._client); + } + + /** @internal */ + private async _withDeveloperCertificateTrustInternal(trust: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, trust }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDeveloperCertificateTrust', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withDeveloperCertificateTrust(trust: boolean): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._withDeveloperCertificateTrustInternal(trust), this._client); + } + + /** @internal */ + private async _withCertificateTrustScopeInternal(scope: CertificateTrustScope): Promise { + const rpcArgs: Record = { builder: this._handle, scope }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCertificateTrustScope', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withCertificateTrustScope(scope: CertificateTrustScope): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._withCertificateTrustScopeInternal(scope), this._client); + } + + /** @internal */ + private async _withHttpsDeveloperCertificateInternal(password?: Awaitable): Promise { + password = isPromiseLike(password) ? await password : password; + const rpcArgs: Record = { builder: this._handle }; + if (password !== undefined) rpcArgs.password = password; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): RedisCommanderResourcePromise { + let password = options?.password; + return new RedisCommanderResourcePromiseImpl(this._withHttpsDeveloperCertificateInternal(password), this._client); + } + + /** @internal */ + private async _withoutHttpsCertificateInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withoutHttpsCertificate', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withoutHttpsCertificate(): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._withoutHttpsCertificateInternal(), this._client); + } + + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: Awaitable, type: string): Promise { + resourceBuilder = isPromiseLike(resourceBuilder) ? await resourceBuilder : resourceBuilder; + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._withRelationshipInternal(resourceBuilder, type), this._client); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: Awaitable): Promise { + parent = isPromiseLike(parent) ? await parent : parent; + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withParentRelationship(parent: Awaitable): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._withParentRelationshipInternal(parent), this._client); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: Awaitable): Promise { + child = isPromiseLike(child) ? await child : child; + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withChildRelationship(child: Awaitable): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._withChildRelationshipInternal(child), this._client); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): RedisCommanderResourcePromise { + const iconVariant = options?.iconVariant; + return new RedisCommanderResourcePromiseImpl(this._withIconNameInternal(iconName, iconVariant), this._client); + } + + /** @internal */ + private async _withHttpProbeInternal(probeType: ProbeType, path?: string, initialDelaySeconds?: number, periodSeconds?: number, timeoutSeconds?: number, failureThreshold?: number, successThreshold?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, probeType }; + if (path !== undefined) rpcArgs.path = path; + if (initialDelaySeconds !== undefined) rpcArgs.initialDelaySeconds = initialDelaySeconds; + if (periodSeconds !== undefined) rpcArgs.periodSeconds = periodSeconds; + if (timeoutSeconds !== undefined) rpcArgs.timeoutSeconds = timeoutSeconds; + if (failureThreshold !== undefined) rpcArgs.failureThreshold = failureThreshold; + if (successThreshold !== undefined) rpcArgs.successThreshold = successThreshold; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpProbe', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): RedisCommanderResourcePromise { + const path = options?.path; + const initialDelaySeconds = options?.initialDelaySeconds; + const periodSeconds = options?.periodSeconds; + const timeoutSeconds = options?.timeoutSeconds; + const failureThreshold = options?.failureThreshold; + const successThreshold = options?.successThreshold; + const endpointName = options?.endpointName; + return new RedisCommanderResourcePromiseImpl(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName), this._client); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + excludeFromMcp(): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._excludeFromMcpInternal(), this._client); + } + + /** @internal */ + private async _withImagePushOptionsInternal(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ContainerImagePushOptionsCallbackContextHandle; + const arg = new ContainerImagePushOptionsCallbackContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImagePushOptions', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._withImagePushOptionsInternal(callback), this._client); + } + + /** @internal */ + private async _withRemoteImageNameInternal(remoteImageName: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageName', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withRemoteImageName(remoteImageName: string): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._withRemoteImageNameInternal(remoteImageName), this._client); + } + + /** @internal */ + private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageTag', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withRemoteImageTag(remoteImageTag: string): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._withRemoteImageTagInternal(remoteImageTag), this._client); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): RedisCommanderResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new RedisCommanderResourcePromiseImpl(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description), this._client); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._withPipelineConfigurationInternal(callback), this._client); + } + + /** @internal */ + private async _withVolumeInternal(target: string, name?: string, isReadOnly?: boolean): Promise { + const rpcArgs: Record = { resource: this._handle, target }; + if (name !== undefined) rpcArgs.name = name; + if (isReadOnly !== undefined) rpcArgs.isReadOnly = isReadOnly; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withVolume', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withVolume(target: string, options?: WithVolumeOptions): RedisCommanderResourcePromise { + const name = options?.name; + const isReadOnly = options?.isReadOnly; + return new RedisCommanderResourcePromiseImpl(this._withVolumeInternal(target, name, isReadOnly), this._client); + } + + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); + } + + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._onBeforeResourceStartedInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._onResourceStoppedInternal(callback), this._client); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._onInitializeResourceInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceEndpointsAllocated', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._onResourceEndpointsAllocatedInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._onResourceReadyInternal(callback), this._client); + } + + async createExecutionConfiguration(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/createExecutionConfiguration', + rpcArgs + ); + } + + /** @internal */ + private async _withLikeC4ReferenceWithEnvironmentInternal(source: Awaitable, configure?: (obj: LikeC4RelationshipDetailsAnnotation) => Promise, connectionName?: string, optional?: boolean, skipAspireReference?: boolean): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4RelationshipDetailsAnnotationHandle; + const obj = new LikeC4RelationshipDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + source = isPromiseLike(source) ? await source : source; + const rpcArgs: Record = { builder: this._handle, source }; + if (configure !== undefined) rpcArgs.configure = configureId; + if (connectionName !== undefined) rpcArgs.connectionName = connectionName; + if (optional !== undefined) rpcArgs.optional = optional; + if (skipAspireReference !== undefined) rpcArgs.skipAspireReference = skipAspireReference; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4ReferenceWithEnvironment', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): RedisCommanderResourcePromise { + const configure = options?.configure; + const connectionName = options?.connectionName; + const optional = options?.optional; + const skipAspireReference = options?.skipAspireReference; + return new RedisCommanderResourcePromiseImpl(this._withLikeC4ReferenceWithEnvironmentInternal(source, configure, connectionName, optional, skipAspireReference), this._client); + } + + /** @internal */ + private async _withLikeC4DetailsInternal(label?: string, technology?: string, description?: string, summary?: string, icon?: string, configure?: (obj: LikeC4NodeDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4NodeDetailsAnnotationHandle; + const obj = new LikeC4NodeDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + const rpcArgs: Record = { builder: this._handle }; + if (label !== undefined) rpcArgs.label = label; + if (technology !== undefined) rpcArgs.technology = technology; + if (description !== undefined) rpcArgs.description = description; + if (summary !== undefined) rpcArgs.summary = summary; + if (icon !== undefined) rpcArgs.icon = icon; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4DetailsParameters', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): RedisCommanderResourcePromise { + const label = options?.label; + const technology = options?.technology; + const description = options?.description; + const summary = options?.summary; + const icon = options?.icon; + const configure = options?.configure; + return new RedisCommanderResourcePromiseImpl(this._withLikeC4DetailsInternal(label, technology, description, summary, icon, configure), this._client); + } + + /** @internal */ + private async _withLikeC4ReferenceInternal(target: Awaitable, configure?: (obj: LikeC4RelationshipDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4RelationshipDetailsAnnotationHandle; + const obj = new LikeC4RelationshipDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target }; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Reference', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): RedisCommanderResourcePromise { + const configure = options?.configure; + return new RedisCommanderResourcePromiseImpl(this._withLikeC4ReferenceInternal(target, configure), this._client); + } + + /** @internal */ + private async _withLikeC4GroupInternal(groupName: string): Promise { + const rpcArgs: Record = { builder: this._handle, groupName }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Group', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withLikeC4Group(groupName: string): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._withLikeC4GroupInternal(groupName), this._client); + } + + /** @internal */ + private async _excludeFromLikeC4Internal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/excludeFromLikeC4', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + excludeFromLikeC4(): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._excludeFromLikeC4Internal(), this._client); + } + + /** @internal */ + private async _withAzureUserAssignedIdentityInternal(identityResourceBuilder: Awaitable): Promise { + identityResourceBuilder = isPromiseLike(identityResourceBuilder) ? await identityResourceBuilder : identityResourceBuilder; + const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._withAzureUserAssignedIdentityInternal(identityResourceBuilder), this._client); + } + + /** @internal */ + private async _withRoleAssignmentsInternal(target: Awaitable, roles: AzureKeyVaultRole[]): Promise { + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target, roles }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.KeyVault/withKeyVaultRoleAssignments', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._withRoleAssignmentsInternal(target, roles), this._client); + } + + /** @internal */ + private async _withHostPortInternal(port?: number): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Redis/withRedisCommanderHostPort', + rpcArgs + ); + return new RedisCommanderResourceImpl(result, this._client); + } + + withHostPort(options?: WithHostPortOptions): RedisCommanderResourcePromise { + const port = options?.port; + return new RedisCommanderResourcePromiseImpl(this._withHostPortInternal(port), this._client); + } + +} + +/** + * Thenable wrapper for RedisCommanderResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +class RedisCommanderResourcePromiseImpl implements RedisCommanderResourcePromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: RedisCommanderResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + withContainerRegistry(registry: Awaitable): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withContainerRegistry(registry)), this._client); + } + + withBindMount(source: string, target: string, options?: WithBindMountOptions): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withBindMount(source, target, options)), this._client); + } + + withEntrypoint(entrypoint: string): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withEntrypoint(entrypoint)), this._client); + } + + withImageTag(tag: string): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withImageTag(tag)), this._client); + } + + withImageRegistry(registry: string): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withImageRegistry(registry)), this._client); + } + + withImage(image: string, options?: WithImageOptions): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withImage(image, options)), this._client); + } + + withImageSHA256(sha256: string): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withImageSHA256(sha256)), this._client); + } + + withContainerRuntimeArgs(args: string[]): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withContainerRuntimeArgs(args)), this._client); + } + + withLifetime(lifetime: ContainerLifetime): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withLifetime(lifetime)), this._client); + } + + withImagePullPolicy(pullPolicy: ImagePullPolicy): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withImagePullPolicy(pullPolicy)), this._client); + } + + publishAsContainer(): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.publishAsContainer()), this._client); + } + + withDockerfile(contextPath: string, options?: WithDockerfileOptions): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withDockerfile(contextPath, options)), this._client); + } + + withContainerName(name: string): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withContainerName(name)), this._client); + } + + withBuildArg(name: string, value: string | ParameterResource | Awaitable): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withBuildArg(name, value)), this._client); + } + + withBuildSecret(name: string, value: Awaitable): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withBuildSecret(name, value)), this._client); + } + + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withContainerCertificatePaths(options)), this._client); + } + + withEndpointProxySupport(proxyEnabled: boolean): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withEndpointProxySupport(proxyEnabled)), this._client); + } + + withDockerfileBuilder(contextPath: string, callback: (arg: DockerfileBuilderCallbackContext) => Promise, options?: WithDockerfileBuilderOptions): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withDockerfileBuilder(contextPath, callback, options)), this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withDockerfileBaseImage(options)), this._client); + } + + withContainerNetworkAlias(alias: string): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withContainerNetworkAlias(alias)), this._client); + } + + withMcpServer(options?: WithMcpServerOptions): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withMcpServer(options)), this._client); + } + + withOtlpExporter(options?: WithOtlpExporterOptions): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withOtlpExporter(options)), this._client); + } + + publishAsConnectionString(): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.publishAsConnectionString()), this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withRequiredCommand(command, options)), this._client); + } + + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withEnvironment(name, value)), this._client); + } + + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentCallback(callback)), this._client); + } + + withArgs(args: string[]): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withArgs(args)), this._client); + } + + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withArgsCallback(callback)), this._client); + } + + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withReferenceEnvironment(options)), this._client); + } + + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withReference(source, options)), this._client); + } + + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withEndpointCallback(endpointName, callback, options)), this._client); + } + + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withHttpEndpointCallback(callback, options)), this._client); + } + + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withHttpsEndpointCallback(callback, options)), this._client); + } + + withEndpoint(options?: WithEndpointOptions): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withEndpoint(options)), this._client); + } + + withHttpEndpoint(options?: WithHttpEndpointOptions): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withHttpEndpoint(options)), this._client); + } + + withHttpsEndpoint(options?: WithHttpsEndpointOptions): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withHttpsEndpoint(options)), this._client); + } + + withExternalHttpEndpoints(): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withExternalHttpEndpoints()), this._client); + } + + getEndpoint(name: string): Promise { + return this._promise.then(obj => obj.getEndpoint(name)); + } + + asHttp2Service(): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.asHttp2Service()), this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withUrls(callback)), this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withUrl(url, options)), this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback)), this._client); + } + + excludeFromManifest(): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.excludeFromManifest()), this._client); + } + + waitFor(dependency: Awaitable, options?: WaitForOptions): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.waitFor(dependency, options)), this._client); + } + + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.waitForStart(dependency, options)), this._client); + } + + withExplicitStart(): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withExplicitStart()), this._client); + } + + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.waitForCompletion(dependency, options)), this._client); + } + + withHealthCheck(key: string): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withHealthCheck(key)), this._client); + } + + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withHttpHealthCheck(options)), this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options)), this._client); + } + + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withHttpCommand(path, displayName, options)), this._client); + } + + withDeveloperCertificateTrust(trust: boolean): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust)), this._client); + } + + withCertificateTrustScope(scope: CertificateTrustScope): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withCertificateTrustScope(scope)), this._client); + } + + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options)), this._client); + } + + withoutHttpsCertificate(): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withoutHttpsCertificate()), this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withRelationship(resourceBuilder, type)), this._client); + } + + withParentRelationship(parent: Awaitable): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withParentRelationship(parent)), this._client); + } + + withChildRelationship(child: Awaitable): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withChildRelationship(child)), this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withIconName(iconName, options)), this._client); + } + + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withHttpProbe(probeType, options)), this._client); + } + + excludeFromMcp(): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.excludeFromMcp()), this._client); + } + + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withImagePushOptions(callback)), this._client); + } + + withRemoteImageName(remoteImageName: string): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withRemoteImageName(remoteImageName)), this._client); + } + + withRemoteImageTag(remoteImageTag: string): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag)), this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options)), this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withPipelineConfiguration(callback)), this._client); + } + + withVolume(target: string, options?: WithVolumeOptions): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withVolume(target, options)), this._client); + } + + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.onBeforeResourceStarted(callback)), this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.onResourceStopped(callback)), this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.onInitializeResource(callback)), this._client); + } + + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback)), this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.onResourceReady(callback)), this._client); + } + + createExecutionConfiguration(): Promise { + return this._promise.then(obj => obj.createExecutionConfiguration()); + } + + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4ReferenceWithEnvironment(source, options)), this._client); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Details(options)), this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Reference(target, options)), this._client); + } + + withLikeC4Group(groupName: string): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Group(groupName)), this._client); + } + + excludeFromLikeC4(): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.excludeFromLikeC4()), this._client); + } + + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withAzureUserAssignedIdentity(identityResourceBuilder)), this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withRoleAssignments(target, roles)), this._client); + } + + withHostPort(options?: WithHostPortOptions): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromiseImpl(this._promise.then(obj => obj.withHostPort(options)), this._client); + } + +} + +// ============================================================================ +// RedisInsightResource +// ============================================================================ + +export interface RedisInsightResource { + toJSON(): MarshalledHandle; + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): RedisInsightResourcePromise; + /** Adds a bind mount */ + withBindMount(source: string, target: string, options?: WithBindMountOptions): RedisInsightResourcePromise; + /** Sets the container entrypoint */ + withEntrypoint(entrypoint: string): RedisInsightResourcePromise; + /** Sets the container image tag */ + withImageTag(tag: string): RedisInsightResourcePromise; + /** Sets the container image registry */ + withImageRegistry(registry: string): RedisInsightResourcePromise; + /** Sets the container image */ + withImage(image: string, options?: WithImageOptions): RedisInsightResourcePromise; + /** Sets the image SHA256 digest */ + withImageSHA256(sha256: string): RedisInsightResourcePromise; + /** Adds runtime arguments for the container */ + withContainerRuntimeArgs(args: string[]): RedisInsightResourcePromise; + /** Sets the lifetime behavior of the container resource */ + withLifetime(lifetime: ContainerLifetime): RedisInsightResourcePromise; + /** Sets the container image pull policy */ + withImagePullPolicy(pullPolicy: ImagePullPolicy): RedisInsightResourcePromise; + /** Configures the resource to be published as a container */ + publishAsContainer(): RedisInsightResourcePromise; + /** Configures the resource to use a Dockerfile */ + withDockerfile(contextPath: string, options?: WithDockerfileOptions): RedisInsightResourcePromise; + /** Sets the container name */ + withContainerName(name: string): RedisInsightResourcePromise; + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource | Awaitable): RedisInsightResourcePromise; + /** Adds a build secret from a parameter resource */ + withBuildSecret(name: string, value: Awaitable): RedisInsightResourcePromise; + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): RedisInsightResourcePromise; + /** Configures endpoint proxy support */ + withEndpointProxySupport(proxyEnabled: boolean): RedisInsightResourcePromise; + /** Configures the resource to use a programmatically generated Dockerfile */ + withDockerfileBuilder(contextPath: string, callback: (arg: DockerfileBuilderCallbackContext) => Promise, options?: WithDockerfileBuilderOptions): RedisInsightResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): RedisInsightResourcePromise; + /** Adds a network alias for the container */ + withContainerNetworkAlias(alias: string): RedisInsightResourcePromise; + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): RedisInsightResourcePromise; + /** Configures OTLP telemetry export */ + withOtlpExporter(options?: WithOtlpExporterOptions): RedisInsightResourcePromise; + /** Publishes the resource as a connection string */ + publishAsConnectionString(): RedisInsightResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): RedisInsightResourcePromise; + /** Sets an environment variable */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): RedisInsightResourcePromise; + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): RedisInsightResourcePromise; + /** Adds arguments */ + withArgs(args: string[]): RedisInsightResourcePromise; + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): RedisInsightResourcePromise; + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): RedisInsightResourcePromise; + /** Adds a reference to another resource */ + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): RedisInsightResourcePromise; + /** Updates a named endpoint via callback */ + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): RedisInsightResourcePromise; + /** Updates an HTTP endpoint via callback */ + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): RedisInsightResourcePromise; + /** Updates an HTTPS endpoint via callback */ + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): RedisInsightResourcePromise; + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): RedisInsightResourcePromise; + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): RedisInsightResourcePromise; + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): RedisInsightResourcePromise; + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): RedisInsightResourcePromise; + /** Gets an endpoint reference */ + getEndpoint(name: string): Promise; + /** Configures resource for HTTP/2 */ + asHttp2Service(): RedisInsightResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): RedisInsightResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): RedisInsightResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): RedisInsightResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): RedisInsightResourcePromise; + /** Waits for another resource to be ready */ + waitFor(dependency: Awaitable, options?: WaitForOptions): RedisInsightResourcePromise; + /** Waits for another resource to start */ + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): RedisInsightResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): RedisInsightResourcePromise; + /** Waits for resource completion */ + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): RedisInsightResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): RedisInsightResourcePromise; + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): RedisInsightResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): RedisInsightResourcePromise; + /** Adds an HTTP resource command */ + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): RedisInsightResourcePromise; + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): RedisInsightResourcePromise; + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): RedisInsightResourcePromise; + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): RedisInsightResourcePromise; + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): RedisInsightResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): RedisInsightResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): RedisInsightResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): RedisInsightResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): RedisInsightResourcePromise; + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): RedisInsightResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): RedisInsightResourcePromise; + /** Sets image push options via callback */ + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): RedisInsightResourcePromise; + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): RedisInsightResourcePromise; + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): RedisInsightResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): RedisInsightResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): RedisInsightResourcePromise; + /** Adds a volume */ + withVolume(target: string, options?: WithVolumeOptions): RedisInsightResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): RedisInsightResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): RedisInsightResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): RedisInsightResourcePromise; + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): RedisInsightResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): RedisInsightResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Create a new reference, while also allowing customization of how a resource appears in the generated LikeC4 diagram. */ + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): RedisInsightResourcePromise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): RedisInsightResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): RedisInsightResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): RedisInsightResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): RedisInsightResourcePromise; + /** Associates an Azure user-assigned identity with a compute resource */ + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): RedisInsightResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): RedisInsightResourcePromise; + /** Sets the host port for Redis Insight */ + withHostPort(options?: WithHostPortOptions): RedisInsightResourcePromise; + /** Adds a data volume for Redis Insight */ + withDataVolume(options?: WithDataVolumeOptions): RedisInsightResourcePromise; + /** Adds a data bind mount for Redis Insight */ + withDataBindMount(source: string): RedisInsightResourcePromise; +} + +export interface RedisInsightResourcePromise extends PromiseLike { + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): RedisInsightResourcePromise; + /** Adds a bind mount */ + withBindMount(source: string, target: string, options?: WithBindMountOptions): RedisInsightResourcePromise; + /** Sets the container entrypoint */ + withEntrypoint(entrypoint: string): RedisInsightResourcePromise; + /** Sets the container image tag */ + withImageTag(tag: string): RedisInsightResourcePromise; + /** Sets the container image registry */ + withImageRegistry(registry: string): RedisInsightResourcePromise; + /** Sets the container image */ + withImage(image: string, options?: WithImageOptions): RedisInsightResourcePromise; + /** Sets the image SHA256 digest */ + withImageSHA256(sha256: string): RedisInsightResourcePromise; + /** Adds runtime arguments for the container */ + withContainerRuntimeArgs(args: string[]): RedisInsightResourcePromise; + /** Sets the lifetime behavior of the container resource */ + withLifetime(lifetime: ContainerLifetime): RedisInsightResourcePromise; + /** Sets the container image pull policy */ + withImagePullPolicy(pullPolicy: ImagePullPolicy): RedisInsightResourcePromise; + /** Configures the resource to be published as a container */ + publishAsContainer(): RedisInsightResourcePromise; + /** Configures the resource to use a Dockerfile */ + withDockerfile(contextPath: string, options?: WithDockerfileOptions): RedisInsightResourcePromise; + /** Sets the container name */ + withContainerName(name: string): RedisInsightResourcePromise; + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource | Awaitable): RedisInsightResourcePromise; + /** Adds a build secret from a parameter resource */ + withBuildSecret(name: string, value: Awaitable): RedisInsightResourcePromise; + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): RedisInsightResourcePromise; + /** Configures endpoint proxy support */ + withEndpointProxySupport(proxyEnabled: boolean): RedisInsightResourcePromise; + /** Configures the resource to use a programmatically generated Dockerfile */ + withDockerfileBuilder(contextPath: string, callback: (arg: DockerfileBuilderCallbackContext) => Promise, options?: WithDockerfileBuilderOptions): RedisInsightResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): RedisInsightResourcePromise; + /** Adds a network alias for the container */ + withContainerNetworkAlias(alias: string): RedisInsightResourcePromise; + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): RedisInsightResourcePromise; + /** Configures OTLP telemetry export */ + withOtlpExporter(options?: WithOtlpExporterOptions): RedisInsightResourcePromise; + /** Publishes the resource as a connection string */ + publishAsConnectionString(): RedisInsightResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): RedisInsightResourcePromise; + /** Sets an environment variable */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): RedisInsightResourcePromise; + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): RedisInsightResourcePromise; + /** Adds arguments */ + withArgs(args: string[]): RedisInsightResourcePromise; + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): RedisInsightResourcePromise; + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): RedisInsightResourcePromise; + /** Adds a reference to another resource */ + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): RedisInsightResourcePromise; + /** Updates a named endpoint via callback */ + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): RedisInsightResourcePromise; + /** Updates an HTTP endpoint via callback */ + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): RedisInsightResourcePromise; + /** Updates an HTTPS endpoint via callback */ + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): RedisInsightResourcePromise; + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): RedisInsightResourcePromise; + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): RedisInsightResourcePromise; + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): RedisInsightResourcePromise; + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): RedisInsightResourcePromise; + /** Gets an endpoint reference */ + getEndpoint(name: string): Promise; + /** Configures resource for HTTP/2 */ + asHttp2Service(): RedisInsightResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): RedisInsightResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): RedisInsightResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): RedisInsightResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): RedisInsightResourcePromise; + /** Waits for another resource to be ready */ + waitFor(dependency: Awaitable, options?: WaitForOptions): RedisInsightResourcePromise; + /** Waits for another resource to start */ + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): RedisInsightResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): RedisInsightResourcePromise; + /** Waits for resource completion */ + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): RedisInsightResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): RedisInsightResourcePromise; + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): RedisInsightResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): RedisInsightResourcePromise; + /** Adds an HTTP resource command */ + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): RedisInsightResourcePromise; + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): RedisInsightResourcePromise; + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): RedisInsightResourcePromise; + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): RedisInsightResourcePromise; + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): RedisInsightResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): RedisInsightResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): RedisInsightResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): RedisInsightResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): RedisInsightResourcePromise; + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): RedisInsightResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): RedisInsightResourcePromise; + /** Sets image push options via callback */ + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): RedisInsightResourcePromise; + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): RedisInsightResourcePromise; + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): RedisInsightResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): RedisInsightResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): RedisInsightResourcePromise; + /** Adds a volume */ + withVolume(target: string, options?: WithVolumeOptions): RedisInsightResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): RedisInsightResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): RedisInsightResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): RedisInsightResourcePromise; + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): RedisInsightResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): RedisInsightResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Create a new reference, while also allowing customization of how a resource appears in the generated LikeC4 diagram. */ + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): RedisInsightResourcePromise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): RedisInsightResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): RedisInsightResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): RedisInsightResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): RedisInsightResourcePromise; + /** Associates an Azure user-assigned identity with a compute resource */ + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): RedisInsightResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): RedisInsightResourcePromise; + /** Sets the host port for Redis Insight */ + withHostPort(options?: WithHostPortOptions): RedisInsightResourcePromise; + /** Adds a data volume for Redis Insight */ + withDataVolume(options?: WithDataVolumeOptions): RedisInsightResourcePromise; + /** Adds a data bind mount for Redis Insight */ + withDataBindMount(source: string): RedisInsightResourcePromise; +} + +// ============================================================================ +// RedisInsightResourceImpl +// ============================================================================ + +class RedisInsightResourceImpl extends ResourceBuilderBase implements RedisInsightResource { + constructor(handle: RedisInsightResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: Awaitable): Promise { + registry = isPromiseLike(registry) ? await registry : registry; + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withContainerRegistry(registry: Awaitable): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._withContainerRegistryInternal(registry), this._client); + } + + /** @internal */ + private async _withBindMountInternal(source: string, target: string, isReadOnly?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, source, target }; + if (isReadOnly !== undefined) rpcArgs.isReadOnly = isReadOnly; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBindMount', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withBindMount(source: string, target: string, options?: WithBindMountOptions): RedisInsightResourcePromise { + const isReadOnly = options?.isReadOnly; + return new RedisInsightResourcePromiseImpl(this._withBindMountInternal(source, target, isReadOnly), this._client); + } + + /** @internal */ + private async _withEntrypointInternal(entrypoint: string): Promise { + const rpcArgs: Record = { builder: this._handle, entrypoint }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEntrypoint', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withEntrypoint(entrypoint: string): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._withEntrypointInternal(entrypoint), this._client); + } + + /** @internal */ + private async _withImageTagInternal(tag: string): Promise { + const rpcArgs: Record = { builder: this._handle, tag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImageTag', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withImageTag(tag: string): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._withImageTagInternal(tag), this._client); + } + + /** @internal */ + private async _withImageRegistryInternal(registry: string): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImageRegistry', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withImageRegistry(registry: string): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._withImageRegistryInternal(registry), this._client); + } + + /** @internal */ + private async _withImageInternal(image: string, tag?: string): Promise { + const rpcArgs: Record = { builder: this._handle, image }; + if (tag !== undefined) rpcArgs.tag = tag; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImage', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withImage(image: string, options?: WithImageOptions): RedisInsightResourcePromise { + const tag = options?.tag; + return new RedisInsightResourcePromiseImpl(this._withImageInternal(image, tag), this._client); + } + + /** @internal */ + private async _withImageSHA256Internal(sha256: string): Promise { + const rpcArgs: Record = { builder: this._handle, sha256 }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImageSHA256', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withImageSHA256(sha256: string): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._withImageSHA256Internal(sha256), this._client); + } + + /** @internal */ + private async _withContainerRuntimeArgsInternal(args: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, args }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRuntimeArgs', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withContainerRuntimeArgs(args: string[]): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._withContainerRuntimeArgsInternal(args), this._client); + } + + /** @internal */ + private async _withLifetimeInternal(lifetime: ContainerLifetime): Promise { + const rpcArgs: Record = { builder: this._handle, lifetime }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withLifetime', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withLifetime(lifetime: ContainerLifetime): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._withLifetimeInternal(lifetime), this._client); + } + + /** @internal */ + private async _withImagePullPolicyInternal(pullPolicy: ImagePullPolicy): Promise { + const rpcArgs: Record = { builder: this._handle, pullPolicy }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImagePullPolicy', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withImagePullPolicy(pullPolicy: ImagePullPolicy): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._withImagePullPolicyInternal(pullPolicy), this._client); + } + + /** @internal */ + private async _publishAsContainerInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsContainer', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + publishAsContainer(): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._publishAsContainerInternal(), this._client); + } + + /** @internal */ + private async _withDockerfileInternal(contextPath: string, dockerfilePath?: string, stage?: string): Promise { + const rpcArgs: Record = { builder: this._handle, contextPath }; + if (dockerfilePath !== undefined) rpcArgs.dockerfilePath = dockerfilePath; + if (stage !== undefined) rpcArgs.stage = stage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfile', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withDockerfile(contextPath: string, options?: WithDockerfileOptions): RedisInsightResourcePromise { + const dockerfilePath = options?.dockerfilePath; + const stage = options?.stage; + return new RedisInsightResourcePromiseImpl(this._withDockerfileInternal(contextPath, dockerfilePath, stage), this._client); + } + + /** @internal */ + private async _withContainerNameInternal(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerName', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withContainerName(name: string): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._withContainerNameInternal(name), this._client); + } + + /** @internal */ + private async _withBuildArgInternal(name: string, value: string | ParameterResource | Awaitable): Promise { + value = isPromiseLike(value) ? await value : value; + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuildArg', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withBuildArg(name: string, value: string | ParameterResource | Awaitable): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._withBuildArgInternal(name, value), this._client); + } + + /** @internal */ + private async _withBuildSecretInternal(name: string, value: Awaitable): Promise { + value = isPromiseLike(value) ? await value : value; + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParameterBuildSecret', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withBuildSecret(name: string, value: Awaitable): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._withBuildSecretInternal(name, value), this._client); + } + + /** @internal */ + private async _withContainerCertificatePathsInternal(customCertificatesDestination?: string, defaultCertificateBundlePaths?: string[], defaultCertificateDirectoryPaths?: string[]): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (customCertificatesDestination !== undefined) rpcArgs.customCertificatesDestination = customCertificatesDestination; + if (defaultCertificateBundlePaths !== undefined) rpcArgs.defaultCertificateBundlePaths = defaultCertificateBundlePaths; + if (defaultCertificateDirectoryPaths !== undefined) rpcArgs.defaultCertificateDirectoryPaths = defaultCertificateDirectoryPaths; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerCertificatePaths', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): RedisInsightResourcePromise { + const customCertificatesDestination = options?.customCertificatesDestination; + const defaultCertificateBundlePaths = options?.defaultCertificateBundlePaths; + const defaultCertificateDirectoryPaths = options?.defaultCertificateDirectoryPaths; + return new RedisInsightResourcePromiseImpl(this._withContainerCertificatePathsInternal(customCertificatesDestination, defaultCertificateBundlePaths, defaultCertificateDirectoryPaths), this._client); + } + + /** @internal */ + private async _withEndpointProxySupportInternal(proxyEnabled: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, proxyEnabled }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpointProxySupport', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withEndpointProxySupport(proxyEnabled: boolean): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._withEndpointProxySupportInternal(proxyEnabled), this._client); + } + + /** @internal */ + private async _withDockerfileBuilderInternal(contextPath: string, callback: (arg: DockerfileBuilderCallbackContext) => Promise, stage?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as DockerfileBuilderCallbackContextHandle; + const arg = new DockerfileBuilderCallbackContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, contextPath, callback: callbackId }; + if (stage !== undefined) rpcArgs.stage = stage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBuilder', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withDockerfileBuilder(contextPath: string, callback: (arg: DockerfileBuilderCallbackContext) => Promise, options?: WithDockerfileBuilderOptions): RedisInsightResourcePromise { + const stage = options?.stage; + return new RedisInsightResourcePromiseImpl(this._withDockerfileBuilderInternal(contextPath, callback, stage), this._client); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): RedisInsightResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new RedisInsightResourcePromiseImpl(this._withDockerfileBaseImageInternal(buildImage, runtimeImage), this._client); + } + + /** @internal */ + private async _withContainerNetworkAliasInternal(alias: string): Promise { + const rpcArgs: Record = { builder: this._handle, alias }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerNetworkAlias', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withContainerNetworkAlias(alias: string): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._withContainerNetworkAliasInternal(alias), this._client); + } + + /** @internal */ + private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withMcpServer', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withMcpServer(options?: WithMcpServerOptions): RedisInsightResourcePromise { + const path = options?.path; + const endpointName = options?.endpointName; + return new RedisInsightResourcePromiseImpl(this._withMcpServerInternal(path, endpointName), this._client); + } + + /** @internal */ + private async _withOtlpExporterInternal(protocol?: OtlpProtocol): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (protocol !== undefined) rpcArgs.protocol = protocol; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporter', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withOtlpExporter(options?: WithOtlpExporterOptions): RedisInsightResourcePromise { + const protocol = options?.protocol; + return new RedisInsightResourcePromiseImpl(this._withOtlpExporterInternal(protocol), this._client); + } + + /** @internal */ + private async _publishAsConnectionStringInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsConnectionString', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + publishAsConnectionString(): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._publishAsConnectionStringInternal(), this._client); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): RedisInsightResourcePromise { + const helpLink = options?.helpLink; + return new RedisInsightResourcePromiseImpl(this._withRequiredCommandInternal(command, helpLink), this._client); + } + + /** @internal */ + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): Promise { + value = isPromiseLike(value) ? await value : value; + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironment', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._withEnvironmentInternal(name, value), this._client); + } + + /** @internal */ + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentCallback', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._withEnvironmentCallbackInternal(callback), this._client); + } + + /** @internal */ + private async _withArgsInternal(args: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, args }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgs', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withArgs(args: string[]): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._withArgsInternal(args), this._client); + } + + /** @internal */ + private async _withArgsCallbackInternal(callback: (obj: CommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; + const obj = new CommandLineArgsCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallback', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._withArgsCallbackInternal(callback), this._client); + } + + /** @internal */ + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceEnvironment', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._withReferenceEnvironmentInternal(options), this._client); + } + + /** @internal */ + private async _withReferenceInternal(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, connectionName?: string, optional?: boolean, name?: string): Promise { + source = isPromiseLike(source) ? await source : source; + const rpcArgs: Record = { builder: this._handle, source }; + if (connectionName !== undefined) rpcArgs.connectionName = connectionName; + if (optional !== undefined) rpcArgs.optional = optional; + if (name !== undefined) rpcArgs.name = name; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReference', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): RedisInsightResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new RedisInsightResourcePromiseImpl(this._withReferenceInternal(source, connectionName, optional, name), this._client); + } + + /** @internal */ + private async _withEndpointCallbackInternal(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpointCallback', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): RedisInsightResourcePromise { + const createIfNotExists = options?.createIfNotExists; + return new RedisInsightResourcePromiseImpl(this._withEndpointCallbackInternal(endpointName, callback, createIfNotExists), this._client); + } + + /** @internal */ + private async _withHttpEndpointCallbackInternal(callback: (obj: EndpointUpdateContext) => Promise, name?: string, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + if (name !== undefined) rpcArgs.name = name; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpEndpointCallback', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): RedisInsightResourcePromise { + const name = options?.name; + const createIfNotExists = options?.createIfNotExists; + return new RedisInsightResourcePromiseImpl(this._withHttpEndpointCallbackInternal(callback, name, createIfNotExists), this._client); + } + + /** @internal */ + private async _withHttpsEndpointCallbackInternal(callback: (obj: EndpointUpdateContext) => Promise, name?: string, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + if (name !== undefined) rpcArgs.name = name; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsEndpointCallback', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): RedisInsightResourcePromise { + const name = options?.name; + const createIfNotExists = options?.createIfNotExists; + return new RedisInsightResourcePromiseImpl(this._withHttpsEndpointCallbackInternal(callback, name, createIfNotExists), this._client); + } + + /** @internal */ + private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (scheme !== undefined) rpcArgs.scheme = scheme; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + if (isExternal !== undefined) rpcArgs.isExternal = isExternal; + if (protocol !== undefined) rpcArgs.protocol = protocol; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpoint', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withEndpoint(options?: WithEndpointOptions): RedisInsightResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const scheme = options?.scheme; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + const isExternal = options?.isExternal; + const protocol = options?.protocol; + return new RedisInsightResourcePromiseImpl(this._withEndpointInternal(port, targetPort, scheme, name, env, isProxied, isExternal, protocol), this._client); + } + + /** @internal */ + private async _withHttpEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpEndpoint', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withHttpEndpoint(options?: WithHttpEndpointOptions): RedisInsightResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new RedisInsightResourcePromiseImpl(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied), this._client); + } + + /** @internal */ + private async _withHttpsEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsEndpoint', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withHttpsEndpoint(options?: WithHttpsEndpointOptions): RedisInsightResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new RedisInsightResourcePromiseImpl(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied), this._client); + } + + /** @internal */ + private async _withExternalHttpEndpointsInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExternalHttpEndpoints', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withExternalHttpEndpoints(): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._withExternalHttpEndpointsInternal(), this._client); + } + + async getEndpoint(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getEndpoint', + rpcArgs + ); + } + + /** @internal */ + private async _asHttp2ServiceInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/asHttp2Service', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + asHttp2Service(): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._asHttp2ServiceInternal(), this._client); + } + + /** @internal */ + private async _withUrlsInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrls', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._withUrlsInternal(callback), this._client); + } + + /** @internal */ + private async _withUrlInternal(url: string | ReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): RedisInsightResourcePromise { + const displayText = options?.displayText; + return new RedisInsightResourcePromiseImpl(this._withUrlInternal(url, displayText), this._client); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._withUrlForEndpointInternal(endpointName, callback), this._client); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + excludeFromManifest(): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._excludeFromManifestInternal(), this._client); + } + + /** @internal */ + private async _waitForInternal(dependency: Awaitable, waitBehavior?: WaitBehavior): Promise { + dependency = isPromiseLike(dependency) ? await dependency : dependency; + const rpcArgs: Record = { builder: this._handle, dependency }; + if (waitBehavior !== undefined) rpcArgs.waitBehavior = waitBehavior; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitFor', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + waitFor(dependency: Awaitable, options?: WaitForOptions): RedisInsightResourcePromise { + const waitBehavior = options?.waitBehavior; + return new RedisInsightResourcePromiseImpl(this._waitForInternal(dependency, waitBehavior), this._client); + } + + /** @internal */ + private async _waitForStartInternal(dependency: Awaitable, waitBehavior?: WaitBehavior): Promise { + dependency = isPromiseLike(dependency) ? await dependency : dependency; + const rpcArgs: Record = { builder: this._handle, dependency }; + if (waitBehavior !== undefined) rpcArgs.waitBehavior = waitBehavior; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStart', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): RedisInsightResourcePromise { + const waitBehavior = options?.waitBehavior; + return new RedisInsightResourcePromiseImpl(this._waitForStartInternal(dependency, waitBehavior), this._client); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withExplicitStart(): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._withExplicitStartInternal(), this._client); + } + + /** @internal */ + private async _waitForCompletionInternal(dependency: Awaitable, exitCode?: number): Promise { + dependency = isPromiseLike(dependency) ? await dependency : dependency; + const rpcArgs: Record = { builder: this._handle, dependency }; + if (exitCode !== undefined) rpcArgs.exitCode = exitCode; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceCompletion', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): RedisInsightResourcePromise { + const exitCode = options?.exitCode; + return new RedisInsightResourcePromiseImpl(this._waitForCompletionInternal(dependency, exitCode), this._client); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withHealthCheck(key: string): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._withHealthCheckInternal(key), this._client); + } + + /** @internal */ + private async _withHttpHealthCheckInternal(path?: string, statusCode?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (statusCode !== undefined) rpcArgs.statusCode = statusCode; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpHealthCheck', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): RedisInsightResourcePromise { + const path = options?.path; + const statusCode = options?.statusCode; + const endpointName = options?.endpointName; + return new RedisInsightResourcePromiseImpl(this._withHttpHealthCheckInternal(path, statusCode, endpointName), this._client); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContextImpl(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): RedisInsightResourcePromise { + const commandOptions = options?.commandOptions; + return new RedisInsightResourcePromiseImpl(this._withCommandInternal(name, displayName, executeCommand, commandOptions), this._client); + } + + /** @internal */ + private async _withHttpCommandInternal(path: string, displayName: string, options?: HttpCommandExportOptions): Promise { + const rpcArgs: Record = { builder: this._handle, path, displayName }; + if (options !== undefined) rpcArgs.options = options; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpCommand', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._withHttpCommandInternal(path, displayName, options), this._client); + } + + /** @internal */ + private async _withDeveloperCertificateTrustInternal(trust: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, trust }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDeveloperCertificateTrust', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withDeveloperCertificateTrust(trust: boolean): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._withDeveloperCertificateTrustInternal(trust), this._client); + } + + /** @internal */ + private async _withCertificateTrustScopeInternal(scope: CertificateTrustScope): Promise { + const rpcArgs: Record = { builder: this._handle, scope }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCertificateTrustScope', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withCertificateTrustScope(scope: CertificateTrustScope): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._withCertificateTrustScopeInternal(scope), this._client); + } + + /** @internal */ + private async _withHttpsDeveloperCertificateInternal(password?: Awaitable): Promise { + password = isPromiseLike(password) ? await password : password; + const rpcArgs: Record = { builder: this._handle }; + if (password !== undefined) rpcArgs.password = password; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): RedisInsightResourcePromise { + let password = options?.password; + return new RedisInsightResourcePromiseImpl(this._withHttpsDeveloperCertificateInternal(password), this._client); + } + + /** @internal */ + private async _withoutHttpsCertificateInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withoutHttpsCertificate', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withoutHttpsCertificate(): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._withoutHttpsCertificateInternal(), this._client); + } + + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: Awaitable, type: string): Promise { + resourceBuilder = isPromiseLike(resourceBuilder) ? await resourceBuilder : resourceBuilder; + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._withRelationshipInternal(resourceBuilder, type), this._client); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: Awaitable): Promise { + parent = isPromiseLike(parent) ? await parent : parent; + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withParentRelationship(parent: Awaitable): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._withParentRelationshipInternal(parent), this._client); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: Awaitable): Promise { + child = isPromiseLike(child) ? await child : child; + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withChildRelationship(child: Awaitable): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._withChildRelationshipInternal(child), this._client); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): RedisInsightResourcePromise { + const iconVariant = options?.iconVariant; + return new RedisInsightResourcePromiseImpl(this._withIconNameInternal(iconName, iconVariant), this._client); + } + + /** @internal */ + private async _withHttpProbeInternal(probeType: ProbeType, path?: string, initialDelaySeconds?: number, periodSeconds?: number, timeoutSeconds?: number, failureThreshold?: number, successThreshold?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, probeType }; + if (path !== undefined) rpcArgs.path = path; + if (initialDelaySeconds !== undefined) rpcArgs.initialDelaySeconds = initialDelaySeconds; + if (periodSeconds !== undefined) rpcArgs.periodSeconds = periodSeconds; + if (timeoutSeconds !== undefined) rpcArgs.timeoutSeconds = timeoutSeconds; + if (failureThreshold !== undefined) rpcArgs.failureThreshold = failureThreshold; + if (successThreshold !== undefined) rpcArgs.successThreshold = successThreshold; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpProbe', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): RedisInsightResourcePromise { + const path = options?.path; + const initialDelaySeconds = options?.initialDelaySeconds; + const periodSeconds = options?.periodSeconds; + const timeoutSeconds = options?.timeoutSeconds; + const failureThreshold = options?.failureThreshold; + const successThreshold = options?.successThreshold; + const endpointName = options?.endpointName; + return new RedisInsightResourcePromiseImpl(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName), this._client); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + excludeFromMcp(): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._excludeFromMcpInternal(), this._client); + } + + /** @internal */ + private async _withImagePushOptionsInternal(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ContainerImagePushOptionsCallbackContextHandle; + const arg = new ContainerImagePushOptionsCallbackContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImagePushOptions', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._withImagePushOptionsInternal(callback), this._client); + } + + /** @internal */ + private async _withRemoteImageNameInternal(remoteImageName: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageName', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withRemoteImageName(remoteImageName: string): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._withRemoteImageNameInternal(remoteImageName), this._client); + } + + /** @internal */ + private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageTag', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withRemoteImageTag(remoteImageTag: string): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._withRemoteImageTagInternal(remoteImageTag), this._client); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): RedisInsightResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new RedisInsightResourcePromiseImpl(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description), this._client); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._withPipelineConfigurationInternal(callback), this._client); + } + + /** @internal */ + private async _withVolumeInternal(target: string, name?: string, isReadOnly?: boolean): Promise { + const rpcArgs: Record = { resource: this._handle, target }; + if (name !== undefined) rpcArgs.name = name; + if (isReadOnly !== undefined) rpcArgs.isReadOnly = isReadOnly; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withVolume', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withVolume(target: string, options?: WithVolumeOptions): RedisInsightResourcePromise { + const name = options?.name; + const isReadOnly = options?.isReadOnly; + return new RedisInsightResourcePromiseImpl(this._withVolumeInternal(target, name, isReadOnly), this._client); + } + + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); + } + + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._onBeforeResourceStartedInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._onResourceStoppedInternal(callback), this._client); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._onInitializeResourceInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceEndpointsAllocated', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._onResourceEndpointsAllocatedInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._onResourceReadyInternal(callback), this._client); + } + + async createExecutionConfiguration(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/createExecutionConfiguration', + rpcArgs + ); + } + + /** @internal */ + private async _withLikeC4ReferenceWithEnvironmentInternal(source: Awaitable, configure?: (obj: LikeC4RelationshipDetailsAnnotation) => Promise, connectionName?: string, optional?: boolean, skipAspireReference?: boolean): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4RelationshipDetailsAnnotationHandle; + const obj = new LikeC4RelationshipDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + source = isPromiseLike(source) ? await source : source; + const rpcArgs: Record = { builder: this._handle, source }; + if (configure !== undefined) rpcArgs.configure = configureId; + if (connectionName !== undefined) rpcArgs.connectionName = connectionName; + if (optional !== undefined) rpcArgs.optional = optional; + if (skipAspireReference !== undefined) rpcArgs.skipAspireReference = skipAspireReference; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4ReferenceWithEnvironment', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): RedisInsightResourcePromise { + const configure = options?.configure; + const connectionName = options?.connectionName; + const optional = options?.optional; + const skipAspireReference = options?.skipAspireReference; + return new RedisInsightResourcePromiseImpl(this._withLikeC4ReferenceWithEnvironmentInternal(source, configure, connectionName, optional, skipAspireReference), this._client); + } + + /** @internal */ + private async _withLikeC4DetailsInternal(label?: string, technology?: string, description?: string, summary?: string, icon?: string, configure?: (obj: LikeC4NodeDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4NodeDetailsAnnotationHandle; + const obj = new LikeC4NodeDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + const rpcArgs: Record = { builder: this._handle }; + if (label !== undefined) rpcArgs.label = label; + if (technology !== undefined) rpcArgs.technology = technology; + if (description !== undefined) rpcArgs.description = description; + if (summary !== undefined) rpcArgs.summary = summary; + if (icon !== undefined) rpcArgs.icon = icon; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4DetailsParameters', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): RedisInsightResourcePromise { + const label = options?.label; + const technology = options?.technology; + const description = options?.description; + const summary = options?.summary; + const icon = options?.icon; + const configure = options?.configure; + return new RedisInsightResourcePromiseImpl(this._withLikeC4DetailsInternal(label, technology, description, summary, icon, configure), this._client); + } + + /** @internal */ + private async _withLikeC4ReferenceInternal(target: Awaitable, configure?: (obj: LikeC4RelationshipDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4RelationshipDetailsAnnotationHandle; + const obj = new LikeC4RelationshipDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target }; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Reference', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): RedisInsightResourcePromise { + const configure = options?.configure; + return new RedisInsightResourcePromiseImpl(this._withLikeC4ReferenceInternal(target, configure), this._client); + } + + /** @internal */ + private async _withLikeC4GroupInternal(groupName: string): Promise { + const rpcArgs: Record = { builder: this._handle, groupName }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Group', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withLikeC4Group(groupName: string): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._withLikeC4GroupInternal(groupName), this._client); + } + + /** @internal */ + private async _excludeFromLikeC4Internal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/excludeFromLikeC4', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + excludeFromLikeC4(): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._excludeFromLikeC4Internal(), this._client); + } + + /** @internal */ + private async _withAzureUserAssignedIdentityInternal(identityResourceBuilder: Awaitable): Promise { + identityResourceBuilder = isPromiseLike(identityResourceBuilder) ? await identityResourceBuilder : identityResourceBuilder; + const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._withAzureUserAssignedIdentityInternal(identityResourceBuilder), this._client); + } + + /** @internal */ + private async _withRoleAssignmentsInternal(target: Awaitable, roles: AzureKeyVaultRole[]): Promise { + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target, roles }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.KeyVault/withKeyVaultRoleAssignments', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._withRoleAssignmentsInternal(target, roles), this._client); + } + + /** @internal */ + private async _withHostPortInternal(port?: number): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Redis/withRedisInsightHostPort', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withHostPort(options?: WithHostPortOptions): RedisInsightResourcePromise { + const port = options?.port; + return new RedisInsightResourcePromiseImpl(this._withHostPortInternal(port), this._client); + } + + /** @internal */ + private async _withDataVolumeInternal(name?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (name !== undefined) rpcArgs.name = name; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Redis/withRedisInsightDataVolume', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withDataVolume(options?: WithDataVolumeOptions): RedisInsightResourcePromise { + const name = options?.name; + return new RedisInsightResourcePromiseImpl(this._withDataVolumeInternal(name), this._client); + } + + /** @internal */ + private async _withDataBindMountInternal(source: string): Promise { + const rpcArgs: Record = { builder: this._handle, source }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Redis/withRedisInsightDataBindMount', + rpcArgs + ); + return new RedisInsightResourceImpl(result, this._client); + } + + withDataBindMount(source: string): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._withDataBindMountInternal(source), this._client); + } + +} + +/** + * Thenable wrapper for RedisInsightResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +class RedisInsightResourcePromiseImpl implements RedisInsightResourcePromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: RedisInsightResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + withContainerRegistry(registry: Awaitable): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withContainerRegistry(registry)), this._client); + } + + withBindMount(source: string, target: string, options?: WithBindMountOptions): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withBindMount(source, target, options)), this._client); + } + + withEntrypoint(entrypoint: string): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withEntrypoint(entrypoint)), this._client); + } + + withImageTag(tag: string): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withImageTag(tag)), this._client); + } + + withImageRegistry(registry: string): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withImageRegistry(registry)), this._client); + } + + withImage(image: string, options?: WithImageOptions): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withImage(image, options)), this._client); + } + + withImageSHA256(sha256: string): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withImageSHA256(sha256)), this._client); + } + + withContainerRuntimeArgs(args: string[]): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withContainerRuntimeArgs(args)), this._client); + } + + withLifetime(lifetime: ContainerLifetime): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withLifetime(lifetime)), this._client); + } + + withImagePullPolicy(pullPolicy: ImagePullPolicy): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withImagePullPolicy(pullPolicy)), this._client); + } + + publishAsContainer(): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.publishAsContainer()), this._client); + } + + withDockerfile(contextPath: string, options?: WithDockerfileOptions): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withDockerfile(contextPath, options)), this._client); + } + + withContainerName(name: string): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withContainerName(name)), this._client); + } + + withBuildArg(name: string, value: string | ParameterResource | Awaitable): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withBuildArg(name, value)), this._client); + } + + withBuildSecret(name: string, value: Awaitable): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withBuildSecret(name, value)), this._client); + } + + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withContainerCertificatePaths(options)), this._client); + } + + withEndpointProxySupport(proxyEnabled: boolean): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withEndpointProxySupport(proxyEnabled)), this._client); + } + + withDockerfileBuilder(contextPath: string, callback: (arg: DockerfileBuilderCallbackContext) => Promise, options?: WithDockerfileBuilderOptions): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withDockerfileBuilder(contextPath, callback, options)), this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withDockerfileBaseImage(options)), this._client); + } + + withContainerNetworkAlias(alias: string): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withContainerNetworkAlias(alias)), this._client); + } + + withMcpServer(options?: WithMcpServerOptions): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withMcpServer(options)), this._client); + } + + withOtlpExporter(options?: WithOtlpExporterOptions): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withOtlpExporter(options)), this._client); + } + + publishAsConnectionString(): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.publishAsConnectionString()), this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withRequiredCommand(command, options)), this._client); + } + + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withEnvironment(name, value)), this._client); + } + + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentCallback(callback)), this._client); + } + + withArgs(args: string[]): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withArgs(args)), this._client); + } + + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withArgsCallback(callback)), this._client); + } + + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withReferenceEnvironment(options)), this._client); + } + + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withReference(source, options)), this._client); + } + + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withEndpointCallback(endpointName, callback, options)), this._client); + } + + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withHttpEndpointCallback(callback, options)), this._client); + } + + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withHttpsEndpointCallback(callback, options)), this._client); + } + + withEndpoint(options?: WithEndpointOptions): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withEndpoint(options)), this._client); + } + + withHttpEndpoint(options?: WithHttpEndpointOptions): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withHttpEndpoint(options)), this._client); + } + + withHttpsEndpoint(options?: WithHttpsEndpointOptions): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withHttpsEndpoint(options)), this._client); + } + + withExternalHttpEndpoints(): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withExternalHttpEndpoints()), this._client); + } + + getEndpoint(name: string): Promise { + return this._promise.then(obj => obj.getEndpoint(name)); + } + + asHttp2Service(): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.asHttp2Service()), this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withUrls(callback)), this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withUrl(url, options)), this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback)), this._client); + } + + excludeFromManifest(): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.excludeFromManifest()), this._client); + } + + waitFor(dependency: Awaitable, options?: WaitForOptions): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.waitFor(dependency, options)), this._client); + } + + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.waitForStart(dependency, options)), this._client); + } + + withExplicitStart(): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withExplicitStart()), this._client); + } + + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.waitForCompletion(dependency, options)), this._client); + } + + withHealthCheck(key: string): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withHealthCheck(key)), this._client); + } + + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withHttpHealthCheck(options)), this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options)), this._client); + } + + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withHttpCommand(path, displayName, options)), this._client); + } + + withDeveloperCertificateTrust(trust: boolean): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust)), this._client); + } + + withCertificateTrustScope(scope: CertificateTrustScope): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withCertificateTrustScope(scope)), this._client); + } + + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options)), this._client); + } + + withoutHttpsCertificate(): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withoutHttpsCertificate()), this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withRelationship(resourceBuilder, type)), this._client); + } + + withParentRelationship(parent: Awaitable): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withParentRelationship(parent)), this._client); + } + + withChildRelationship(child: Awaitable): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withChildRelationship(child)), this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withIconName(iconName, options)), this._client); + } + + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withHttpProbe(probeType, options)), this._client); + } + + excludeFromMcp(): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.excludeFromMcp()), this._client); + } + + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withImagePushOptions(callback)), this._client); + } + + withRemoteImageName(remoteImageName: string): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withRemoteImageName(remoteImageName)), this._client); + } + + withRemoteImageTag(remoteImageTag: string): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag)), this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options)), this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withPipelineConfiguration(callback)), this._client); + } + + withVolume(target: string, options?: WithVolumeOptions): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withVolume(target, options)), this._client); + } + + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.onBeforeResourceStarted(callback)), this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.onResourceStopped(callback)), this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.onInitializeResource(callback)), this._client); + } + + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback)), this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.onResourceReady(callback)), this._client); + } + + createExecutionConfiguration(): Promise { + return this._promise.then(obj => obj.createExecutionConfiguration()); + } + + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4ReferenceWithEnvironment(source, options)), this._client); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Details(options)), this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Reference(target, options)), this._client); + } + + withLikeC4Group(groupName: string): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Group(groupName)), this._client); + } + + excludeFromLikeC4(): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.excludeFromLikeC4()), this._client); + } + + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withAzureUserAssignedIdentity(identityResourceBuilder)), this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withRoleAssignments(target, roles)), this._client); + } + + withHostPort(options?: WithHostPortOptions): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withHostPort(options)), this._client); + } + + withDataVolume(options?: WithDataVolumeOptions): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withDataVolume(options)), this._client); + } + + withDataBindMount(source: string): RedisInsightResourcePromise { + return new RedisInsightResourcePromiseImpl(this._promise.then(obj => obj.withDataBindMount(source)), this._client); + } + +} + +// ============================================================================ +// RedisResource +// ============================================================================ + +export interface RedisResource { + toJSON(): MarshalledHandle; + /** Gets the PrimaryEndpoint property */ + primaryEndpoint(): Promise; + /** Gets the Host property */ + host(): Promise; + /** Gets the Port property */ + port(): Promise; + /** Gets the PasswordParameter property */ + passwordParameter: { + get: () => Promise; + set: (value: Awaitable) => Promise; + }; + /** Gets the TlsEnabled property */ + tlsEnabled(): Promise; + /** Gets the ConnectionStringExpression property */ + connectionStringExpression(): Promise; + /** Gets the UriExpression property */ + uriExpression(): Promise; + /** Gets the Entrypoint property */ + entrypoint: { + get: () => Promise; + set: (value: string) => Promise; + }; + /** Gets the ShellExecution property */ + shellExecution: { + get: () => Promise; + set: (value: boolean) => Promise; + }; + /** Gets the Name property */ + name(): Promise; + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): RedisResourcePromise; + /** Adds a bind mount */ + withBindMount(source: string, target: string, options?: WithBindMountOptions): RedisResourcePromise; + /** Sets the container entrypoint */ + withEntrypoint(entrypoint: string): RedisResourcePromise; + /** Sets the container image tag */ + withImageTag(tag: string): RedisResourcePromise; + /** Sets the container image registry */ + withImageRegistry(registry: string): RedisResourcePromise; + /** Sets the container image */ + withImage(image: string, options?: WithImageOptions): RedisResourcePromise; + /** Sets the image SHA256 digest */ + withImageSHA256(sha256: string): RedisResourcePromise; + /** Adds runtime arguments for the container */ + withContainerRuntimeArgs(args: string[]): RedisResourcePromise; + /** Sets the lifetime behavior of the container resource */ + withLifetime(lifetime: ContainerLifetime): RedisResourcePromise; + /** Sets the container image pull policy */ + withImagePullPolicy(pullPolicy: ImagePullPolicy): RedisResourcePromise; + /** Configures the resource to be published as a container */ + publishAsContainer(): RedisResourcePromise; + /** Configures the resource to use a Dockerfile */ + withDockerfile(contextPath: string, options?: WithDockerfileOptions): RedisResourcePromise; + /** Sets the container name */ + withContainerName(name: string): RedisResourcePromise; + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource | Awaitable): RedisResourcePromise; + /** Adds a build secret from a parameter resource */ + withBuildSecret(name: string, value: Awaitable): RedisResourcePromise; + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): RedisResourcePromise; + /** Configures endpoint proxy support */ + withEndpointProxySupport(proxyEnabled: boolean): RedisResourcePromise; + /** Configures the resource to use a programmatically generated Dockerfile */ + withDockerfileBuilder(contextPath: string, callback: (arg: DockerfileBuilderCallbackContext) => Promise, options?: WithDockerfileBuilderOptions): RedisResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): RedisResourcePromise; + /** Adds a network alias for the container */ + withContainerNetworkAlias(alias: string): RedisResourcePromise; + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): RedisResourcePromise; + /** Configures OTLP telemetry export */ + withOtlpExporter(options?: WithOtlpExporterOptions): RedisResourcePromise; + /** Publishes the resource as a connection string */ + publishAsConnectionString(): RedisResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): RedisResourcePromise; + /** Sets an environment variable */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): RedisResourcePromise; + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): RedisResourcePromise; + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): RedisResourcePromise; + /** Adds arguments */ + withArgs(args: string[]): RedisResourcePromise; + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): RedisResourcePromise; + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): RedisResourcePromise; + /** Adds a reference to another resource */ + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): RedisResourcePromise; + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise; + /** Updates a named endpoint via callback */ + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): RedisResourcePromise; + /** Updates an HTTP endpoint via callback */ + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): RedisResourcePromise; + /** Updates an HTTPS endpoint via callback */ + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): RedisResourcePromise; + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): RedisResourcePromise; + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): RedisResourcePromise; + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): RedisResourcePromise; + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): RedisResourcePromise; + /** Gets an endpoint reference */ + getEndpoint(name: string): Promise; + /** Configures resource for HTTP/2 */ + asHttp2Service(): RedisResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): RedisResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): RedisResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): RedisResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): RedisResourcePromise; + /** Waits for another resource to be ready */ + waitFor(dependency: Awaitable, options?: WaitForOptions): RedisResourcePromise; + /** Waits for another resource to start */ + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): RedisResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): RedisResourcePromise; + /** Waits for resource completion */ + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): RedisResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): RedisResourcePromise; + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): RedisResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): RedisResourcePromise; + /** Adds an HTTP resource command */ + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): RedisResourcePromise; + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): RedisResourcePromise; + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): RedisResourcePromise; + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): RedisResourcePromise; + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): RedisResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): RedisResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): RedisResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): RedisResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): RedisResourcePromise; + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): RedisResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): RedisResourcePromise; + /** Sets image push options via callback */ + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): RedisResourcePromise; + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): RedisResourcePromise; + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): RedisResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): RedisResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): RedisResourcePromise; + /** Adds a volume */ + withVolume(target: string, options?: WithVolumeOptions): RedisResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): RedisResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): RedisResourcePromise; + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): RedisResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): RedisResourcePromise; + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): RedisResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): RedisResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Create a new reference, while also allowing customization of how a resource appears in the generated LikeC4 diagram. */ + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): RedisResourcePromise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): RedisResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): RedisResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): RedisResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): RedisResourcePromise; + /** Associates an Azure user-assigned identity with a compute resource */ + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): RedisResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): RedisResourcePromise; + /** Adds Redis Commander management UI */ + withRedisCommander(options?: WithRedisCommanderOptions): RedisResourcePromise; + /** Adds Redis Insight management UI */ + withRedisInsight(options?: WithRedisInsightOptions): RedisResourcePromise; + /** Adds a data volume with persistence */ + withDataVolume(options?: WithDataVolumeOptions): RedisResourcePromise; + /** Adds a data bind mount with persistence */ + withDataBindMount(source: string, options?: WithDataBindMountOptions): RedisResourcePromise; + /** Configures Redis persistence */ + withPersistence(options?: WithPersistenceOptions): RedisResourcePromise; + /** Configures the password for Redis */ + withPassword(password: Awaitable): RedisResourcePromise; + /** Sets the host port for Redis */ + withHostPort(options?: WithHostPortOptions): RedisResourcePromise; +} + +export interface RedisResourcePromise extends PromiseLike { + /** Gets the PrimaryEndpoint property */ + primaryEndpoint(): Promise; + /** Gets the Host property */ + host(): Promise; + /** Gets the Port property */ + port(): Promise; + /** Gets the TlsEnabled property */ + tlsEnabled(): Promise; + /** Gets the ConnectionStringExpression property */ + connectionStringExpression(): Promise; + /** Gets the UriExpression property */ + uriExpression(): Promise; + /** Gets the Name property */ + name(): Promise; + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): RedisResourcePromise; + /** Adds a bind mount */ + withBindMount(source: string, target: string, options?: WithBindMountOptions): RedisResourcePromise; + /** Sets the container entrypoint */ + withEntrypoint(entrypoint: string): RedisResourcePromise; + /** Sets the container image tag */ + withImageTag(tag: string): RedisResourcePromise; + /** Sets the container image registry */ + withImageRegistry(registry: string): RedisResourcePromise; + /** Sets the container image */ + withImage(image: string, options?: WithImageOptions): RedisResourcePromise; + /** Sets the image SHA256 digest */ + withImageSHA256(sha256: string): RedisResourcePromise; + /** Adds runtime arguments for the container */ + withContainerRuntimeArgs(args: string[]): RedisResourcePromise; + /** Sets the lifetime behavior of the container resource */ + withLifetime(lifetime: ContainerLifetime): RedisResourcePromise; + /** Sets the container image pull policy */ + withImagePullPolicy(pullPolicy: ImagePullPolicy): RedisResourcePromise; + /** Configures the resource to be published as a container */ + publishAsContainer(): RedisResourcePromise; + /** Configures the resource to use a Dockerfile */ + withDockerfile(contextPath: string, options?: WithDockerfileOptions): RedisResourcePromise; + /** Sets the container name */ + withContainerName(name: string): RedisResourcePromise; + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource | Awaitable): RedisResourcePromise; + /** Adds a build secret from a parameter resource */ + withBuildSecret(name: string, value: Awaitable): RedisResourcePromise; + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): RedisResourcePromise; + /** Configures endpoint proxy support */ + withEndpointProxySupport(proxyEnabled: boolean): RedisResourcePromise; + /** Configures the resource to use a programmatically generated Dockerfile */ + withDockerfileBuilder(contextPath: string, callback: (arg: DockerfileBuilderCallbackContext) => Promise, options?: WithDockerfileBuilderOptions): RedisResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): RedisResourcePromise; + /** Adds a network alias for the container */ + withContainerNetworkAlias(alias: string): RedisResourcePromise; + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): RedisResourcePromise; + /** Configures OTLP telemetry export */ + withOtlpExporter(options?: WithOtlpExporterOptions): RedisResourcePromise; + /** Publishes the resource as a connection string */ + publishAsConnectionString(): RedisResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): RedisResourcePromise; + /** Sets an environment variable */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): RedisResourcePromise; + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): RedisResourcePromise; + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): RedisResourcePromise; + /** Adds arguments */ + withArgs(args: string[]): RedisResourcePromise; + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): RedisResourcePromise; + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): RedisResourcePromise; + /** Adds a reference to another resource */ + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): RedisResourcePromise; + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise; + /** Updates a named endpoint via callback */ + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): RedisResourcePromise; + /** Updates an HTTP endpoint via callback */ + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): RedisResourcePromise; + /** Updates an HTTPS endpoint via callback */ + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): RedisResourcePromise; + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): RedisResourcePromise; + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): RedisResourcePromise; + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): RedisResourcePromise; + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): RedisResourcePromise; + /** Gets an endpoint reference */ + getEndpoint(name: string): Promise; + /** Configures resource for HTTP/2 */ + asHttp2Service(): RedisResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): RedisResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): RedisResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): RedisResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): RedisResourcePromise; + /** Waits for another resource to be ready */ + waitFor(dependency: Awaitable, options?: WaitForOptions): RedisResourcePromise; + /** Waits for another resource to start */ + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): RedisResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): RedisResourcePromise; + /** Waits for resource completion */ + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): RedisResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): RedisResourcePromise; + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): RedisResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): RedisResourcePromise; + /** Adds an HTTP resource command */ + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): RedisResourcePromise; + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): RedisResourcePromise; + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): RedisResourcePromise; + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): RedisResourcePromise; + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): RedisResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): RedisResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): RedisResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): RedisResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): RedisResourcePromise; + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): RedisResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): RedisResourcePromise; + /** Sets image push options via callback */ + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): RedisResourcePromise; + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): RedisResourcePromise; + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): RedisResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): RedisResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): RedisResourcePromise; + /** Adds a volume */ + withVolume(target: string, options?: WithVolumeOptions): RedisResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): RedisResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): RedisResourcePromise; + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): RedisResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): RedisResourcePromise; + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): RedisResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): RedisResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Create a new reference, while also allowing customization of how a resource appears in the generated LikeC4 diagram. */ + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): RedisResourcePromise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): RedisResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): RedisResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): RedisResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): RedisResourcePromise; + /** Associates an Azure user-assigned identity with a compute resource */ + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): RedisResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): RedisResourcePromise; + /** Adds Redis Commander management UI */ + withRedisCommander(options?: WithRedisCommanderOptions): RedisResourcePromise; + /** Adds Redis Insight management UI */ + withRedisInsight(options?: WithRedisInsightOptions): RedisResourcePromise; + /** Adds a data volume with persistence */ + withDataVolume(options?: WithDataVolumeOptions): RedisResourcePromise; + /** Adds a data bind mount with persistence */ + withDataBindMount(source: string, options?: WithDataBindMountOptions): RedisResourcePromise; + /** Configures Redis persistence */ + withPersistence(options?: WithPersistenceOptions): RedisResourcePromise; + /** Configures the password for Redis */ + withPassword(password: Awaitable): RedisResourcePromise; + /** Sets the host port for Redis */ + withHostPort(options?: WithHostPortOptions): RedisResourcePromise; +} + +// ============================================================================ +// RedisResourceImpl +// ============================================================================ + +class RedisResourceImpl extends ResourceBuilderBase implements RedisResource { + constructor(handle: RedisResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + async primaryEndpoint(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/RedisResource.primaryEndpoint', + { context: this._handle } + ); + return new EndpointReferenceImpl(handle, this._client); + } + + async host(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/RedisResource.host', + { context: this._handle } + ); + return new EndpointReferenceExpressionImpl(handle, this._client); + } + + async port(): Promise { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/RedisResource.port', + { context: this._handle } + ); + return new EndpointReferenceExpressionImpl(handle, this._client); + } + + passwordParameter = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/RedisResource.passwordParameter', + { context: this._handle } + ); + return new ParameterResourceImpl(handle, this._client); + }, + set: async (value: Awaitable): Promise => { + value = isPromiseLike(value) ? await value : value; + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/RedisResource.setPasswordParameter', + { context: this._handle, value } + ); + } + }; + + async tlsEnabled(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/RedisResource.tlsEnabled', + { context: this._handle } + ); + } + + async connectionStringExpression(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/RedisResource.connectionStringExpression', + { context: this._handle } + ); + } + + async uriExpression(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/RedisResource.uriExpression', + { context: this._handle } + ); + } + + entrypoint = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/RedisResource.entrypoint', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/RedisResource.setEntrypoint', + { context: this._handle, value } + ); + } + }; + + shellExecution = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/RedisResource.shellExecution', + { context: this._handle } + ); + }, + set: async (value: boolean): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/RedisResource.setShellExecution', + { context: this._handle, value } + ); + } + }; + + async name(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/RedisResource.name', + { context: this._handle } + ); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: Awaitable): Promise { + registry = isPromiseLike(registry) ? await registry : registry; + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withContainerRegistry(registry: Awaitable): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._withContainerRegistryInternal(registry), this._client); + } + + /** @internal */ + private async _withBindMountInternal(source: string, target: string, isReadOnly?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, source, target }; + if (isReadOnly !== undefined) rpcArgs.isReadOnly = isReadOnly; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBindMount', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withBindMount(source: string, target: string, options?: WithBindMountOptions): RedisResourcePromise { + const isReadOnly = options?.isReadOnly; + return new RedisResourcePromiseImpl(this._withBindMountInternal(source, target, isReadOnly), this._client); + } + + /** @internal */ + private async _withEntrypointInternal(entrypoint: string): Promise { + const rpcArgs: Record = { builder: this._handle, entrypoint }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEntrypoint', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withEntrypoint(entrypoint: string): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._withEntrypointInternal(entrypoint), this._client); + } + + /** @internal */ + private async _withImageTagInternal(tag: string): Promise { + const rpcArgs: Record = { builder: this._handle, tag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImageTag', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withImageTag(tag: string): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._withImageTagInternal(tag), this._client); + } + + /** @internal */ + private async _withImageRegistryInternal(registry: string): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImageRegistry', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withImageRegistry(registry: string): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._withImageRegistryInternal(registry), this._client); + } + + /** @internal */ + private async _withImageInternal(image: string, tag?: string): Promise { + const rpcArgs: Record = { builder: this._handle, image }; + if (tag !== undefined) rpcArgs.tag = tag; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImage', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withImage(image: string, options?: WithImageOptions): RedisResourcePromise { + const tag = options?.tag; + return new RedisResourcePromiseImpl(this._withImageInternal(image, tag), this._client); + } + + /** @internal */ + private async _withImageSHA256Internal(sha256: string): Promise { + const rpcArgs: Record = { builder: this._handle, sha256 }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImageSHA256', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withImageSHA256(sha256: string): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._withImageSHA256Internal(sha256), this._client); + } + + /** @internal */ + private async _withContainerRuntimeArgsInternal(args: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, args }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRuntimeArgs', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withContainerRuntimeArgs(args: string[]): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._withContainerRuntimeArgsInternal(args), this._client); + } + + /** @internal */ + private async _withLifetimeInternal(lifetime: ContainerLifetime): Promise { + const rpcArgs: Record = { builder: this._handle, lifetime }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withLifetime', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withLifetime(lifetime: ContainerLifetime): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._withLifetimeInternal(lifetime), this._client); + } + + /** @internal */ + private async _withImagePullPolicyInternal(pullPolicy: ImagePullPolicy): Promise { + const rpcArgs: Record = { builder: this._handle, pullPolicy }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImagePullPolicy', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withImagePullPolicy(pullPolicy: ImagePullPolicy): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._withImagePullPolicyInternal(pullPolicy), this._client); + } + + /** @internal */ + private async _publishAsContainerInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsContainer', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + publishAsContainer(): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._publishAsContainerInternal(), this._client); + } + + /** @internal */ + private async _withDockerfileInternal(contextPath: string, dockerfilePath?: string, stage?: string): Promise { + const rpcArgs: Record = { builder: this._handle, contextPath }; + if (dockerfilePath !== undefined) rpcArgs.dockerfilePath = dockerfilePath; + if (stage !== undefined) rpcArgs.stage = stage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfile', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withDockerfile(contextPath: string, options?: WithDockerfileOptions): RedisResourcePromise { + const dockerfilePath = options?.dockerfilePath; + const stage = options?.stage; + return new RedisResourcePromiseImpl(this._withDockerfileInternal(contextPath, dockerfilePath, stage), this._client); + } + + /** @internal */ + private async _withContainerNameInternal(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerName', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withContainerName(name: string): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._withContainerNameInternal(name), this._client); + } + + /** @internal */ + private async _withBuildArgInternal(name: string, value: string | ParameterResource | Awaitable): Promise { + value = isPromiseLike(value) ? await value : value; + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuildArg', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withBuildArg(name: string, value: string | ParameterResource | Awaitable): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._withBuildArgInternal(name, value), this._client); + } + + /** @internal */ + private async _withBuildSecretInternal(name: string, value: Awaitable): Promise { + value = isPromiseLike(value) ? await value : value; + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParameterBuildSecret', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withBuildSecret(name: string, value: Awaitable): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._withBuildSecretInternal(name, value), this._client); + } + + /** @internal */ + private async _withContainerCertificatePathsInternal(customCertificatesDestination?: string, defaultCertificateBundlePaths?: string[], defaultCertificateDirectoryPaths?: string[]): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (customCertificatesDestination !== undefined) rpcArgs.customCertificatesDestination = customCertificatesDestination; + if (defaultCertificateBundlePaths !== undefined) rpcArgs.defaultCertificateBundlePaths = defaultCertificateBundlePaths; + if (defaultCertificateDirectoryPaths !== undefined) rpcArgs.defaultCertificateDirectoryPaths = defaultCertificateDirectoryPaths; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerCertificatePaths', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): RedisResourcePromise { + const customCertificatesDestination = options?.customCertificatesDestination; + const defaultCertificateBundlePaths = options?.defaultCertificateBundlePaths; + const defaultCertificateDirectoryPaths = options?.defaultCertificateDirectoryPaths; + return new RedisResourcePromiseImpl(this._withContainerCertificatePathsInternal(customCertificatesDestination, defaultCertificateBundlePaths, defaultCertificateDirectoryPaths), this._client); + } + + /** @internal */ + private async _withEndpointProxySupportInternal(proxyEnabled: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, proxyEnabled }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpointProxySupport', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withEndpointProxySupport(proxyEnabled: boolean): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._withEndpointProxySupportInternal(proxyEnabled), this._client); + } + + /** @internal */ + private async _withDockerfileBuilderInternal(contextPath: string, callback: (arg: DockerfileBuilderCallbackContext) => Promise, stage?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as DockerfileBuilderCallbackContextHandle; + const arg = new DockerfileBuilderCallbackContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, contextPath, callback: callbackId }; + if (stage !== undefined) rpcArgs.stage = stage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBuilder', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withDockerfileBuilder(contextPath: string, callback: (arg: DockerfileBuilderCallbackContext) => Promise, options?: WithDockerfileBuilderOptions): RedisResourcePromise { + const stage = options?.stage; + return new RedisResourcePromiseImpl(this._withDockerfileBuilderInternal(contextPath, callback, stage), this._client); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): RedisResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new RedisResourcePromiseImpl(this._withDockerfileBaseImageInternal(buildImage, runtimeImage), this._client); + } + + /** @internal */ + private async _withContainerNetworkAliasInternal(alias: string): Promise { + const rpcArgs: Record = { builder: this._handle, alias }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerNetworkAlias', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withContainerNetworkAlias(alias: string): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._withContainerNetworkAliasInternal(alias), this._client); + } + + /** @internal */ + private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withMcpServer', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withMcpServer(options?: WithMcpServerOptions): RedisResourcePromise { + const path = options?.path; + const endpointName = options?.endpointName; + return new RedisResourcePromiseImpl(this._withMcpServerInternal(path, endpointName), this._client); + } + + /** @internal */ + private async _withOtlpExporterInternal(protocol?: OtlpProtocol): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (protocol !== undefined) rpcArgs.protocol = protocol; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporter', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withOtlpExporter(options?: WithOtlpExporterOptions): RedisResourcePromise { + const protocol = options?.protocol; + return new RedisResourcePromiseImpl(this._withOtlpExporterInternal(protocol), this._client); + } + + /** @internal */ + private async _publishAsConnectionStringInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsConnectionString', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + publishAsConnectionString(): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._publishAsConnectionStringInternal(), this._client); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): RedisResourcePromise { + const helpLink = options?.helpLink; + return new RedisResourcePromiseImpl(this._withRequiredCommandInternal(command, helpLink), this._client); + } + + /** @internal */ + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): Promise { + value = isPromiseLike(value) ? await value : value; + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironment', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._withEnvironmentInternal(name, value), this._client); + } + + /** @internal */ + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentCallback', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._withEnvironmentCallbackInternal(callback), this._client); + } + + /** @internal */ + private async _withConnectionPropertyInternal(name: string, value: string | ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withConnectionProperty', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withConnectionProperty(name: string, value: string | ReferenceExpression): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._withConnectionPropertyInternal(name, value), this._client); + } + + /** @internal */ + private async _withArgsInternal(args: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, args }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgs', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withArgs(args: string[]): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._withArgsInternal(args), this._client); + } + + /** @internal */ + private async _withArgsCallbackInternal(callback: (obj: CommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; + const obj = new CommandLineArgsCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallback', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._withArgsCallbackInternal(callback), this._client); + } + + /** @internal */ + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceEnvironment', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._withReferenceEnvironmentInternal(options), this._client); + } + + /** @internal */ + private async _withReferenceInternal(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, connectionName?: string, optional?: boolean, name?: string): Promise { + source = isPromiseLike(source) ? await source : source; + const rpcArgs: Record = { builder: this._handle, source }; + if (connectionName !== undefined) rpcArgs.connectionName = connectionName; + if (optional !== undefined) rpcArgs.optional = optional; + if (name !== undefined) rpcArgs.name = name; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReference', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): RedisResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new RedisResourcePromiseImpl(this._withReferenceInternal(source, connectionName, optional, name), this._client); + } + + async getConnectionProperty(key: string): Promise { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + + /** @internal */ + private async _withEndpointCallbackInternal(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpointCallback', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): RedisResourcePromise { + const createIfNotExists = options?.createIfNotExists; + return new RedisResourcePromiseImpl(this._withEndpointCallbackInternal(endpointName, callback, createIfNotExists), this._client); + } + + /** @internal */ + private async _withHttpEndpointCallbackInternal(callback: (obj: EndpointUpdateContext) => Promise, name?: string, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + if (name !== undefined) rpcArgs.name = name; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpEndpointCallback', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): RedisResourcePromise { + const name = options?.name; + const createIfNotExists = options?.createIfNotExists; + return new RedisResourcePromiseImpl(this._withHttpEndpointCallbackInternal(callback, name, createIfNotExists), this._client); + } + + /** @internal */ + private async _withHttpsEndpointCallbackInternal(callback: (obj: EndpointUpdateContext) => Promise, name?: string, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + if (name !== undefined) rpcArgs.name = name; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsEndpointCallback', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): RedisResourcePromise { + const name = options?.name; + const createIfNotExists = options?.createIfNotExists; + return new RedisResourcePromiseImpl(this._withHttpsEndpointCallbackInternal(callback, name, createIfNotExists), this._client); + } + + /** @internal */ + private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (scheme !== undefined) rpcArgs.scheme = scheme; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + if (isExternal !== undefined) rpcArgs.isExternal = isExternal; + if (protocol !== undefined) rpcArgs.protocol = protocol; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpoint', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withEndpoint(options?: WithEndpointOptions): RedisResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const scheme = options?.scheme; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + const isExternal = options?.isExternal; + const protocol = options?.protocol; + return new RedisResourcePromiseImpl(this._withEndpointInternal(port, targetPort, scheme, name, env, isProxied, isExternal, protocol), this._client); + } + + /** @internal */ + private async _withHttpEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpEndpoint', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withHttpEndpoint(options?: WithHttpEndpointOptions): RedisResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new RedisResourcePromiseImpl(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied), this._client); + } + + /** @internal */ + private async _withHttpsEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsEndpoint', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withHttpsEndpoint(options?: WithHttpsEndpointOptions): RedisResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new RedisResourcePromiseImpl(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied), this._client); + } + + /** @internal */ + private async _withExternalHttpEndpointsInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExternalHttpEndpoints', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withExternalHttpEndpoints(): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._withExternalHttpEndpointsInternal(), this._client); + } + + async getEndpoint(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getEndpoint', + rpcArgs + ); + } + + /** @internal */ + private async _asHttp2ServiceInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/asHttp2Service', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + asHttp2Service(): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._asHttp2ServiceInternal(), this._client); + } + + /** @internal */ + private async _withUrlsInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrls', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._withUrlsInternal(callback), this._client); + } + + /** @internal */ + private async _withUrlInternal(url: string | ReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): RedisResourcePromise { + const displayText = options?.displayText; + return new RedisResourcePromiseImpl(this._withUrlInternal(url, displayText), this._client); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._withUrlForEndpointInternal(endpointName, callback), this._client); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + excludeFromManifest(): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._excludeFromManifestInternal(), this._client); + } + + /** @internal */ + private async _waitForInternal(dependency: Awaitable, waitBehavior?: WaitBehavior): Promise { + dependency = isPromiseLike(dependency) ? await dependency : dependency; + const rpcArgs: Record = { builder: this._handle, dependency }; + if (waitBehavior !== undefined) rpcArgs.waitBehavior = waitBehavior; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitFor', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + waitFor(dependency: Awaitable, options?: WaitForOptions): RedisResourcePromise { + const waitBehavior = options?.waitBehavior; + return new RedisResourcePromiseImpl(this._waitForInternal(dependency, waitBehavior), this._client); + } + + /** @internal */ + private async _waitForStartInternal(dependency: Awaitable, waitBehavior?: WaitBehavior): Promise { + dependency = isPromiseLike(dependency) ? await dependency : dependency; + const rpcArgs: Record = { builder: this._handle, dependency }; + if (waitBehavior !== undefined) rpcArgs.waitBehavior = waitBehavior; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStart', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): RedisResourcePromise { + const waitBehavior = options?.waitBehavior; + return new RedisResourcePromiseImpl(this._waitForStartInternal(dependency, waitBehavior), this._client); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withExplicitStart(): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._withExplicitStartInternal(), this._client); + } + + /** @internal */ + private async _waitForCompletionInternal(dependency: Awaitable, exitCode?: number): Promise { + dependency = isPromiseLike(dependency) ? await dependency : dependency; + const rpcArgs: Record = { builder: this._handle, dependency }; + if (exitCode !== undefined) rpcArgs.exitCode = exitCode; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceCompletion', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): RedisResourcePromise { + const exitCode = options?.exitCode; + return new RedisResourcePromiseImpl(this._waitForCompletionInternal(dependency, exitCode), this._client); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withHealthCheck(key: string): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._withHealthCheckInternal(key), this._client); + } + + /** @internal */ + private async _withHttpHealthCheckInternal(path?: string, statusCode?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (statusCode !== undefined) rpcArgs.statusCode = statusCode; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpHealthCheck', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): RedisResourcePromise { + const path = options?.path; + const statusCode = options?.statusCode; + const endpointName = options?.endpointName; + return new RedisResourcePromiseImpl(this._withHttpHealthCheckInternal(path, statusCode, endpointName), this._client); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContextImpl(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): RedisResourcePromise { + const commandOptions = options?.commandOptions; + return new RedisResourcePromiseImpl(this._withCommandInternal(name, displayName, executeCommand, commandOptions), this._client); + } + + /** @internal */ + private async _withHttpCommandInternal(path: string, displayName: string, options?: HttpCommandExportOptions): Promise { + const rpcArgs: Record = { builder: this._handle, path, displayName }; + if (options !== undefined) rpcArgs.options = options; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpCommand', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._withHttpCommandInternal(path, displayName, options), this._client); + } + + /** @internal */ + private async _withDeveloperCertificateTrustInternal(trust: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, trust }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDeveloperCertificateTrust', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withDeveloperCertificateTrust(trust: boolean): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._withDeveloperCertificateTrustInternal(trust), this._client); + } + + /** @internal */ + private async _withCertificateTrustScopeInternal(scope: CertificateTrustScope): Promise { + const rpcArgs: Record = { builder: this._handle, scope }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCertificateTrustScope', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withCertificateTrustScope(scope: CertificateTrustScope): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._withCertificateTrustScopeInternal(scope), this._client); + } + + /** @internal */ + private async _withHttpsDeveloperCertificateInternal(password?: Awaitable): Promise { + password = isPromiseLike(password) ? await password : password; + const rpcArgs: Record = { builder: this._handle }; + if (password !== undefined) rpcArgs.password = password; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): RedisResourcePromise { + let password = options?.password; + return new RedisResourcePromiseImpl(this._withHttpsDeveloperCertificateInternal(password), this._client); + } + + /** @internal */ + private async _withoutHttpsCertificateInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withoutHttpsCertificate', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withoutHttpsCertificate(): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._withoutHttpsCertificateInternal(), this._client); + } + + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: Awaitable, type: string): Promise { + resourceBuilder = isPromiseLike(resourceBuilder) ? await resourceBuilder : resourceBuilder; + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._withRelationshipInternal(resourceBuilder, type), this._client); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: Awaitable): Promise { + parent = isPromiseLike(parent) ? await parent : parent; + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withParentRelationship(parent: Awaitable): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._withParentRelationshipInternal(parent), this._client); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: Awaitable): Promise { + child = isPromiseLike(child) ? await child : child; + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withChildRelationship(child: Awaitable): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._withChildRelationshipInternal(child), this._client); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): RedisResourcePromise { + const iconVariant = options?.iconVariant; + return new RedisResourcePromiseImpl(this._withIconNameInternal(iconName, iconVariant), this._client); + } + + /** @internal */ + private async _withHttpProbeInternal(probeType: ProbeType, path?: string, initialDelaySeconds?: number, periodSeconds?: number, timeoutSeconds?: number, failureThreshold?: number, successThreshold?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, probeType }; + if (path !== undefined) rpcArgs.path = path; + if (initialDelaySeconds !== undefined) rpcArgs.initialDelaySeconds = initialDelaySeconds; + if (periodSeconds !== undefined) rpcArgs.periodSeconds = periodSeconds; + if (timeoutSeconds !== undefined) rpcArgs.timeoutSeconds = timeoutSeconds; + if (failureThreshold !== undefined) rpcArgs.failureThreshold = failureThreshold; + if (successThreshold !== undefined) rpcArgs.successThreshold = successThreshold; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpProbe', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): RedisResourcePromise { + const path = options?.path; + const initialDelaySeconds = options?.initialDelaySeconds; + const periodSeconds = options?.periodSeconds; + const timeoutSeconds = options?.timeoutSeconds; + const failureThreshold = options?.failureThreshold; + const successThreshold = options?.successThreshold; + const endpointName = options?.endpointName; + return new RedisResourcePromiseImpl(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName), this._client); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + excludeFromMcp(): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._excludeFromMcpInternal(), this._client); + } + + /** @internal */ + private async _withImagePushOptionsInternal(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ContainerImagePushOptionsCallbackContextHandle; + const arg = new ContainerImagePushOptionsCallbackContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImagePushOptions', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._withImagePushOptionsInternal(callback), this._client); + } + + /** @internal */ + private async _withRemoteImageNameInternal(remoteImageName: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageName', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withRemoteImageName(remoteImageName: string): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._withRemoteImageNameInternal(remoteImageName), this._client); + } + + /** @internal */ + private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageTag', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withRemoteImageTag(remoteImageTag: string): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._withRemoteImageTagInternal(remoteImageTag), this._client); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): RedisResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new RedisResourcePromiseImpl(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description), this._client); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._withPipelineConfigurationInternal(callback), this._client); + } + + /** @internal */ + private async _withVolumeInternal(target: string, name?: string, isReadOnly?: boolean): Promise { + const rpcArgs: Record = { resource: this._handle, target }; + if (name !== undefined) rpcArgs.name = name; + if (isReadOnly !== undefined) rpcArgs.isReadOnly = isReadOnly; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withVolume', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withVolume(target: string, options?: WithVolumeOptions): RedisResourcePromise { + const name = options?.name; + const isReadOnly = options?.isReadOnly; + return new RedisResourcePromiseImpl(this._withVolumeInternal(target, name, isReadOnly), this._client); + } + + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); + } + + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._onBeforeResourceStartedInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._onResourceStoppedInternal(callback), this._client); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onConnectionStringAvailable', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._onConnectionStringAvailableInternal(callback), this._client); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._onInitializeResourceInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceEndpointsAllocated', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._onResourceEndpointsAllocatedInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._onResourceReadyInternal(callback), this._client); + } + + async createExecutionConfiguration(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/createExecutionConfiguration', + rpcArgs + ); + } + + /** @internal */ + private async _withLikeC4ReferenceWithEnvironmentInternal(source: Awaitable, configure?: (obj: LikeC4RelationshipDetailsAnnotation) => Promise, connectionName?: string, optional?: boolean, skipAspireReference?: boolean): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4RelationshipDetailsAnnotationHandle; + const obj = new LikeC4RelationshipDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + source = isPromiseLike(source) ? await source : source; + const rpcArgs: Record = { builder: this._handle, source }; + if (configure !== undefined) rpcArgs.configure = configureId; + if (connectionName !== undefined) rpcArgs.connectionName = connectionName; + if (optional !== undefined) rpcArgs.optional = optional; + if (skipAspireReference !== undefined) rpcArgs.skipAspireReference = skipAspireReference; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4ReferenceWithEnvironment', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): RedisResourcePromise { + const configure = options?.configure; + const connectionName = options?.connectionName; + const optional = options?.optional; + const skipAspireReference = options?.skipAspireReference; + return new RedisResourcePromiseImpl(this._withLikeC4ReferenceWithEnvironmentInternal(source, configure, connectionName, optional, skipAspireReference), this._client); + } + + /** @internal */ + private async _withLikeC4DetailsInternal(label?: string, technology?: string, description?: string, summary?: string, icon?: string, configure?: (obj: LikeC4NodeDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4NodeDetailsAnnotationHandle; + const obj = new LikeC4NodeDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + const rpcArgs: Record = { builder: this._handle }; + if (label !== undefined) rpcArgs.label = label; + if (technology !== undefined) rpcArgs.technology = technology; + if (description !== undefined) rpcArgs.description = description; + if (summary !== undefined) rpcArgs.summary = summary; + if (icon !== undefined) rpcArgs.icon = icon; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4DetailsParameters', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): RedisResourcePromise { + const label = options?.label; + const technology = options?.technology; + const description = options?.description; + const summary = options?.summary; + const icon = options?.icon; + const configure = options?.configure; + return new RedisResourcePromiseImpl(this._withLikeC4DetailsInternal(label, technology, description, summary, icon, configure), this._client); + } + + /** @internal */ + private async _withLikeC4ReferenceInternal(target: Awaitable, configure?: (obj: LikeC4RelationshipDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4RelationshipDetailsAnnotationHandle; + const obj = new LikeC4RelationshipDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target }; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Reference', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): RedisResourcePromise { + const configure = options?.configure; + return new RedisResourcePromiseImpl(this._withLikeC4ReferenceInternal(target, configure), this._client); + } + + /** @internal */ + private async _withLikeC4GroupInternal(groupName: string): Promise { + const rpcArgs: Record = { builder: this._handle, groupName }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Group', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withLikeC4Group(groupName: string): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._withLikeC4GroupInternal(groupName), this._client); + } + + /** @internal */ + private async _excludeFromLikeC4Internal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/excludeFromLikeC4', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + excludeFromLikeC4(): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._excludeFromLikeC4Internal(), this._client); + } + + /** @internal */ + private async _withAzureUserAssignedIdentityInternal(identityResourceBuilder: Awaitable): Promise { + identityResourceBuilder = isPromiseLike(identityResourceBuilder) ? await identityResourceBuilder : identityResourceBuilder; + const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._withAzureUserAssignedIdentityInternal(identityResourceBuilder), this._client); + } + + /** @internal */ + private async _withRoleAssignmentsInternal(target: Awaitable, roles: AzureKeyVaultRole[]): Promise { + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target, roles }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.KeyVault/withKeyVaultRoleAssignments', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._withRoleAssignmentsInternal(target, roles), this._client); + } + + /** @internal */ + private async _withRedisCommanderInternal(configureContainer?: (obj: RedisCommanderResource) => Promise, containerName?: string): Promise { + const configureContainerId = configureContainer ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as RedisCommanderResourceHandle; + const obj = new RedisCommanderResourceImpl(objHandle, this._client); + await configureContainer(obj); + }) : undefined; + const rpcArgs: Record = { builder: this._handle }; + if (configureContainer !== undefined) rpcArgs.configureContainer = configureContainerId; + if (containerName !== undefined) rpcArgs.containerName = containerName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Redis/withRedisCommander', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withRedisCommander(options?: WithRedisCommanderOptions): RedisResourcePromise { + const configureContainer = options?.configureContainer; + const containerName = options?.containerName; + return new RedisResourcePromiseImpl(this._withRedisCommanderInternal(configureContainer, containerName), this._client); + } + + /** @internal */ + private async _withRedisInsightInternal(configureContainer?: (obj: RedisInsightResource) => Promise, containerName?: string): Promise { + const configureContainerId = configureContainer ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as RedisInsightResourceHandle; + const obj = new RedisInsightResourceImpl(objHandle, this._client); + await configureContainer(obj); + }) : undefined; + const rpcArgs: Record = { builder: this._handle }; + if (configureContainer !== undefined) rpcArgs.configureContainer = configureContainerId; + if (containerName !== undefined) rpcArgs.containerName = containerName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Redis/withRedisInsight', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withRedisInsight(options?: WithRedisInsightOptions): RedisResourcePromise { + const configureContainer = options?.configureContainer; + const containerName = options?.containerName; + return new RedisResourcePromiseImpl(this._withRedisInsightInternal(configureContainer, containerName), this._client); + } + + /** @internal */ + private async _withDataVolumeInternal(name?: string, isReadOnly?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (name !== undefined) rpcArgs.name = name; + if (isReadOnly !== undefined) rpcArgs.isReadOnly = isReadOnly; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Redis/withDataVolume', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withDataVolume(options?: WithDataVolumeOptions): RedisResourcePromise { + const name = options?.name; + const isReadOnly = options?.isReadOnly; + return new RedisResourcePromiseImpl(this._withDataVolumeInternal(name, isReadOnly), this._client); + } + + /** @internal */ + private async _withDataBindMountInternal(source: string, isReadOnly?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, source }; + if (isReadOnly !== undefined) rpcArgs.isReadOnly = isReadOnly; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Redis/withDataBindMount', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withDataBindMount(source: string, options?: WithDataBindMountOptions): RedisResourcePromise { + const isReadOnly = options?.isReadOnly; + return new RedisResourcePromiseImpl(this._withDataBindMountInternal(source, isReadOnly), this._client); + } + + /** @internal */ + private async _withPersistenceInternal(interval?: number, keysChangedThreshold?: number): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (interval !== undefined) rpcArgs.interval = interval; + if (keysChangedThreshold !== undefined) rpcArgs.keysChangedThreshold = keysChangedThreshold; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Redis/withPersistence', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withPersistence(options?: WithPersistenceOptions): RedisResourcePromise { + const interval = options?.interval; + const keysChangedThreshold = options?.keysChangedThreshold; + return new RedisResourcePromiseImpl(this._withPersistenceInternal(interval, keysChangedThreshold), this._client); + } + + /** @internal */ + private async _withPasswordInternal(password: Awaitable): Promise { + password = isPromiseLike(password) ? await password : password; + const rpcArgs: Record = { builder: this._handle, password }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Redis/withPassword', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withPassword(password: Awaitable): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._withPasswordInternal(password), this._client); + } + + /** @internal */ + private async _withHostPortInternal(port?: number): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Redis/withHostPort', + rpcArgs + ); + return new RedisResourceImpl(result, this._client); + } + + withHostPort(options?: WithHostPortOptions): RedisResourcePromise { + const port = options?.port; + return new RedisResourcePromiseImpl(this._withHostPortInternal(port), this._client); + } + +} + +/** + * Thenable wrapper for RedisResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +class RedisResourcePromiseImpl implements RedisResourcePromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: RedisResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + primaryEndpoint(): Promise { + return this._promise.then(obj => obj.primaryEndpoint()); + } + + host(): Promise { + return this._promise.then(obj => obj.host()); + } + + port(): Promise { + return this._promise.then(obj => obj.port()); + } + + tlsEnabled(): Promise { + return this._promise.then(obj => obj.tlsEnabled()); + } + + connectionStringExpression(): Promise { + return this._promise.then(obj => obj.connectionStringExpression()); + } + + uriExpression(): Promise { + return this._promise.then(obj => obj.uriExpression()); + } + + name(): Promise { + return this._promise.then(obj => obj.name()); + } + + withContainerRegistry(registry: Awaitable): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withContainerRegistry(registry)), this._client); + } + + withBindMount(source: string, target: string, options?: WithBindMountOptions): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withBindMount(source, target, options)), this._client); + } + + withEntrypoint(entrypoint: string): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withEntrypoint(entrypoint)), this._client); + } + + withImageTag(tag: string): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withImageTag(tag)), this._client); + } + + withImageRegistry(registry: string): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withImageRegistry(registry)), this._client); + } + + withImage(image: string, options?: WithImageOptions): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withImage(image, options)), this._client); + } + + withImageSHA256(sha256: string): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withImageSHA256(sha256)), this._client); + } + + withContainerRuntimeArgs(args: string[]): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withContainerRuntimeArgs(args)), this._client); + } + + withLifetime(lifetime: ContainerLifetime): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withLifetime(lifetime)), this._client); + } + + withImagePullPolicy(pullPolicy: ImagePullPolicy): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withImagePullPolicy(pullPolicy)), this._client); + } + + publishAsContainer(): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.publishAsContainer()), this._client); + } + + withDockerfile(contextPath: string, options?: WithDockerfileOptions): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withDockerfile(contextPath, options)), this._client); + } + + withContainerName(name: string): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withContainerName(name)), this._client); + } + + withBuildArg(name: string, value: string | ParameterResource | Awaitable): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withBuildArg(name, value)), this._client); + } + + withBuildSecret(name: string, value: Awaitable): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withBuildSecret(name, value)), this._client); + } + + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withContainerCertificatePaths(options)), this._client); + } + + withEndpointProxySupport(proxyEnabled: boolean): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withEndpointProxySupport(proxyEnabled)), this._client); + } + + withDockerfileBuilder(contextPath: string, callback: (arg: DockerfileBuilderCallbackContext) => Promise, options?: WithDockerfileBuilderOptions): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withDockerfileBuilder(contextPath, callback, options)), this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withDockerfileBaseImage(options)), this._client); + } + + withContainerNetworkAlias(alias: string): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withContainerNetworkAlias(alias)), this._client); + } + + withMcpServer(options?: WithMcpServerOptions): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withMcpServer(options)), this._client); + } + + withOtlpExporter(options?: WithOtlpExporterOptions): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withOtlpExporter(options)), this._client); + } + + publishAsConnectionString(): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.publishAsConnectionString()), this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withRequiredCommand(command, options)), this._client); + } + + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withEnvironment(name, value)), this._client); + } + + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentCallback(callback)), this._client); + } + + withConnectionProperty(name: string, value: string | ReferenceExpression): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withConnectionProperty(name, value)), this._client); + } + + withArgs(args: string[]): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withArgs(args)), this._client); + } + + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withArgsCallback(callback)), this._client); + } + + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withReferenceEnvironment(options)), this._client); + } + + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withReference(source, options)), this._client); + } + + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withEndpointCallback(endpointName, callback, options)), this._client); + } + + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withHttpEndpointCallback(callback, options)), this._client); + } + + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withHttpsEndpointCallback(callback, options)), this._client); + } + + withEndpoint(options?: WithEndpointOptions): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withEndpoint(options)), this._client); + } + + withHttpEndpoint(options?: WithHttpEndpointOptions): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withHttpEndpoint(options)), this._client); + } + + withHttpsEndpoint(options?: WithHttpsEndpointOptions): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withHttpsEndpoint(options)), this._client); + } + + withExternalHttpEndpoints(): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withExternalHttpEndpoints()), this._client); + } + + getEndpoint(name: string): Promise { + return this._promise.then(obj => obj.getEndpoint(name)); + } + + asHttp2Service(): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.asHttp2Service()), this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withUrls(callback)), this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withUrl(url, options)), this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback)), this._client); + } + + excludeFromManifest(): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.excludeFromManifest()), this._client); + } + + waitFor(dependency: Awaitable, options?: WaitForOptions): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.waitFor(dependency, options)), this._client); + } + + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.waitForStart(dependency, options)), this._client); + } + + withExplicitStart(): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withExplicitStart()), this._client); + } + + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.waitForCompletion(dependency, options)), this._client); + } + + withHealthCheck(key: string): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withHealthCheck(key)), this._client); + } + + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withHttpHealthCheck(options)), this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options)), this._client); + } + + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withHttpCommand(path, displayName, options)), this._client); + } + + withDeveloperCertificateTrust(trust: boolean): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust)), this._client); + } + + withCertificateTrustScope(scope: CertificateTrustScope): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withCertificateTrustScope(scope)), this._client); + } + + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options)), this._client); + } + + withoutHttpsCertificate(): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withoutHttpsCertificate()), this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withRelationship(resourceBuilder, type)), this._client); + } + + withParentRelationship(parent: Awaitable): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withParentRelationship(parent)), this._client); + } + + withChildRelationship(child: Awaitable): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withChildRelationship(child)), this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withIconName(iconName, options)), this._client); + } + + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withHttpProbe(probeType, options)), this._client); + } + + excludeFromMcp(): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.excludeFromMcp()), this._client); + } + + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withImagePushOptions(callback)), this._client); + } + + withRemoteImageName(remoteImageName: string): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withRemoteImageName(remoteImageName)), this._client); + } + + withRemoteImageTag(remoteImageTag: string): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag)), this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options)), this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withPipelineConfiguration(callback)), this._client); + } + + withVolume(target: string, options?: WithVolumeOptions): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withVolume(target, options)), this._client); + } + + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.onBeforeResourceStarted(callback)), this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.onResourceStopped(callback)), this._client); + } + + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.onConnectionStringAvailable(callback)), this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.onInitializeResource(callback)), this._client); + } + + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback)), this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.onResourceReady(callback)), this._client); + } + + createExecutionConfiguration(): Promise { + return this._promise.then(obj => obj.createExecutionConfiguration()); + } + + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4ReferenceWithEnvironment(source, options)), this._client); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Details(options)), this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Reference(target, options)), this._client); + } + + withLikeC4Group(groupName: string): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Group(groupName)), this._client); + } + + excludeFromLikeC4(): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.excludeFromLikeC4()), this._client); + } + + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withAzureUserAssignedIdentity(identityResourceBuilder)), this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withRoleAssignments(target, roles)), this._client); + } + + withRedisCommander(options?: WithRedisCommanderOptions): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withRedisCommander(options)), this._client); + } + + withRedisInsight(options?: WithRedisInsightOptions): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withRedisInsight(options)), this._client); + } + + withDataVolume(options?: WithDataVolumeOptions): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withDataVolume(options)), this._client); + } + + withDataBindMount(source: string, options?: WithDataBindMountOptions): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withDataBindMount(source, options)), this._client); + } + + withPersistence(options?: WithPersistenceOptions): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withPersistence(options)), this._client); + } + + withPassword(password: Awaitable): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withPassword(password)), this._client); + } + + withHostPort(options?: WithHostPortOptions): RedisResourcePromise { + return new RedisResourcePromiseImpl(this._promise.then(obj => obj.withHostPort(options)), this._client); + } + +} + +// ============================================================================ +// ViteAppResource +// ============================================================================ + +export interface ViteAppResource { + toJSON(): MarshalledHandle; + /** Gets the Command property */ + command(): Promise; + /** Gets the WorkingDirectory property */ + workingDirectory(): Promise; + /** Gets the Name property */ + name(): Promise; + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): ViteAppResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ViteAppResourcePromise; + /** Publishes an executable as a Docker file */ + publishAsDockerFile(configure: (obj: ContainerResource) => Promise): ViteAppResourcePromise; + /** Sets the executable command */ + withExecutableCommand(command: string): ViteAppResourcePromise; + /** Sets the executable working directory */ + withWorkingDirectory(workingDirectory: string): ViteAppResourcePromise; + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): ViteAppResourcePromise; + /** Configures OTLP telemetry export */ + withOtlpExporter(options?: WithOtlpExporterOptions): ViteAppResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ViteAppResourcePromise; + /** Sets an environment variable */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): ViteAppResourcePromise; + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ViteAppResourcePromise; + /** Adds arguments */ + withArgs(args: string[]): ViteAppResourcePromise; + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): ViteAppResourcePromise; + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ViteAppResourcePromise; + /** Adds a reference to another resource */ + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): ViteAppResourcePromise; + /** Updates a named endpoint via callback */ + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): ViteAppResourcePromise; + /** Updates an HTTP endpoint via callback */ + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): ViteAppResourcePromise; + /** Updates an HTTPS endpoint via callback */ + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): ViteAppResourcePromise; + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): ViteAppResourcePromise; + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): ViteAppResourcePromise; + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): ViteAppResourcePromise; + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): ViteAppResourcePromise; + /** Gets an endpoint reference */ + getEndpoint(name: string): Promise; + /** Configures resource for HTTP/2 */ + asHttp2Service(): ViteAppResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): ViteAppResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): ViteAppResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ViteAppResourcePromise; + /** Sets the source directory for container files */ + withContainerFilesSource(sourcePath: string): ViteAppResourcePromise; + /** Clears all container file sources */ + clearContainerFilesSources(): ViteAppResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): ViteAppResourcePromise; + /** Waits for another resource to be ready */ + waitFor(dependency: Awaitable, options?: WaitForOptions): ViteAppResourcePromise; + /** Waits for another resource to start */ + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): ViteAppResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): ViteAppResourcePromise; + /** Waits for resource completion */ + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): ViteAppResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): ViteAppResourcePromise; + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ViteAppResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ViteAppResourcePromise; + /** Adds an HTTP resource command */ + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): ViteAppResourcePromise; + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): ViteAppResourcePromise; + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): ViteAppResourcePromise; + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ViteAppResourcePromise; + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): ViteAppResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): ViteAppResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): ViteAppResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): ViteAppResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ViteAppResourcePromise; + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ViteAppResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ViteAppResourcePromise; + /** Sets image push options via callback */ + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): ViteAppResourcePromise; + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): ViteAppResourcePromise; + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): ViteAppResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ViteAppResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ViteAppResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ViteAppResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ViteAppResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ViteAppResourcePromise; + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ViteAppResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ViteAppResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Publishes the JavaScript application as a standalone static website using YARP. */ + publishAsStaticWebsite(options?: PublishAsStaticWebsiteOptions): ViteAppResourcePromise; + /** Publishes the JavaScript application as a standalone Node.js server that runs a built artifact directly. */ + publishAsNodeServer(entryPoint: string, options?: PublishAsNodeServerOptions): ViteAppResourcePromise; + /** Publishes the JavaScript application as a Node.js server that uses a package manager script at runtime. */ + publishAsNpmScript(options?: PublishAsNpmScriptOptions): ViteAppResourcePromise; + /** Configures a custom Vite configuration file */ + withViteConfig(configPath: string): ViteAppResourcePromise; + /** Configures npm as the package manager */ + withNpm(options?: WithNpmOptions): ViteAppResourcePromise; + /** Configures Bun as the package manager */ + withBun(options?: WithBunOptions): ViteAppResourcePromise; + /** Configures yarn as the package manager */ + withYarn(options?: WithYarnOptions): ViteAppResourcePromise; + /** Configures pnpm as the package manager */ + withPnpm(options?: WithPnpmOptions): ViteAppResourcePromise; + /** Specifies an npm script to run before starting the application */ + withBuildScript(scriptName: string, options?: WithBuildScriptOptions): ViteAppResourcePromise; + /** Specifies an npm script to run during development */ + withRunScript(scriptName: string, options?: WithRunScriptOptions): ViteAppResourcePromise; + /** Configures a browser debugger for the JavaScript application */ + withBrowserDebugger(options?: WithBrowserDebuggerOptions): ViteAppResourcePromise; + /** Create a new reference, while also allowing customization of how a resource appears in the generated LikeC4 diagram. */ + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): ViteAppResourcePromise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): ViteAppResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): ViteAppResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): ViteAppResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): ViteAppResourcePromise; + /** Associates an Azure user-assigned identity with a compute resource */ + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): ViteAppResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): ViteAppResourcePromise; +} + +export interface ViteAppResourcePromise extends PromiseLike { + /** Gets the Command property */ + command(): Promise; + /** Gets the WorkingDirectory property */ + workingDirectory(): Promise; + /** Gets the Name property */ + name(): Promise; + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): ViteAppResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ViteAppResourcePromise; + /** Publishes an executable as a Docker file */ + publishAsDockerFile(configure: (obj: ContainerResource) => Promise): ViteAppResourcePromise; + /** Sets the executable command */ + withExecutableCommand(command: string): ViteAppResourcePromise; + /** Sets the executable working directory */ + withWorkingDirectory(workingDirectory: string): ViteAppResourcePromise; + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): ViteAppResourcePromise; + /** Configures OTLP telemetry export */ + withOtlpExporter(options?: WithOtlpExporterOptions): ViteAppResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ViteAppResourcePromise; + /** Sets an environment variable */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): ViteAppResourcePromise; + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ViteAppResourcePromise; + /** Adds arguments */ + withArgs(args: string[]): ViteAppResourcePromise; + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): ViteAppResourcePromise; + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ViteAppResourcePromise; + /** Adds a reference to another resource */ + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): ViteAppResourcePromise; + /** Updates a named endpoint via callback */ + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): ViteAppResourcePromise; + /** Updates an HTTP endpoint via callback */ + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): ViteAppResourcePromise; + /** Updates an HTTPS endpoint via callback */ + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): ViteAppResourcePromise; + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): ViteAppResourcePromise; + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): ViteAppResourcePromise; + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): ViteAppResourcePromise; + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): ViteAppResourcePromise; + /** Gets an endpoint reference */ + getEndpoint(name: string): Promise; + /** Configures resource for HTTP/2 */ + asHttp2Service(): ViteAppResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): ViteAppResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): ViteAppResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ViteAppResourcePromise; + /** Sets the source directory for container files */ + withContainerFilesSource(sourcePath: string): ViteAppResourcePromise; + /** Clears all container file sources */ + clearContainerFilesSources(): ViteAppResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): ViteAppResourcePromise; + /** Waits for another resource to be ready */ + waitFor(dependency: Awaitable, options?: WaitForOptions): ViteAppResourcePromise; + /** Waits for another resource to start */ + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): ViteAppResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): ViteAppResourcePromise; + /** Waits for resource completion */ + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): ViteAppResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): ViteAppResourcePromise; + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ViteAppResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ViteAppResourcePromise; + /** Adds an HTTP resource command */ + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): ViteAppResourcePromise; + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): ViteAppResourcePromise; + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): ViteAppResourcePromise; + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ViteAppResourcePromise; + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): ViteAppResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): ViteAppResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): ViteAppResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): ViteAppResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ViteAppResourcePromise; + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ViteAppResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ViteAppResourcePromise; + /** Sets image push options via callback */ + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): ViteAppResourcePromise; + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): ViteAppResourcePromise; + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): ViteAppResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ViteAppResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ViteAppResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ViteAppResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ViteAppResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ViteAppResourcePromise; + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ViteAppResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ViteAppResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Publishes the JavaScript application as a standalone static website using YARP. */ + publishAsStaticWebsite(options?: PublishAsStaticWebsiteOptions): ViteAppResourcePromise; + /** Publishes the JavaScript application as a standalone Node.js server that runs a built artifact directly. */ + publishAsNodeServer(entryPoint: string, options?: PublishAsNodeServerOptions): ViteAppResourcePromise; + /** Publishes the JavaScript application as a Node.js server that uses a package manager script at runtime. */ + publishAsNpmScript(options?: PublishAsNpmScriptOptions): ViteAppResourcePromise; + /** Configures a custom Vite configuration file */ + withViteConfig(configPath: string): ViteAppResourcePromise; + /** Configures npm as the package manager */ + withNpm(options?: WithNpmOptions): ViteAppResourcePromise; + /** Configures Bun as the package manager */ + withBun(options?: WithBunOptions): ViteAppResourcePromise; + /** Configures yarn as the package manager */ + withYarn(options?: WithYarnOptions): ViteAppResourcePromise; + /** Configures pnpm as the package manager */ + withPnpm(options?: WithPnpmOptions): ViteAppResourcePromise; + /** Specifies an npm script to run before starting the application */ + withBuildScript(scriptName: string, options?: WithBuildScriptOptions): ViteAppResourcePromise; + /** Specifies an npm script to run during development */ + withRunScript(scriptName: string, options?: WithRunScriptOptions): ViteAppResourcePromise; + /** Configures a browser debugger for the JavaScript application */ + withBrowserDebugger(options?: WithBrowserDebuggerOptions): ViteAppResourcePromise; + /** Create a new reference, while also allowing customization of how a resource appears in the generated LikeC4 diagram. */ + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): ViteAppResourcePromise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): ViteAppResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): ViteAppResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): ViteAppResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): ViteAppResourcePromise; + /** Associates an Azure user-assigned identity with a compute resource */ + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): ViteAppResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): ViteAppResourcePromise; +} + +// ============================================================================ +// ViteAppResourceImpl +// ============================================================================ + +class ViteAppResourceImpl extends ResourceBuilderBase implements ViteAppResource { + constructor(handle: ViteAppResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + async command(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/JavaScriptAppResource.command', + { context: this._handle } + ); + } + + async workingDirectory(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/JavaScriptAppResource.workingDirectory', + { context: this._handle } + ); + } + + async name(): Promise { + return await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/JavaScriptAppResource.name', + { context: this._handle } + ); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: Awaitable): Promise { + registry = isPromiseLike(registry) ? await registry : registry; + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withContainerRegistry(registry: Awaitable): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._withContainerRegistryInternal(registry), this._client); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ViteAppResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new ViteAppResourcePromiseImpl(this._withDockerfileBaseImageInternal(buildImage, runtimeImage), this._client); + } + + /** @internal */ + private async _publishAsDockerFileInternal(configure: (obj: ContainerResource) => Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ContainerResourceHandle; + const obj = new ContainerResourceImpl(objHandle, this._client); + await configure(obj); + }); + const rpcArgs: Record = { builder: this._handle, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsDockerFile', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + publishAsDockerFile(configure: (obj: ContainerResource) => Promise): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._publishAsDockerFileInternal(configure), this._client); + } + + /** @internal */ + private async _withExecutableCommandInternal(command: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExecutableCommand', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withExecutableCommand(command: string): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._withExecutableCommandInternal(command), this._client); + } + + /** @internal */ + private async _withWorkingDirectoryInternal(workingDirectory: string): Promise { + const rpcArgs: Record = { builder: this._handle, workingDirectory }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withWorkingDirectory', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withWorkingDirectory(workingDirectory: string): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._withWorkingDirectoryInternal(workingDirectory), this._client); + } + + /** @internal */ + private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withMcpServer', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withMcpServer(options?: WithMcpServerOptions): ViteAppResourcePromise { + const path = options?.path; + const endpointName = options?.endpointName; + return new ViteAppResourcePromiseImpl(this._withMcpServerInternal(path, endpointName), this._client); + } + + /** @internal */ + private async _withOtlpExporterInternal(protocol?: OtlpProtocol): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (protocol !== undefined) rpcArgs.protocol = protocol; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporter', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withOtlpExporter(options?: WithOtlpExporterOptions): ViteAppResourcePromise { + const protocol = options?.protocol; + return new ViteAppResourcePromiseImpl(this._withOtlpExporterInternal(protocol), this._client); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ViteAppResourcePromise { + const helpLink = options?.helpLink; + return new ViteAppResourcePromiseImpl(this._withRequiredCommandInternal(command, helpLink), this._client); + } + + /** @internal */ + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): Promise { + value = isPromiseLike(value) ? await value : value; + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironment', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._withEnvironmentInternal(name, value), this._client); + } + + /** @internal */ + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentCallback', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._withEnvironmentCallbackInternal(callback), this._client); + } + + /** @internal */ + private async _withArgsInternal(args: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, args }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgs', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withArgs(args: string[]): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._withArgsInternal(args), this._client); + } + + /** @internal */ + private async _withArgsCallbackInternal(callback: (obj: CommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; + const obj = new CommandLineArgsCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallback', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._withArgsCallbackInternal(callback), this._client); + } + + /** @internal */ + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceEnvironment', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._withReferenceEnvironmentInternal(options), this._client); + } + + /** @internal */ + private async _withReferenceInternal(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, connectionName?: string, optional?: boolean, name?: string): Promise { + source = isPromiseLike(source) ? await source : source; + const rpcArgs: Record = { builder: this._handle, source }; + if (connectionName !== undefined) rpcArgs.connectionName = connectionName; + if (optional !== undefined) rpcArgs.optional = optional; + if (name !== undefined) rpcArgs.name = name; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReference', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): ViteAppResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new ViteAppResourcePromiseImpl(this._withReferenceInternal(source, connectionName, optional, name), this._client); + } + + /** @internal */ + private async _withEndpointCallbackInternal(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpointCallback', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): ViteAppResourcePromise { + const createIfNotExists = options?.createIfNotExists; + return new ViteAppResourcePromiseImpl(this._withEndpointCallbackInternal(endpointName, callback, createIfNotExists), this._client); + } + + /** @internal */ + private async _withHttpEndpointCallbackInternal(callback: (obj: EndpointUpdateContext) => Promise, name?: string, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + if (name !== undefined) rpcArgs.name = name; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpEndpointCallback', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): ViteAppResourcePromise { + const name = options?.name; + const createIfNotExists = options?.createIfNotExists; + return new ViteAppResourcePromiseImpl(this._withHttpEndpointCallbackInternal(callback, name, createIfNotExists), this._client); + } + + /** @internal */ + private async _withHttpsEndpointCallbackInternal(callback: (obj: EndpointUpdateContext) => Promise, name?: string, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + if (name !== undefined) rpcArgs.name = name; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsEndpointCallback', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): ViteAppResourcePromise { + const name = options?.name; + const createIfNotExists = options?.createIfNotExists; + return new ViteAppResourcePromiseImpl(this._withHttpsEndpointCallbackInternal(callback, name, createIfNotExists), this._client); + } + + /** @internal */ + private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (scheme !== undefined) rpcArgs.scheme = scheme; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + if (isExternal !== undefined) rpcArgs.isExternal = isExternal; + if (protocol !== undefined) rpcArgs.protocol = protocol; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpoint', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withEndpoint(options?: WithEndpointOptions): ViteAppResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const scheme = options?.scheme; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + const isExternal = options?.isExternal; + const protocol = options?.protocol; + return new ViteAppResourcePromiseImpl(this._withEndpointInternal(port, targetPort, scheme, name, env, isProxied, isExternal, protocol), this._client); + } + + /** @internal */ + private async _withHttpEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpEndpoint', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withHttpEndpoint(options?: WithHttpEndpointOptions): ViteAppResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new ViteAppResourcePromiseImpl(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied), this._client); + } + + /** @internal */ + private async _withHttpsEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsEndpoint', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withHttpsEndpoint(options?: WithHttpsEndpointOptions): ViteAppResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new ViteAppResourcePromiseImpl(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied), this._client); + } + + /** @internal */ + private async _withExternalHttpEndpointsInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExternalHttpEndpoints', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withExternalHttpEndpoints(): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._withExternalHttpEndpointsInternal(), this._client); + } + + async getEndpoint(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getEndpoint', + rpcArgs + ); + } + + /** @internal */ + private async _asHttp2ServiceInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/asHttp2Service', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + asHttp2Service(): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._asHttp2ServiceInternal(), this._client); + } + + /** @internal */ + private async _withUrlsInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrls', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._withUrlsInternal(callback), this._client); + } + + /** @internal */ + private async _withUrlInternal(url: string | ReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): ViteAppResourcePromise { + const displayText = options?.displayText; + return new ViteAppResourcePromiseImpl(this._withUrlInternal(url, displayText), this._client); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._withUrlForEndpointInternal(endpointName, callback), this._client); + } + + /** @internal */ + private async _withContainerFilesSourceInternal(sourcePath: string): Promise { + const rpcArgs: Record = { builder: this._handle, sourcePath }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerFilesSource', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withContainerFilesSource(sourcePath: string): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._withContainerFilesSourceInternal(sourcePath), this._client); + } + + /** @internal */ + private async _clearContainerFilesSourcesInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/clearContainerFilesSources', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + clearContainerFilesSources(): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._clearContainerFilesSourcesInternal(), this._client); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + excludeFromManifest(): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._excludeFromManifestInternal(), this._client); + } + + /** @internal */ + private async _waitForInternal(dependency: Awaitable, waitBehavior?: WaitBehavior): Promise { + dependency = isPromiseLike(dependency) ? await dependency : dependency; + const rpcArgs: Record = { builder: this._handle, dependency }; + if (waitBehavior !== undefined) rpcArgs.waitBehavior = waitBehavior; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitFor', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + waitFor(dependency: Awaitable, options?: WaitForOptions): ViteAppResourcePromise { + const waitBehavior = options?.waitBehavior; + return new ViteAppResourcePromiseImpl(this._waitForInternal(dependency, waitBehavior), this._client); + } + + /** @internal */ + private async _waitForStartInternal(dependency: Awaitable, waitBehavior?: WaitBehavior): Promise { + dependency = isPromiseLike(dependency) ? await dependency : dependency; + const rpcArgs: Record = { builder: this._handle, dependency }; + if (waitBehavior !== undefined) rpcArgs.waitBehavior = waitBehavior; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStart', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): ViteAppResourcePromise { + const waitBehavior = options?.waitBehavior; + return new ViteAppResourcePromiseImpl(this._waitForStartInternal(dependency, waitBehavior), this._client); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withExplicitStart(): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._withExplicitStartInternal(), this._client); + } + + /** @internal */ + private async _waitForCompletionInternal(dependency: Awaitable, exitCode?: number): Promise { + dependency = isPromiseLike(dependency) ? await dependency : dependency; + const rpcArgs: Record = { builder: this._handle, dependency }; + if (exitCode !== undefined) rpcArgs.exitCode = exitCode; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceCompletion', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): ViteAppResourcePromise { + const exitCode = options?.exitCode; + return new ViteAppResourcePromiseImpl(this._waitForCompletionInternal(dependency, exitCode), this._client); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withHealthCheck(key: string): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._withHealthCheckInternal(key), this._client); + } + + /** @internal */ + private async _withHttpHealthCheckInternal(path?: string, statusCode?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (statusCode !== undefined) rpcArgs.statusCode = statusCode; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpHealthCheck', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ViteAppResourcePromise { + const path = options?.path; + const statusCode = options?.statusCode; + const endpointName = options?.endpointName; + return new ViteAppResourcePromiseImpl(this._withHttpHealthCheckInternal(path, statusCode, endpointName), this._client); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContextImpl(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ViteAppResourcePromise { + const commandOptions = options?.commandOptions; + return new ViteAppResourcePromiseImpl(this._withCommandInternal(name, displayName, executeCommand, commandOptions), this._client); + } + + /** @internal */ + private async _withHttpCommandInternal(path: string, displayName: string, options?: HttpCommandExportOptions): Promise { + const rpcArgs: Record = { builder: this._handle, path, displayName }; + if (options !== undefined) rpcArgs.options = options; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpCommand', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._withHttpCommandInternal(path, displayName, options), this._client); + } + + /** @internal */ + private async _withDeveloperCertificateTrustInternal(trust: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, trust }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDeveloperCertificateTrust', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withDeveloperCertificateTrust(trust: boolean): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._withDeveloperCertificateTrustInternal(trust), this._client); + } + + /** @internal */ + private async _withCertificateTrustScopeInternal(scope: CertificateTrustScope): Promise { + const rpcArgs: Record = { builder: this._handle, scope }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCertificateTrustScope', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withCertificateTrustScope(scope: CertificateTrustScope): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._withCertificateTrustScopeInternal(scope), this._client); + } + + /** @internal */ + private async _withHttpsDeveloperCertificateInternal(password?: Awaitable): Promise { + password = isPromiseLike(password) ? await password : password; + const rpcArgs: Record = { builder: this._handle }; + if (password !== undefined) rpcArgs.password = password; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ViteAppResourcePromise { + let password = options?.password; + return new ViteAppResourcePromiseImpl(this._withHttpsDeveloperCertificateInternal(password), this._client); + } + + /** @internal */ + private async _withoutHttpsCertificateInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withoutHttpsCertificate', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withoutHttpsCertificate(): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._withoutHttpsCertificateInternal(), this._client); + } + + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: Awaitable, type: string): Promise { + resourceBuilder = isPromiseLike(resourceBuilder) ? await resourceBuilder : resourceBuilder; + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._withRelationshipInternal(resourceBuilder, type), this._client); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: Awaitable): Promise { + parent = isPromiseLike(parent) ? await parent : parent; + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withParentRelationship(parent: Awaitable): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._withParentRelationshipInternal(parent), this._client); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: Awaitable): Promise { + child = isPromiseLike(child) ? await child : child; + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withChildRelationship(child: Awaitable): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._withChildRelationshipInternal(child), this._client); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): ViteAppResourcePromise { + const iconVariant = options?.iconVariant; + return new ViteAppResourcePromiseImpl(this._withIconNameInternal(iconName, iconVariant), this._client); + } + + /** @internal */ + private async _withHttpProbeInternal(probeType: ProbeType, path?: string, initialDelaySeconds?: number, periodSeconds?: number, timeoutSeconds?: number, failureThreshold?: number, successThreshold?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, probeType }; + if (path !== undefined) rpcArgs.path = path; + if (initialDelaySeconds !== undefined) rpcArgs.initialDelaySeconds = initialDelaySeconds; + if (periodSeconds !== undefined) rpcArgs.periodSeconds = periodSeconds; + if (timeoutSeconds !== undefined) rpcArgs.timeoutSeconds = timeoutSeconds; + if (failureThreshold !== undefined) rpcArgs.failureThreshold = failureThreshold; + if (successThreshold !== undefined) rpcArgs.successThreshold = successThreshold; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpProbe', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ViteAppResourcePromise { + const path = options?.path; + const initialDelaySeconds = options?.initialDelaySeconds; + const periodSeconds = options?.periodSeconds; + const timeoutSeconds = options?.timeoutSeconds; + const failureThreshold = options?.failureThreshold; + const successThreshold = options?.successThreshold; + const endpointName = options?.endpointName; + return new ViteAppResourcePromiseImpl(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName), this._client); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + excludeFromMcp(): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._excludeFromMcpInternal(), this._client); + } + + /** @internal */ + private async _withImagePushOptionsInternal(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ContainerImagePushOptionsCallbackContextHandle; + const arg = new ContainerImagePushOptionsCallbackContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImagePushOptions', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._withImagePushOptionsInternal(callback), this._client); + } + + /** @internal */ + private async _withRemoteImageNameInternal(remoteImageName: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageName', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withRemoteImageName(remoteImageName: string): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._withRemoteImageNameInternal(remoteImageName), this._client); + } + + /** @internal */ + private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageTag', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withRemoteImageTag(remoteImageTag: string): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._withRemoteImageTagInternal(remoteImageTag), this._client); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ViteAppResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new ViteAppResourcePromiseImpl(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description), this._client); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._withPipelineConfigurationInternal(callback), this._client); + } + + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); + } + + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._onBeforeResourceStartedInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._onResourceStoppedInternal(callback), this._client); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._onInitializeResourceInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceEndpointsAllocated', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._onResourceEndpointsAllocatedInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._onResourceReadyInternal(callback), this._client); + } + + async createExecutionConfiguration(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/createExecutionConfiguration', + rpcArgs + ); + } + + /** @internal */ + private async _publishAsStaticWebsiteInternal(apiPath?: string, apiTarget?: Awaitable, outputPath?: string, stripPrefix?: boolean, targetEndpointName?: string): Promise { + apiTarget = isPromiseLike(apiTarget) ? await apiTarget : apiTarget; + const rpcArgs: Record = { builder: this._handle }; + if (apiPath !== undefined) rpcArgs.apiPath = apiPath; + if (apiTarget !== undefined) rpcArgs.apiTarget = apiTarget; + if (outputPath !== undefined) rpcArgs.outputPath = outputPath; + if (stripPrefix !== undefined) rpcArgs.stripPrefix = stripPrefix; + if (targetEndpointName !== undefined) rpcArgs.targetEndpointName = targetEndpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/publishAsStaticWebsite', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + publishAsStaticWebsite(options?: PublishAsStaticWebsiteOptions): ViteAppResourcePromise { + const apiPath = options?.apiPath; + let apiTarget = options?.apiTarget; + const outputPath = options?.outputPath; + const stripPrefix = options?.stripPrefix; + const targetEndpointName = options?.targetEndpointName; + return new ViteAppResourcePromiseImpl(this._publishAsStaticWebsiteInternal(apiPath, apiTarget, outputPath, stripPrefix, targetEndpointName), this._client); + } + + /** @internal */ + private async _publishAsNodeServerInternal(entryPoint: string, outputPath?: string): Promise { + const rpcArgs: Record = { builder: this._handle, entryPoint }; + if (outputPath !== undefined) rpcArgs.outputPath = outputPath; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/publishAsNodeServer', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + publishAsNodeServer(entryPoint: string, options?: PublishAsNodeServerOptions): ViteAppResourcePromise { + const outputPath = options?.outputPath; + return new ViteAppResourcePromiseImpl(this._publishAsNodeServerInternal(entryPoint, outputPath), this._client); + } + + /** @internal */ + private async _publishAsNpmScriptInternal(startScriptName?: string, runScriptArguments?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (startScriptName !== undefined) rpcArgs.startScriptName = startScriptName; + if (runScriptArguments !== undefined) rpcArgs.runScriptArguments = runScriptArguments; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/publishAsNpmScript', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + publishAsNpmScript(options?: PublishAsNpmScriptOptions): ViteAppResourcePromise { + const startScriptName = options?.startScriptName; + const runScriptArguments = options?.runScriptArguments; + return new ViteAppResourcePromiseImpl(this._publishAsNpmScriptInternal(startScriptName, runScriptArguments), this._client); + } + + /** @internal */ + private async _withViteConfigInternal(configPath: string): Promise { + const rpcArgs: Record = { builder: this._handle, configPath }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/withViteConfig', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withViteConfig(configPath: string): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._withViteConfigInternal(configPath), this._client); + } + + /** @internal */ + private async _withNpmInternal(install?: boolean, installCommand?: string, installArgs?: string[]): Promise { + const rpcArgs: Record = { resource: this._handle }; + if (install !== undefined) rpcArgs.install = install; + if (installCommand !== undefined) rpcArgs.installCommand = installCommand; + if (installArgs !== undefined) rpcArgs.installArgs = installArgs; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/withNpm', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withNpm(options?: WithNpmOptions): ViteAppResourcePromise { + const install = options?.install; + const installCommand = options?.installCommand; + const installArgs = options?.installArgs; + return new ViteAppResourcePromiseImpl(this._withNpmInternal(install, installCommand, installArgs), this._client); + } + + /** @internal */ + private async _withBunInternal(install?: boolean, installArgs?: string[]): Promise { + const rpcArgs: Record = { resource: this._handle }; + if (install !== undefined) rpcArgs.install = install; + if (installArgs !== undefined) rpcArgs.installArgs = installArgs; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/withBun', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withBun(options?: WithBunOptions): ViteAppResourcePromise { + const install = options?.install; + const installArgs = options?.installArgs; + return new ViteAppResourcePromiseImpl(this._withBunInternal(install, installArgs), this._client); + } + + /** @internal */ + private async _withYarnInternal(install?: boolean, installArgs?: string[]): Promise { + const rpcArgs: Record = { resource: this._handle }; + if (install !== undefined) rpcArgs.install = install; + if (installArgs !== undefined) rpcArgs.installArgs = installArgs; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/withYarn', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withYarn(options?: WithYarnOptions): ViteAppResourcePromise { + const install = options?.install; + const installArgs = options?.installArgs; + return new ViteAppResourcePromiseImpl(this._withYarnInternal(install, installArgs), this._client); + } + + /** @internal */ + private async _withPnpmInternal(install?: boolean, installArgs?: string[]): Promise { + const rpcArgs: Record = { resource: this._handle }; + if (install !== undefined) rpcArgs.install = install; + if (installArgs !== undefined) rpcArgs.installArgs = installArgs; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/withPnpm', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withPnpm(options?: WithPnpmOptions): ViteAppResourcePromise { + const install = options?.install; + const installArgs = options?.installArgs; + return new ViteAppResourcePromiseImpl(this._withPnpmInternal(install, installArgs), this._client); + } + + /** @internal */ + private async _withBuildScriptInternal(scriptName: string, args?: string[]): Promise { + const rpcArgs: Record = { resource: this._handle, scriptName }; + if (args !== undefined) rpcArgs.args = args; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/withBuildScript', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withBuildScript(scriptName: string, options?: WithBuildScriptOptions): ViteAppResourcePromise { + const args = options?.args; + return new ViteAppResourcePromiseImpl(this._withBuildScriptInternal(scriptName, args), this._client); + } + + /** @internal */ + private async _withRunScriptInternal(scriptName: string, args?: string[]): Promise { + const rpcArgs: Record = { resource: this._handle, scriptName }; + if (args !== undefined) rpcArgs.args = args; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/withRunScript', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withRunScript(scriptName: string, options?: WithRunScriptOptions): ViteAppResourcePromise { + const args = options?.args; + return new ViteAppResourcePromiseImpl(this._withRunScriptInternal(scriptName, args), this._client); + } + + /** @internal */ + private async _withBrowserDebuggerInternal(browser?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (browser !== undefined) rpcArgs.browser = browser; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/withBrowserDebugger', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withBrowserDebugger(options?: WithBrowserDebuggerOptions): ViteAppResourcePromise { + const browser = options?.browser; + return new ViteAppResourcePromiseImpl(this._withBrowserDebuggerInternal(browser), this._client); + } + + /** @internal */ + private async _withLikeC4ReferenceWithEnvironmentInternal(source: Awaitable, configure?: (obj: LikeC4RelationshipDetailsAnnotation) => Promise, connectionName?: string, optional?: boolean, skipAspireReference?: boolean): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4RelationshipDetailsAnnotationHandle; + const obj = new LikeC4RelationshipDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + source = isPromiseLike(source) ? await source : source; + const rpcArgs: Record = { builder: this._handle, source }; + if (configure !== undefined) rpcArgs.configure = configureId; + if (connectionName !== undefined) rpcArgs.connectionName = connectionName; + if (optional !== undefined) rpcArgs.optional = optional; + if (skipAspireReference !== undefined) rpcArgs.skipAspireReference = skipAspireReference; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4ReferenceWithEnvironment', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): ViteAppResourcePromise { + const configure = options?.configure; + const connectionName = options?.connectionName; + const optional = options?.optional; + const skipAspireReference = options?.skipAspireReference; + return new ViteAppResourcePromiseImpl(this._withLikeC4ReferenceWithEnvironmentInternal(source, configure, connectionName, optional, skipAspireReference), this._client); + } + + /** @internal */ + private async _withLikeC4DetailsInternal(label?: string, technology?: string, description?: string, summary?: string, icon?: string, configure?: (obj: LikeC4NodeDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4NodeDetailsAnnotationHandle; + const obj = new LikeC4NodeDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + const rpcArgs: Record = { builder: this._handle }; + if (label !== undefined) rpcArgs.label = label; + if (technology !== undefined) rpcArgs.technology = technology; + if (description !== undefined) rpcArgs.description = description; + if (summary !== undefined) rpcArgs.summary = summary; + if (icon !== undefined) rpcArgs.icon = icon; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4DetailsParameters', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): ViteAppResourcePromise { + const label = options?.label; + const technology = options?.technology; + const description = options?.description; + const summary = options?.summary; + const icon = options?.icon; + const configure = options?.configure; + return new ViteAppResourcePromiseImpl(this._withLikeC4DetailsInternal(label, technology, description, summary, icon, configure), this._client); + } + + /** @internal */ + private async _withLikeC4ReferenceInternal(target: Awaitable, configure?: (obj: LikeC4RelationshipDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4RelationshipDetailsAnnotationHandle; + const obj = new LikeC4RelationshipDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target }; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Reference', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): ViteAppResourcePromise { + const configure = options?.configure; + return new ViteAppResourcePromiseImpl(this._withLikeC4ReferenceInternal(target, configure), this._client); + } + + /** @internal */ + private async _withLikeC4GroupInternal(groupName: string): Promise { + const rpcArgs: Record = { builder: this._handle, groupName }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Group', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withLikeC4Group(groupName: string): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._withLikeC4GroupInternal(groupName), this._client); + } + + /** @internal */ + private async _excludeFromLikeC4Internal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/excludeFromLikeC4', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + excludeFromLikeC4(): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._excludeFromLikeC4Internal(), this._client); + } + + /** @internal */ + private async _withAzureUserAssignedIdentityInternal(identityResourceBuilder: Awaitable): Promise { + identityResourceBuilder = isPromiseLike(identityResourceBuilder) ? await identityResourceBuilder : identityResourceBuilder; + const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._withAzureUserAssignedIdentityInternal(identityResourceBuilder), this._client); + } + + /** @internal */ + private async _withRoleAssignmentsInternal(target: Awaitable, roles: AzureKeyVaultRole[]): Promise { + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target, roles }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.KeyVault/withKeyVaultRoleAssignments', + rpcArgs + ); + return new ViteAppResourceImpl(result, this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._withRoleAssignmentsInternal(target, roles), this._client); + } + +} + +/** + * Thenable wrapper for ViteAppResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +class ViteAppResourcePromiseImpl implements ViteAppResourcePromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: ViteAppResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + command(): Promise { + return this._promise.then(obj => obj.command()); + } + + workingDirectory(): Promise { + return this._promise.then(obj => obj.workingDirectory()); + } + + name(): Promise { + return this._promise.then(obj => obj.name()); + } + + withContainerRegistry(registry: Awaitable): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withContainerRegistry(registry)), this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withDockerfileBaseImage(options)), this._client); + } + + publishAsDockerFile(configure: (obj: ContainerResource) => Promise): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.publishAsDockerFile(configure)), this._client); + } + + withExecutableCommand(command: string): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withExecutableCommand(command)), this._client); + } + + withWorkingDirectory(workingDirectory: string): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withWorkingDirectory(workingDirectory)), this._client); + } + + withMcpServer(options?: WithMcpServerOptions): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withMcpServer(options)), this._client); + } + + withOtlpExporter(options?: WithOtlpExporterOptions): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withOtlpExporter(options)), this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withRequiredCommand(command, options)), this._client); + } + + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withEnvironment(name, value)), this._client); + } + + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentCallback(callback)), this._client); + } + + withArgs(args: string[]): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withArgs(args)), this._client); + } + + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withArgsCallback(callback)), this._client); + } + + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withReferenceEnvironment(options)), this._client); + } + + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withReference(source, options)), this._client); + } + + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withEndpointCallback(endpointName, callback, options)), this._client); + } + + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withHttpEndpointCallback(callback, options)), this._client); + } + + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withHttpsEndpointCallback(callback, options)), this._client); + } + + withEndpoint(options?: WithEndpointOptions): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withEndpoint(options)), this._client); + } + + withHttpEndpoint(options?: WithHttpEndpointOptions): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withHttpEndpoint(options)), this._client); + } + + withHttpsEndpoint(options?: WithHttpsEndpointOptions): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withHttpsEndpoint(options)), this._client); + } + + withExternalHttpEndpoints(): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withExternalHttpEndpoints()), this._client); + } + + getEndpoint(name: string): Promise { + return this._promise.then(obj => obj.getEndpoint(name)); + } + + asHttp2Service(): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.asHttp2Service()), this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withUrls(callback)), this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withUrl(url, options)), this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback)), this._client); + } + + withContainerFilesSource(sourcePath: string): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withContainerFilesSource(sourcePath)), this._client); + } + + clearContainerFilesSources(): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.clearContainerFilesSources()), this._client); + } + + excludeFromManifest(): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.excludeFromManifest()), this._client); + } + + waitFor(dependency: Awaitable, options?: WaitForOptions): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.waitFor(dependency, options)), this._client); + } + + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.waitForStart(dependency, options)), this._client); + } + + withExplicitStart(): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withExplicitStart()), this._client); + } + + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.waitForCompletion(dependency, options)), this._client); + } + + withHealthCheck(key: string): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withHealthCheck(key)), this._client); + } + + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withHttpHealthCheck(options)), this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options)), this._client); + } + + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withHttpCommand(path, displayName, options)), this._client); + } + + withDeveloperCertificateTrust(trust: boolean): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust)), this._client); + } + + withCertificateTrustScope(scope: CertificateTrustScope): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withCertificateTrustScope(scope)), this._client); + } + + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options)), this._client); + } + + withoutHttpsCertificate(): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withoutHttpsCertificate()), this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withRelationship(resourceBuilder, type)), this._client); + } + + withParentRelationship(parent: Awaitable): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withParentRelationship(parent)), this._client); + } + + withChildRelationship(child: Awaitable): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withChildRelationship(child)), this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withIconName(iconName, options)), this._client); + } + + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withHttpProbe(probeType, options)), this._client); + } + + excludeFromMcp(): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.excludeFromMcp()), this._client); + } + + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withImagePushOptions(callback)), this._client); + } + + withRemoteImageName(remoteImageName: string): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withRemoteImageName(remoteImageName)), this._client); + } + + withRemoteImageTag(remoteImageTag: string): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag)), this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options)), this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withPipelineConfiguration(callback)), this._client); + } + + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.onBeforeResourceStarted(callback)), this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.onResourceStopped(callback)), this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.onInitializeResource(callback)), this._client); + } + + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback)), this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.onResourceReady(callback)), this._client); + } + + createExecutionConfiguration(): Promise { + return this._promise.then(obj => obj.createExecutionConfiguration()); + } + + publishAsStaticWebsite(options?: PublishAsStaticWebsiteOptions): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.publishAsStaticWebsite(options)), this._client); + } + + publishAsNodeServer(entryPoint: string, options?: PublishAsNodeServerOptions): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.publishAsNodeServer(entryPoint, options)), this._client); + } + + publishAsNpmScript(options?: PublishAsNpmScriptOptions): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.publishAsNpmScript(options)), this._client); + } + + withViteConfig(configPath: string): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withViteConfig(configPath)), this._client); + } + + withNpm(options?: WithNpmOptions): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withNpm(options)), this._client); + } + + withBun(options?: WithBunOptions): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withBun(options)), this._client); + } + + withYarn(options?: WithYarnOptions): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withYarn(options)), this._client); + } + + withPnpm(options?: WithPnpmOptions): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withPnpm(options)), this._client); + } + + withBuildScript(scriptName: string, options?: WithBuildScriptOptions): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withBuildScript(scriptName, options)), this._client); + } + + withRunScript(scriptName: string, options?: WithRunScriptOptions): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withRunScript(scriptName, options)), this._client); + } + + withBrowserDebugger(options?: WithBrowserDebuggerOptions): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withBrowserDebugger(options)), this._client); + } + + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4ReferenceWithEnvironment(source, options)), this._client); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Details(options)), this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Reference(target, options)), this._client); + } + + withLikeC4Group(groupName: string): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Group(groupName)), this._client); + } + + excludeFromLikeC4(): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.excludeFromLikeC4()), this._client); + } + + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withAzureUserAssignedIdentity(identityResourceBuilder)), this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): ViteAppResourcePromise { + return new ViteAppResourcePromiseImpl(this._promise.then(obj => obj.withRoleAssignments(target, roles)), this._client); + } + +} + +// ============================================================================ +// AzureResource +// ============================================================================ + +export interface AzureResource { + toJSON(): MarshalledHandle; + /** Publishes an Azure resource to the manifest as a connection string */ + publishAsConnectionString(): AzureResourcePromise; + /** Gets the normalized Bicep identifier for an Azure resource */ + getBicepIdentifier(): Promise; + /** Clears the default Azure role assignments from a resource */ + clearDefaultRoleAssignments(): AzureResourcePromise; + /** Determines whether a resource is marked as existing */ + isExisting(): Promise; + /** Marks an Azure resource as existing in run mode */ + runAsExisting(name: string | ParameterResource | Awaitable, options?: RunAsExistingOptions): AzureResourcePromise; + /** Marks an Azure resource as existing in publish mode */ + publishAsExisting(name: string | ParameterResource | Awaitable, options?: PublishAsExistingOptions): AzureResourcePromise; + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource | Awaitable, options?: AsExistingOptions): AzureResourcePromise; +} + +export interface AzureResourcePromise extends PromiseLike { + /** Publishes an Azure resource to the manifest as a connection string */ + publishAsConnectionString(): AzureResourcePromise; + /** Gets the normalized Bicep identifier for an Azure resource */ + getBicepIdentifier(): Promise; + /** Clears the default Azure role assignments from a resource */ + clearDefaultRoleAssignments(): AzureResourcePromise; + /** Determines whether a resource is marked as existing */ + isExisting(): Promise; + /** Marks an Azure resource as existing in run mode */ + runAsExisting(name: string | ParameterResource | Awaitable, options?: RunAsExistingOptions): AzureResourcePromise; + /** Marks an Azure resource as existing in publish mode */ + publishAsExisting(name: string | ParameterResource | Awaitable, options?: PublishAsExistingOptions): AzureResourcePromise; + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource | Awaitable, options?: AsExistingOptions): AzureResourcePromise; +} + +// ============================================================================ +// AzureResourceImpl +// ============================================================================ + +class AzureResourceImpl extends ResourceBuilderBase implements AzureResource { + constructor(handle: IAzureResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _publishAsConnectionStringInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/publishAsConnectionString', + rpcArgs + ); + return new AzureResourceImpl(result, this._client); + } + + publishAsConnectionString(): AzureResourcePromise { + return new AzureResourcePromiseImpl(this._publishAsConnectionStringInternal(), this._client); + } + + async getBicepIdentifier(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/getBicepIdentifier', + rpcArgs + ); + } + + /** @internal */ + private async _clearDefaultRoleAssignmentsInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/clearDefaultRoleAssignments', + rpcArgs + ); + return new AzureResourceImpl(result, this._client); + } + + clearDefaultRoleAssignments(): AzureResourcePromise { + return new AzureResourcePromiseImpl(this._clearDefaultRoleAssignmentsInternal(), this._client); + } + + async isExisting(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/isExisting', + rpcArgs + ); + } + + /** @internal */ + private async _runAsExistingInternal(name: string | ParameterResource | Awaitable, resourceGroup?: string | ParameterResource | Awaitable): Promise { + name = isPromiseLike(name) ? await name : name; + resourceGroup = isPromiseLike(resourceGroup) ? await resourceGroup : resourceGroup; + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/runAsExisting', + rpcArgs + ); + return new AzureResourceImpl(result, this._client); + } + + runAsExisting(name: string | ParameterResource | Awaitable, options?: RunAsExistingOptions): AzureResourcePromise { + let resourceGroup = options?.resourceGroup; + return new AzureResourcePromiseImpl(this._runAsExistingInternal(name, resourceGroup), this._client); + } + + /** @internal */ + private async _publishAsExistingInternal(name: string | ParameterResource | Awaitable, resourceGroup?: string | ParameterResource | Awaitable): Promise { + name = isPromiseLike(name) ? await name : name; + resourceGroup = isPromiseLike(resourceGroup) ? await resourceGroup : resourceGroup; + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/publishAsExisting', + rpcArgs + ); + return new AzureResourceImpl(result, this._client); + } + + publishAsExisting(name: string | ParameterResource | Awaitable, options?: PublishAsExistingOptions): AzureResourcePromise { + let resourceGroup = options?.resourceGroup; + return new AzureResourcePromiseImpl(this._publishAsExistingInternal(name, resourceGroup), this._client); + } + + /** @internal */ + private async _asExistingInternal(name: string | ParameterResource | Awaitable, resourceGroup?: string | ParameterResource | Awaitable): Promise { + name = isPromiseLike(name) ? await name : name; + resourceGroup = isPromiseLike(resourceGroup) ? await resourceGroup : resourceGroup; + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/asExisting', + rpcArgs + ); + return new AzureResourceImpl(result, this._client); + } + + asExisting(name: string | ParameterResource | Awaitable, options?: AsExistingOptions): AzureResourcePromise { + let resourceGroup = options?.resourceGroup; + return new AzureResourcePromiseImpl(this._asExistingInternal(name, resourceGroup), this._client); + } + +} + +/** + * Thenable wrapper for AzureResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +class AzureResourcePromiseImpl implements AzureResourcePromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: AzureResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + publishAsConnectionString(): AzureResourcePromise { + return new AzureResourcePromiseImpl(this._promise.then(obj => obj.publishAsConnectionString()), this._client); + } + + getBicepIdentifier(): Promise { + return this._promise.then(obj => obj.getBicepIdentifier()); + } + + clearDefaultRoleAssignments(): AzureResourcePromise { + return new AzureResourcePromiseImpl(this._promise.then(obj => obj.clearDefaultRoleAssignments()), this._client); + } + + isExisting(): Promise { + return this._promise.then(obj => obj.isExisting()); + } + + runAsExisting(name: string | ParameterResource | Awaitable, options?: RunAsExistingOptions): AzureResourcePromise { + return new AzureResourcePromiseImpl(this._promise.then(obj => obj.runAsExisting(name, options)), this._client); + } + + publishAsExisting(name: string | ParameterResource | Awaitable, options?: PublishAsExistingOptions): AzureResourcePromise { + return new AzureResourcePromiseImpl(this._promise.then(obj => obj.publishAsExisting(name, options)), this._client); + } + + asExisting(name: string | ParameterResource | Awaitable, options?: AsExistingOptions): AzureResourcePromise { + return new AzureResourcePromiseImpl(this._promise.then(obj => obj.asExisting(name, options)), this._client); + } + +} + +// ============================================================================ +// ComputeResource +// ============================================================================ + +export interface ComputeResource { + toJSON(): MarshalledHandle; + /** Sets image push options via callback */ + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): ComputeResourcePromise; + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): ComputeResourcePromise; + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): ComputeResourcePromise; + /** Associates an Azure user-assigned identity with a compute resource */ + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): ComputeResourcePromise; +} + +export interface ComputeResourcePromise extends PromiseLike { + /** Sets image push options via callback */ + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): ComputeResourcePromise; + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): ComputeResourcePromise; + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): ComputeResourcePromise; + /** Associates an Azure user-assigned identity with a compute resource */ + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): ComputeResourcePromise; +} + +// ============================================================================ +// ComputeResourceImpl +// ============================================================================ + +class ComputeResourceImpl extends ResourceBuilderBase implements ComputeResource { + constructor(handle: IComputeResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withImagePushOptionsInternal(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ContainerImagePushOptionsCallbackContextHandle; + const arg = new ContainerImagePushOptionsCallbackContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImagePushOptions', + rpcArgs + ); + return new ComputeResourceImpl(result, this._client); + } + + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): ComputeResourcePromise { + return new ComputeResourcePromiseImpl(this._withImagePushOptionsInternal(callback), this._client); + } + + /** @internal */ + private async _withRemoteImageNameInternal(remoteImageName: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageName', + rpcArgs + ); + return new ComputeResourceImpl(result, this._client); + } + + withRemoteImageName(remoteImageName: string): ComputeResourcePromise { + return new ComputeResourcePromiseImpl(this._withRemoteImageNameInternal(remoteImageName), this._client); + } + + /** @internal */ + private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageTag', + rpcArgs + ); + return new ComputeResourceImpl(result, this._client); + } + + withRemoteImageTag(remoteImageTag: string): ComputeResourcePromise { + return new ComputeResourcePromiseImpl(this._withRemoteImageTagInternal(remoteImageTag), this._client); + } + + /** @internal */ + private async _withAzureUserAssignedIdentityInternal(identityResourceBuilder: Awaitable): Promise { + identityResourceBuilder = isPromiseLike(identityResourceBuilder) ? await identityResourceBuilder : identityResourceBuilder; + const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', + rpcArgs + ); + return new ComputeResourceImpl(result, this._client); + } + + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): ComputeResourcePromise { + return new ComputeResourcePromiseImpl(this._withAzureUserAssignedIdentityInternal(identityResourceBuilder), this._client); + } + +} + +/** + * Thenable wrapper for ComputeResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +class ComputeResourcePromiseImpl implements ComputeResourcePromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: ComputeResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + withImagePushOptions(callback: (arg: ContainerImagePushOptionsCallbackContext) => Promise): ComputeResourcePromise { + return new ComputeResourcePromiseImpl(this._promise.then(obj => obj.withImagePushOptions(callback)), this._client); + } + + withRemoteImageName(remoteImageName: string): ComputeResourcePromise { + return new ComputeResourcePromiseImpl(this._promise.then(obj => obj.withRemoteImageName(remoteImageName)), this._client); + } + + withRemoteImageTag(remoteImageTag: string): ComputeResourcePromise { + return new ComputeResourcePromiseImpl(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag)), this._client); + } + + withAzureUserAssignedIdentity(identityResourceBuilder: Awaitable): ComputeResourcePromise { + return new ComputeResourcePromiseImpl(this._promise.then(obj => obj.withAzureUserAssignedIdentity(identityResourceBuilder)), this._client); + } + +} + +// ============================================================================ +// ContainerFilesDestinationResource +// ============================================================================ + +export interface ContainerFilesDestinationResource { + toJSON(): MarshalledHandle; + /** Configures the resource to copy container files from the specified source during publishing */ + publishWithContainerFiles(source: Awaitable, destinationPath: string): ContainerFilesDestinationResourcePromise; +} + +export interface ContainerFilesDestinationResourcePromise extends PromiseLike { + /** Configures the resource to copy container files from the specified source during publishing */ + publishWithContainerFiles(source: Awaitable, destinationPath: string): ContainerFilesDestinationResourcePromise; +} + +// ============================================================================ +// ContainerFilesDestinationResourceImpl +// ============================================================================ + +class ContainerFilesDestinationResourceImpl extends ResourceBuilderBase implements ContainerFilesDestinationResource { + constructor(handle: IContainerFilesDestinationResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _publishWithContainerFilesInternal(source: Awaitable, destinationPath: string): Promise { + source = isPromiseLike(source) ? await source : source; + const rpcArgs: Record = { builder: this._handle, source, destinationPath }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishWithContainerFilesFromResource', + rpcArgs + ); + return new ContainerFilesDestinationResourceImpl(result, this._client); + } + + publishWithContainerFiles(source: Awaitable, destinationPath: string): ContainerFilesDestinationResourcePromise { + return new ContainerFilesDestinationResourcePromiseImpl(this._publishWithContainerFilesInternal(source, destinationPath), this._client); + } + +} + +/** + * Thenable wrapper for ContainerFilesDestinationResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +class ContainerFilesDestinationResourcePromiseImpl implements ContainerFilesDestinationResourcePromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: ContainerFilesDestinationResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + publishWithContainerFiles(source: Awaitable, destinationPath: string): ContainerFilesDestinationResourcePromise { + return new ContainerFilesDestinationResourcePromiseImpl(this._promise.then(obj => obj.publishWithContainerFiles(source, destinationPath)), this._client); + } + +} + +// ============================================================================ +// Resource +// ============================================================================ + +export interface Resource { + toJSON(): MarshalledHandle; + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): ResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): ResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): ResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): ResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): ResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): ResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): ResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): ResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): ResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): ResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): ResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): ResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): ResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): ResourcePromise; +} + +export interface ResourcePromise extends PromiseLike { + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: Awaitable): ResourcePromise; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ResourcePromise; + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ResourcePromise; + /** Customizes displayed URLs via callback */ + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): ResourcePromise; + /** Adds or modifies displayed URLs */ + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): ResourcePromise; + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ResourcePromise; + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): ResourcePromise; + /** Prevents resource from starting automatically */ + withExplicitStart(): ResourcePromise; + /** Adds a health check by key */ + withHealthCheck(key: string): ResourcePromise; + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ResourcePromise; + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: Awaitable, type: string): ResourcePromise; + /** Sets the parent relationship */ + withParentRelationship(parent: Awaitable): ResourcePromise; + /** Sets a child relationship */ + withChildRelationship(child: Awaitable): ResourcePromise; + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ResourcePromise; + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ResourcePromise; + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ResourcePromise; + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ResourcePromise; + /** Gets the resource name */ + getResourceName(): Promise; + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ResourcePromise; + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ResourcePromise; + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ResourcePromise; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ResourcePromise; + /** Creates an execution configuration builder */ + createExecutionConfiguration(): Promise; + /** Customises how a resource appears in the generated LikeC4 diagram. */ + withLikeC4Details(options?: WithLikeC4DetailsOptions): ResourcePromise; + /** Customises how the relationship from this resource to the target appears in the generated LikeC4 diagram. */ + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): ResourcePromise; + /** Assigns this resource to a named group in the generated LikeC4 diagram. */ + withLikeC4Group(groupName: string): ResourcePromise; + /** Excludes a resource from the generated LikeC4 diagram. */ + excludeFromLikeC4(): ResourcePromise; + /** Assigns Key Vault roles to a resource */ + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): ResourcePromise; +} + +// ============================================================================ +// ResourceImpl +// ============================================================================ + +class ResourceImpl extends ResourceBuilderBase implements Resource { + constructor(handle: IResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: Awaitable): Promise { + registry = isPromiseLike(registry) ? await registry : registry; + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new ResourceImpl(result, this._client); + } + + withContainerRegistry(registry: Awaitable): ResourcePromise { + return new ResourcePromiseImpl(this._withContainerRegistryInternal(registry), this._client); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new ResourceImpl(result, this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new ResourcePromiseImpl(this._withDockerfileBaseImageInternal(buildImage, runtimeImage), this._client); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new ResourceImpl(result, this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ResourcePromise { + const helpLink = options?.helpLink; + return new ResourcePromiseImpl(this._withRequiredCommandInternal(command, helpLink), this._client); + } + + /** @internal */ + private async _withUrlsInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrls', + rpcArgs + ); + return new ResourceImpl(result, this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): ResourcePromise { + return new ResourcePromiseImpl(this._withUrlsInternal(callback), this._client); + } + + /** @internal */ + private async _withUrlInternal(url: string | ReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new ResourceImpl(result, this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): ResourcePromise { + const displayText = options?.displayText; + return new ResourcePromiseImpl(this._withUrlInternal(url, displayText), this._client); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new ResourceImpl(result, this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ResourcePromise { + return new ResourcePromiseImpl(this._withUrlForEndpointInternal(endpointName, callback), this._client); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new ResourceImpl(result, this._client); + } + + excludeFromManifest(): ResourcePromise { + return new ResourcePromiseImpl(this._excludeFromManifestInternal(), this._client); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new ResourceImpl(result, this._client); + } + + withExplicitStart(): ResourcePromise { + return new ResourcePromiseImpl(this._withExplicitStartInternal(), this._client); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new ResourceImpl(result, this._client); + } + + withHealthCheck(key: string): ResourcePromise { + return new ResourcePromiseImpl(this._withHealthCheckInternal(key), this._client); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContextImpl(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new ResourceImpl(result, this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ResourcePromise { + const commandOptions = options?.commandOptions; + return new ResourcePromiseImpl(this._withCommandInternal(name, displayName, executeCommand, commandOptions), this._client); + } + + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: Awaitable, type: string): Promise { + resourceBuilder = isPromiseLike(resourceBuilder) ? await resourceBuilder : resourceBuilder; + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ResourceImpl(result, this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): ResourcePromise { + return new ResourcePromiseImpl(this._withRelationshipInternal(resourceBuilder, type), this._client); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: Awaitable): Promise { + parent = isPromiseLike(parent) ? await parent : parent; + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new ResourceImpl(result, this._client); + } + + withParentRelationship(parent: Awaitable): ResourcePromise { + return new ResourcePromiseImpl(this._withParentRelationshipInternal(parent), this._client); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: Awaitable): Promise { + child = isPromiseLike(child) ? await child : child; + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', + rpcArgs + ); + return new ResourceImpl(result, this._client); + } + + withChildRelationship(child: Awaitable): ResourcePromise { + return new ResourcePromiseImpl(this._withChildRelationshipInternal(child), this._client); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new ResourceImpl(result, this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): ResourcePromise { + const iconVariant = options?.iconVariant; + return new ResourcePromiseImpl(this._withIconNameInternal(iconName, iconVariant), this._client); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new ResourceImpl(result, this._client); + } + + excludeFromMcp(): ResourcePromise { + return new ResourcePromiseImpl(this._excludeFromMcpInternal(), this._client); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new ResourceImpl(result, this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new ResourcePromiseImpl(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description), this._client); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new ResourceImpl(result, this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ResourcePromise { + return new ResourcePromiseImpl(this._withPipelineConfigurationInternal(callback), this._client); + } + + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); + } + + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new ResourceImpl(result, this._client); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ResourcePromise { + return new ResourcePromiseImpl(this._onBeforeResourceStartedInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new ResourceImpl(result, this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ResourcePromise { + return new ResourcePromiseImpl(this._onResourceStoppedInternal(callback), this._client); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new ResourceImpl(result, this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ResourcePromise { + return new ResourcePromiseImpl(this._onInitializeResourceInternal(callback), this._client); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new ResourceImpl(result, this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ResourcePromise { + return new ResourcePromiseImpl(this._onResourceReadyInternal(callback), this._client); + } + + async createExecutionConfiguration(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/createExecutionConfiguration', + rpcArgs + ); + } + + /** @internal */ + private async _withLikeC4DetailsInternal(label?: string, technology?: string, description?: string, summary?: string, icon?: string, configure?: (obj: LikeC4NodeDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4NodeDetailsAnnotationHandle; + const obj = new LikeC4NodeDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + const rpcArgs: Record = { builder: this._handle }; + if (label !== undefined) rpcArgs.label = label; + if (technology !== undefined) rpcArgs.technology = technology; + if (description !== undefined) rpcArgs.description = description; + if (summary !== undefined) rpcArgs.summary = summary; + if (icon !== undefined) rpcArgs.icon = icon; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4DetailsParameters', + rpcArgs + ); + return new ResourceImpl(result, this._client); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): ResourcePromise { + const label = options?.label; + const technology = options?.technology; + const description = options?.description; + const summary = options?.summary; + const icon = options?.icon; + const configure = options?.configure; + return new ResourcePromiseImpl(this._withLikeC4DetailsInternal(label, technology, description, summary, icon, configure), this._client); + } + + /** @internal */ + private async _withLikeC4ReferenceInternal(target: Awaitable, configure?: (obj: LikeC4RelationshipDetailsAnnotation) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4RelationshipDetailsAnnotationHandle; + const obj = new LikeC4RelationshipDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target }; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Reference', + rpcArgs + ); + return new ResourceImpl(result, this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): ResourcePromise { + const configure = options?.configure; + return new ResourcePromiseImpl(this._withLikeC4ReferenceInternal(target, configure), this._client); + } + + /** @internal */ + private async _withLikeC4GroupInternal(groupName: string): Promise { + const rpcArgs: Record = { builder: this._handle, groupName }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4Group', + rpcArgs + ); + return new ResourceImpl(result, this._client); + } + + withLikeC4Group(groupName: string): ResourcePromise { + return new ResourcePromiseImpl(this._withLikeC4GroupInternal(groupName), this._client); + } + + /** @internal */ + private async _excludeFromLikeC4Internal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/excludeFromLikeC4', + rpcArgs + ); + return new ResourceImpl(result, this._client); + } + + excludeFromLikeC4(): ResourcePromise { + return new ResourcePromiseImpl(this._excludeFromLikeC4Internal(), this._client); + } + + /** @internal */ + private async _withRoleAssignmentsInternal(target: Awaitable, roles: AzureKeyVaultRole[]): Promise { + target = isPromiseLike(target) ? await target : target; + const rpcArgs: Record = { builder: this._handle, target, roles }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.KeyVault/withKeyVaultRoleAssignments', + rpcArgs + ); + return new ResourceImpl(result, this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): ResourcePromise { + return new ResourcePromiseImpl(this._withRoleAssignmentsInternal(target, roles), this._client); + } + +} + +/** + * Thenable wrapper for Resource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +class ResourcePromiseImpl implements ResourcePromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: Resource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + withContainerRegistry(registry: Awaitable): ResourcePromise { + return new ResourcePromiseImpl(this._promise.then(obj => obj.withContainerRegistry(registry)), this._client); + } + + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ResourcePromise { + return new ResourcePromiseImpl(this._promise.then(obj => obj.withDockerfileBaseImage(options)), this._client); + } + + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ResourcePromise { + return new ResourcePromiseImpl(this._promise.then(obj => obj.withRequiredCommand(command, options)), this._client); + } + + withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise): ResourcePromise { + return new ResourcePromiseImpl(this._promise.then(obj => obj.withUrls(callback)), this._client); + } + + withUrl(url: string | ReferenceExpression, options?: WithUrlOptions): ResourcePromise { + return new ResourcePromiseImpl(this._promise.then(obj => obj.withUrl(url, options)), this._client); + } + + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ResourcePromise { + return new ResourcePromiseImpl(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback)), this._client); + } + + excludeFromManifest(): ResourcePromise { + return new ResourcePromiseImpl(this._promise.then(obj => obj.excludeFromManifest()), this._client); + } + + withExplicitStart(): ResourcePromise { + return new ResourcePromiseImpl(this._promise.then(obj => obj.withExplicitStart()), this._client); + } + + withHealthCheck(key: string): ResourcePromise { + return new ResourcePromiseImpl(this._promise.then(obj => obj.withHealthCheck(key)), this._client); + } + + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ResourcePromise { + return new ResourcePromiseImpl(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options)), this._client); + } + + withRelationship(resourceBuilder: Awaitable, type: string): ResourcePromise { + return new ResourcePromiseImpl(this._promise.then(obj => obj.withRelationship(resourceBuilder, type)), this._client); + } + + withParentRelationship(parent: Awaitable): ResourcePromise { + return new ResourcePromiseImpl(this._promise.then(obj => obj.withParentRelationship(parent)), this._client); + } + + withChildRelationship(child: Awaitable): ResourcePromise { + return new ResourcePromiseImpl(this._promise.then(obj => obj.withChildRelationship(child)), this._client); + } + + withIconName(iconName: string, options?: WithIconNameOptions): ResourcePromise { + return new ResourcePromiseImpl(this._promise.then(obj => obj.withIconName(iconName, options)), this._client); + } + + excludeFromMcp(): ResourcePromise { + return new ResourcePromiseImpl(this._promise.then(obj => obj.excludeFromMcp()), this._client); + } + + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ResourcePromise { + return new ResourcePromiseImpl(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options)), this._client); + } + + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ResourcePromise { + return new ResourcePromiseImpl(this._promise.then(obj => obj.withPipelineConfiguration(callback)), this._client); + } + + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ResourcePromise { + return new ResourcePromiseImpl(this._promise.then(obj => obj.onBeforeResourceStarted(callback)), this._client); + } + + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ResourcePromise { + return new ResourcePromiseImpl(this._promise.then(obj => obj.onResourceStopped(callback)), this._client); + } + + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ResourcePromise { + return new ResourcePromiseImpl(this._promise.then(obj => obj.onInitializeResource(callback)), this._client); + } + + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ResourcePromise { + return new ResourcePromiseImpl(this._promise.then(obj => obj.onResourceReady(callback)), this._client); + } + + createExecutionConfiguration(): Promise { + return this._promise.then(obj => obj.createExecutionConfiguration()); + } + + withLikeC4Details(options?: WithLikeC4DetailsOptions): ResourcePromise { + return new ResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Details(options)), this._client); + } + + withLikeC4Reference(target: Awaitable, options?: WithLikeC4ReferenceOptions): ResourcePromise { + return new ResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Reference(target, options)), this._client); + } + + withLikeC4Group(groupName: string): ResourcePromise { + return new ResourcePromiseImpl(this._promise.then(obj => obj.withLikeC4Group(groupName)), this._client); + } + + excludeFromLikeC4(): ResourcePromise { + return new ResourcePromiseImpl(this._promise.then(obj => obj.excludeFromLikeC4()), this._client); + } + + withRoleAssignments(target: Awaitable, roles: AzureKeyVaultRole[]): ResourcePromise { + return new ResourcePromiseImpl(this._promise.then(obj => obj.withRoleAssignments(target, roles)), this._client); + } + +} + +// ============================================================================ +// ResourceWithArgs +// ============================================================================ + +export interface ResourceWithArgs { + toJSON(): MarshalledHandle; + /** Adds arguments */ + withArgs(args: string[]): ResourceWithArgsPromise; + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): ResourceWithArgsPromise; +} + +export interface ResourceWithArgsPromise extends PromiseLike { + /** Adds arguments */ + withArgs(args: string[]): ResourceWithArgsPromise; + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): ResourceWithArgsPromise; +} + +// ============================================================================ +// ResourceWithArgsImpl +// ============================================================================ + +class ResourceWithArgsImpl extends ResourceBuilderBase implements ResourceWithArgs { + constructor(handle: IResourceWithArgsHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withArgsInternal(args: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, args }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgs', + rpcArgs + ); + return new ResourceWithArgsImpl(result, this._client); + } + + withArgs(args: string[]): ResourceWithArgsPromise { + return new ResourceWithArgsPromiseImpl(this._withArgsInternal(args), this._client); + } + + /** @internal */ + private async _withArgsCallbackInternal(callback: (obj: CommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; + const obj = new CommandLineArgsCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallback', + rpcArgs + ); + return new ResourceWithArgsImpl(result, this._client); + } + + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): ResourceWithArgsPromise { + return new ResourceWithArgsPromiseImpl(this._withArgsCallbackInternal(callback), this._client); + } + +} + +/** + * Thenable wrapper for ResourceWithArgs that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +class ResourceWithArgsPromiseImpl implements ResourceWithArgsPromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: ResourceWithArgs) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + withArgs(args: string[]): ResourceWithArgsPromise { + return new ResourceWithArgsPromiseImpl(this._promise.then(obj => obj.withArgs(args)), this._client); + } + + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): ResourceWithArgsPromise { + return new ResourceWithArgsPromiseImpl(this._promise.then(obj => obj.withArgsCallback(callback)), this._client); + } + +} + +// ============================================================================ +// ResourceWithConnectionString +// ============================================================================ + +export interface ResourceWithConnectionString { + toJSON(): MarshalledHandle; + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): ResourceWithConnectionStringPromise; + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise; + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): ResourceWithConnectionStringPromise; +} + +export interface ResourceWithConnectionStringPromise extends PromiseLike { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): ResourceWithConnectionStringPromise; + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise; + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): ResourceWithConnectionStringPromise; +} + +// ============================================================================ +// ResourceWithConnectionStringImpl +// ============================================================================ + +class ResourceWithConnectionStringImpl extends ResourceBuilderBase implements ResourceWithConnectionString { + constructor(handle: IResourceWithConnectionStringHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withConnectionPropertyInternal(name: string, value: string | ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withConnectionProperty', + rpcArgs + ); + return new ResourceWithConnectionStringImpl(result, this._client); + } + + withConnectionProperty(name: string, value: string | ReferenceExpression): ResourceWithConnectionStringPromise { + return new ResourceWithConnectionStringPromiseImpl(this._withConnectionPropertyInternal(name, value), this._client); + } + + async getConnectionProperty(key: string): Promise { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onConnectionStringAvailable', + rpcArgs + ); + return new ResourceWithConnectionStringImpl(result, this._client); + } + + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): ResourceWithConnectionStringPromise { + return new ResourceWithConnectionStringPromiseImpl(this._onConnectionStringAvailableInternal(callback), this._client); + } + +} + +/** + * Thenable wrapper for ResourceWithConnectionString that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +class ResourceWithConnectionStringPromiseImpl implements ResourceWithConnectionStringPromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: ResourceWithConnectionString) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + withConnectionProperty(name: string, value: string | ReferenceExpression): ResourceWithConnectionStringPromise { + return new ResourceWithConnectionStringPromiseImpl(this._promise.then(obj => obj.withConnectionProperty(name, value)), this._client); + } + + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): ResourceWithConnectionStringPromise { + return new ResourceWithConnectionStringPromiseImpl(this._promise.then(obj => obj.onConnectionStringAvailable(callback)), this._client); + } + +} + +// ============================================================================ +// ResourceWithContainerFiles +// ============================================================================ + +export interface ResourceWithContainerFiles { + toJSON(): MarshalledHandle; + /** Sets the source directory for container files */ + withContainerFilesSource(sourcePath: string): ResourceWithContainerFilesPromise; + /** Clears all container file sources */ + clearContainerFilesSources(): ResourceWithContainerFilesPromise; +} + +export interface ResourceWithContainerFilesPromise extends PromiseLike { + /** Sets the source directory for container files */ + withContainerFilesSource(sourcePath: string): ResourceWithContainerFilesPromise; + /** Clears all container file sources */ + clearContainerFilesSources(): ResourceWithContainerFilesPromise; +} + +// ============================================================================ +// ResourceWithContainerFilesImpl +// ============================================================================ + +class ResourceWithContainerFilesImpl extends ResourceBuilderBase implements ResourceWithContainerFiles { + constructor(handle: IResourceWithContainerFilesHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerFilesSourceInternal(sourcePath: string): Promise { + const rpcArgs: Record = { builder: this._handle, sourcePath }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerFilesSource', + rpcArgs + ); + return new ResourceWithContainerFilesImpl(result, this._client); + } + + withContainerFilesSource(sourcePath: string): ResourceWithContainerFilesPromise { + return new ResourceWithContainerFilesPromiseImpl(this._withContainerFilesSourceInternal(sourcePath), this._client); + } + + /** @internal */ + private async _clearContainerFilesSourcesInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/clearContainerFilesSources', + rpcArgs + ); + return new ResourceWithContainerFilesImpl(result, this._client); + } + + clearContainerFilesSources(): ResourceWithContainerFilesPromise { + return new ResourceWithContainerFilesPromiseImpl(this._clearContainerFilesSourcesInternal(), this._client); + } + +} + +/** + * Thenable wrapper for ResourceWithContainerFiles that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +class ResourceWithContainerFilesPromiseImpl implements ResourceWithContainerFilesPromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: ResourceWithContainerFiles) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + withContainerFilesSource(sourcePath: string): ResourceWithContainerFilesPromise { + return new ResourceWithContainerFilesPromiseImpl(this._promise.then(obj => obj.withContainerFilesSource(sourcePath)), this._client); + } + + clearContainerFilesSources(): ResourceWithContainerFilesPromise { + return new ResourceWithContainerFilesPromiseImpl(this._promise.then(obj => obj.clearContainerFilesSources()), this._client); + } + +} + +// ============================================================================ +// ResourceWithEndpoints +// ============================================================================ + +export interface ResourceWithEndpoints { + toJSON(): MarshalledHandle; + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): ResourceWithEndpointsPromise; + /** Updates a named endpoint via callback */ + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): ResourceWithEndpointsPromise; + /** Updates an HTTP endpoint via callback */ + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): ResourceWithEndpointsPromise; + /** Updates an HTTPS endpoint via callback */ + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): ResourceWithEndpointsPromise; + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): ResourceWithEndpointsPromise; + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): ResourceWithEndpointsPromise; + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): ResourceWithEndpointsPromise; + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): ResourceWithEndpointsPromise; + /** Gets an endpoint reference */ + getEndpoint(name: string): Promise; + /** Configures resource for HTTP/2 */ + asHttp2Service(): ResourceWithEndpointsPromise; + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ResourceWithEndpointsPromise; + /** Adds an HTTP resource command */ + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): ResourceWithEndpointsPromise; + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ResourceWithEndpointsPromise; + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ResourceWithEndpointsPromise; +} + +export interface ResourceWithEndpointsPromise extends PromiseLike { + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): ResourceWithEndpointsPromise; + /** Updates a named endpoint via callback */ + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): ResourceWithEndpointsPromise; + /** Updates an HTTP endpoint via callback */ + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): ResourceWithEndpointsPromise; + /** Updates an HTTPS endpoint via callback */ + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): ResourceWithEndpointsPromise; + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): ResourceWithEndpointsPromise; + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): ResourceWithEndpointsPromise; + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): ResourceWithEndpointsPromise; + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): ResourceWithEndpointsPromise; + /** Gets an endpoint reference */ + getEndpoint(name: string): Promise; + /** Configures resource for HTTP/2 */ + asHttp2Service(): ResourceWithEndpointsPromise; + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ResourceWithEndpointsPromise; + /** Adds an HTTP resource command */ + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): ResourceWithEndpointsPromise; + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ResourceWithEndpointsPromise; + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ResourceWithEndpointsPromise; +} + +// ============================================================================ +// ResourceWithEndpointsImpl +// ============================================================================ + +class ResourceWithEndpointsImpl extends ResourceBuilderBase implements ResourceWithEndpoints { + constructor(handle: IResourceWithEndpointsHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withMcpServer', + rpcArgs + ); + return new ResourceWithEndpointsImpl(result, this._client); + } + + withMcpServer(options?: WithMcpServerOptions): ResourceWithEndpointsPromise { + const path = options?.path; + const endpointName = options?.endpointName; + return new ResourceWithEndpointsPromiseImpl(this._withMcpServerInternal(path, endpointName), this._client); + } + + /** @internal */ + private async _withEndpointCallbackInternal(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpointCallback', + rpcArgs + ); + return new ResourceWithEndpointsImpl(result, this._client); + } + + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): ResourceWithEndpointsPromise { + const createIfNotExists = options?.createIfNotExists; + return new ResourceWithEndpointsPromiseImpl(this._withEndpointCallbackInternal(endpointName, callback, createIfNotExists), this._client); + } + + /** @internal */ + private async _withHttpEndpointCallbackInternal(callback: (obj: EndpointUpdateContext) => Promise, name?: string, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + if (name !== undefined) rpcArgs.name = name; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpEndpointCallback', + rpcArgs + ); + return new ResourceWithEndpointsImpl(result, this._client); + } + + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): ResourceWithEndpointsPromise { + const name = options?.name; + const createIfNotExists = options?.createIfNotExists; + return new ResourceWithEndpointsPromiseImpl(this._withHttpEndpointCallbackInternal(callback, name, createIfNotExists), this._client); + } + + /** @internal */ + private async _withHttpsEndpointCallbackInternal(callback: (obj: EndpointUpdateContext) => Promise, name?: string, createIfNotExists?: boolean): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EndpointUpdateContextHandle; + const obj = new EndpointUpdateContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + if (name !== undefined) rpcArgs.name = name; + if (createIfNotExists !== undefined) rpcArgs.createIfNotExists = createIfNotExists; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsEndpointCallback', + rpcArgs + ); + return new ResourceWithEndpointsImpl(result, this._client); + } + + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): ResourceWithEndpointsPromise { + const name = options?.name; + const createIfNotExists = options?.createIfNotExists; + return new ResourceWithEndpointsPromiseImpl(this._withHttpsEndpointCallbackInternal(callback, name, createIfNotExists), this._client); + } + + /** @internal */ + private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (scheme !== undefined) rpcArgs.scheme = scheme; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + if (isExternal !== undefined) rpcArgs.isExternal = isExternal; + if (protocol !== undefined) rpcArgs.protocol = protocol; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpoint', + rpcArgs + ); + return new ResourceWithEndpointsImpl(result, this._client); + } + + withEndpoint(options?: WithEndpointOptions): ResourceWithEndpointsPromise { + const port = options?.port; + const targetPort = options?.targetPort; + const scheme = options?.scheme; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + const isExternal = options?.isExternal; + const protocol = options?.protocol; + return new ResourceWithEndpointsPromiseImpl(this._withEndpointInternal(port, targetPort, scheme, name, env, isProxied, isExternal, protocol), this._client); + } + + /** @internal */ + private async _withHttpEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpEndpoint', + rpcArgs + ); + return new ResourceWithEndpointsImpl(result, this._client); + } + + withHttpEndpoint(options?: WithHttpEndpointOptions): ResourceWithEndpointsPromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new ResourceWithEndpointsPromiseImpl(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied), this._client); + } + + /** @internal */ + private async _withHttpsEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsEndpoint', + rpcArgs + ); + return new ResourceWithEndpointsImpl(result, this._client); + } + + withHttpsEndpoint(options?: WithHttpsEndpointOptions): ResourceWithEndpointsPromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new ResourceWithEndpointsPromiseImpl(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied), this._client); + } + + /** @internal */ + private async _withExternalHttpEndpointsInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExternalHttpEndpoints', + rpcArgs + ); + return new ResourceWithEndpointsImpl(result, this._client); + } + + withExternalHttpEndpoints(): ResourceWithEndpointsPromise { + return new ResourceWithEndpointsPromiseImpl(this._withExternalHttpEndpointsInternal(), this._client); + } + + async getEndpoint(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getEndpoint', + rpcArgs + ); + } + + /** @internal */ + private async _asHttp2ServiceInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/asHttp2Service', + rpcArgs + ); + return new ResourceWithEndpointsImpl(result, this._client); + } + + asHttp2Service(): ResourceWithEndpointsPromise { + return new ResourceWithEndpointsPromiseImpl(this._asHttp2ServiceInternal(), this._client); + } + + /** @internal */ + private async _withHttpHealthCheckInternal(path?: string, statusCode?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (statusCode !== undefined) rpcArgs.statusCode = statusCode; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpHealthCheck', + rpcArgs + ); + return new ResourceWithEndpointsImpl(result, this._client); + } + + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ResourceWithEndpointsPromise { + const path = options?.path; + const statusCode = options?.statusCode; + const endpointName = options?.endpointName; + return new ResourceWithEndpointsPromiseImpl(this._withHttpHealthCheckInternal(path, statusCode, endpointName), this._client); + } + + /** @internal */ + private async _withHttpCommandInternal(path: string, displayName: string, options?: HttpCommandExportOptions): Promise { + const rpcArgs: Record = { builder: this._handle, path, displayName }; + if (options !== undefined) rpcArgs.options = options; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpCommand', + rpcArgs + ); + return new ResourceWithEndpointsImpl(result, this._client); + } + + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): ResourceWithEndpointsPromise { + return new ResourceWithEndpointsPromiseImpl(this._withHttpCommandInternal(path, displayName, options), this._client); + } + + /** @internal */ + private async _withHttpProbeInternal(probeType: ProbeType, path?: string, initialDelaySeconds?: number, periodSeconds?: number, timeoutSeconds?: number, failureThreshold?: number, successThreshold?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, probeType }; + if (path !== undefined) rpcArgs.path = path; + if (initialDelaySeconds !== undefined) rpcArgs.initialDelaySeconds = initialDelaySeconds; + if (periodSeconds !== undefined) rpcArgs.periodSeconds = periodSeconds; + if (timeoutSeconds !== undefined) rpcArgs.timeoutSeconds = timeoutSeconds; + if (failureThreshold !== undefined) rpcArgs.failureThreshold = failureThreshold; + if (successThreshold !== undefined) rpcArgs.successThreshold = successThreshold; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpProbe', + rpcArgs + ); + return new ResourceWithEndpointsImpl(result, this._client); + } + + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ResourceWithEndpointsPromise { + const path = options?.path; + const initialDelaySeconds = options?.initialDelaySeconds; + const periodSeconds = options?.periodSeconds; + const timeoutSeconds = options?.timeoutSeconds; + const failureThreshold = options?.failureThreshold; + const successThreshold = options?.successThreshold; + const endpointName = options?.endpointName; + return new ResourceWithEndpointsPromiseImpl(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName), this._client); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEventImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceEndpointsAllocated', + rpcArgs + ); + return new ResourceWithEndpointsImpl(result, this._client); + } + + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ResourceWithEndpointsPromise { + return new ResourceWithEndpointsPromiseImpl(this._onResourceEndpointsAllocatedInternal(callback), this._client); + } + +} + +/** + * Thenable wrapper for ResourceWithEndpoints that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +class ResourceWithEndpointsPromiseImpl implements ResourceWithEndpointsPromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: ResourceWithEndpoints) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + withMcpServer(options?: WithMcpServerOptions): ResourceWithEndpointsPromise { + return new ResourceWithEndpointsPromiseImpl(this._promise.then(obj => obj.withMcpServer(options)), this._client); + } + + withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise, options?: WithEndpointCallbackOptions): ResourceWithEndpointsPromise { + return new ResourceWithEndpointsPromiseImpl(this._promise.then(obj => obj.withEndpointCallback(endpointName, callback, options)), this._client); + } + + withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpEndpointCallbackOptions): ResourceWithEndpointsPromise { + return new ResourceWithEndpointsPromiseImpl(this._promise.then(obj => obj.withHttpEndpointCallback(callback, options)), this._client); + } + + withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise, options?: WithHttpsEndpointCallbackOptions): ResourceWithEndpointsPromise { + return new ResourceWithEndpointsPromiseImpl(this._promise.then(obj => obj.withHttpsEndpointCallback(callback, options)), this._client); + } + + withEndpoint(options?: WithEndpointOptions): ResourceWithEndpointsPromise { + return new ResourceWithEndpointsPromiseImpl(this._promise.then(obj => obj.withEndpoint(options)), this._client); + } + + withHttpEndpoint(options?: WithHttpEndpointOptions): ResourceWithEndpointsPromise { + return new ResourceWithEndpointsPromiseImpl(this._promise.then(obj => obj.withHttpEndpoint(options)), this._client); + } + + withHttpsEndpoint(options?: WithHttpsEndpointOptions): ResourceWithEndpointsPromise { + return new ResourceWithEndpointsPromiseImpl(this._promise.then(obj => obj.withHttpsEndpoint(options)), this._client); + } + + withExternalHttpEndpoints(): ResourceWithEndpointsPromise { + return new ResourceWithEndpointsPromiseImpl(this._promise.then(obj => obj.withExternalHttpEndpoints()), this._client); + } + + getEndpoint(name: string): Promise { + return this._promise.then(obj => obj.getEndpoint(name)); + } + + asHttp2Service(): ResourceWithEndpointsPromise { + return new ResourceWithEndpointsPromiseImpl(this._promise.then(obj => obj.asHttp2Service()), this._client); + } + + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ResourceWithEndpointsPromise { + return new ResourceWithEndpointsPromiseImpl(this._promise.then(obj => obj.withHttpHealthCheck(options)), this._client); + } + + withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): ResourceWithEndpointsPromise { + return new ResourceWithEndpointsPromiseImpl(this._promise.then(obj => obj.withHttpCommand(path, displayName, options)), this._client); + } + + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ResourceWithEndpointsPromise { + return new ResourceWithEndpointsPromiseImpl(this._promise.then(obj => obj.withHttpProbe(probeType, options)), this._client); + } + + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ResourceWithEndpointsPromise { + return new ResourceWithEndpointsPromiseImpl(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback)), this._client); + } + +} + +// ============================================================================ +// ResourceWithEnvironment +// ============================================================================ + +export interface ResourceWithEnvironment { + toJSON(): MarshalledHandle; + /** Configures OTLP telemetry export */ + withOtlpExporter(options?: WithOtlpExporterOptions): ResourceWithEnvironmentPromise; + /** Sets an environment variable */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): ResourceWithEnvironmentPromise; + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise; + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ResourceWithEnvironmentPromise; + /** Adds a reference to another resource */ + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): ResourceWithEnvironmentPromise; + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): ResourceWithEnvironmentPromise; + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): ResourceWithEnvironmentPromise; + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ResourceWithEnvironmentPromise; + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): ResourceWithEnvironmentPromise; + /** Create a new reference, while also allowing customization of how a resource appears in the generated LikeC4 diagram. */ + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): ResourceWithEnvironmentPromise; +} + +export interface ResourceWithEnvironmentPromise extends PromiseLike { + /** Configures OTLP telemetry export */ + withOtlpExporter(options?: WithOtlpExporterOptions): ResourceWithEnvironmentPromise; + /** Sets an environment variable */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): ResourceWithEnvironmentPromise; + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise; + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ResourceWithEnvironmentPromise; + /** Adds a reference to another resource */ + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): ResourceWithEnvironmentPromise; + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): ResourceWithEnvironmentPromise; + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): ResourceWithEnvironmentPromise; + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ResourceWithEnvironmentPromise; + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): ResourceWithEnvironmentPromise; + /** Create a new reference, while also allowing customization of how a resource appears in the generated LikeC4 diagram. */ + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): ResourceWithEnvironmentPromise; +} + +// ============================================================================ +// ResourceWithEnvironmentImpl +// ============================================================================ + +class ResourceWithEnvironmentImpl extends ResourceBuilderBase implements ResourceWithEnvironment { + constructor(handle: IResourceWithEnvironmentHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withOtlpExporterInternal(protocol?: OtlpProtocol): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (protocol !== undefined) rpcArgs.protocol = protocol; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporter', + rpcArgs + ); + return new ResourceWithEnvironmentImpl(result, this._client); + } + + withOtlpExporter(options?: WithOtlpExporterOptions): ResourceWithEnvironmentPromise { + const protocol = options?.protocol; + return new ResourceWithEnvironmentPromiseImpl(this._withOtlpExporterInternal(protocol), this._client); + } + + /** @internal */ + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): Promise { + value = isPromiseLike(value) ? await value : value; + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironment', + rpcArgs + ); + return new ResourceWithEnvironmentImpl(result, this._client); + } + + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromiseImpl(this._withEnvironmentInternal(name, value), this._client); + } + + /** @internal */ + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContextImpl(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentCallback', + rpcArgs + ); + return new ResourceWithEnvironmentImpl(result, this._client); + } + + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromiseImpl(this._withEnvironmentCallbackInternal(callback), this._client); + } + + /** @internal */ + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceEnvironment', + rpcArgs + ); + return new ResourceWithEnvironmentImpl(result, this._client); + } + + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromiseImpl(this._withReferenceEnvironmentInternal(options), this._client); + } + + /** @internal */ + private async _withReferenceInternal(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, connectionName?: string, optional?: boolean, name?: string): Promise { + source = isPromiseLike(source) ? await source : source; + const rpcArgs: Record = { builder: this._handle, source }; + if (connectionName !== undefined) rpcArgs.connectionName = connectionName; + if (optional !== undefined) rpcArgs.optional = optional; + if (name !== undefined) rpcArgs.name = name; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReference', + rpcArgs + ); + return new ResourceWithEnvironmentImpl(result, this._client); + } + + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): ResourceWithEnvironmentPromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new ResourceWithEnvironmentPromiseImpl(this._withReferenceInternal(source, connectionName, optional, name), this._client); + } + + /** @internal */ + private async _withDeveloperCertificateTrustInternal(trust: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, trust }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDeveloperCertificateTrust', + rpcArgs + ); + return new ResourceWithEnvironmentImpl(result, this._client); + } + + withDeveloperCertificateTrust(trust: boolean): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromiseImpl(this._withDeveloperCertificateTrustInternal(trust), this._client); + } + + /** @internal */ + private async _withCertificateTrustScopeInternal(scope: CertificateTrustScope): Promise { + const rpcArgs: Record = { builder: this._handle, scope }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCertificateTrustScope', + rpcArgs + ); + return new ResourceWithEnvironmentImpl(result, this._client); + } + + withCertificateTrustScope(scope: CertificateTrustScope): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromiseImpl(this._withCertificateTrustScopeInternal(scope), this._client); + } + + /** @internal */ + private async _withHttpsDeveloperCertificateInternal(password?: Awaitable): Promise { + password = isPromiseLike(password) ? await password : password; + const rpcArgs: Record = { builder: this._handle }; + if (password !== undefined) rpcArgs.password = password; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', + rpcArgs + ); + return new ResourceWithEnvironmentImpl(result, this._client); + } + + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ResourceWithEnvironmentPromise { + let password = options?.password; + return new ResourceWithEnvironmentPromiseImpl(this._withHttpsDeveloperCertificateInternal(password), this._client); + } + + /** @internal */ + private async _withoutHttpsCertificateInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withoutHttpsCertificate', + rpcArgs + ); + return new ResourceWithEnvironmentImpl(result, this._client); + } + + withoutHttpsCertificate(): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromiseImpl(this._withoutHttpsCertificateInternal(), this._client); + } + + /** @internal */ + private async _withLikeC4ReferenceWithEnvironmentInternal(source: Awaitable, configure?: (obj: LikeC4RelationshipDetailsAnnotation) => Promise, connectionName?: string, optional?: boolean, skipAspireReference?: boolean): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as LikeC4RelationshipDetailsAnnotationHandle; + const obj = new LikeC4RelationshipDetailsAnnotationImpl(objHandle, this._client); + await configure(obj); + }) : undefined; + source = isPromiseLike(source) ? await source : source; + const rpcArgs: Record = { builder: this._handle, source }; + if (configure !== undefined) rpcArgs.configure = configureId; + if (connectionName !== undefined) rpcArgs.connectionName = connectionName; + if (optional !== undefined) rpcArgs.optional = optional; + if (skipAspireReference !== undefined) rpcArgs.skipAspireReference = skipAspireReference; + const result = await this._client.invokeCapability( + 'AspireC4.Hosting/withLikeC4ReferenceWithEnvironment', + rpcArgs + ); + return new ResourceWithEnvironmentImpl(result, this._client); + } + + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): ResourceWithEnvironmentPromise { + const configure = options?.configure; + const connectionName = options?.connectionName; + const optional = options?.optional; + const skipAspireReference = options?.skipAspireReference; + return new ResourceWithEnvironmentPromiseImpl(this._withLikeC4ReferenceWithEnvironmentInternal(source, configure, connectionName, optional, skipAspireReference), this._client); + } + +} + +/** + * Thenable wrapper for ResourceWithEnvironment that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +class ResourceWithEnvironmentPromiseImpl implements ResourceWithEnvironmentPromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: ResourceWithEnvironment) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + withOtlpExporter(options?: WithOtlpExporterOptions): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromiseImpl(this._promise.then(obj => obj.withOtlpExporter(options)), this._client); + } + + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | AzureKeyVaultResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | PostgresDatabaseResource | PostgresServerResource | RedisResource | ResourceWithConnectionString | AzureKeyVaultSecretResource | BicepOutputReference | EndpointReferenceExpression | Awaitable): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromiseImpl(this._promise.then(obj => obj.withEnvironment(name, value)), this._client); + } + + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromiseImpl(this._promise.then(obj => obj.withEnvironmentCallback(callback)), this._client); + } + + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromiseImpl(this._promise.then(obj => obj.withReferenceEnvironment(options)), this._client); + } + + withReference(source: AspireC4Resource | AzureBicepResource | AzureEnvironmentResource | AzureKeyVaultResource | AzureKeyVaultSecretResource | AzureManagedRedisResource | AzurePostgresFlexibleServerDatabaseResource | AzurePostgresFlexibleServerResource | AzureProvisioningResource | AzureResource | AzureUserAssignedIdentityResource | CSharpAppResource | ComputeResource | ContainerFilesDestinationResource | ContainerRegistryResource | ContainerResource | DotnetToolResource | ExecutableResource | ExternalServiceResource | JavaScriptAppResource | NextJsAppResource | NodeAppResource | ParameterResource | PgAdminContainerResource | PgWebContainerResource | PostgresDatabaseResource | PostgresMcpContainerResource | PostgresServerResource | ProjectResource | RedisCommanderResource | RedisInsightResource | RedisResource | Resource | ResourceWithArgs | ResourceWithConnectionString | ResourceWithContainerFiles | ResourceWithEndpoints | ResourceWithEnvironment | ResourceWithServiceDiscovery | ResourceWithWaitSupport | ViteAppResource | EndpointReference | string | Awaitable, options?: WithReferenceOptions): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromiseImpl(this._promise.then(obj => obj.withReference(source, options)), this._client); + } + + withDeveloperCertificateTrust(trust: boolean): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromiseImpl(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust)), this._client); + } + + withCertificateTrustScope(scope: CertificateTrustScope): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromiseImpl(this._promise.then(obj => obj.withCertificateTrustScope(scope)), this._client); + } + + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromiseImpl(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options)), this._client); + } + + withoutHttpsCertificate(): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromiseImpl(this._promise.then(obj => obj.withoutHttpsCertificate()), this._client); + } + + withLikeC4ReferenceWithEnvironment(source: Awaitable, options?: WithLikeC4ReferenceWithEnvironmentOptions): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromiseImpl(this._promise.then(obj => obj.withLikeC4ReferenceWithEnvironment(source, options)), this._client); + } + +} + +// ============================================================================ +// ResourceWithServiceDiscovery +// ============================================================================ + +export interface ResourceWithServiceDiscovery { + toJSON(): MarshalledHandle; +} + +// ============================================================================ +// ResourceWithServiceDiscoveryImpl +// ============================================================================ + +class ResourceWithServiceDiscoveryImpl extends ResourceBuilderBase implements ResourceWithServiceDiscovery { + constructor(handle: IResourceWithServiceDiscoveryHandle, client: AspireClientRpc) { + super(handle, client); + } + +} + +// ============================================================================ +// ResourceWithWaitSupport +// ============================================================================ + +export interface ResourceWithWaitSupport { + toJSON(): MarshalledHandle; + /** Waits for another resource to be ready */ + waitFor(dependency: Awaitable, options?: WaitForOptions): ResourceWithWaitSupportPromise; + /** Waits for another resource to start */ + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): ResourceWithWaitSupportPromise; + /** Waits for resource completion */ + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): ResourceWithWaitSupportPromise; +} + +export interface ResourceWithWaitSupportPromise extends PromiseLike { + /** Waits for another resource to be ready */ + waitFor(dependency: Awaitable, options?: WaitForOptions): ResourceWithWaitSupportPromise; + /** Waits for another resource to start */ + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): ResourceWithWaitSupportPromise; + /** Waits for resource completion */ + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): ResourceWithWaitSupportPromise; +} + +// ============================================================================ +// ResourceWithWaitSupportImpl +// ============================================================================ + +class ResourceWithWaitSupportImpl extends ResourceBuilderBase implements ResourceWithWaitSupport { + constructor(handle: IResourceWithWaitSupportHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _waitForInternal(dependency: Awaitable, waitBehavior?: WaitBehavior): Promise { + dependency = isPromiseLike(dependency) ? await dependency : dependency; + const rpcArgs: Record = { builder: this._handle, dependency }; + if (waitBehavior !== undefined) rpcArgs.waitBehavior = waitBehavior; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitFor', + rpcArgs + ); + return new ResourceWithWaitSupportImpl(result, this._client); + } + + waitFor(dependency: Awaitable, options?: WaitForOptions): ResourceWithWaitSupportPromise { + const waitBehavior = options?.waitBehavior; + return new ResourceWithWaitSupportPromiseImpl(this._waitForInternal(dependency, waitBehavior), this._client); + } + + /** @internal */ + private async _waitForStartInternal(dependency: Awaitable, waitBehavior?: WaitBehavior): Promise { + dependency = isPromiseLike(dependency) ? await dependency : dependency; + const rpcArgs: Record = { builder: this._handle, dependency }; + if (waitBehavior !== undefined) rpcArgs.waitBehavior = waitBehavior; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStart', + rpcArgs + ); + return new ResourceWithWaitSupportImpl(result, this._client); + } + + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): ResourceWithWaitSupportPromise { + const waitBehavior = options?.waitBehavior; + return new ResourceWithWaitSupportPromiseImpl(this._waitForStartInternal(dependency, waitBehavior), this._client); + } + + /** @internal */ + private async _waitForCompletionInternal(dependency: Awaitable, exitCode?: number): Promise { + dependency = isPromiseLike(dependency) ? await dependency : dependency; + const rpcArgs: Record = { builder: this._handle, dependency }; + if (exitCode !== undefined) rpcArgs.exitCode = exitCode; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceCompletion', + rpcArgs + ); + return new ResourceWithWaitSupportImpl(result, this._client); + } + + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): ResourceWithWaitSupportPromise { + const exitCode = options?.exitCode; + return new ResourceWithWaitSupportPromiseImpl(this._waitForCompletionInternal(dependency, exitCode), this._client); + } + +} + +/** + * Thenable wrapper for ResourceWithWaitSupport that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +class ResourceWithWaitSupportPromiseImpl implements ResourceWithWaitSupportPromise { + constructor(private _promise: Promise, private _client: AspireClientRpc, track = true) { + if (track) { _client.trackPromise(_promise); } + } + + then( + onfulfilled?: ((value: ResourceWithWaitSupport) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + waitFor(dependency: Awaitable, options?: WaitForOptions): ResourceWithWaitSupportPromise { + return new ResourceWithWaitSupportPromiseImpl(this._promise.then(obj => obj.waitFor(dependency, options)), this._client); + } + + waitForStart(dependency: Awaitable, options?: WaitForStartOptions): ResourceWithWaitSupportPromise { + return new ResourceWithWaitSupportPromiseImpl(this._promise.then(obj => obj.waitForStart(dependency, options)), this._client); + } + + waitForCompletion(dependency: Awaitable, options?: WaitForCompletionOptions): ResourceWithWaitSupportPromise { + return new ResourceWithWaitSupportPromiseImpl(this._promise.then(obj => obj.waitForCompletion(dependency, options)), this._client); + } + +} + +// ============================================================================ +// Connection Helper +// ============================================================================ + +/** + * Creates and connects to the Aspire AppHost. + * Reads connection info from environment variables set by `aspire run`. + */ +export async function connect(): Promise { + const socketPath = process.env.REMOTE_APP_HOST_SOCKET_PATH; + if (!socketPath) { + throw new Error( + 'REMOTE_APP_HOST_SOCKET_PATH environment variable not set. ' + + 'Run this application using `aspire run`.' + ); + } + + const client = new AspireClient(socketPath); + await client.connect(); + + // Exit the process if the server connection is lost + client.onDisconnect(() => { + console.error('Connection to AppHost lost. Exiting...'); + process.exit(1); + }); + + return client; +} + +/** + * Creates a new distributed application builder. + * This is the entry point for building Aspire applications. + * + * @param options - Optional configuration options for the builder + * @returns A DistributedApplicationBuilder instance + * + * @example + * const builder = await createBuilder(); + * await builder.addRedis("cache"); + * await builder.addContainer("api", "mcr.microsoft.com/dotnet/samples:aspnetapp"); + * const app = await builder.build(); + * await app.run(); + */ +export async function createBuilder(options?: CreateBuilderOptions): Promise { + const client = await connect(); + + // Apply client-side options before any tracking begins + if (options?.throwOnPendingRejections === false) { + client.throwOnPendingRejections = false; + } + + // Default args, projectDirectory, and appHostFilePath if not provided + // ASPIRE_APPHOST_FILEPATH is set by the CLI for consistent socket hash computation + const effectiveOptions: CreateBuilderOptions = { + ...options, + args: options?.args ?? process.argv.slice(2), + projectDirectory: options?.projectDirectory ?? process.env.ASPIRE_PROJECT_DIRECTORY ?? process.cwd(), + appHostFilePath: options?.appHostFilePath ?? process.env.ASPIRE_APPHOST_FILEPATH + }; + + // Strip client-only options before sending to the host + delete effectiveOptions.throwOnPendingRejections; + + const handle = await client.invokeCapability( + 'Aspire.Hosting/createBuilder', + { argsOrOptions: effectiveOptions } + ); + return new DistributedApplicationBuilderImpl(handle, client); +} + +// Re-export commonly used types +export { Handle, AppHostUsageError, CancellationToken, CapabilityError, registerCallback } from './transport.js'; +export { refExpr, ReferenceExpression } from './base.js'; +export type { HandleReference, Awaitable } from './base.js'; + +// ============================================================================ +// Global Error Handling +// ============================================================================ + +/** + * Set up global error handlers to ensure the process exits properly on errors. + * Node.js doesn't exit on unhandled rejections by default, so we need to handle them. + */ +process.on('unhandledRejection', (reason: unknown) => { + const error = reason instanceof Error ? reason : new Error(String(reason)); + + if (reason instanceof AppHostUsageError) { + console.error(`\n❌ AppHost Error: ${error.message}`); + } else if (reason instanceof CapabilityError) { + console.error(`\n❌ Capability Error: ${error.message}`); + console.error(` Code: ${(reason as CapabilityError).code}`); + if ((reason as CapabilityError).capability) { + console.error(` Capability: ${(reason as CapabilityError).capability}`); + } + } else { + console.error(`\n❌ Unhandled Error: ${error.message}`); + if (error.stack) { + console.error(error.stack); + } + } + + process.exit(1); +}); + +process.on('uncaughtException', (error: Error) => { + if (error instanceof AppHostUsageError) { + console.error(`\n❌ AppHost Error: ${error.message}`); + } else if (error instanceof CapabilityError) { + console.error(`\n❌ Capability Error: ${error.message}`); + console.error(` Code: ${error.code}`); + if (error.capability) { + console.error(` Capability: ${error.capability}`); + } + } else { + console.error(`\n❌ Uncaught Exception: ${error.message}`); + } + // Suppress stack traces for structured errors (AppHostUsageError, CapabilityError) + // to keep polyglot output clean. Use --verbose for full diagnostics. + if (!(error instanceof AppHostUsageError) && !(error instanceof CapabilityError) && error.stack) { + console.error(error.stack); + } + process.exit(1); +}); + +// ============================================================================ +// Handle Wrapper Registrations +// ============================================================================ + +// Register wrapper factories for typed handle wrapping in callbacks +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.AfterResourcesCreatedEvent', (handle, client) => new AfterResourcesCreatedEventImpl(handle as AfterResourcesCreatedEventHandle, client)); +registerHandleWrapper('AspireC4.Hosting/Aspire.Hosting.AspireC4.AspireC4DiagramOptions', (handle, client) => new AspireC4DiagramOptionsImpl(handle as AspireC4DiagramOptionsHandle, client)); +registerHandleWrapper('Aspire.Hosting.Azure/Aspire.Hosting.Azure.AzureResourceInfrastructure', (handle, client) => new AzureResourceInfrastructureImpl(handle as AzureResourceInfrastructureHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.BeforeResourceStartedEvent', (handle, client) => new BeforeResourceStartedEventImpl(handle as BeforeResourceStartedEventHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.BeforeStartEvent', (handle, client) => new BeforeStartEventImpl(handle as BeforeStartEventHandle, client)); +registerHandleWrapper('Aspire.Hosting.Azure/Aspire.Hosting.Azure.BicepOutputReference', (handle, client) => new BicepOutputReferenceImpl(handle as BicepOutputReferenceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.CommandLineArgsCallbackContext', (handle, client) => new CommandLineArgsCallbackContextImpl(handle as CommandLineArgsCallbackContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.CommandLineArgsEditor', (handle, client) => new CommandLineArgsEditorImpl(handle as CommandLineArgsEditorHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ConnectionStringAvailableEvent', (handle, client) => new ConnectionStringAvailableEventImpl(handle as ConnectionStringAvailableEventHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ContainerImagePushOptions', (handle, client) => new ContainerImagePushOptionsImpl(handle as ContainerImagePushOptionsHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ContainerImagePushOptionsCallbackContext', (handle, client) => new ContainerImagePushOptionsCallbackContextImpl(handle as ContainerImagePushOptionsCallbackContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.DistributedApplication', (handle, client) => new DistributedApplicationImpl(handle as DistributedApplicationHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.DistributedApplicationExecutionContext', (handle, client) => new DistributedApplicationExecutionContextImpl(handle as DistributedApplicationExecutionContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.DistributedApplicationModel', (handle, client) => new DistributedApplicationModelImpl(handle as DistributedApplicationModelHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.Docker.DockerfileBuilder', (handle, client) => new DockerfileBuilderImpl(handle as DockerfileBuilderHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.DockerfileBuilderCallbackContext', (handle, client) => new DockerfileBuilderCallbackContextImpl(handle as DockerfileBuilderCallbackContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.Docker.DockerfileStage', (handle, client) => new DockerfileStageImpl(handle as DockerfileStageHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.EndpointReference', (handle, client) => new EndpointReferenceImpl(handle as EndpointReferenceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.EndpointReferenceExpression', (handle, client) => new EndpointReferenceExpressionImpl(handle as EndpointReferenceExpressionHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.EndpointUpdateContext', (handle, client) => new EndpointUpdateContextImpl(handle as EndpointUpdateContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.EnvironmentCallbackContext', (handle, client) => new EnvironmentCallbackContextImpl(handle as EnvironmentCallbackContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.EnvironmentEditor', (handle, client) => new EnvironmentEditorImpl(handle as EnvironmentEditorHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Ats.EventingSubscriberRegistrationContext', (handle, client) => new EventingSubscriberRegistrationContextImpl(handle as EventingSubscriberRegistrationContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ExecuteCommandContext', (handle, client) => new ExecuteCommandContextImpl(handle as ExecuteCommandContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.InitializeResourceEvent', (handle, client) => new InitializeResourceEventImpl(handle as InitializeResourceEventHandle, client)); +registerHandleWrapper('AspireC4.Hosting/Aspire.Hosting.AspireC4.LikeC4.Annotations.LikeC4NodeDetailsAnnotation', (handle, client) => new LikeC4NodeDetailsAnnotationImpl(handle as LikeC4NodeDetailsAnnotationHandle, client)); +registerHandleWrapper('AspireC4.Hosting/Aspire.Hosting.AspireC4.LikeC4.Annotations.LikeC4RelationshipDetailsAnnotation', (handle, client) => new LikeC4RelationshipDetailsAnnotationImpl(handle as LikeC4RelationshipDetailsAnnotationHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.LogFacade', (handle, client) => new LogFacadeImpl(handle as LogFacadeHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineConfigurationContext', (handle, client) => new PipelineConfigurationContextImpl(handle as PipelineConfigurationContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineContext', (handle, client) => new PipelineContextImpl(handle as PipelineContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineEditor', (handle, client) => new PipelineEditorImpl(handle as PipelineEditorHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineStep', (handle, client) => new PipelineStepImpl(handle as PipelineStepHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineStepContext', (handle, client) => new PipelineStepContextImpl(handle as PipelineStepContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineStepFactoryContext', (handle, client) => new PipelineStepFactoryContextImpl(handle as PipelineStepFactoryContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineSummary', (handle, client) => new PipelineSummaryImpl(handle as PipelineSummaryHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ProjectResourceOptions', (handle, client) => new ProjectResourceOptionsImpl(handle as ProjectResourceOptionsHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ReferenceExpressionBuilder', (handle, client) => new ReferenceExpressionBuilderImpl(handle as ReferenceExpressionBuilderHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceEndpointsAllocatedEvent', (handle, client) => new ResourceEndpointsAllocatedEventImpl(handle as ResourceEndpointsAllocatedEventHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceLoggerService', (handle, client) => new ResourceLoggerServiceImpl(handle as ResourceLoggerServiceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceNotificationService', (handle, client) => new ResourceNotificationServiceImpl(handle as ResourceNotificationServiceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceReadyEvent', (handle, client) => new ResourceReadyEventImpl(handle as ResourceReadyEventHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceStoppedEvent', (handle, client) => new ResourceStoppedEventImpl(handle as ResourceStoppedEventHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceUrlsCallbackContext', (handle, client) => new ResourceUrlsCallbackContextImpl(handle as ResourceUrlsCallbackContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceUrlsEditor', (handle, client) => new ResourceUrlsEditorImpl(handle as ResourceUrlsEditorHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.UpdateCommandStateContext', (handle, client) => new UpdateCommandStateContextImpl(handle as UpdateCommandStateContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IAspireStore', (handle, client) => new AspireStoreImpl(handle as IAspireStoreHandle, client)); +registerHandleWrapper('Microsoft.Extensions.Configuration.Abstractions/Microsoft.Extensions.Configuration.IConfiguration', (handle, client) => new ConfigurationImpl(handle as IConfigurationHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.IDistributedApplicationBuilder', (handle, client) => new DistributedApplicationBuilderImpl(handle as IDistributedApplicationBuilderHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Eventing.IDistributedApplicationEventing', (handle, client) => new DistributedApplicationEventingImpl(handle as IDistributedApplicationEventingHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.IDistributedApplicationPipeline', (handle, client) => new DistributedApplicationPipelineImpl(handle as IDistributedApplicationPipelineHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IExecutionConfigurationBuilder', (handle, client) => new ExecutionConfigurationBuilderImpl(handle as IExecutionConfigurationBuilderHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IExecutionConfigurationResult', (handle, client) => new ExecutionConfigurationResultImpl(handle as IExecutionConfigurationResultHandle, client)); +registerHandleWrapper('Microsoft.Extensions.Hosting.Abstractions/Microsoft.Extensions.Hosting.IHostEnvironment', (handle, client) => new HostEnvironmentImpl(handle as IHostEnvironmentHandle, client)); +registerHandleWrapper('Microsoft.Extensions.Logging.Abstractions/Microsoft.Extensions.Logging.ILogger', (handle, client) => new LoggerImpl(handle as ILoggerHandle, client)); +registerHandleWrapper('Microsoft.Extensions.Logging.Abstractions/Microsoft.Extensions.Logging.ILoggerFactory', (handle, client) => new LoggerFactoryImpl(handle as ILoggerFactoryHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.IReportingStep', (handle, client) => new ReportingStepImpl(handle as IReportingStepHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.IReportingTask', (handle, client) => new ReportingTaskImpl(handle as IReportingTaskHandle, client)); +registerHandleWrapper('System.ComponentModel/System.IServiceProvider', (handle, client) => new ServiceProviderImpl(handle as IServiceProviderHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.IUserSecretsManager', (handle, client) => new UserSecretsManagerImpl(handle as IUserSecretsManagerHandle, client)); +registerHandleWrapper('AspireC4.Hosting/Aspire.Hosting.AspireC4.ApplicationModel.AspireC4Resource', (handle, client) => new AspireC4ResourceImpl(handle as AspireC4ResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting.Azure/Aspire.Hosting.Azure.AzureBicepResource', (handle, client) => new AzureBicepResourceImpl(handle as AzureBicepResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting.Azure/Aspire.Hosting.Azure.AzureEnvironmentResource', (handle, client) => new AzureEnvironmentResourceImpl(handle as AzureEnvironmentResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting.Azure.KeyVault/Aspire.Hosting.Azure.AzureKeyVaultResource', (handle, client) => new AzureKeyVaultResourceImpl(handle as AzureKeyVaultResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting.Azure.KeyVault/Aspire.Hosting.Azure.AzureKeyVaultSecretResource', (handle, client) => new AzureKeyVaultSecretResourceImpl(handle as AzureKeyVaultSecretResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting.Azure.Redis/Aspire.Hosting.Azure.AzureManagedRedisResource', (handle, client) => new AzureManagedRedisResourceImpl(handle as AzureManagedRedisResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting.Azure.PostgreSQL/Aspire.Hosting.Azure.AzurePostgresFlexibleServerDatabaseResource', (handle, client) => new AzurePostgresFlexibleServerDatabaseResourceImpl(handle as AzurePostgresFlexibleServerDatabaseResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting.Azure.PostgreSQL/Aspire.Hosting.Azure.AzurePostgresFlexibleServerResource', (handle, client) => new AzurePostgresFlexibleServerResourceImpl(handle as AzurePostgresFlexibleServerResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting.Azure/Aspire.Hosting.Azure.AzureProvisioningResource', (handle, client) => new AzureProvisioningResourceImpl(handle as AzureProvisioningResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting.Azure/Aspire.Hosting.Azure.AzureUserAssignedIdentityResource', (handle, client) => new AzureUserAssignedIdentityResourceImpl(handle as AzureUserAssignedIdentityResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ContainerRegistryResource', (handle, client) => new ContainerRegistryResourceImpl(handle as ContainerRegistryResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ContainerResource', (handle, client) => new ContainerResourceImpl(handle as ContainerResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.CSharpAppResource', (handle, client) => new CSharpAppResourceImpl(handle as CSharpAppResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.DotnetToolResource', (handle, client) => new DotnetToolResourceImpl(handle as DotnetToolResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ExecutableResource', (handle, client) => new ExecutableResourceImpl(handle as ExecutableResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ExternalServiceResource', (handle, client) => new ExternalServiceResourceImpl(handle as ExternalServiceResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting.JavaScript/Aspire.Hosting.JavaScript.JavaScriptAppResource', (handle, client) => new JavaScriptAppResourceImpl(handle as JavaScriptAppResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting.JavaScript/Aspire.Hosting.JavaScript.NextJsAppResource', (handle, client) => new NextJsAppResourceImpl(handle as NextJsAppResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting.JavaScript/Aspire.Hosting.JavaScript.NodeAppResource', (handle, client) => new NodeAppResourceImpl(handle as NodeAppResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ParameterResource', (handle, client) => new ParameterResourceImpl(handle as ParameterResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting.PostgreSQL/Aspire.Hosting.Postgres.PgAdminContainerResource', (handle, client) => new PgAdminContainerResourceImpl(handle as PgAdminContainerResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting.PostgreSQL/Aspire.Hosting.Postgres.PgWebContainerResource', (handle, client) => new PgWebContainerResourceImpl(handle as PgWebContainerResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting.PostgreSQL/Aspire.Hosting.ApplicationModel.PostgresDatabaseResource', (handle, client) => new PostgresDatabaseResourceImpl(handle as PostgresDatabaseResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting.PostgreSQL/Aspire.Hosting.Postgres.PostgresMcpContainerResource', (handle, client) => new PostgresMcpContainerResourceImpl(handle as PostgresMcpContainerResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting.PostgreSQL/Aspire.Hosting.ApplicationModel.PostgresServerResource', (handle, client) => new PostgresServerResourceImpl(handle as PostgresServerResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ProjectResource', (handle, client) => new ProjectResourceImpl(handle as ProjectResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting.Redis/Aspire.Hosting.Redis.RedisCommanderResource', (handle, client) => new RedisCommanderResourceImpl(handle as RedisCommanderResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting.Redis/Aspire.Hosting.Redis.RedisInsightResource', (handle, client) => new RedisInsightResourceImpl(handle as RedisInsightResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting.Redis/Aspire.Hosting.ApplicationModel.RedisResource', (handle, client) => new RedisResourceImpl(handle as RedisResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting.JavaScript/Aspire.Hosting.JavaScript.ViteAppResource', (handle, client) => new ViteAppResourceImpl(handle as ViteAppResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting.Azure/Aspire.Hosting.ApplicationModel.IAzureResource', (handle, client) => new AzureResourceImpl(handle as IAzureResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IComputeResource', (handle, client) => new ComputeResourceImpl(handle as IComputeResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IContainerFilesDestinationResource', (handle, client) => new ContainerFilesDestinationResourceImpl(handle as IContainerFilesDestinationResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResource', (handle, client) => new ResourceImpl(handle as IResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithArgs', (handle, client) => new ResourceWithArgsImpl(handle as IResourceWithArgsHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithConnectionString', (handle, client) => new ResourceWithConnectionStringImpl(handle as IResourceWithConnectionStringHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.IResourceWithContainerFiles', (handle, client) => new ResourceWithContainerFilesImpl(handle as IResourceWithContainerFilesHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithEndpoints', (handle, client) => new ResourceWithEndpointsImpl(handle as IResourceWithEndpointsHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithEnvironment', (handle, client) => new ResourceWithEnvironmentImpl(handle as IResourceWithEnvironmentHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.IResourceWithServiceDiscovery', (handle, client) => new ResourceWithServiceDiscoveryImpl(handle as IResourceWithServiceDiscoveryHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithWaitSupport', (handle, client) => new ResourceWithWaitSupportImpl(handle as IResourceWithWaitSupportHandle, client)); + diff --git a/samples/typescript-app-host/.modules/base.ts b/samples/typescript-app-host/.modules/base.ts new file mode 100644 index 0000000..219eee0 --- /dev/null +++ b/samples/typescript-app-host/.modules/base.ts @@ -0,0 +1,679 @@ +// base.ts - Core Aspire types: base classes, ReferenceExpression +import { Handle, AspireClient, MarshalledHandle, CancellationToken, registerCancellation, registerHandleWrapper, unregisterCancellation } from './transport.js'; +import type { AspireClientRpc } from './transport.js'; + +// Re-export transport types for convenience +export { Handle, AspireClient, CapabilityError, CancellationToken, registerCallback, unregisterCallback, registerCancellation, unregisterCancellation } from './transport.js'; +export type { MarshalledHandle, AtsError, AtsErrorDetails, CallbackFunction } from './transport.js'; +export { AtsErrorCodes, isMarshalledHandle, isAtsError, wrapIfHandle } from './transport.js'; + +/** + * Utility type for parameters that accept either a resolved value or a promise of that value. + * Used by generated APIs to allow passing un-awaited resource builders directly. + */ +export type Awaitable = T | PromiseLike; + +// ============================================================================ +// Reference Expression +// ============================================================================ + +/** + * Represents a reference expression that can be passed to capabilities. + * + * Reference expressions are serialized in the protocol as: + * ```json + * { + * "$expr": { + * "format": "redis://{0}:{1}", + * "valueProviders": [ + * { "$handle": "Aspire.Hosting.ApplicationModel/EndpointReference:1" }, + * { "$handle": "Aspire.Hosting.ApplicationModel/EndpointReference:2" } + * ] + * } + * } + * ``` + * + * @example + * ```typescript + * const redis = await builder.addRedis("cache"); + * const endpoint = await redis.getEndpoint("tcp"); + * + * // Create a reference expression + * const expr = refExpr`redis://${endpoint}:6379`; + * + * // Use it in an environment variable + * await api.withEnvironment("REDIS_URL", expr); + * ``` + */ +const referenceExpressionState = new WeakMap(); + +export class ReferenceExpression { + constructor(format: string, valueProviders: unknown[]); + constructor(handle: Handle, client: AspireClientRpc); + constructor(condition: unknown, matchValue: string, whenTrue: ReferenceExpression, whenFalse: ReferenceExpression); + constructor( + handleOrFormatOrCondition: Handle | string | unknown, + clientOrValueProvidersOrMatchValue: AspireClientRpc | unknown[] | string, + whenTrueOrWhenFalse?: ReferenceExpression, + whenFalse?: ReferenceExpression + ) { + const state: { + format?: string; + valueProviders?: unknown[]; + condition?: unknown; + whenTrue?: ReferenceExpression; + whenFalse?: ReferenceExpression; + matchValue?: string; + handle?: Handle; + client?: AspireClientRpc; + } = {}; + + if (typeof handleOrFormatOrCondition === 'string') { + state.format = handleOrFormatOrCondition; + state.valueProviders = clientOrValueProvidersOrMatchValue as unknown[]; + } else if (isHandleLike(handleOrFormatOrCondition)) { + state.handle = handleOrFormatOrCondition; + state.client = clientOrValueProvidersOrMatchValue as AspireClientRpc; + } else { + state.condition = handleOrFormatOrCondition; + state.matchValue = (clientOrValueProvidersOrMatchValue as string) ?? 'True'; + state.whenTrue = whenTrueOrWhenFalse; + state.whenFalse = whenFalse; + } + + referenceExpressionState.set(this, state); + } + + /** + * Gets whether this reference expression is conditional. + */ + get isConditional(): boolean { + return referenceExpressionState.get(this)?.condition !== undefined; + } + + /** + * Creates a reference expression from a tagged template literal. + * + * @param strings - The template literal string parts + * @param values - The interpolated values (handles to value providers) + * @returns A ReferenceExpression instance + */ + /** + * Serializes the reference expression for JSON-RPC transport. + * In expression mode, uses the $expr format with format + valueProviders. + * In conditional mode, uses the $expr format with condition + whenTrue + whenFalse. + * In handle mode, delegates to the handle's serialization. + */ + toJSON(): { $expr: { format: string; valueProviders?: unknown[] } | { condition: unknown; whenTrue: unknown; whenFalse: unknown; matchValue: string } } | MarshalledHandle { + const state = referenceExpressionState.get(this)!; + + if (state.handle) { + return state.handle.toJSON(); + } + + if (this.isConditional) { + return { + $expr: { + condition: extractHandleForExpr(state.condition), + whenTrue: state.whenTrue!.toJSON(), + whenFalse: state.whenFalse!.toJSON(), + matchValue: state.matchValue! + } + }; + } + + return { + $expr: { + format: state.format!, + valueProviders: state.valueProviders && state.valueProviders.length > 0 ? state.valueProviders : undefined + } + }; + } + + /** + * Resolves the expression to its string value on the server. + * Only available on server-returned ReferenceExpression instances (handle mode). + * + * @param cancellationToken - Optional AbortSignal or CancellationToken for cancellation support + * @returns The resolved string value, or null if the expression resolves to null + */ + async getValue(cancellationToken?: AbortSignal | CancellationToken): Promise { + const state = referenceExpressionState.get(this)!; + + if (!state.handle || !state.client) { + throw new Error('getValue is only available on server-returned ReferenceExpression instances'); + } + const cancellationTokenId = registerCancellation(state.client, cancellationToken); + try { + const rpcArgs: Record = { context: state.handle }; + if (cancellationTokenId !== undefined) rpcArgs.cancellationToken = cancellationTokenId; + return await state.client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/getValue', + rpcArgs + ); + } finally { + unregisterCancellation(cancellationTokenId); + } + } + + /** + * String representation for debugging. + */ + toString(): string { + const state = referenceExpressionState.get(this)!; + + if (state.handle) { + return `ReferenceExpression(handle)`; + } + if (this.isConditional) { + return `ReferenceExpression(conditional)`; + } + return `ReferenceExpression(${state.format})`; + } + + static create(strings: TemplateStringsArray, ...values: unknown[]): ReferenceExpression { + return createReferenceExpression(strings, ...values); + } + + static createConditional( + condition: unknown, + whenTrue: ReferenceExpression, + whenFalse: ReferenceExpression + ): ReferenceExpression; + static createConditional( + condition: unknown, + matchValue: string, + whenTrue: ReferenceExpression, + whenFalse: ReferenceExpression + ): ReferenceExpression; + static createConditional( + condition: unknown, + matchValueOrWhenTrue: string | ReferenceExpression, + whenTrueOrWhenFalse: ReferenceExpression, + whenFalse?: ReferenceExpression + ): ReferenceExpression { + if (typeof matchValueOrWhenTrue === 'string') { + return createConditionalReferenceExpression(condition, matchValueOrWhenTrue, whenTrueOrWhenFalse, whenFalse!); + } + + return createConditionalReferenceExpression(condition, matchValueOrWhenTrue, whenTrueOrWhenFalse); + } +} + +function createReferenceExpression(strings: TemplateStringsArray, ...values: unknown[]): ReferenceExpression { + let format = ''; + for (let i = 0; i < strings.length; i++) { + format += strings[i]; + if (i < values.length) { + format += `{${i}}`; + } + } + + const valueProviders = values.map(extractHandleForExpr); + + return new ReferenceExpression(format, valueProviders); +} + +function createConditionalReferenceExpression( + condition: unknown, + whenTrue: ReferenceExpression, + whenFalse: ReferenceExpression +): ReferenceExpression; +function createConditionalReferenceExpression( + condition: unknown, + matchValue: string, + whenTrue: ReferenceExpression, + whenFalse: ReferenceExpression +): ReferenceExpression; +function createConditionalReferenceExpression( + condition: unknown, + matchValueOrWhenTrue: string | ReferenceExpression, + whenTrueOrWhenFalse: ReferenceExpression, + whenFalse?: ReferenceExpression +): ReferenceExpression { + if (typeof matchValueOrWhenTrue === 'string') { + return new ReferenceExpression(condition, matchValueOrWhenTrue, whenTrueOrWhenFalse, whenFalse!); + } + + return new ReferenceExpression(condition, 'True', matchValueOrWhenTrue, whenTrueOrWhenFalse); +} + +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ReferenceExpression', (handle, client) => + new ReferenceExpression(handle, client) +); + +/** + * Extracts a value for use in reference expressions. + * Supports handles (objects) and string literals. + * @internal + */ +function extractHandleForExpr(value: unknown): unknown { + if (value === null || value === undefined) { + throw new Error('Cannot use null or undefined in reference expression'); + } + + // String literals - include directly in the expression + if (typeof value === 'string') { + return value; + } + + // Number literals - convert to string + if (typeof value === 'number') { + return String(value); + } + + // Handle objects - get their JSON representation + if (isHandleLike(value)) { + return value.toJSON(); + } + + // Objects with marshalled expression/handle payloads + if (typeof value === 'object' && value !== null && ('$handle' in value || '$expr' in value)) { + return value; + } + + // Objects with toJSON that returns a marshalled expression or handle + if (typeof value === 'object' && value !== null && 'toJSON' in value && typeof value.toJSON === 'function') { + const json = value.toJSON(); + if (json && typeof json === 'object' && ('$handle' in json || '$expr' in json)) { + return json; + } + } + + throw new Error( + `Cannot use value of type ${typeof value} in reference expression. ` + + `Expected a Handle, string, or number.` + ); +} + +function isHandleLike(value: unknown): value is Handle { + return ( + value !== null && + typeof value === 'object' && + '$handle' in value && + typeof (value as { $handle?: unknown }).$handle === 'string' && + '$type' in value && + typeof (value as { $type?: unknown }).$type === 'string' && + 'toJSON' in value && + typeof (value as { toJSON?: unknown }).toJSON === 'function' + ); +} + +/** + * Tagged template function for creating reference expressions. + * + * Use this to create dynamic expressions that reference endpoints, parameters, and other + * value providers. The expression is evaluated at runtime by Aspire. + * + * @example + * ```typescript + * const redis = await builder.addRedis("cache"); + * const endpoint = await redis.getEndpoint("tcp"); + * + * // Create a reference expression using the tagged template + * const expr = refExpr`redis://${endpoint}:6379`; + * + * // Use it in an environment variable + * await api.withEnvironment("REDIS_URL", expr); + * ``` + */ +export function refExpr(strings: TemplateStringsArray, ...values: unknown[]): ReferenceExpression { + return ReferenceExpression.create(strings, ...values); +} + +// ============================================================================ +// ResourceBuilderBase +// ============================================================================ + +export interface HandleReference { + toJSON(): MarshalledHandle; +} + +/** + * Base class for resource builders (e.g., RedisBuilder, ContainerBuilder). + * Provides handle management and JSON serialization. + */ +export class ResourceBuilderBase implements HandleReference { + constructor(protected _handle: THandle, protected _client: AspireClientRpc) {} + + toJSON(): MarshalledHandle { return this._handle.toJSON(); } +} + +// ============================================================================ +// AspireList - Mutable List Wrapper +// ============================================================================ + +/** + * Wrapper for a mutable .NET List. + * Provides array-like methods that invoke capabilities on the underlying collection. + * + * @example + * ```typescript + * const items = await resource.getItems(); // Returns AspireList + * const count = await items.count(); + * const first = await items.get(0); + * await items.add(newItem); + * ``` + */ +export type AspireList = { + count(): Promise; + get(index: number): Promise; + add(item: T): Promise; + removeAt(index: number): Promise; + clear(): Promise; + toArray(): Promise; + toTransportValue(): Promise; + toJSON(): MarshalledHandle; +}; + +class AspireListImpl implements AspireList { + private _resolvedHandle?: Handle; + private _resolvePromise?: Promise; + + constructor( + private readonly _handleOrContext: Handle, + private readonly _client: AspireClientRpc, + private readonly _typeId: string, + private readonly _getterCapabilityId?: string + ) { + // If no getter capability, the handle is already the list handle + if (!_getterCapabilityId) { + this._resolvedHandle = _handleOrContext; + } + } + + /** + * Ensures we have the actual list handle by calling the getter if needed. + */ + private async _ensureHandle(): Promise { + if (this._resolvedHandle) { + return this._resolvedHandle; + } + if (this._resolvePromise) { + return this._resolvePromise; + } + // Call the getter capability to get the actual list handle + this._resolvePromise = (async () => { + const result = await this._client.invokeCapability(this._getterCapabilityId!, { + context: this._handleOrContext + }); + this._resolvedHandle = result as Handle; + return this._resolvedHandle; + })(); + return this._resolvePromise; + } + + /** + * Gets the number of elements in the list. + */ + async count(): Promise { + const handle = await this._ensureHandle(); + return await this._client.invokeCapability('Aspire.Hosting/List.length', { + list: handle + }) as number; + } + + /** + * Gets the element at the specified index. + */ + async get(index: number): Promise { + const handle = await this._ensureHandle(); + return await this._client.invokeCapability('Aspire.Hosting/List.get', { + list: handle, + index + }) as T; + } + + /** + * Adds an element to the end of the list. + */ + async add(item: T): Promise { + const handle = await this._ensureHandle(); + await this._client.invokeCapability('Aspire.Hosting/List.add', { + list: handle, + item + }); + } + + /** + * Removes the element at the specified index. + */ + async removeAt(index: number): Promise { + const handle = await this._ensureHandle(); + await this._client.invokeCapability('Aspire.Hosting/List.removeAt', { + list: handle, + index + }); + } + + /** + * Clears all elements from the list. + */ + async clear(): Promise { + const handle = await this._ensureHandle(); + await this._client.invokeCapability('Aspire.Hosting/List.clear', { + list: handle + }); + } + + /** + * Converts the list to an array (creates a copy). + */ + async toArray(): Promise { + const handle = await this._ensureHandle(); + return await this._client.invokeCapability('Aspire.Hosting/List.toArray', { + list: handle + }) as T[]; + } + + async toTransportValue(): Promise { + const handle = await this._ensureHandle(); + return handle.toJSON(); + } + + toJSON(): MarshalledHandle { + if (!this._resolvedHandle) { + throw new Error( + 'AspireList must be resolved before it can be serialized directly. ' + + 'Pass it to generated SDK methods instead of calling JSON.stringify directly.' + ); + } + + return this._resolvedHandle.toJSON(); + } +} + +export const AspireList = AspireListImpl; + +// ============================================================================ +// AspireDict - Mutable Dictionary Wrapper +// ============================================================================ + +/** + * Wrapper for a mutable .NET Dictionary. + * Provides object-like methods that invoke capabilities on the underlying collection. + * + * @example + * ```typescript + * const config = await resource.getConfig(); // Returns AspireDict + * const value = await config.get("key"); + * await config.set("key", "value"); + * const hasKey = await config.containsKey("key"); + * ``` + */ +export type AspireDict = { + count(): Promise; + get(key: K): Promise; + set(key: K, value: V): Promise; + containsKey(key: K): Promise; + remove(key: K): Promise; + clear(): Promise; + keys(): Promise; + values(): Promise; + toObject(): Promise>; + toTransportValue(): Promise; + toJSON(): MarshalledHandle; +}; + +class AspireDictImpl implements AspireDict { + private _resolvedHandle?: Handle; + private _resolvePromise?: Promise; + + constructor( + private readonly _handleOrContext: Handle, + private readonly _client: AspireClientRpc, + private readonly _typeId: string, + private readonly _getterCapabilityId?: string + ) { + // If no getter capability, the handle is already the dictionary handle + if (!_getterCapabilityId) { + this._resolvedHandle = _handleOrContext; + } + } + + /** + * Ensures we have the actual dictionary handle by calling the getter if needed. + */ + private async _ensureHandle(): Promise { + if (this._resolvedHandle) { + return this._resolvedHandle; + } + if (this._resolvePromise) { + return this._resolvePromise; + } + // Call the getter capability to get the actual dictionary handle + this._resolvePromise = (async () => { + const result = await this._client.invokeCapability(this._getterCapabilityId!, { + context: this._handleOrContext + }); + this._resolvedHandle = result as Handle; + return this._resolvedHandle; + })(); + return this._resolvePromise; + } + + /** + * Gets the number of key-value pairs in the dictionary. + */ + async count(): Promise { + const handle = await this._ensureHandle(); + return await this._client.invokeCapability('Aspire.Hosting/Dict.count', { + dict: handle + }) as number; + } + + /** + * Gets the value associated with the specified key. + * @throws If the key is not found. + */ + async get(key: K): Promise { + const handle = await this._ensureHandle(); + return await this._client.invokeCapability('Aspire.Hosting/Dict.get', { + dict: handle, + key + }) as V; + } + + /** + * Sets the value for the specified key. + */ + async set(key: K, value: V): Promise { + const handle = await this._ensureHandle(); + await this._client.invokeCapability('Aspire.Hosting/Dict.set', { + dict: handle, + key, + value + }); + } + + /** + * Determines whether the dictionary contains the specified key. + */ + async containsKey(key: K): Promise { + const handle = await this._ensureHandle(); + return await this._client.invokeCapability('Aspire.Hosting/Dict.has', { + dict: handle, + key + }) as boolean; + } + + /** + * Removes the value with the specified key. + * @returns True if the element was removed; false if the key was not found. + */ + async remove(key: K): Promise { + const handle = await this._ensureHandle(); + return await this._client.invokeCapability('Aspire.Hosting/Dict.remove', { + dict: handle, + key + }) as boolean; + } + + /** + * Clears all key-value pairs from the dictionary. + */ + async clear(): Promise { + const handle = await this._ensureHandle(); + await this._client.invokeCapability('Aspire.Hosting/Dict.clear', { + dict: handle + }); + } + + /** + * Gets all keys in the dictionary. + */ + async keys(): Promise { + const handle = await this._ensureHandle(); + return await this._client.invokeCapability('Aspire.Hosting/Dict.keys', { + dict: handle + }) as K[]; + } + + /** + * Gets all values in the dictionary. + */ + async values(): Promise { + const handle = await this._ensureHandle(); + return await this._client.invokeCapability('Aspire.Hosting/Dict.values', { + dict: handle + }) as V[]; + } + + /** + * Converts the dictionary to a plain object (creates a copy). + * Only works when K is string. + */ + async toObject(): Promise> { + const handle = await this._ensureHandle(); + return await this._client.invokeCapability('Aspire.Hosting/Dict.toObject', { + dict: handle + }) as Record; + } + + async toTransportValue(): Promise { + const handle = await this._ensureHandle(); + return handle.toJSON(); + } + + toJSON(): MarshalledHandle { + if (!this._resolvedHandle) { + throw new Error( + 'AspireDict must be resolved before it can be serialized directly. ' + + 'Pass it to generated SDK methods instead of calling JSON.stringify directly.' + ); + } + + return this._resolvedHandle.toJSON(); + } +} + +export const AspireDict = AspireDictImpl; diff --git a/samples/typescript-app-host/.modules/transport.ts b/samples/typescript-app-host/.modules/transport.ts new file mode 100644 index 0000000..4d955e7 --- /dev/null +++ b/samples/typescript-app-host/.modules/transport.ts @@ -0,0 +1,1092 @@ +// transport.ts - ATS transport layer: RPC, Handle, errors, callbacks +import * as net from 'net'; +import * as rpc from 'vscode-jsonrpc/node.js'; + +// ============================================================================ +// Base Types +// ============================================================================ + +/** + * Structural client surface used by generated wrappers and transport helpers. + * This keeps generated types assignable across separately restored SDK copies. + */ +export interface AspireClientRpc { + readonly connected: boolean; + invokeCapability(capabilityId: string, args?: Record): Promise; + cancelToken(cancellationId: string): Promise; + trackPromise(promise: Promise): void; + flushPendingPromises(): Promise; + /** When true (default), rejected tracked promises are collected and re-thrown by flushPendingPromises. */ + throwOnPendingRejections: boolean; +} + +/** + * Type for callback functions that can be registered and invoked from .NET. + * Internal: receives args and client for handle wrapping. + */ +export type CallbackFunction = (args: unknown, client: AspireClientRpc) => unknown | Promise; + +/** + * Represents a handle to a .NET object in the ATS system. + * Handles are typed references that can be passed between capabilities. + */ +export interface MarshalledHandle { + /** The handle ID (instance number) */ + $handle: string; + /** The ATS type ID */ + $type: string; +} + +/** + * Error details for ATS errors. + */ +export interface AtsErrorDetails { + /** The parameter that caused the error */ + parameter?: string; + /** The expected type or value */ + expected?: string; + /** The actual type or value */ + actual?: string; +} + +/** + * Structured error from ATS capability invocation. + */ +export interface AtsError { + /** Machine-readable error code */ + code: string; + /** Human-readable error message */ + message: string; + /** The capability that failed (if applicable) */ + capability?: string; + /** Additional error details */ + details?: AtsErrorDetails; +} + +/** + * ATS error codes returned by the server. + */ +export const AtsErrorCodes = { + /** Unknown capability ID */ + CapabilityNotFound: 'CAPABILITY_NOT_FOUND', + /** Handle ID doesn't exist or was disposed */ + HandleNotFound: 'HANDLE_NOT_FOUND', + /** Handle type doesn't satisfy capability's type constraint */ + TypeMismatch: 'TYPE_MISMATCH', + /** Missing required argument or wrong type */ + InvalidArgument: 'INVALID_ARGUMENT', + /** Argument value outside valid range */ + ArgumentOutOfRange: 'ARGUMENT_OUT_OF_RANGE', + /** Error occurred during callback invocation */ + CallbackError: 'CALLBACK_ERROR', + /** Unexpected error in capability execution */ + InternalError: 'INTERNAL_ERROR', +} as const; + +/** + * Type guard to check if a value is an ATS error response. + */ +export function isAtsError(value: unknown): value is { $error: AtsError } { + return ( + value !== null && + typeof value === 'object' && + '$error' in value && + typeof (value as { $error: unknown }).$error === 'object' && + (value as { $error: unknown }).$error !== null + ); +} + +/** + * Type guard to check if a value is a marshalled handle. + */ +export function isMarshalledHandle(value: unknown): value is MarshalledHandle { + return ( + value !== null && + typeof value === 'object' && + '$handle' in value && + '$type' in value + ); +} + +function isAbortSignal(value: unknown): value is AbortSignal { + return ( + value !== null && + typeof value === 'object' && + 'aborted' in value && + 'addEventListener' in value && + 'removeEventListener' in value + ); +} + +function isCancellationTokenLike(value: unknown): value is CancellationToken { + return ( + value !== null && + typeof value === 'object' && + 'register' in value && + typeof (value as { register?: unknown }).register === 'function' && + 'toJSON' in value && + typeof (value as { toJSON?: unknown }).toJSON === 'function' + ); +} + +function isPlainObject(value: unknown): value is Record { + if (value === null || typeof value !== 'object') { + return false; + } + + const prototype = Object.getPrototypeOf(value); + return prototype === Object.prototype || prototype === null; +} + +function hasTransportValue(value: unknown): value is { toTransportValue(): unknown | Promise } { + return ( + value !== null && + typeof value === 'object' && + 'toTransportValue' in value && + typeof (value as { toTransportValue?: unknown }).toTransportValue === 'function' + ); +} + +function createAbortError(message: string): Error { + const error = new Error(message); + error.name = 'AbortError'; + return error; +} + +function createCircularReferenceError(capabilityId: string, path: string): AppHostUsageError { + return new AppHostUsageError( + `Argument '${path}' passed to capability '${capabilityId}' contains a circular reference. ` + + 'Circular references are not supported by the AppHost transport.' + ); +} + +// ============================================================================ +// Handle +// ============================================================================ + +/** + * A typed handle to a .NET object in the ATS system. + * Handles are opaque references that can be passed to capabilities. + * + * @typeParam T - The ATS type ID (e.g., "Aspire.Hosting/IDistributedApplicationBuilder") + */ +export class Handle { + readonly $handle: string; + readonly $type: T; + + constructor(marshalled: MarshalledHandle) { + this.$handle = marshalled.$handle; + this.$type = marshalled.$type as T; + } + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { + return { + $handle: this.$handle, + $type: this.$type + }; + } + + /** String representation for debugging */ + toString(): string { + return `Handle<${this.$type}>(${this.$handle})`; + } +} + +// ============================================================================ +// CancellationToken +// ============================================================================ + +/** + * Represents a transport-safe cancellation token value for the generated SDK. + * + * Use a plain {@link AbortSignal} when you create cancellation in user code. + * Generated APIs accept either an {@link AbortSignal} or a {@link CancellationToken}. + * + * Values returned from generated callbacks and context/property getters are + * {@link CancellationToken} instances because they may reference remote + * cancellation token handles received from the AppHost. + * + * @example + * ```typescript + * const controller = new AbortController(); + * await connectionStringExpression.getValue(controller.signal); + * ``` + * + * @example + * ```typescript + * const cancellationToken = await context.cancellationToken.get(); + * const connectionStringExpression = await db.uriExpression.get(); + * const connectionString = await connectionStringExpression.getValue(cancellationToken); + * ``` + */ +const cancellationTokenState = new WeakMap(); + +export class CancellationToken { + constructor(signal?: AbortSignal); + constructor(tokenId?: string); + constructor(value?: AbortSignal | string | null) { + const state: { signal?: AbortSignal; remoteTokenId?: string } = {}; + + if (typeof value === 'string') { + state.remoteTokenId = value; + } else if (isAbortSignal(value)) { + state.signal = value; + } + + cancellationTokenState.set(this, state); + } + + /** + * Creates a cancellation token from a local {@link AbortSignal}. + */ + toJSON(): string | undefined { + return cancellationTokenState.get(this)?.remoteTokenId; + } + + register(client?: AspireClientRpc): string | undefined { + const state = cancellationTokenState.get(this); + + if (state?.remoteTokenId !== undefined) { + return state.remoteTokenId; + } + + return client + ? registerCancellation(client, state?.signal) + : registerCancellation(state?.signal); + } + + /** + * Creates transport-safe cancellation token values for the generated SDK. + */ + static from(signal?: AbortSignal): CancellationToken { + return new CancellationToken(signal); + } + + /** + * Creates a cancellation token from a transport value. + * Generated code uses this to materialize values that come from the AppHost. + */ + static fromValue(value: unknown): CancellationToken { + if (isCancellationTokenLike(value)) { + return value; + } + + if (typeof value === 'string') { + return new CancellationToken(value); + } + + if (isAbortSignal(value)) { + return new CancellationToken(value); + } + + return new CancellationToken(); + } +} + +// ============================================================================ +// Handle Wrapper Registry +// ============================================================================ + +/** + * Factory function for creating typed wrapper instances from handles. + */ +export type HandleWrapperFactory = (handle: Handle, client: AspireClientRpc) => unknown; + +/** + * Registry of handle wrapper factories by type ID. + * Generated code registers wrapper classes here so callback handles can be properly typed. + */ +const handleWrapperRegistry = new Map(); + +/** + * Register a wrapper factory for a type ID. + * Called by generated code to register wrapper classes. + */ +export function registerHandleWrapper(typeId: string, factory: HandleWrapperFactory): void { + handleWrapperRegistry.set(typeId, factory); +} + +/** + * Checks if a value is a marshalled handle and wraps it appropriately. + * Uses the wrapper registry to create typed wrapper instances when available. + * + * @param value - The value to potentially wrap + * @param client - Optional client for creating typed wrapper instances + */ +export function wrapIfHandle(value: unknown, client?: AspireClientRpc): unknown { + if (isMarshalledHandle(value)) { + const handle = new Handle(value); + const typeId = value.$type; + + // Try to find a registered wrapper factory for this type + if (typeId && client) { + const factory = handleWrapperRegistry.get(typeId); + if (factory) { + return factory(handle, client); + } + } + + return handle; + } + + if (Array.isArray(value)) { + for (let i = 0; i < value.length; i++) { + value[i] = wrapIfHandle(value[i], client); + } + + return value; + } + + if (isPlainObject(value)) { + for (const [key, nestedValue] of Object.entries(value)) { + value[key] = wrapIfHandle(nestedValue, client); + } + } + + return value; +} + +// ============================================================================ +// Capability Error +// ============================================================================ + +/** + * Error thrown when an ATS capability invocation fails. + */ +export class CapabilityError extends Error { + constructor( + /** The structured error from the server */ + public readonly error: AtsError + ) { + super(error.message); + this.name = 'CapabilityError'; + Object.setPrototypeOf(this, new.target.prototype); + } + + /** Machine-readable error code */ + get code(): string { + return this.error.code; + } + + /** The capability that failed (if applicable) */ + get capability(): string | undefined { + return this.error.capability; + } +} + +/** + * Error thrown when the AppHost script uses the generated SDK incorrectly. + */ +export class AppHostUsageError extends Error { + constructor(message: string) { + super(message); + this.name = 'AppHostUsageError'; + Object.setPrototypeOf(this, new.target.prototype); + } +} + +export function isPromiseLike(value: unknown): value is PromiseLike { + return ( + value !== null && + (typeof value === 'object' || typeof value === 'function') && + 'then' in value && + typeof (value as { then?: unknown }).then === 'function' + ); +} + +function validateCapabilityArgs( + capabilityId: string, + args?: Record +): void { + if (!args) { + return; + } + + const validateValue = (value: unknown, path: string, ancestors: Set): void => { + if (value === null || value === undefined) { + return; + } + + if (isPromiseLike(value)) { + throw new AppHostUsageError( + `Argument '${path}' passed to capability '${capabilityId}' is a Promise-like value. ` + + `This usually means an async builder call was not awaited. ` + + `Did you forget 'await' on a call like builder.addPostgres(...) or resource.addDatabase(...)?` + ); + } + + if (typeof value !== 'object') { + return; + } + + if (ancestors.has(value)) { + throw createCircularReferenceError(capabilityId, path); + } + + ancestors.add(value); + try { + if (Array.isArray(value)) { + for (let i = 0; i < value.length; i++) { + validateValue(value[i], `${path}[${i}]`, ancestors); + } + return; + } + + for (const [key, nestedValue] of Object.entries(value)) { + validateValue(nestedValue, `${path}.${key}`, ancestors); + } + } finally { + ancestors.delete(value); + } + }; + + for (const [key, value] of Object.entries(args)) { + validateValue(value, key, new Set()); + } +} + +// ============================================================================ +// Callback Registry +// ============================================================================ + +const callbackRegistry = new Map(); +let callbackIdCounter = 0; + +/** + * Register a callback function that can be invoked from the .NET side. + * Returns a callback ID that should be passed to methods accepting callbacks. + * + * .NET passes arguments as an object with positional keys: `{ p0: value0, p1: value1, ... }` + * This function automatically extracts positional parameters and wraps handles. + * + * @example + * // Single parameter callback + * const id = registerCallback((ctx) => console.log(ctx)); + * // .NET sends: { p0: { $handle: "...", $type: "..." } } + * // Callback receives: Handle instance + * + * @example + * // Multi-parameter callback + * const id = registerCallback((a, b) => console.log(a, b)); + * // .NET sends: { p0: "hello", p1: 42 } + * // Callback receives: "hello", 42 + */ +export function registerCallback( + callback: (...args: any[]) => TResult | Promise +): string { + const callbackId = `callback_${++callbackIdCounter}_${Date.now()}`; + + // Wrap the callback to handle .NET's positional argument format + const wrapper: CallbackFunction = async (args: unknown, client: AspireClientRpc) => { + // .NET sends args as object { p0: value0, p1: value1, ... } + if (args && typeof args === 'object' && !Array.isArray(args)) { + const argObj = args as Record; + const argArray: unknown[] = []; + + // Extract positional parameters (p0, p1, p2, ...) + for (let i = 0; ; i++) { + const key = `p${i}`; + if (key in argObj) { + argArray.push(wrapIfHandle(argObj[key], client)); + } else { + break; + } + } + + if (argArray.length > 0) { + // Spread positional arguments to callback + const result = await callback(...argArray); + // DTO writeback protocol: when a void callback returns undefined, we + // return the original args object so the .NET host can detect property + // mutations made by the callback and apply them back to the original + // C# DTO objects. DTO args are plain JS objects (not Handle wrappers), + // so any property changes the callback made are reflected in args. + // + // Non-void callbacks (result !== undefined) return their actual result. + // The .NET side only activates writeback for void delegates whose + // parameters include [AspireDto] types — all other cases discard the + // returned args object, so the extra wire payload is harmless. + // + // IMPORTANT: callbacks that intentionally return undefined will also + // trigger this path. For non-void delegate types, the C# proxy uses + // a result-unmarshalling path (not writeback), so returning args will + // cause an unmarshal error. Void callbacks should never return a + // meaningful value; non-void callbacks should always return one. + return result !== undefined ? result : args; + } + + // No positional params found — nothing to write back + return await callback(); + } + + // Null/undefined - call with no args + if (args === null || args === undefined) { + return await callback(); + } + + // Primitive value - pass as single arg (shouldn't happen with current protocol) + return await callback(wrapIfHandle(args, client)); + }; + + callbackRegistry.set(callbackId, wrapper); + return callbackId; +} + +/** + * Unregister a callback by its ID. + */ +export function unregisterCallback(callbackId: string): boolean { + return callbackRegistry.delete(callbackId); +} + +/** + * Get the number of registered callbacks. + */ +export function getCallbackCount(): number { + return callbackRegistry.size; +} + +// ============================================================================ +// Cancellation Token Registry +// ============================================================================ + +/** + * Registry for cancellation tokens. + * Maps cancellation IDs to cleanup functions. + */ +const cancellationRegistry = new Map void>(); +let cancellationIdCounter = 0; +const connectedClients = new Set(); + +function resolveCancellationClient(client?: AspireClientRpc): AspireClientRpc { + if (client) { + return client; + } + + if (connectedClients.size === 1) { + return connectedClients.values().next().value as AspireClient; + } + + if (connectedClients.size === 0) { + throw new Error( + 'registerCancellation(signal) requires a connected AspireClient. ' + + 'Pass the client explicitly or connect the client first.' + ); + } + + throw new Error( + 'registerCancellation(signal) is ambiguous when multiple AspireClient instances are connected. ' + + 'Pass the client explicitly.' + ); +} + +function isAspireClientLike(value: unknown): value is AspireClientRpc { + if (!value || typeof value !== 'object') { + return false; + } + + const candidate = value as { + invokeCapability?: unknown; + cancelToken?: unknown; + connected?: unknown; + }; + + return typeof candidate.invokeCapability === 'function' + && typeof candidate.cancelToken === 'function' + && typeof candidate.connected === 'boolean'; +} + +/** + * Registers cancellation support for a local signal or SDK cancellation token. + * Returns a cancellation ID that should be passed to methods accepting cancellation input. + * + * When the AbortSignal is aborted, sends a cancelToken request to the host. + * + * @param client - The AspireClient that should route the cancellation request + * @param signalOrToken - The signal or token to register (optional) + * @returns The cancellation ID, or undefined if no value was provided or the token maps to CancellationToken.None + */ +export function registerCancellation(client: AspireClientRpc, signalOrToken?: AbortSignal | CancellationToken): string | undefined; +/** + * Registers cancellation support using the single connected AspireClient. + * + * @param signalOrToken - The signal or token to register (optional) + * @returns The cancellation ID, or undefined if no value was provided, the signal was already aborted, or the token maps to CancellationToken.None + * + * @example + * const controller = new AbortController(); + * await expression.getValue(controller.signal); + * + * @example + * const controller = new AbortController(); + * const id = registerCancellation(controller.signal); + * // Pass id to capability invocation + * // Later: controller.abort() will cancel the operation + */ +export function registerCancellation(signalOrToken?: AbortSignal | CancellationToken): string | undefined; +export function registerCancellation( + clientOrSignalOrToken?: AspireClientRpc | AbortSignal | CancellationToken, + maybeSignalOrToken?: AbortSignal | CancellationToken +): string | undefined { + const client = isAspireClientLike(clientOrSignalOrToken) ? clientOrSignalOrToken : undefined; + const signalOrToken = client + ? maybeSignalOrToken + : clientOrSignalOrToken as AbortSignal | CancellationToken | undefined; + + if (!signalOrToken) { + return undefined; + } + + if (isCancellationTokenLike(signalOrToken)) { + return signalOrToken.register(client); + } + + const signal = signalOrToken; + const cancellationClient = resolveCancellationClient(client); + + if (signal.aborted) { + throw createAbortError('The operation was aborted before it was sent to the AppHost.'); + } + + const cancellationId = `ct_${++cancellationIdCounter}_${Date.now()}`; + + // Set up the abort listener + const onAbort = () => { + // Send cancel request to host + if (cancellationClient.connected) { + cancellationClient.cancelToken(cancellationId).catch(() => { + // Ignore errors - the operation may have already completed + }); + } + // Clean up the listener + cancellationRegistry.delete(cancellationId); + }; + + // Listen for abort + signal.addEventListener('abort', onAbort, { once: true }); + + // Store cleanup function + cancellationRegistry.set(cancellationId, () => { + signal.removeEventListener('abort', onAbort); + }); + + return cancellationId; +} + +async function marshalTransportValue( + value: unknown, + client: AspireClientRpc, + cancellationIds: string[], + capabilityId: string, + path: string = 'args', + ancestors: Set = new Set() +): Promise { + if (value === null || value === undefined || typeof value !== 'object') { + return value; + } + + if (isCancellationTokenLike(value)) { + const cancellationId = value.register(client); + if (cancellationId !== undefined) { + cancellationIds.push(cancellationId); + } + + return cancellationId; + } + + if (ancestors.has(value)) { + throw createCircularReferenceError(capabilityId, path); + } + + const nextAncestors = new Set(ancestors); + nextAncestors.add(value); + + if (hasTransportValue(value)) { + return await marshalTransportValue(await value.toTransportValue(), client, cancellationIds, capabilityId, path, nextAncestors); + } + + if (Array.isArray(value)) { + return await Promise.all( + value.map((item, index) => marshalTransportValue(item, client, cancellationIds, capabilityId, `${path}[${index}]`, nextAncestors)) + ); + } + + if (isPlainObject(value)) { + const entries = await Promise.all( + Object.entries(value).map(async ([key, nestedValue]) => + [key, await marshalTransportValue(nestedValue, client, cancellationIds, capabilityId, `${path}.${key}`, nextAncestors)] as const) + ); + + return Object.fromEntries(entries); + } + + return value; +} + +/** + * Unregister a cancellation token by its ID. + * Call this when the operation completes to clean up resources. + * + * @param cancellationId - The cancellation ID to unregister + */ +export function unregisterCancellation(cancellationId: string | undefined): void { + if (!cancellationId) { + return; + } + + const cleanup = cancellationRegistry.get(cancellationId); + if (cleanup) { + cleanup(); + cancellationRegistry.delete(cancellationId); + } +} + +// ============================================================================ +// AspireClient (JSON-RPC Connection) +// ============================================================================ + +/** + * Client for connecting to the Aspire AppHost via socket/named pipe. + */ +export class AspireClient implements AspireClientRpc { + private connection: rpc.MessageConnection | null = null; + private socket: net.Socket | null = null; + private disconnectCallbacks: (() => void)[] = []; + private _pendingCalls = 0; + private _connectPromise: Promise | null = null; + private _disconnectNotified = false; + private _pendingPromises: Set> = new Set(); + private _rejectedErrors: Set = new Set(); + throwOnPendingRejections = true; + + constructor(private socketPath: string) { } + + trackPromise(promise: Promise): void { + this._pendingPromises.add(promise); + // Remove on both resolve and reject. The reject handler swallows the + // error to prevent Node.js unhandled-rejection crashes. + // + // When throwOnPendingRejections is true (default), rejection errors are + // eagerly collected so that flushPendingPromises can re-throw them even + // if the promise settles before flush is called. + // + // Limitation: JavaScript provides no way to detect whether a rejection + // was already observed by the caller (e.g., try { await p } catch {}). + // The .then() reject handler fires regardless. This means user-caught + // rejections will also be re-thrown by build(). We accept this tradeoff + // because the common case — an un-awaited chain fails silently — should + // fail loud. The uncommon case (catch an error from an un-awaited chain, + // then continue to build) can opt out with: + // createBuilder({ throwOnPendingRejections: false }) + promise.then( + () => this._pendingPromises.delete(promise), + (err) => { + this._pendingPromises.delete(promise); + if (this.throwOnPendingRejections) { + this._rejectedErrors.add(err); + } + } + ); + } + + async flushPendingPromises(): Promise { + if (this._pendingPromises.size > 0) { + console.warn(`Flushing ${this._pendingPromises.size} pending promise(s). Consider awaiting fluent calls to avoid implicit flushing.`); + // Snapshot the current set before awaiting. Promises tracked after + // flush starts (e.g. by .then() callbacks or the build PromiseImpl + // constructor) are excluded. This prevents deadlocks where a tracked + // promise depends on flush completing. + const pending = [...this._pendingPromises]; + await Promise.allSettled(pending); + } + if (this._rejectedErrors.size > 0) { + const errors = [...this._rejectedErrors]; + this._rejectedErrors.clear(); + throw new AggregateError(errors, 'One or more unawaited fluent calls failed'); + } + } + + /** + * Register a callback to be called when the connection is lost + */ + onDisconnect(callback: () => void): void { + this.disconnectCallbacks.push(callback); + } + + private notifyDisconnect(): void { + if (this._disconnectNotified) { + return; + } + + this._disconnectNotified = true; + + for (const callback of this.disconnectCallbacks) { + try { + callback(); + } catch { + // Ignore callback errors + } + } + } + + connect(timeoutMs: number = 5000): Promise { + if (this.connected) { + return Promise.resolve(); + } + + if (this._connectPromise) { + return this._connectPromise; + } + + this._disconnectNotified = false; + + // On Windows, use named pipes; on Unix, use Unix domain sockets + const isWindows = process.platform === 'win32'; + const pipePath = isWindows ? `\\\\.\\pipe\\${this.socketPath}` : this.socketPath; + + this._connectPromise = new Promise((resolve, reject) => { + const socket = net.createConnection(pipePath); + this.socket = socket; + + let settled = false; + + const cleanupPendingListeners = () => { + socket.removeListener('connect', onConnect); + socket.removeListener('error', onPendingError); + socket.removeListener('close', onPendingClose); + }; + + const failConnect = (error: Error) => { + if (settled) { + return; + } + + settled = true; + clearTimeout(timeout); + cleanupPendingListeners(); + this._connectPromise = null; + + if (this.socket === socket) { + this.socket = null; + } + + if (!socket.destroyed) { + socket.destroy(); + } + + reject(error); + }; + + const onConnectedSocketError = (error: Error) => { + console.error('Socket error:', error); + }; + + const onConnectedSocketClose = () => { + socket.removeListener('error', onConnectedSocketError); + + if (this.socket && this.socket !== socket) { + return; + } + + const connection = this.connection; + this.connection = null; + this._connectPromise = null; + + if (this.socket === socket) { + this.socket = null; + } + + connectedClients.delete(this); + + try { + connection?.dispose(); + } catch { + // Ignore connection disposal errors during shutdown. + } + + this.notifyDisconnect(); + }; + + const onPendingError = (error: Error) => { + failConnect(error); + }; + + const onPendingClose = () => { + failConnect(new Error('Connection closed before JSON-RPC was established')); + }; + + const onConnect = async () => { + if (settled) { + return; + } + + clearTimeout(timeout); + cleanupPendingListeners(); + + try { + const reader = new rpc.SocketMessageReader(socket); + const writer = new rpc.SocketMessageWriter(socket); + this.connection = rpc.createMessageConnection(reader, writer); + + this.connection.onClose(() => { + this.connection = null; + }); + this.connection.onError((err: any) => console.error('JsonRpc connection error:', err)); + + // Handle callback invocations from the .NET side + this.connection.onRequest('invokeCallback', async (callbackId: string, args: unknown) => { + const callback = callbackRegistry.get(callbackId); + if (!callback) { + throw new Error(`Callback not found: ${callbackId}`); + } + try { + // The registered wrapper handles arg unpacking and handle wrapping + // Pass this client so handles can be wrapped with typed wrapper classes + return await Promise.resolve(callback(args, this)); + } catch (error) { + const message = error instanceof Error ? error.message : String(error); + throw new Error(`Callback execution failed: ${message}`); + } + }); + + socket.on('error', onConnectedSocketError); + socket.on('close', onConnectedSocketClose); + + const authToken = process.env.ASPIRE_REMOTE_APPHOST_TOKEN; + if (!authToken) { + throw new Error('ASPIRE_REMOTE_APPHOST_TOKEN environment variable is not set.'); + } + this.connection.listen(); + const authenticated = await this.connection.sendRequest('authenticate', authToken); + if (!authenticated) { + throw new Error('Failed to authenticate to the AppHost server.'); + } + + connectedClients.add(this); + this._connectPromise = null; + settled = true; + + resolve(); + } catch (error) { + failConnect(error instanceof Error ? error : new Error(String(error))); + } + }; + + const timeout = setTimeout(() => { + failConnect(new Error('Connection timeout')); + }, timeoutMs); + + socket.once('error', onPendingError); + socket.once('close', onPendingClose); + socket.once('connect', onConnect); + }); + + return this._connectPromise; + } + + ping(): Promise { + if (!this.connection) return Promise.reject(new Error('Not connected to AppHost')); + return this.connection.sendRequest('ping'); + } + + /** + * Cancel a CancellationToken by its ID. + * Called when an AbortSignal is aborted. + * + * @param tokenId - The token ID to cancel + * @returns True if the token was found and cancelled, false otherwise + */ + cancelToken(tokenId: string): Promise { + if (!this.connection) return Promise.reject(new Error('Not connected to AppHost')); + return this.connection.sendRequest('cancelToken', tokenId); + } + + /** + * Invoke an ATS capability by ID. + * + * Capabilities are operations exposed by [AspireExport] attributes. + * Results are automatically wrapped in Handle objects when applicable. + * + * @param capabilityId - The capability ID (e.g., "Aspire.Hosting/createBuilder") + * @param args - Arguments to pass to the capability + * @returns The capability result, wrapped as Handle if it's a handle type + * @throws CapabilityError if the capability fails + */ + async invokeCapability( + capabilityId: string, + args?: Record + ): Promise { + if (!this.connection) { + throw new Error('Not connected to AppHost'); + } + + validateCapabilityArgs(capabilityId, args); + const cancellationIds: string[] = []; + + try { + const rpcArgs = await marshalTransportValue(args ?? null, this, cancellationIds, capabilityId); + + // Ref counting: The vscode-jsonrpc socket keeps Node's event loop alive. + // We ref() during RPC calls so the process doesn't exit mid-call, and + // unref() when idle so the process can exit naturally after all work completes. + if (this._pendingCalls === 0) { + this.socket?.ref(); + } + this._pendingCalls++; + + try { + const result = await this.connection.sendRequest( + 'invokeCapability', + capabilityId, + rpcArgs + ); + + // Check for structured error response + if (isAtsError(result)) { + throw new CapabilityError(result.$error); + } + + // Wrap handles automatically + return wrapIfHandle(result, this) as T; + } finally { + this._pendingCalls--; + if (this._pendingCalls === 0) { + this.socket?.unref(); + } + } + } finally { + for (const cancellationId of cancellationIds) { + unregisterCancellation(cancellationId); + } + } + } + + disconnect(): void { + const connection = this.connection; + const socket = this.socket; + + this.connection = null; + this.socket = null; + this._connectPromise = null; + connectedClients.delete(this); + + try { + connection?.dispose(); + } catch { + // Ignore connection disposal errors during shutdown. + } + + if (socket && !socket.destroyed) { + socket.end(); + socket.destroy(); + } + } + + get connected(): boolean { + return this.connection !== null && this.socket !== null; + } +} diff --git a/skills/purview-aspirec4-entityframework/SKILL.md b/skills/purview-aspirec4-entityframework/SKILL.md index e241cfa..abd7215 100644 --- a/skills/purview-aspirec4-entityframework/SKILL.md +++ b/skills/purview-aspirec4-entityframework/SKILL.md @@ -13,10 +13,21 @@ metadata: # Entity Framework Core ER diagrams -`AspireC4.Hosting.EntityFrameworkCore` adds a second diagram beside the architecture one: a live -[d2](https://d2lang.com) `sql_table` ER diagram built from your Entity Framework Core `DbContext` -types, linked from each contributing project in the dashboard and on its element in the architecture -diagram. +`AspireC4.Hosting.EntityFrameworkCore` adds a second diagram beside the architecture one: a live ER +diagram built from your Entity Framework Core `DbContext` types, linked from each contributing project in +the dashboard and on its element in the architecture diagram. + +It is **additive and optional**. `AddAspireC4()` is always the base, and `WithEntityFrameworkDiagram()` is +an extension on the `IResourceBuilder` it returns, so the architecture diagram is always +present — run one diagram or both, but never the ER diagram alone. + +## Target frameworks + +| Package | Target framework | Shipped as | +| --- | --- | --- | +| `AspireC4.Hosting.EntityFrameworkCore` | `net10.0` | `lib/net10.0/` library; the AppHost must target `net10.0` | +| `AspireC4.EntityFrameworkCore` | `netstandard2.0` | analyzer-only under `analyzers/dotnet/cs/`, so it loads into any project's compiler and adds no runtime assembly | +| `AspireC4.EntityFrameworkCore.ModelDump` | `net10.0` | build-time tool under `tools/`, invoked by MSBuild, so the building machine needs a .NET 10 runtime | ## Packages @@ -189,6 +200,9 @@ apphost/.aspirec4/images/ architecture-index.png <- architecture diagram ``` +That folder is also the place to take a screenshot from: it is written by the AppHost itself, so nothing +has to be captured by hand. + The name drops the `.gen` marker: `schema.gen` produces `schema.svg`, not `schema.gen.svg`. The marker earns its place on a generated source file sitting in a directory you also hand-edit, which an image in the shared folder never is. The dashboard row carries an **Images** property with the resolved path and diff --git a/skills/purview-aspirec4-quickstart/SKILL.md b/skills/purview-aspirec4-quickstart/SKILL.md index 8a595d2..caaddbf 100644 --- a/skills/purview-aspirec4-quickstart/SKILL.md +++ b/skills/purview-aspirec4-quickstart/SKILL.md @@ -3,8 +3,8 @@ name: purview-aspirec4-quickstart description: >- Use when adding AspireC4 to an Aspire AppHost to generate a live LikeC4 architecture diagram - installing AspireC4.Hosting, calling AddAspireC4, what happens on startup, running the LikeC4 - server as a Docker sidecar or through a local Node CLI, and finding the diagram in the Aspire - dashboard. + server as a Docker sidecar or through a local Node CLI, finding the diagram in the Aspire + dashboard, and deciding whether to add the optional Entity Framework Core ER diagram as well. metadata: product: AspireC4 repository: purview-dev/aspirec4 @@ -17,7 +17,7 @@ it beside your application. ## Prerequisites -- .NET 8 or later. +- .NET 10 or later. `AspireC4.Hosting` targets `net10.0`, so the AppHost must too. - **Aspire 13.5.3 or later.** An AppHost project must reference both the AppHost SDK and `Aspire.Hosting.AppHost`. - **Docker**, to run the LikeC4 sidecar container — or a local Node CLI runtime if you use @@ -60,6 +60,31 @@ On startup AspireC4: Open the Aspire dashboard and select the `aspirec4` resource, or its **View LikeC4 Diagram** link. +## Architecture only, or both diagrams + +`AddAspireC4()` on its own is the whole integration: the LikeC4 architecture diagram is the base, and it +is the only diagram many applications need. Nothing else has to be installed. + +A second, optional ER diagram of your Entity Framework Core `DbContext` types is added by a separate +AppHost package, on the builder `AddAspireC4()` returns: + +```csharp +builder.AddAspireC4() + .WithEntityFrameworkDiagram(); +``` + +`WithEntityFrameworkDiagram()` is an extension on `IResourceBuilder`, so the architecture +diagram is always present — the ER diagram can never be used on its own. With both registered, the +dashboard nests them under one `aspirec4` parent row and each contributing project links to its schema. +See `purview-aspirec4-entityframework` for the packages, the fidelity sources and the renderers. + +## Looking at the output + +Every view is exported as an image on startup — the architecture diagram as PNG, the ER diagram as SVG +and PNG — into `./.aspirec4/images/` beside the AppHost. That folder is the fastest way to see (or +share) the diagram without opening the dashboard, and it is where to look when asked for a screenshot. +`WithoutImageExport()` turns it off. + ## Upgrading from 13.5 13.6 is breaking for anything that reads AspireC4's generated files or addresses its dashboard diff --git a/src/src/AspireC4.SourceGenerators/Extensions/System/Runtime/CompilerServices/IsExternalInit.cs b/src/src/AspireC4.SourceGenerators/Extensions/System/Runtime/CompilerServices/IsExternalInit.cs new file mode 100644 index 0000000..3a6dd60 --- /dev/null +++ b/src/src/AspireC4.SourceGenerators/Extensions/System/Runtime/CompilerServices/IsExternalInit.cs @@ -0,0 +1,15 @@ +#if NETSTANDARD2_0 || NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_0 || NETCOREAPP2_1 || NETCOREAPP2_2 || NETCOREAPP3_0 || NETCOREAPP3_1 || NET45 || NET451 || NET452 || NET6 || NET461 || NET462 || NET47 || NET471 || NET472 || NET48 + +using System.ComponentModel; + +// Compilation error of CS0518 IsExternalInit is not defined when using .NET Standard. +// re: https://mking.net/blog/error-cs0518-isexternalinit-not-defined +#pragma warning disable IDE0130 // Namespace does not match folder structure +namespace System.Runtime.CompilerServices; + +#pragma warning restore IDE0130 // Namespace does not match folder structure + +[EditorBrowsable(EditorBrowsableState.Never)] +static class IsExternalInit; + +#endif diff --git a/src/src/AspireC4.SourceGenerators/LikeC4DiagnosticRules.cs b/src/src/AspireC4.SourceGenerators/LikeC4DiagnosticRules.cs new file mode 100644 index 0000000..8eafaeb --- /dev/null +++ b/src/src/AspireC4.SourceGenerators/LikeC4DiagnosticRules.cs @@ -0,0 +1,206 @@ +using Microsoft.CodeAnalysis; + +namespace Aspire.Hosting.AspireC4.SourceGenerators; + +/// +/// Provides the diagnostic descriptors shared between the source generator and the analyzer. +/// Each rule is tagged with the component that owns it, based on the data sources it needs: +/// +/// +/// +/// +/// Generator () +/// +/// Rules tagged need the merged view of both +/// the DSL-file (AdditionalText .c4) definitions and the [LikeC4Registry] +/// class definitions. Only the generator can access AdditionalText files, so it owns these. +/// +/// +/// +/// Analyzer () +/// +/// Rules tagged depend solely on [LikeC4Registry] +/// class definitions, which analyzers can read from the compilation. The analyzer owns these. +/// +/// +/// +/// +static class LikeC4DiagnosticRules +{ + /// Indicates which component emits a diagnostic rule. + enum DiagnosticRuleSource + { + /// The rule needs both DSL-file and class definitions; emitted by the generator. + RequiresBothSources, + + /// The rule needs only class definitions; emitted by the analyzer. + ClassOnly, + } + + /// SOURCE: Generator — RequiresBothSources. Emitted when a .WithTag() argument is not declared in the active definitions. + public static readonly DiagnosticDescriptor UndeclaredTag = new( + id: "ASPIREC4001", + title: "Undeclared LikeC4 tag", + messageFormat: "Tag '{0}' is not declared. Add it to a 'specification {{ tag {0} }}' block in a .c4 additional file, " + + "or as 'public const string' in the 'Tags' nested class of your [LikeC4Registry] class.", + category: "AspireC4", + defaultSeverity: DiagnosticSeverity.Warning, + isEnabledByDefault: true, + description: "All tags passed to WithTag() must be declared in the LikeC4 specification block of an additional " + + ".c4 file (when AspireC4Strict has a non-off severity), or as public const string fields in the Tags nested class " + + "of a [LikeC4Registry]-annotated class." + ); + + /// + /// SOURCE: Generator — RequiresBothSources. Emitted when a .WithKind() argument is not declared in any + /// active element-kind or relationship-kind definition source. + /// + public static readonly DiagnosticDescriptor UndeclaredKind = new( + id: "ASPIREC4002", + title: "Undeclared LikeC4 element or relationship kind", + messageFormat: "Kind '{0}' is not declared. Add it to a 'specification {{ element {0} }}' or " + + "'specification {{ relationship {0} }}' block in a .c4 additional file, " + + "or as 'public const string' in 'ElementKinds' or 'RelationshipKinds' nested class of your [LikeC4Registry] class.", + category: "AspireC4", + defaultSeverity: DiagnosticSeverity.Warning, + isEnabledByDefault: true, + description: "All kinds passed to WithKind() must be declared in the LikeC4 specification block of an additional " + + ".c4 file (when AspireC4Strict has a non-off severity), or as public const string fields in the ElementKinds or " + + "RelationshipKinds nested class of a [LikeC4Registry]-annotated class." + ); + + /// SOURCE: Analyzer — ClassOnly. Emitted when more than one class per assembly carries [LikeC4Registry]. + public static readonly DiagnosticDescriptor MultipleDefinitionsClasses = new( + id: "ASPIREC4003", + title: "Multiple [LikeC4Registry] classes", + messageFormat: "Only one class per assembly may carry [LikeC4Registry]. Duplicate found: '{0}'.", + category: "AspireC4", + defaultSeverity: DiagnosticSeverity.Warning, + isEnabledByDefault: true, + description: "Only one class per assembly may be annotated with [LikeC4Registry]. " + + "Consolidate all tag, element-kind, relationship-kind, group, and metadata-key definitions into a single class.", + customTags: [WellKnownDiagnosticTags.CompilationEnd] + ); + + /// SOURCE: Analyzer — ClassOnly. Emitted when a .WithLikeC4Group() argument is not declared in the active definitions. + public static readonly DiagnosticDescriptor UndeclaredGroup = new( + id: "ASPIREC4004", + title: "Undeclared LikeC4 group", + messageFormat: "Group '{0}' is not declared. Add it as 'public const string' in the 'Groups' nested class of your [LikeC4Registry] class.", + category: "AspireC4", + defaultSeverity: DiagnosticSeverity.Warning, + isEnabledByDefault: true, + description: "All group names passed to WithLikeC4Group() must be declared as public const string fields " + + "in the Groups nested class of a [LikeC4Registry]-annotated class." + ); + + /// + /// SOURCE: Analyzer — ClassOnly. Emitted when a registry type is declared both via a named nested class + /// and via individual [KnownType] attributes on constants. + /// + public static readonly DiagnosticDescriptor DuplicateTypeDeclaration = new( + id: "ASPIREC4005", + title: "Duplicate LikeC4 registry type declaration", + messageFormat: "Registry type '{0}' is declared both as a nested class and via [KnownType] attributes. Use only one declaration approach per type.", + category: "AspireC4", + defaultSeverity: DiagnosticSeverity.Warning, + isEnabledByDefault: true, + description: "A registry type (e.g. Tag, Group) must be declared either as a nested static class " + + "(e.g. 'public static class Tags { ... }') OR via [KnownType] attributes on individual constants, not both.", + customTags: [WellKnownDiagnosticTags.CompilationEnd] + ); + + /// SOURCE: Analyzer — ClassOnly. Emitted when a .WithMetadata() key argument is not declared in the active definitions. + public static readonly DiagnosticDescriptor UndeclaredMetadataKey = new( + id: "ASPIREC4006", + title: "Undeclared LikeC4 metadata key", + messageFormat: "Metadata key '{0}' is not declared. Add it as 'public const string' in the 'MetadataKeys' nested class of your [LikeC4Registry] class.", + category: "AspireC4", + defaultSeverity: DiagnosticSeverity.Warning, + isEnabledByDefault: true, + description: "All metadata keys passed to WithMetadata() must be declared as public const string fields " + + "in the MetadataKeys nested class of a [LikeC4Registry]-annotated class. " + + "Keys are compared after normalising whitespace and punctuation to underscores, and are case-insensitive." + ); + + // --- Shared severity helpers --- + + /// Severity constants: 0 = Inherit, 1 = Off, 2 = Suggestion, 3 = Warning, 4 = Error. + public const int SeverityInherit = 0; + public const int SeverityOff = 1; + public const int SeveritySuggestion = 2; + public const int SeverityWarning = 3; + public const int SeverityError = 4; + + /// + /// Parses the AspireC4Strict MSBuild value into a global severity and a flag indicating whether + /// metadata-key validation is included. Mirrors the historical ParseGlobalStrict behaviour. + /// + public static (DiagnosticSeverity? Severity, bool IncludesMetadata) ParseGlobalStrict(string? val) + { + if (string.IsNullOrWhiteSpace(val)) + return (null, false); + + var normalized = val!.Trim(); + if (normalized.Equals("off", StringComparison.OrdinalIgnoreCase)) + return (null, false); + if (normalized.Equals("suggestion", StringComparison.OrdinalIgnoreCase)) + return (DiagnosticSeverity.Info, false); + if (normalized.Equals("warning", StringComparison.OrdinalIgnoreCase)) + return (DiagnosticSeverity.Warning, false); + if ( + normalized.Equals("error", StringComparison.OrdinalIgnoreCase) + || normalized.Equals("true", StringComparison.OrdinalIgnoreCase) + || normalized.Equals("yes", StringComparison.OrdinalIgnoreCase) + || normalized.Equals("all", StringComparison.OrdinalIgnoreCase) + ) + return (DiagnosticSeverity.Error, false); + if (normalized.Equals("allincludingmetadata", StringComparison.OrdinalIgnoreCase)) + return (DiagnosticSeverity.Error, true); + + return (null, false); + } + + /// Returns the descriptor, or a copy with the specified default severity when it differs. + public static DiagnosticDescriptor WithSeverity(DiagnosticDescriptor descriptor, DiagnosticSeverity severity) => + severity == descriptor.DefaultSeverity + ? descriptor + : new DiagnosticDescriptor( + descriptor.Id, + descriptor.Title, + descriptor.MessageFormat, + descriptor.Category, + severity, + descriptor.IsEnabledByDefault, + descriptor.Description, + descriptor.HelpLinkUri + ); + + /// Resolves the registry-wide severity from the [LikeC4Registry(Strict=...)] raw mode. + public static DiagnosticSeverity? ResolveRegistrySeverity( + int registryRaw, + DiagnosticSeverity? globalStrict, + bool hasClassValidation + ) => + registryRaw switch + { + SeverityOff => null, + SeverityInherit => globalStrict ?? (hasClassValidation ? DiagnosticSeverity.Info : null), + SeveritySuggestion => DiagnosticSeverity.Info, + SeverityWarning => DiagnosticSeverity.Warning, + SeverityError => DiagnosticSeverity.Error, + _ => null, + }; + + /// Resolves a per-type severity from the raw mode, inheriting the registry severity when Inherit. + public static DiagnosticSeverity? ResolveTypeSeverity(int typeRaw, DiagnosticSeverity? registrySeverity) => + typeRaw switch + { + SeverityOff => null, + SeverityInherit => registrySeverity, + SeveritySuggestion => DiagnosticSeverity.Info, + SeverityWarning => DiagnosticSeverity.Warning, + SeverityError => DiagnosticSeverity.Error, + _ => registrySeverity, + }; +} diff --git a/src/src/AspireC4.SourceGenerators/LikeC4RegistryAnalyzer.cs b/src/src/AspireC4.SourceGenerators/LikeC4RegistryAnalyzer.cs new file mode 100644 index 0000000..8a65b1a --- /dev/null +++ b/src/src/AspireC4.SourceGenerators/LikeC4RegistryAnalyzer.cs @@ -0,0 +1,291 @@ +using System.Collections.Immutable; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using Microsoft.CodeAnalysis.Diagnostics; + +namespace Aspire.Hosting.AspireC4.SourceGenerators; + +/// +/// Class-based LikeC4 registry analyzer. Reports the [LikeC4Registry]-only diagnostics +/// (ASPIREC4003, ASPIREC4004, ASPIREC4005, ASPIREC4006) — i.e. the rules that only require the +/// class definitions and do not need the AdditionalText (.c4) DSL files. +/// The DSL-file-dependent rules (ASPIREC4001, ASPIREC4002) are owned by +/// . See for ownership tags. +/// +[DiagnosticAnalyzer(LanguageNames.CSharp)] +public sealed class LikeC4RegistryAnalyzer : DiagnosticAnalyzer +{ + const string WithGroupMethodName = "WithLikeC4Group"; + const string WithMetadataMethodName = "WithMetadata"; + + /// + public override ImmutableArray SupportedDiagnostics { get; } = + ImmutableArray.Create( + LikeC4DiagnosticRules.MultipleDefinitionsClasses, + LikeC4DiagnosticRules.UndeclaredGroup, + LikeC4DiagnosticRules.DuplicateTypeDeclaration, + LikeC4DiagnosticRules.UndeclaredMetadataKey + ); + + /// + public override void Initialize(AnalysisContext context) + { + if (context is null) + throw new ArgumentNullException(nameof(context)); + + context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); + context.EnableConcurrentExecution(); + + context.RegisterCompilationStartAction(startContext => + { + // Honour the same opt-out as the generator. + var options = startContext.Options.AnalyzerConfigOptionsProvider.GlobalOptions; + if ( + TryGetOption(options, "build_property.DisableAspireC4SourceGenerator") is { } disabledVal + && string.Equals(disabledVal, "true", StringComparison.OrdinalIgnoreCase) + ) + return; + + var globalStrict = LikeC4DiagnosticRules.ParseGlobalStrict( + TryGetOption(options, "build_property.AspireC4Strict") + ); + + var state = new RegistryState(startContext.Compilation); + var config = new Lazy(() => BuildConfig(state, globalStrict)); + + startContext.RegisterSyntaxNodeAction( + context => AnalyzeInvocation(context, state, config), + SyntaxKind.InvocationExpression + ); + + startContext.RegisterCompilationEndAction(context => ReportStructural(context, state)); + }); + } + + // --- Configuration --- + + sealed class ValidationConfig( + HashSet groups, + HashSet metadata, + DiagnosticSeverity? groupSeverity, + DiagnosticSeverity? metadataSeverity, + bool isExplicitlyEnabled + ) + { + public HashSet Groups { get; } = groups; + public HashSet Metadata { get; } = metadata; + public DiagnosticSeverity? GroupSeverity { get; } = groupSeverity; + public DiagnosticSeverity? MetadataSeverity { get; } = metadataSeverity; + public bool IsExplicitlyEnabled { get; } = isExplicitlyEnabled; + } + + static ValidationConfig BuildConfig( + RegistryState state, + (DiagnosticSeverity? Severity, bool IncludesMetadata) globalStrict + ) + { + var registries = state.Registries; + bool hasClassValidation = registries.Length > 0; + var primaryDef = hasClassValidation ? registries[0] : null; + + int registryRaw = primaryDef?.RegistryStrictMode ?? LikeC4DiagnosticRules.SeverityInherit; + bool registryExplicit = registryRaw != LikeC4DiagnosticRules.SeverityInherit; + bool globalExplicit = globalStrict.Severity is not null; + bool isExplicitlyEnabled = registryExplicit || globalExplicit; + + var registrySeverity = LikeC4DiagnosticRules.ResolveRegistrySeverity( + registryRaw, + globalStrict.Severity, + hasClassValidation + ); + + int groupsTypeRaw = primaryDef?.GroupsTypeStrictMode ?? LikeC4DiagnosticRules.SeverityInherit; + var groupsSeverity = LikeC4DiagnosticRules.ResolveTypeSeverity(groupsTypeRaw, registrySeverity); + + int metadataTypeRaw = primaryDef?.MetadataKeysTypeStrictMode ?? LikeC4DiagnosticRules.SeverityInherit; + var metadataSeverity = + metadataTypeRaw != LikeC4DiagnosticRules.SeverityInherit + ? LikeC4DiagnosticRules.ResolveTypeSeverity(metadataTypeRaw, registrySeverity) + : (globalStrict.IncludesMetadata ? registrySeverity : null); + + var allowedGroups = LikeC4StrictValidatorGenerator.BuildAllowedSet( + [], + registries.SelectMany(static d => d.Groups) + ); + var allowedMetadata = LikeC4StrictValidatorGenerator.BuildAllowedSet( + [], + registries + .SelectMany(static d => d.MetadataKeys) + .Select(LikeC4StrictValidatorGenerator.NormaliseMetadataKeyForComparison) + ); + + return new ValidationConfig( + allowedGroups, + allowedMetadata, + groupsSeverity, + metadataSeverity, + isExplicitlyEnabled + ); + } + + // --- Call-site validation (ASPIREC4004 / ASPIREC4006) --- + + static void AnalyzeInvocation( + SyntaxNodeAnalysisContext context, + RegistryState state, + Lazy configLazy + ) + { + if (context.Node is not InvocationExpressionSyntax invocation) + return; + + if ( + invocation.ArgumentList.Arguments.Count == 0 + || invocation.Expression is not MemberAccessExpressionSyntax member + ) + return; + + var methodName = member.Name.Identifier.Text; + if (methodName != WithGroupMethodName && methodName != WithMetadataMethodName) + return; + + var firstArg = invocation.ArgumentList.Arguments[0].Expression; + var constant = context.SemanticModel.GetConstantValue(firstArg, context.CancellationToken); + if (!constant.HasValue || constant.Value is not string value) + return; + + var config = configLazy.Value; + + if (methodName == WithGroupMethodName && config.GroupSeverity is { } groupSeverity) + { + if ((config.Groups.Count > 0 || config.IsExplicitlyEnabled) && !config.Groups.Contains(value)) + { + var descriptor = LikeC4DiagnosticRules.WithSeverity( + LikeC4DiagnosticRules.UndeclaredGroup, + groupSeverity + ); + context.ReportDiagnostic(Diagnostic.Create(descriptor, firstArg.GetLocation(), value)); + } + + return; + } + + if (methodName == WithMetadataMethodName && config.MetadataSeverity is { } metadataSeverity) + { + if ( + (config.Metadata.Count > 0 || config.IsExplicitlyEnabled) + && !config.Metadata.Contains(LikeC4StrictValidatorGenerator.NormaliseMetadataKeyForComparison(value)) + ) + { + var descriptor = LikeC4DiagnosticRules.WithSeverity( + LikeC4DiagnosticRules.UndeclaredMetadataKey, + metadataSeverity + ); + context.ReportDiagnostic(Diagnostic.Create(descriptor, firstArg.GetLocation(), value)); + } + } + } + + // --- Structural validation (ASPIREC4003 / ASPIREC4005) --- + + static void ReportStructural(CompilationAnalysisContext context, RegistryState state) + { + var registries = state.Registries; + + if (registries.Length > 1) + { + for (int i = 1; i < registries.Length; i++) + { + context.ReportDiagnostic( + Diagnostic.Create( + LikeC4DiagnosticRules.MultipleDefinitionsClasses, + registries[i].Location, + registries[i].DisplayName + ) + ); + } + } + + foreach (var def in registries) + { + foreach (var (typeName, dupLocation) in def.DuplicateTypeDeclarations) + { + context.ReportDiagnostic( + Diagnostic.Create(LikeC4DiagnosticRules.DuplicateTypeDeclaration, dupLocation, typeName) + ); + } + } + } + + // --- Registry discovery --- + + /// + /// Lazily discovers all [LikeC4Registry]-annotated classes in the compilation and extracts + /// their . Discovery is independent of the analyzer's symbol-action + /// scheduling, so it is safe under concurrent execution. + /// + sealed class RegistryState(Compilation compilation) + { + readonly Lazy> _registries = new(() => FindRegistryDefinitions(compilation)); + public ImmutableArray Registries => _registries.Value; + + static ImmutableArray FindRegistryDefinitions(Compilation compilation) + { + var builder = ImmutableArray.CreateBuilder(); + + var registryAttribute = compilation.GetTypeByMetadataName( + "Aspire.Hosting.AspireC4.LikeC4RegistryAttribute" + ); + if (registryAttribute is null) + return builder.ToImmutable(); + + foreach (var type in GetAllNamedTypes(compilation.Assembly.GlobalNamespace)) + { + var attributes = type.GetAttributes(); + bool isRegistry = attributes.Any(a => + registryAttribute is not null + && SymbolEqualityComparer.Default.Equals(a.AttributeClass, registryAttribute) + ); + if (!isRegistry) + continue; + + builder.Add( + LikeC4StrictValidatorGenerator.ExtractClassDefinitions(type, attributes, CancellationToken.None) + ); + } + + return builder.ToImmutable(); + } + + static IEnumerable GetAllNamedTypes(INamespaceSymbol ns) + { + foreach (var type in ns.GetTypeMembers()) + { + foreach (var nested in GetAllNamedTypes(type)) + yield return nested; + } + + foreach (var childNs in ns.GetNamespaceMembers()) + { + foreach (var nested in GetAllNamedTypes(childNs)) + yield return nested; + } + } + + static IEnumerable GetAllNamedTypes(INamedTypeSymbol type) + { + yield return type; + foreach (var nested in type.GetTypeMembers()) + { + foreach (var child in GetAllNamedTypes(nested)) + yield return child; + } + } + } + + // --- Shared helpers --- + + static string? TryGetOption(AnalyzerConfigOptions options, string key) => + options.TryGetValue(key, out var value) ? value : null; +} diff --git a/src/src/AspireC4/README.md b/src/src/AspireC4/README.md index e6a09c1..769f513 100644 --- a/src/src/AspireC4/README.md +++ b/src/src/AspireC4/README.md @@ -8,6 +8,7 @@ the Aspire dashboard. ## Prerequisites +- **.NET 10 or later.** This package targets `net10.0`, so the AppHost that references it must too. - **Aspire 13.5.3 or later.** The AppHost must reference both the AppHost SDK and `Aspire.Hosting.AppHost`. - **Docker** (or Podman) for the default LikeC4 sidecar container. @@ -54,6 +55,15 @@ builder.Build().Run(); When the AppHost starts, this writes `./.aspirec4/likec4/model.gen.c4` and starts the LikeC4 server. The diagram refreshes as the Aspire app changes. Open it from the `aspirec4` resource in the dashboard. +## Screenshots + +![AspireC4 architecture diagram of the sample AppHost: a Node app referencing Redis Commander, local Redis and Postgres in a local dev group, PgWeb, Azure Redis and Azure Postgres, with labelled relationships](https://raw.githubusercontent.com/purview-dev/aspirec4/main/docs/images/screenshots/architecture-diagram.png) + +The image above is captured from the sample AppHost in the +[repository](https://github.com/purview-dev/aspirec4) and stored in `docs/images/screenshots/`. Your own +diagram exports a PNG for every view to `./.aspirec4/images/` on startup (`ExportImages`), which is the +easiest way to capture one. + ## Configuration Configure the diagram in the `configure` callback, or through the `AspireC4` configuration section. @@ -160,6 +170,12 @@ Add [`AspireC4.Hosting.EntityFrameworkCore`](https://www.nuget.org/packages/Aspi to the AppHost and call `.WithEntityFrameworkDiagram()` to add a live ER diagram of your `DbContext` types, linked from the architecture diagram. +It is **additive, and optional**: `AddAspireC4()` stays exactly as it is, and +`WithEntityFrameworkDiagram()` is an extension on the builder it returns, so the two diagrams run side by +side — or you keep the architecture diagram on its own and never install the package. The ER diagram has +its own renderers (`Interactive` by default, plus `Mermaid`, `Dbml` and `D2`) and options; see that +package's README. + ## More information - [Full documentation](https://purview.dev/docs/aspirec4/) diff --git a/src/src/EntityFrameworkCore.Analyzers/README.md b/src/src/EntityFrameworkCore.Analyzers/README.md index 2e2f6d9..e188038 100644 --- a/src/src/EntityFrameworkCore.Analyzers/README.md +++ b/src/src/EntityFrameworkCore.Analyzers/README.md @@ -21,6 +21,15 @@ configuration. | `DbSet`, navigations, `[Key]`, `[Table]`, `[Column]`, `[Required]`, `[MaxLength]`, `[Index]`, … | All of that, **plus** `HasDefaultSchema`, `ToTable`, `HasKey`, `Ignore`, `HasIndex(...).IsUnique()`, `HasColumnName`, `HasColumnType`, `HasMaxLength`, `IsRequired`, `HasComment` | | Fidelity: `Approximate` | Fidelity: `Full` | +## Requirements + +- **`netstandard2.0` analyzer, no runtime surface.** The package ships under `analyzers/dotnet/cs/`, so it + loads into the compiler for whatever framework your project targets and adds nothing to your build + output. The generated `[assembly: AspireC4EfModel]` attribute is compiled into your own assembly, which + the `net10.0` AppHost then reads. +- The project still has to be registered in the AppHost with `AddProject(...)`, and the AppHost + still has to call `WithEntityFrameworkDiagram()`. + ## Installation Add it to the project that **declares** your `DbContext`. That can be the service project or a class @@ -38,9 +47,6 @@ yours: ``` -The service project still has to be registered in the AppHost with `AddProject(...)`, and the -AppHost has to call `WithEntityFrameworkDiagram()`. - ## How it works At compile time the generator analyses every `DbContext` in the project and emits the model as a single diff --git a/src/src/EntityFrameworkCore.ModelDump/README.md b/src/src/EntityFrameworkCore.ModelDump/README.md index b160081..ab0e4d7 100644 --- a/src/src/EntityFrameworkCore.ModelDump/README.md +++ b/src/src/EntityFrameworkCore.ModelDump/README.md @@ -34,6 +34,11 @@ dotnet add package AspireC4.EntityFrameworkCore.ModelDump The reference is the opt-in. The package is a development dependency, so it adds nothing to your build output or to the projects that reference yours. +The dump tool itself targets **`net10.0`** and is invoked as `dotnet .dll` in an MSBuild `Exec` +after `Build`, so the machine doing the build needs a .NET 10 runtime. A build that cannot run the tool +simply produces no dump (the target is `ContinueOnError`); the AppHost then falls back to the other +sources. + ### 2. Make sure the project has a design-time factory The dump creates each context through `IDesignTimeDbContextFactory`, which is the same entry point diff --git a/src/src/EntityFrameworkCore/README.md b/src/src/EntityFrameworkCore/README.md index e2e40e7..d342f4d 100644 --- a/src/src/EntityFrameworkCore/README.md +++ b/src/src/EntityFrameworkCore/README.md @@ -6,10 +6,20 @@ Adds a live **ER diagram of your Entity Framework Core `DbContext` types** to an [Aspire](https://learn.microsoft.com/en-us/dotnet/aspire/) AppHost, alongside the [AspireC4](https://www.nuget.org/packages/AspireC4.Hosting) architecture diagram and linked from it. +It is **optional and additive**: the architecture diagram from `AddAspireC4()` is always the base, and +`WithEntityFrameworkDiagram()` adds the ER diagram beside it. You can run the architecture diagram on its +own without this package; there is no way to have the ER diagram without it, because the extension hangs +off the builder `AddAspireC4()` returns. + You install it in the **AppHost** and call one method. Your service projects need no changes. ## Prerequisites +- **.NET 10 or later.** This package targets `net10.0`; the optional + [`AspireC4.EntityFrameworkCore`](https://www.nuget.org/packages/AspireC4.EntityFrameworkCore) analyzer is + `netstandard2.0` and the + [`AspireC4.EntityFrameworkCore.ModelDump`](https://www.nuget.org/packages/AspireC4.EntityFrameworkCore.ModelDump) + tool is `net10.0`. - An Aspire 13.5+ AppHost already using [`AspireC4.Hosting`](https://www.nuget.org/packages/AspireC4.Hosting) (this package depends on it, so installing this one brings it in). - The projects that own your `DbContext` types are registered in the AppHost with @@ -91,6 +101,15 @@ When a context is available from more than one source, the best one is used: **d **descriptor**, then **metadata**. Each context in the diagram records its fidelity, so an approximate model is never mistaken for a complete one. +## Screenshots + +![AspireC4 interactive ER diagram of the sample AppHost: five DbContext groups of tables with primary and foreign key badges and crow's-foot relationship edges](https://raw.githubusercontent.com/purview-dev/aspirec4/main/docs/images/screenshots/entity-framework-er-diagram.png) + +The image above is captured from the sample AppHost in the +[repository](https://github.com/purview-dev/aspirec4) and stored in `docs/images/screenshots/`. Your own +diagram exports to `./.aspirec4/images/` on startup (`ExportImages`, SVG and PNG by default), and the +viewer has its own **Save as SVG / PNG** buttons. + ## Choosing which contexts appear By default every project resource is scanned. To narrow that down: diff --git a/src/tests/AspireC4.SourceGenerators.UnitTests/LikeC4RegistryAnalyzerTests.cs b/src/tests/AspireC4.SourceGenerators.UnitTests/LikeC4RegistryAnalyzerTests.cs new file mode 100644 index 0000000..62a4b9e --- /dev/null +++ b/src/tests/AspireC4.SourceGenerators.UnitTests/LikeC4RegistryAnalyzerTests.cs @@ -0,0 +1,536 @@ +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Globalization; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.Diagnostics; + +namespace Aspire.Hosting.AspireC4.SourceGenerators; + +public sealed class LikeC4RegistryAnalyzerTests +{ + const string AttributeSource = """ + namespace Aspire.Hosting.AspireC4 + { + [System.AttributeUsage(System.AttributeTargets.Class, Inherited = false, AllowMultiple = false)] + internal sealed class LikeC4RegistryAttribute : System.Attribute + { + public LikeC4Severity Strict { get; init; } = LikeC4Severity.Inherit; + } + internal enum LikeC4RegistryType { Tag = 0, ElementKind = 1, RelationshipKind = 2, Group = 3, MetadataKey = 4 } + internal enum LikeC4Severity { Inherit = 0, Off = 1, Suggestion = 2, Warning = 3, Error = 4 } + [System.AttributeUsage(System.AttributeTargets.Field, Inherited = false, AllowMultiple = false)] + internal sealed class KnownTypeAttribute : System.Attribute + { + public KnownTypeAttribute(LikeC4RegistryType type) { Type = type; } + public LikeC4RegistryType Type { get; } + public LikeC4Severity Strict { get; init; } = LikeC4Severity.Inherit; + } + } + """; + + // ----------------------------------------------------------------------- + // Multiple [LikeC4Registry] classes (ASPIREC4003) + // ----------------------------------------------------------------------- + + [Test] + public async Task Analyze_WithMultipleDefinitionsClasses_EmitsMultipleDefinitionsDiagnostic( + CancellationToken cancellationToken + ) + { + // Arrange + const string source = """ + using Aspire.Hosting.AspireC4; + namespace TestApp; + + [LikeC4Registry] + class FirstDefinitions { public static class Tags { public const string External = "external"; } } + + [LikeC4Registry] + class SecondDefinitions { public static class Tags { public const string Internal = "internal"; } } + """; + + // Act + var diagnostics = RunAnalyzer(source, cancellationToken: cancellationToken); + + // Assert + var result = GetDiagnostics(diagnostics, "ASPIREC4003"); + await Assert.That(result.Count).IsGreaterThan(0); + } + + [Test] + public async Task Analyze_WithSingleDefinitionsClass_EmitsNoMultipleDefinitionsDiagnostic( + CancellationToken cancellationToken + ) + { + // Arrange + const string source = """ + using Aspire.Hosting.AspireC4; + namespace TestApp; + + [LikeC4Registry] + class OnlyDefinitions { public static class Tags { public const string External = "external"; } } + """; + + // Act + var diagnostics = RunAnalyzer(source, cancellationToken: cancellationToken); + + // Assert + await Assert.That(GetDiagnostics(diagnostics, "ASPIREC4003")).IsEmpty(); + } + + // ----------------------------------------------------------------------- + // Group validation (ASPIREC4004) + // ----------------------------------------------------------------------- + + [Test] + public async Task Analyze_WithDeclaredGroup_EmitsNoDiagnostic(CancellationToken cancellationToken) + { + // Arrange + const string source = """ + using Aspire.Hosting.AspireC4; + namespace TestApp; + + [LikeC4Registry] + class MyRegistry + { + public static class Groups { public const string Frontend = "Frontend"; } + } + + class Setup { static void Configure() { var a = new object(); a.WithLikeC4Group("Frontend"); } } + """; + + // Act + var diagnostics = RunAnalyzer(source, cancellationToken: cancellationToken); + + // Assert + await Assert.That(GetDiagnostics(diagnostics, "ASPIREC4004")).IsEmpty(); + } + + [Test] + public async Task Analyze_WithUndeclaredGroup_EmitsUndeclaredGroupDiagnostic(CancellationToken cancellationToken) + { + // Arrange + const string source = """ + using Aspire.Hosting.AspireC4; + namespace TestApp; + + [LikeC4Registry] + class MyRegistry + { + public static class Groups { public const string Frontend = "Frontend"; } + } + + class Setup { static void Configure() { var a = new object(); a.WithLikeC4Group("Backend"); } } + """; + + // Act + var diagnostics = RunAnalyzer(source, cancellationToken: cancellationToken); + + // Assert + var result = GetDiagnostics(diagnostics, "ASPIREC4004"); + await Assert.That(result.Count).IsGreaterThan(0); + await Assert.That(result[0].GetMessage(CultureInfo.InvariantCulture)).Contains("Backend"); + } + + [Test] + public async Task Analyze_WithGroupCaseVariant_EmitsNoDiagnostic(CancellationToken cancellationToken) + { + // Arrange — group comparison is case-insensitive + const string source = """ + using Aspire.Hosting.AspireC4; + namespace TestApp; + + [LikeC4Registry] + class MyRegistry + { + public static class Groups { public const string Frontend = "Frontend"; } + } + + class Setup { static void Configure() { var a = new object(); a.WithLikeC4Group("frontend"); } } + """; + + // Act + var diagnostics = RunAnalyzer(source, cancellationToken: cancellationToken); + + // Assert + await Assert.That(GetDiagnostics(diagnostics, "ASPIREC4004")).IsEmpty(); + } + + [Test] + public async Task Analyze_WithoutGroupsNestedClass_EmitsNoDiagnosticForGroup(CancellationToken cancellationToken) + { + // Arrange — registry exists but has no Groups nested class → no group validation + const string source = """ + using Aspire.Hosting.AspireC4; + namespace TestApp; + + [LikeC4Registry] + class MyRegistry { public static class Tags { public const string External = "external"; } } + + class Setup { static void Configure() { var a = new object(); a.WithLikeC4Group("anything"); } } + """; + + // Act + var diagnostics = RunAnalyzer(source, cancellationToken: cancellationToken); + + // Assert + await Assert.That(GetDiagnostics(diagnostics, "ASPIREC4004")).IsEmpty(); + } + + [Test] + public async Task Analyze_WithNoDefinitionsClassAndGroupCallSite_EmitsNoDiagnostic( + CancellationToken cancellationToken + ) + { + // Arrange + const string source = """ + namespace TestApp; + class Setup { static void Configure() { var a = new object(); a.WithLikeC4Group("Frontend"); } } + """; + + // Act + var diagnostics = RunAnalyzer(source, cancellationToken: cancellationToken); + + // Assert + await Assert.That(GetDiagnostics(diagnostics, "ASPIREC4004")).IsEmpty(); + } + + [Test] + public async Task Analyze_WithKnownTypeGroupField_ValidatesGroupCallSite(CancellationToken cancellationToken) + { + // Arrange + const string source = """ + using Aspire.Hosting.AspireC4; + namespace TestApp; + + [LikeC4Registry] + static class MyRegistry + { + [KnownType(LikeC4RegistryType.Group)] + public const string Frontend = "Frontend"; + } + + class Setup + { + static void Configure() + { + var a = new object(); + a.WithLikeC4Group("Backend"); + } + } + """; + + // Act + var diagnostics = RunAnalyzer(source, cancellationToken: cancellationToken); + + // Assert + var result = GetDiagnostics(diagnostics, "ASPIREC4004"); + await Assert.That(result.Count).IsGreaterThan(0); + await Assert.That(result[0].GetMessage(CultureInfo.InvariantCulture)).Contains("Backend"); + } + + // ----------------------------------------------------------------------- + // Duplicate type declaration (ASPIREC4005) + // ----------------------------------------------------------------------- + + [Test] + public async Task Analyze_WithDuplicateTypeDeclaration_EmitsDuplicateTypeDeclarationDiagnostic( + CancellationToken cancellationToken + ) + { + // Arrange — Tags declared both as nested class AND via [KnownType] on a field + const string source = """ + using Aspire.Hosting.AspireC4; + namespace TestApp; + + [LikeC4Registry] + static class MyRegistry + { + [KnownType(LikeC4RegistryType.Tag)] + public const string InlineTag = "inline-tag"; + + public static class Tags + { + public const string External = "external"; + } + } + + class Setup { static void Configure() { } } + """; + + // Act + var diagnostics = RunAnalyzer(source, cancellationToken: cancellationToken); + + // Assert + var result = GetDiagnostics(diagnostics, "ASPIREC4005"); + await Assert.That(result.Count).IsGreaterThan(0); + } + + // ----------------------------------------------------------------------- + // MetadataKeys (ASPIREC4006) + // ----------------------------------------------------------------------- + + static string MetadataSource(string keyValue, string callSite) => + $$""" + using Aspire.Hosting.AspireC4; + namespace TestApp; + + [LikeC4Registry] + class MyRegistry + { + public static class MetadataKeys { public const string AzureSku = "{{keyValue}}"; } + } + + class Setup { static void Configure() { var a = new object(); a{{callSite}}; } } + """; + + [Test] + public async Task Analyze_WithMetadataKeysNestedClass_ExtractsWithoutError(CancellationToken cancellationToken) + { + // Arrange — no call sites, just a MetadataKeys nested class + const string source = """ + using Aspire.Hosting.AspireC4; + namespace TestApp; + + [LikeC4Registry] + class MyRegistry { public static class MetadataKeys { public const string AzureSku = "Azure SKU"; } } + + class Setup { static void Configure() { } } + """; + + // Act — AllIncludingMetadata enables metadata key validation + var diagnostics = RunAnalyzer(source, strictMode: "AllIncludingMetadata", cancellationToken: cancellationToken); + + // Assert — no diagnostics from having a MetadataKeys nested class + await Assert.That(GetAspireDiagnostics(diagnostics)).IsEmpty(); + } + + [Test] + public async Task Analyze_WithMetadataCallSite_ExactMatch_EmitsNoDiagnostics(CancellationToken cancellationToken) + { + // Arrange + var source = MetadataSource("Azure_SKU", ".WithMetadata(\"Azure_SKU\", \"Standard_LRS\")"); + + // Act + var diagnostics = RunAnalyzer(source, strictMode: "AllIncludingMetadata", cancellationToken: cancellationToken); + + // Assert + await Assert.That(GetDiagnostics(diagnostics, "ASPIREC4006")).IsEmpty(); + } + + [Test] + public async Task Analyze_WithMetadataCallSite_SpaceVariant_EmitsNoDiagnostics(CancellationToken cancellationToken) + { + // Arrange — call site uses "azure sku" (space instead of underscore) + var source = MetadataSource("Azure_SKU", ".WithMetadata(\"azure sku\", \"Standard_LRS\")"); + + // Act + var diagnostics = RunAnalyzer(source, strictMode: "AllIncludingMetadata", cancellationToken: cancellationToken); + + // Assert — normalises to the same key + await Assert.That(GetDiagnostics(diagnostics, "ASPIREC4006")).IsEmpty(); + } + + [Test] + public async Task Analyze_WithMetadataCallSite_CaseVariant_EmitsNoDiagnostics(CancellationToken cancellationToken) + { + // Arrange + var source = MetadataSource("Azure_SKU", ".WithMetadata(\"AZURE_sku\", \"Standard_LRS\")"); + + // Act + var diagnostics = RunAnalyzer(source, strictMode: "AllIncludingMetadata", cancellationToken: cancellationToken); + + // Assert + await Assert.That(GetDiagnostics(diagnostics, "ASPIREC4006")).IsEmpty(); + } + + [Test] + public async Task Analyze_WithMetadataCallSite_RegistryKeyHasSpaces_CallSiteHasUnderscores_EmitsNoDiagnostics( + CancellationToken cancellationToken + ) + { + // Arrange — registry declares "Azure SKU" (with space); call site uses "Azure_SKU" + var source = MetadataSource("Azure SKU", ".WithMetadata(\"Azure_SKU\", \"Standard_LRS\")"); + + // Act + var diagnostics = RunAnalyzer(source, strictMode: "AllIncludingMetadata", cancellationToken: cancellationToken); + + // Assert + await Assert.That(GetDiagnostics(diagnostics, "ASPIREC4006")).IsEmpty(); + } + + [Test] + public async Task Analyze_WithMetadataCallSite_UndeclaredKey_EmitsDiagnostic(CancellationToken cancellationToken) + { + // Arrange + var source = MetadataSource("Azure_SKU", ".WithMetadata(\"unknown_key\", \"value\")"); + + // Act + var diagnostics = RunAnalyzer(source, strictMode: "AllIncludingMetadata", cancellationToken: cancellationToken); + + // Assert + var aspireDiags = GetDiagnostics(diagnostics, "ASPIREC4006"); + await Assert.That(aspireDiags.Count).IsEqualTo(1); + await Assert.That(aspireDiags[0].GetMessage(CultureInfo.InvariantCulture)).Contains("unknown_key"); + } + + // ----------------------------------------------------------------------- + // Severity escalation + // ----------------------------------------------------------------------- + + [Test] + public async Task Analyze_WithRegistryStrictEnableAndUndeclaredGroup_EmitsErrorSeverity( + CancellationToken cancellationToken + ) + { + // Arrange + const string source = """ + using Aspire.Hosting.AspireC4; + namespace TestApp; + + [LikeC4Registry(Strict = LikeC4Severity.Error)] + static class MyRegistry + { + public static class Groups { public const string Frontend = "Frontend"; } + } + + class Setup + { + static void Configure() + { + var a = new object(); + a.WithLikeC4Group("Backend"); + } + } + """; + + // Act + var diagnostics = RunAnalyzer(source, cancellationToken: cancellationToken); + + // Assert + var result = GetDiagnostics(diagnostics, "ASPIREC4004"); + await Assert.That(result.Count).IsGreaterThan(0); + await Assert.That(result[0].Severity).IsEqualTo(DiagnosticSeverity.Error); + } + + // ----------------------------------------------------------------------- + // DisableAspireC4SourceGenerator MSBuild property + // ----------------------------------------------------------------------- + + [Test] + public async Task Analyze_WithDisabledPropertyTrue_EmitsNoDiagnostics(CancellationToken cancellationToken) + { + // Arrange — undeclared group and metadata, duplicate declaration, two registries + const string source = """ + using Aspire.Hosting.AspireC4; + namespace TestApp; + + [LikeC4Registry] + static class FirstRegistry + { + [KnownType(LikeC4RegistryType.Tag)] + public const string InlineTag = "inline-tag"; + + public static class Tags { public const string External = "external"; } + } + + [LikeC4Registry] + static class SecondRegistry + { + public static class Groups { public const string Frontend = "Frontend"; } + } + + class Setup + { + static void Configure() + { + var a = new object(); + a.WithLikeC4Group("Backend"); + a.WithMetadata("unknown_key", "value"); + } + } + """; + + // Act + var diagnostics = RunAnalyzer(source, disabled: true, cancellationToken: cancellationToken); + + // Assert — analyzer disabled, so no ASPIREC4 diagnostics + await Assert.That(GetAspireDiagnostics(diagnostics)).IsEmpty(); + } + + // ----------------------------------------------------------------------- + + static ImmutableArray RunAnalyzer( + string source, + string? strictMode = null, + bool disabled = false, + CancellationToken cancellationToken = default + ) + { + var compilation = CSharpCompilation.Create( + "TestAssembly", + [ + CSharpSyntaxTree.ParseText(AttributeSource, cancellationToken: cancellationToken), + CSharpSyntaxTree.ParseText(source, cancellationToken: cancellationToken), + ], + GetMetadataReferences(), + new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary) + ); + + var buildProperties = new Dictionary(StringComparer.OrdinalIgnoreCase); + if (strictMode is not null) + buildProperties["build_property.AspireC4Strict"] = strictMode; + if (disabled) + buildProperties["build_property.DisableAspireC4SourceGenerator"] = "true"; + + AnalyzerOptions? options = + buildProperties.Count > 0 + ? new AnalyzerOptions( + ImmutableArray.Empty, + new TestAnalyzerConfigOptionsProvider(buildProperties) + ) + : null; + + var withAnalyzers = compilation.WithAnalyzers( + ImmutableArray.Create(new LikeC4RegistryAnalyzer()), + options + ); + + return withAnalyzers.GetAnalyzerDiagnosticsAsync(cancellationToken).GetAwaiter().GetResult(); + } + + static IEnumerable GetMetadataReferences() => + [ + MetadataReference.CreateFromFile(typeof(object).Assembly.Location), + MetadataReference.CreateFromFile(typeof(Compilation).Assembly.Location), + MetadataReference.CreateFromFile(typeof(CSharpCompilation).Assembly.Location), + ]; + + static IReadOnlyList GetDiagnostics(ImmutableArray diagnostics, string diagnosticId) => + [.. diagnostics.Where(d => d.Id == diagnosticId)]; + + static IReadOnlyList GetAspireDiagnostics(ImmutableArray diagnostics) => + [.. diagnostics.Where(d => d.Id.StartsWith("ASPIREC4", StringComparison.Ordinal))]; + + // ----------------------------------------------------------------------- + // Test infrastructure — AnalyzerConfigOptionsProvider + // ----------------------------------------------------------------------- + + sealed class TestAnalyzerConfigOptionsProvider(Dictionary options) : AnalyzerConfigOptionsProvider + { + readonly TestAnalyzerConfigOptions _options = new(options); + + public override AnalyzerConfigOptions GlobalOptions => _options; + + public override AnalyzerConfigOptions GetOptions(SyntaxTree tree) => _options; + + public override AnalyzerConfigOptions GetOptions(AdditionalText textFile) => _options; + } + + sealed class TestAnalyzerConfigOptions(Dictionary options) : AnalyzerConfigOptions + { + public override bool TryGetValue(string requestedKey, [NotNullWhen(true)] out string? optionValue) => + options.TryGetValue(requestedKey, out optionValue); + } +}